diff --git a/.editorconfig b/.editorconfig index da28f2067e..5829347320 100644 --- a/.editorconfig +++ b/.editorconfig @@ -276,7 +276,7 @@ dotnet_diagnostic.IDE0078.severity = silent # Requires C# 9 - TODO Consider enab # IDE0083 Use pattern matching ('not' operator) #csharp_style_prefer_not_pattern = true -dotnet_diagnostic.IDE0083.severity = silent # Requires C# 9 - TODO Consider enabling +dotnet_diagnostic.IDE0083.severity = warning # IDE0170 Simplify property pattern #csharp_style_prefer_extended_property_pattern = true diff --git a/OpenRA.Game/Exts.cs b/OpenRA.Game/Exts.cs index 3fae7d9be1..9825fce45f 100644 --- a/OpenRA.Game/Exts.cs +++ b/OpenRA.Game/Exts.cs @@ -510,7 +510,7 @@ namespace OpenRA public static bool IsTraitEnabled(this T trait) { - return !(trait is IDisabledTrait disabledTrait) || !disabledTrait.IsTraitDisabled; + return trait is not IDisabledTrait disabledTrait || !disabledTrait.IsTraitDisabled; } public static T FirstEnabledTraitOrDefault(this IEnumerable ts) diff --git a/OpenRA.Game/FileSystem/FileSystem.cs b/OpenRA.Game/FileSystem/FileSystem.cs index 16d775310d..d08d13acfd 100644 --- a/OpenRA.Game/FileSystem/FileSystem.cs +++ b/OpenRA.Game/FileSystem/FileSystem.cs @@ -309,7 +309,7 @@ namespace OpenRA.FileSystem if (!installedMods.TryGetValue(parentPath[1..], out var mod)) return null; - if (!(mod.Package is Folder)) + if (mod.Package is not Folder) return null; path = Path.Combine(mod.Package.Name, filename); diff --git a/OpenRA.Game/Graphics/WorldRenderer.cs b/OpenRA.Game/Graphics/WorldRenderer.cs index 27608d6f98..ae385670ee 100644 --- a/OpenRA.Game/Graphics/WorldRenderer.cs +++ b/OpenRA.Game/Graphics/WorldRenderer.cs @@ -177,7 +177,7 @@ namespace OpenRA.Graphics foreach (var e in World.Effects) { - if (!(e is IEffectAboveShroud ea)) + if (e is not IEffectAboveShroud ea) continue; foreach (var renderable in ea.RenderAboveShroud(this)) @@ -218,7 +218,7 @@ namespace OpenRA.Graphics foreach (var e in World.Effects) { - if (!(e is IEffectAnnotation ea)) + if (e is not IEffectAnnotation ea) continue; foreach (var renderAnnotation in ea.RenderAnnotation(this)) diff --git a/OpenRA.Game/Map/ActorReference.cs b/OpenRA.Game/Map/ActorReference.cs index 090375ccab..13029a0fe5 100644 --- a/OpenRA.Game/Map/ActorReference.cs +++ b/OpenRA.Game/Map/ActorReference.cs @@ -87,7 +87,7 @@ namespace OpenRA var ret = new MiniYaml(Type); foreach (var o in initDict.Value) { - if (!(o is ActorInit init) || o is ISuppressInitExport) + if (o is not ActorInit init || o is ISuppressInitExport) continue; if (initFilter != null && !initFilter(init)) diff --git a/OpenRA.Game/Map/MapPreview.cs b/OpenRA.Game/Map/MapPreview.cs index 470f53ca51..6c3ff528a6 100644 --- a/OpenRA.Game/Map/MapPreview.cs +++ b/OpenRA.Game/Map/MapPreview.cs @@ -481,7 +481,7 @@ namespace OpenRA innerData.Status = MapStatus.Downloading; var installLocation = cache.MapLocations.FirstOrDefault(p => p.Value == MapClassification.User); - if (!(installLocation.Key is IReadWritePackage mapInstallPackage)) + if (installLocation.Key is not IReadWritePackage mapInstallPackage) { Log.Write("debug", "Map install directory not found"); innerData.Status = MapStatus.DownloadError; diff --git a/OpenRA.Game/Network/OrderManager.cs b/OpenRA.Game/Network/OrderManager.cs index 9cb0b2aa97..aa7687f6e2 100644 --- a/OpenRA.Game/Network/OrderManager.cs +++ b/OpenRA.Game/Network/OrderManager.cs @@ -99,7 +99,7 @@ namespace OpenRA.Network // Generating sync reports is expensive, so only do it if we have // other players to compare against if a desync did occur - generateSyncReport = !(Connection is ReplayConnection) && LobbyInfo.GlobalSettings.EnableSyncReports; + generateSyncReport = Connection is not ReplayConnection && LobbyInfo.GlobalSettings.EnableSyncReports; NetFrameNumber = 1; LocalFrameNumber = 0; diff --git a/OpenRA.Game/Primitives/Color.cs b/OpenRA.Game/Primitives/Color.cs index 1d5f79f006..efe18fdba4 100644 --- a/OpenRA.Game/Primitives/Color.cs +++ b/OpenRA.Game/Primitives/Color.cs @@ -210,7 +210,7 @@ namespace OpenRA.Primitives public override bool Equals(object obj) { - if (!(obj is Color)) + if (obj is not Color) return false; return this == (Color)obj; diff --git a/OpenRA.Game/Primitives/Rectangle.cs b/OpenRA.Game/Primitives/Rectangle.cs index 655cb5e0bd..37eec0e5bf 100644 --- a/OpenRA.Game/Primitives/Rectangle.cs +++ b/OpenRA.Game/Primitives/Rectangle.cs @@ -88,7 +88,7 @@ namespace OpenRA.Primitives public override bool Equals(object obj) { - if (!(obj is Rectangle)) + if (obj is not Rectangle) return false; return this == (Rectangle)obj; diff --git a/OpenRA.Game/Primitives/Size.cs b/OpenRA.Game/Primitives/Size.cs index b4c3775b9b..a1611c6864 100644 --- a/OpenRA.Game/Primitives/Size.cs +++ b/OpenRA.Game/Primitives/Size.cs @@ -53,7 +53,7 @@ namespace OpenRA.Primitives public override bool Equals(object obj) { - if (!(obj is Size)) + if (obj is not Size) return false; return this == (Size)obj; diff --git a/OpenRA.Game/Scripting/ScriptMemberWrapper.cs b/OpenRA.Game/Scripting/ScriptMemberWrapper.cs index b8ffb652a1..5224621cd1 100644 --- a/OpenRA.Game/Scripting/ScriptMemberWrapper.cs +++ b/OpenRA.Game/Scripting/ScriptMemberWrapper.cs @@ -87,7 +87,7 @@ namespace OpenRA.Scripting { foreach (var arg in clrArgs) { - if (!(arg is LuaValue[] table)) + if (arg is not LuaValue[] table) continue; foreach (var value in table) diff --git a/OpenRA.Game/Scripting/ScriptTypes.cs b/OpenRA.Game/Scripting/ScriptTypes.cs index 062464e0f0..edfd8ff943 100644 --- a/OpenRA.Game/Scripting/ScriptTypes.cs +++ b/OpenRA.Game/Scripting/ScriptTypes.cs @@ -125,7 +125,7 @@ namespace OpenRA.Scripting else { var elementHasClrValue = kv.Value.TryGetClrValue(innerType, out element); - if (!elementHasClrValue || !(element is LuaValue)) + if (!elementHasClrValue || element is not LuaValue) kv.Value.Dispose(); if (!elementHasClrValue) throw new LuaException($"Unable to convert table value of type {kv.Value.WrappedClrType()} to type {innerType}"); diff --git a/OpenRA.Game/WDist.cs b/OpenRA.Game/WDist.cs index 691542c41c..8156c006ff 100644 --- a/OpenRA.Game/WDist.cs +++ b/OpenRA.Game/WDist.cs @@ -97,7 +97,7 @@ namespace OpenRA public int CompareTo(object obj) { - if (!(obj is WDist)) + if (obj is not WDist) return 1; return Length.CompareTo(((WDist)obj).Length); } diff --git a/OpenRA.Game/World.cs b/OpenRA.Game/World.cs index aa3d83f716..6e184a5328 100644 --- a/OpenRA.Game/World.cs +++ b/OpenRA.Game/World.cs @@ -355,7 +355,7 @@ namespace OpenRA { effects.Add(e); - if (!(e is ISpatiallyPartitionable)) + if (e is not ISpatiallyPartitionable) unpartitionedEffects.Add(e); if (e is ISync se) @@ -366,7 +366,7 @@ namespace OpenRA { effects.Remove(e); - if (!(e is ISpatiallyPartitionable)) + if (e is not ISpatiallyPartitionable) unpartitionedEffects.Remove(e); if (e is ISync se) diff --git a/OpenRA.Mods.Cnc/Traits/Conditions/GrantConditionOnJumpjetLayer.cs b/OpenRA.Mods.Cnc/Traits/Conditions/GrantConditionOnJumpjetLayer.cs index 8f401d7aee..d94145b715 100644 --- a/OpenRA.Mods.Cnc/Traits/Conditions/GrantConditionOnJumpjetLayer.cs +++ b/OpenRA.Mods.Cnc/Traits/Conditions/GrantConditionOnJumpjetLayer.cs @@ -20,7 +20,7 @@ namespace OpenRA.Mods.Cnc.Traits public override void RulesetLoaded(Ruleset rules, ActorInfo ai) { var mobileInfo = ai.TraitInfoOrDefault(); - if (mobileInfo == null || !(mobileInfo.LocomotorInfo is JumpjetLocomotorInfo)) + if (mobileInfo == null || mobileInfo.LocomotorInfo is not JumpjetLocomotorInfo) throw new YamlException("GrantConditionOnJumpjetLayer requires Mobile to be linked to a JumpjetLocomotor!"); base.RulesetLoaded(rules, ai); diff --git a/OpenRA.Mods.Common/Activities/Move/Move.cs b/OpenRA.Mods.Common/Activities/Move/Move.cs index 5675ce28e3..614eaf0985 100644 --- a/OpenRA.Mods.Common/Activities/Move/Move.cs +++ b/OpenRA.Mods.Common/Activities/Move/Move.cs @@ -316,7 +316,7 @@ namespace OpenRA.Mods.Common.Activities { foreach (var actor in self.World.ActorMap.GetActorsAt(cell)) { - if (!(actor.OccupiesSpace is Mobile move) || move.IsTraitDisabled || !move.IsLeaving()) + if (actor.OccupiesSpace is not Mobile move || move.IsTraitDisabled || !move.IsLeaving()) return false; } diff --git a/OpenRA.Mods.Common/Activities/Resupply.cs b/OpenRA.Mods.Common/Activities/Resupply.cs index 189aa28a9c..40eb05c7bf 100644 --- a/OpenRA.Mods.Common/Activities/Resupply.cs +++ b/OpenRA.Mods.Common/Activities/Resupply.cs @@ -242,7 +242,7 @@ namespace OpenRA.Mods.Common.Activities else if (repairableNear == null) QueueChild(move.MoveToTarget(self, host)); } - else if (repairableNear == null && !(self.CurrentActivity.NextActivity is Move)) + else if (repairableNear == null && self.CurrentActivity.NextActivity is not Move) QueueChild(move.MoveToTarget(self, host)); } diff --git a/OpenRA.Mods.Common/Installer/SourceResolvers/GogSourceResolver.cs b/OpenRA.Mods.Common/Installer/SourceResolvers/GogSourceResolver.cs index 74a1a9b305..0a7c8323b7 100644 --- a/OpenRA.Mods.Common/Installer/SourceResolvers/GogSourceResolver.cs +++ b/OpenRA.Mods.Common/Installer/SourceResolvers/GogSourceResolver.cs @@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Installer foreach (var prefix in prefixes) { - if (!(Registry.GetValue($"{prefix}GOG.com\\Games\\{appId.Value}", "path", null) is string installDir)) + if (Registry.GetValue($"{prefix}GOG.com\\Games\\{appId.Value}", "path", null) is not string installDir) continue; if (InstallerUtils.IsValidSourcePath(installDir, modSource)) diff --git a/OpenRA.Mods.Common/Installer/SourceResolvers/RegistryDirectoryFromFileSourceResolver.cs b/OpenRA.Mods.Common/Installer/SourceResolvers/RegistryDirectoryFromFileSourceResolver.cs index 894f44c478..b708594773 100644 --- a/OpenRA.Mods.Common/Installer/SourceResolvers/RegistryDirectoryFromFileSourceResolver.cs +++ b/OpenRA.Mods.Common/Installer/SourceResolvers/RegistryDirectoryFromFileSourceResolver.cs @@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Installer foreach (var prefix in source.RegistryPrefixes) { - if (!(Microsoft.Win32.Registry.GetValue(prefix + source.RegistryKey, source.RegistryValue, null) is string path)) + if (Microsoft.Win32.Registry.GetValue(prefix + source.RegistryKey, source.RegistryValue, null) is not string path) continue; path = Path.GetDirectoryName(path); diff --git a/OpenRA.Mods.Common/Installer/SourceResolvers/RegistryDirectorySourceResolver.cs b/OpenRA.Mods.Common/Installer/SourceResolvers/RegistryDirectorySourceResolver.cs index 3f167a7402..83b3bb6c0f 100644 --- a/OpenRA.Mods.Common/Installer/SourceResolvers/RegistryDirectorySourceResolver.cs +++ b/OpenRA.Mods.Common/Installer/SourceResolvers/RegistryDirectorySourceResolver.cs @@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Installer foreach (var prefix in source.RegistryPrefixes) { - if (!(Microsoft.Win32.Registry.GetValue(prefix + source.RegistryKey, source.RegistryValue, null) is string path)) + if (Microsoft.Win32.Registry.GetValue(prefix + source.RegistryKey, source.RegistryValue, null) is not string path) continue; // Resolve 8.3 format (DOS-style) paths to the full path. diff --git a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs index b7f141b15a..393f07540e 100644 --- a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs +++ b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs @@ -413,7 +413,7 @@ namespace OpenRA.Mods.Common.Traits } // Add takeoff activity if Aircraft trait is not paused and the actor should not land when idle. - if (ForceLanding && !IsTraitPaused && !cruising && !(self.CurrentActivity is TakeOff)) + if (ForceLanding && !IsTraitPaused && !cruising && self.CurrentActivity is not TakeOff) { ForceLanding = false; diff --git a/OpenRA.Mods.Common/Traits/BotModules/HarvesterBotModule.cs b/OpenRA.Mods.Common/Traits/BotModules/HarvesterBotModule.cs index b98d5a91a5..4aee505138 100644 --- a/OpenRA.Mods.Common/Traits/BotModules/HarvesterBotModule.cs +++ b/OpenRA.Mods.Common/Traits/BotModules/HarvesterBotModule.cs @@ -112,7 +112,7 @@ namespace OpenRA.Mods.Common.Traits if (!h.Key.IsIdle) { // Ignore this actor if FindAndDeliverResources is working fine or it is performing a different activity - if (!(h.Key.CurrentActivity is FindAndDeliverResources act) || !act.LastSearchFailed) + if (h.Key.CurrentActivity is not FindAndDeliverResources act || !act.LastSearchFailed) continue; } diff --git a/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoTransforms.cs b/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoTransforms.cs index fdb588fa27..3a49990f58 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoTransforms.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoTransforms.cs @@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Traits // The DeployTransform order does not have a position associated with it, // so we can only queue a new transformation if something else has // already triggered the undeploy. - if (!order.Queued || !(self.CurrentActivity is Transform currentTransform)) + if (!order.Queued || self.CurrentActivity is not Transform currentTransform) return; currentTransform.Queue(new IssueOrderAfterTransform("DeployTransform", order.Target)); diff --git a/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnSubterraneanLayer.cs b/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnSubterraneanLayer.cs index 9c6287be15..028c4f54d5 100644 --- a/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnSubterraneanLayer.cs +++ b/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnSubterraneanLayer.cs @@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Traits public override void RulesetLoaded(Ruleset rules, ActorInfo ai) { var mobileInfo = ai.TraitInfoOrDefault(); - if (mobileInfo == null || !(mobileInfo.LocomotorInfo is SubterraneanLocomotorInfo)) + if (mobileInfo == null || mobileInfo.LocomotorInfo is not SubterraneanLocomotorInfo) throw new YamlException("GrantConditionOnSubterraneanLayer requires Mobile to be linked to a SubterraneanLocomotor!"); base.RulesetLoaded(rules, ai); diff --git a/OpenRA.Mods.Common/Traits/Render/SelectionDecorations.cs b/OpenRA.Mods.Common/Traits/Render/SelectionDecorations.cs index 355467f9cc..3c1e2133f1 100644 --- a/OpenRA.Mods.Common/Traits/Render/SelectionDecorations.cs +++ b/OpenRA.Mods.Common/Traits/Render/SelectionDecorations.cs @@ -73,7 +73,7 @@ namespace OpenRA.Mods.Common.Traits.Render protected override IEnumerable RenderSelectionBars(Actor self, WorldRenderer wr, bool displayHealth, bool displayExtra) { // Don't render the selection bars for non-selectable actors - if (!(interactable is Selectable) || (!displayHealth && !displayExtra)) + if (interactable is not Selectable || (!displayHealth && !displayExtra)) yield break; var bounds = interactable.DecorationBounds(self, wr); diff --git a/OpenRA.Mods.Common/Traits/Render/WithProductionDoorOverlay.cs b/OpenRA.Mods.Common/Traits/Render/WithProductionDoorOverlay.cs index 9dbf71e486..43a5976c41 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithProductionDoorOverlay.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithProductionDoorOverlay.cs @@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Traits.Render if (exitingActor == null) return; - if (!exitingActor.IsInWorld || exitingActor.Location != openExit || !(exitingActor.CurrentActivity is Mobile.ReturnToCellActivity)) + if (!exitingActor.IsInWorld || exitingActor.Location != openExit || exitingActor.CurrentActivity is not Mobile.ReturnToCellActivity) { desiredFrame = 0; exitingActor = null; diff --git a/OpenRA.Mods.Common/Traits/World/TerrainRenderer.cs b/OpenRA.Mods.Common/Traits/World/TerrainRenderer.cs index 9c4c70bf34..aca1cbff19 100644 --- a/OpenRA.Mods.Common/Traits/World/TerrainRenderer.cs +++ b/OpenRA.Mods.Common/Traits/World/TerrainRenderer.cs @@ -159,7 +159,7 @@ namespace OpenRA.Mods.Common.Traits IEnumerable ITiledTerrainRenderer.RenderUIPreview(WorldRenderer wr, TerrainTemplateInfo t, int2 origin, float scale) { - if (!(t is DefaultTerrainTemplateInfo template)) + if (t is not DefaultTerrainTemplateInfo template) yield break; var ts = map.Grid.TileSize; @@ -187,7 +187,7 @@ namespace OpenRA.Mods.Common.Traits IEnumerable ITiledTerrainRenderer.RenderPreview(WorldRenderer wr, TerrainTemplateInfo t, WPos origin) { - if (!(t is DefaultTerrainTemplateInfo template)) + if (t is not DefaultTerrainTemplateInfo template) yield break; var i = 0; diff --git a/OpenRA.Mods.Common/UpdateRules/UpdateUtils.cs b/OpenRA.Mods.Common/UpdateRules/UpdateUtils.cs index ed520cf127..3b2172df88 100644 --- a/OpenRA.Mods.Common/UpdateRules/UpdateUtils.cs +++ b/OpenRA.Mods.Common/UpdateRules/UpdateUtils.cs @@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.UpdateRules var yaml = new YamlFileSet(); foreach (var filename in files) { - if (!modData.ModFiles.TryGetPackageContaining(filename, out var package, out var name) || !(package is IReadWritePackage)) + if (!modData.ModFiles.TryGetPackageContaining(filename, out var package, out var name) || package is not IReadWritePackage) { Console.WriteLine("Failed to load file `{0}` for writing. It will not be updated.", filename); continue; diff --git a/OpenRA.Mods.Common/UtilityCommands/UpdateMapCommand.cs b/OpenRA.Mods.Common/UtilityCommands/UpdateMapCommand.cs index c8915be1d9..a9ccbd9963 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpdateMapCommand.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpdateMapCommand.cs @@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.UtilityCommands // HACK: We know that maps can only be oramap or folders, which are ReadWrite var folder = new Folder(Platform.EngineDir); - if (!(folder.OpenPackage(args[1], modData.ModFiles) is IReadWritePackage package)) + if (folder.OpenPackage(args[1], modData.ModFiles) is not IReadWritePackage package) throw new FileNotFoundException(args[1]); IEnumerable rules = null; diff --git a/OpenRA.Mods.Common/Widgets/Logic/DisconnectWatcherLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/DisconnectWatcherLogic.cs index b3318b8db3..13f4e26188 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/DisconnectWatcherLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/DisconnectWatcherLogic.cs @@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var disconnected = false; widget.Get("DISCONNECT_WATCHER").OnTick = () => { - if (!(orderManager.Connection is NetworkConnection connection)) + if (orderManager.Connection is not NetworkConnection connection) return; if (disconnected || connection.ConnectionState != ConnectionState.NotConnected) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Editor/SaveMapLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Editor/SaveMapLogic.cs index 32a0e7aacb..fb22379996 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Editor/SaveMapLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Editor/SaveMapLogic.cs @@ -126,7 +126,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic foreach (var kv in modData.MapCache.MapLocations) { - if (!(kv.Key is Folder folder)) + if (kv.Key is not Folder folder) continue; try @@ -209,7 +209,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic try { - if (!(map.Package is IReadWritePackage package) || package.Name != combinedPath) + if (map.Package is not IReadWritePackage package || package.Name != combinedPath) { selectedDirectory.Folder.Delete(combinedPath); if (fileType == MapFileType.OraMap) diff --git a/OpenRA.Mods.Common/Widgets/Logic/GameSaveBrowserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/GameSaveBrowserLogic.cs index 0f834e5fd3..ed0c71eb9c 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/GameSaveBrowserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/GameSaveBrowserLogic.cs @@ -276,7 +276,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic games[games.IndexOf(oldPath)] = newPath; foreach (var c in gameList.Children) { - if (!(c is ScrollItemWidget item) || item.ItemKey != oldPath) + if (c is not ScrollItemWidget item || item.ItemKey != oldPath) continue; item.ItemKey = newPath; diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ClassicProductionLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ClassicProductionLogic.cs index 246ad0ce3e..b09ce9ded8 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ClassicProductionLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ClassicProductionLogic.cs @@ -133,7 +133,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic // Select the first active tab foreach (var b in typesContainer.Children) { - if (!(b is ProductionTypeButtonWidget button) || button.IsDisabled()) + if (b is not ProductionTypeButtonWidget button || button.IsDisabled()) continue; button.OnClick(); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/CommandBarLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/CommandBarLogic.cs index 22e8c82f91..f70dfe4b1f 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/CommandBarLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/CommandBarLogic.cs @@ -95,7 +95,7 @@ namespace OpenRA.Mods.Common.Widgets forceAttackButton.IsDisabled = () => { UpdateStateIfNecessary(); return forceAttackDisabled; }; forceAttackButton.IsHighlighted = () => !forceAttackButton.IsDisabled() && IsForceModifiersActive(Modifiers.Ctrl) - && !(world.OrderGenerator is AttackMoveOrderGenerator); + && world.OrderGenerator is not AttackMoveOrderGenerator; forceAttackButton.OnClick = () => { diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyOptionsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyOptionsLogic.cs index ea5a459d78..bea3ecf6e9 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyOptionsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyOptionsLogic.cs @@ -122,7 +122,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic }; } - foreach (var option in allOptions.Where(o => !(o is LobbyBooleanOption))) + foreach (var option in allOptions.Where(o => o is not LobbyBooleanOption)) { if (dropdownColumns.Count == 0) { diff --git a/OpenRA.Mods.Common/Widgets/WorldInteractionControllerWidget.cs b/OpenRA.Mods.Common/Widgets/WorldInteractionControllerWidget.cs index 706fcf5a11..b2a7280d15 100644 --- a/OpenRA.Mods.Common/Widgets/WorldInteractionControllerWidget.cs +++ b/OpenRA.Mods.Common/Widgets/WorldInteractionControllerWidget.cs @@ -88,7 +88,7 @@ namespace OpenRA.Mods.Common.Widgets var multiClick = mi.MultiTapCount >= 2; - if (!(World.OrderGenerator is UnitOrderGenerator uog)) + if (World.OrderGenerator is not UnitOrderGenerator uog) { ApplyOrders(World, mi); isDragging = false; diff --git a/OpenRA.Mods.D2k/Traits/Buildings/D2kBuilding.cs b/OpenRA.Mods.D2k/Traits/Buildings/D2kBuilding.cs index c33839bfd8..b6b33f2557 100644 --- a/OpenRA.Mods.D2k/Traits/Buildings/D2kBuilding.cs +++ b/OpenRA.Mods.D2k/Traits/Buildings/D2kBuilding.cs @@ -84,7 +84,7 @@ namespace OpenRA.Mods.D2k.Traits.Buildings { var map = self.World.Map; - if (!(self.World.Map.Rules.TerrainInfo is ITemplatedTerrainInfo terrainInfo)) + if (self.World.Map.Rules.TerrainInfo is not ITemplatedTerrainInfo terrainInfo) throw new InvalidDataException("D2kBuilding requires a template-based tileset."); var template = terrainInfo.Templates[info.ConcreteTemplate];