From 0338258b45ca885e6007ae38ed5b770091449bfc Mon Sep 17 00:00:00 2001 From: RoosterDragon Date: Mon, 25 Nov 2024 20:44:40 +0000 Subject: [PATCH] Fix IDE0200 --- .editorconfig | 2 +- OpenRA.Game/Graphics/Animation.cs | 2 +- OpenRA.Game/Graphics/WorldRenderer.cs | 2 +- OpenRA.Game/Primitives/Polygon.cs | 2 +- OpenRA.Mods.Cnc/SpriteLoaders/ShpTDLoader.cs | 2 +- OpenRA.Mods.Cnc/Traits/World/TSShroudPalette.cs | 2 +- .../Traits/World/WithResourceAnimation.cs | 2 +- OpenRA.Mods.Common/ActorExts.cs | 2 +- OpenRA.Mods.Common/Lint/CheckChromeHotkeys.cs | 2 +- OpenRA.Mods.Common/Lint/CheckConditions.cs | 8 ++++---- OpenRA.Mods.Common/Lint/CheckLocomotorReferences.cs | 2 +- OpenRA.Mods.Common/Lint/CheckNotifications.cs | 2 +- OpenRA.Mods.Common/Lint/CheckSyncAnnotations.cs | 2 +- OpenRA.Mods.Common/Lint/CheckVoiceReferences.cs | 4 ++-- OpenRA.Mods.Common/MapGenerator/TilingPath.cs | 2 +- OpenRA.Mods.Common/Traits/Attack/AttackGarrisoned.cs | 2 +- .../BotModules/BotModuleLogic/MinelayerBotModule.cs | 2 +- .../Traits/BotModules/SquadManagerBotModule.cs | 4 ++-- OpenRA.Mods.Common/Traits/BotModules/Squads/Squad.cs | 2 +- OpenRA.Mods.Common/Traits/CaptureManager.cs | 2 +- OpenRA.Mods.Common/Traits/Cargo.cs | 6 +++--- OpenRA.Mods.Common/Traits/EntersTunnels.cs | 2 +- OpenRA.Mods.Common/Traits/Render/WithSpriteBarrel.cs | 2 +- OpenRA.Mods.Common/Traits/Sellable.cs | 2 +- OpenRA.Mods.Common/Traits/Sound/AnnounceOnSeen.cs | 2 +- .../Traits/SupportPowers/SupportPowerManager.cs | 2 +- .../Traits/World/CliffBackImpassabilityLayer.cs | 2 +- OpenRA.Mods.Common/Traits/World/ControlGroups.cs | 2 +- OpenRA.Mods.Common/Traits/World/Selection.cs | 2 +- OpenRA.Mods.Common/Traits/World/ShroudRenderer.cs | 2 +- OpenRA.Mods.Common/Util.cs | 2 +- .../Widgets/Logic/AssetBrowserLogic.cs | 2 +- .../Widgets/Logic/Editor/ActorEditLogic.cs | 2 +- .../Widgets/Logic/Editor/MapEditorLogic.cs | 4 ++-- .../Widgets/Logic/Editor/MapEditorSelectionLogic.cs | 2 +- .../Widgets/Logic/Editor/MapOverlaysLogic.cs | 2 +- .../Widgets/Logic/Editor/SaveMapLogic.cs | 2 +- .../Widgets/Logic/GameSaveBrowserLogic.cs | 6 +++--- .../Widgets/Logic/Ingame/ObserverStatsLogic.cs | 8 ++++---- .../Widgets/Logic/ReplayBrowserLogic.cs | 2 +- .../Widgets/Logic/Settings/HotkeysSettingsLogic.cs | 2 +- .../Widgets/Logic/Settings/InputSettingsLogic.cs | 4 ++-- OpenRA.Mods.Common/Widgets/TextFieldWidget.cs | 2 +- OpenRA.Mods.D2k/Traits/Sandworm.cs | 2 +- OpenRA.Platforms.Default/ThreadedGraphicsContext.cs | 12 ++++++------ 45 files changed, 64 insertions(+), 64 deletions(-) diff --git a/.editorconfig b/.editorconfig index bd22b2b4cb..f275e86cac 100644 --- a/.editorconfig +++ b/.editorconfig @@ -63,7 +63,7 @@ dotnet_diagnostic.IDE0161.severity = warning # IDE0200 Remove unnecessary lambda expression #csharp_style_prefer_method_group_conversion = true -dotnet_diagnostic.IDE0200.severity = suggestion # TODO: Consider enabling +dotnet_diagnostic.IDE0200.severity = warning # IDE0210 Convert to top-level statements/IDE0211 Convert to 'Program.Main' style program csharp_style_prefer_top_level_statements = false diff --git a/OpenRA.Game/Graphics/Animation.cs b/OpenRA.Game/Graphics/Animation.cs index 78609531b8..d2ce02874b 100644 --- a/OpenRA.Game/Graphics/Animation.cs +++ b/OpenRA.Game/Graphics/Animation.cs @@ -252,7 +252,7 @@ namespace OpenRA.Graphics public string GetRandomExistingSequence(string[] sequences, MersenneTwister random) { - return sequences.Where(s => HasSequence(s)).RandomOrDefault(random); + return sequences.Where(HasSequence).RandomOrDefault(random); } } } diff --git a/OpenRA.Game/Graphics/WorldRenderer.cs b/OpenRA.Game/Graphics/WorldRenderer.cs index 4df9e491dd..336d00e5d6 100644 --- a/OpenRA.Game/Graphics/WorldRenderer.cs +++ b/OpenRA.Game/Graphics/WorldRenderer.cs @@ -70,7 +70,7 @@ namespace OpenRA.Graphics renderers = world.WorldActor.TraitsImplementing().ToArray(); terrainRenderer = world.WorldActor.TraitOrDefault(); - debugVis = Exts.Lazy(() => world.WorldActor.TraitOrDefault()); + debugVis = Exts.Lazy(world.WorldActor.TraitOrDefault); postProcessPasses = world.WorldActor.TraitsImplementing().ToArray(); } diff --git a/OpenRA.Game/Primitives/Polygon.cs b/OpenRA.Game/Primitives/Polygon.cs index be4cdec2c6..8af66c593f 100644 --- a/OpenRA.Game/Primitives/Polygon.cs +++ b/OpenRA.Game/Primitives/Polygon.cs @@ -87,7 +87,7 @@ namespace OpenRA.Primitives return true; // Easy case 4: Polygon vertex is inside rect - if (Vertices.Any(p => rect.Contains(p))) + if (Vertices.Any(rect.Contains)) return true; // Hard case: check intersection of every line segment pair diff --git a/OpenRA.Mods.Cnc/SpriteLoaders/ShpTDLoader.cs b/OpenRA.Mods.Cnc/SpriteLoaders/ShpTDLoader.cs index 2658bca903..6f3ab2bcb9 100644 --- a/OpenRA.Mods.Cnc/SpriteLoaders/ShpTDLoader.cs +++ b/OpenRA.Mods.Cnc/SpriteLoaders/ShpTDLoader.cs @@ -288,7 +288,7 @@ namespace OpenRA.Mods.Cnc.SpriteLoaders public static void Write(Stream s, Size size, IEnumerable frames) { - var compressedFrames = frames.Select(f => LCWCompression.Encode(f)).ToList(); + var compressedFrames = frames.Select(LCWCompression.Encode).ToList(); // note: end-of-file and all-zeroes headers var dataOffset = 14 + (compressedFrames.Count + 2) * 8; diff --git a/OpenRA.Mods.Cnc/Traits/World/TSShroudPalette.cs b/OpenRA.Mods.Cnc/Traits/World/TSShroudPalette.cs index ea6b7c0dac..6b26796b21 100644 --- a/OpenRA.Mods.Cnc/Traits/World/TSShroudPalette.cs +++ b/OpenRA.Mods.Cnc/Traits/World/TSShroudPalette.cs @@ -44,7 +44,7 @@ namespace OpenRA.Mods.Cnc.Traits return 0; } - wr.AddPalette(info.Name, new ImmutablePalette(Enumerable.Range(0, Palette.Size).Select(i => MakeColor(i)))); + wr.AddPalette(info.Name, new ImmutablePalette(Enumerable.Range(0, Palette.Size).Select(MakeColor))); } public IEnumerable PaletteNames { get { yield return info.Name; } } diff --git a/OpenRA.Mods.Cnc/Traits/World/WithResourceAnimation.cs b/OpenRA.Mods.Cnc/Traits/World/WithResourceAnimation.cs index 65a5fc62a3..7087bd8fa9 100644 --- a/OpenRA.Mods.Cnc/Traits/World/WithResourceAnimation.cs +++ b/OpenRA.Mods.Cnc/Traits/World/WithResourceAnimation.cs @@ -95,7 +95,7 @@ namespace OpenRA.Mods.Cnc.Traits var ratio = Common.Util.RandomInRange(world.LocalRandom, info.Ratio); var positions = cells.Shuffle(world.LocalRandom) .Take(Math.Max(1, cells.Count * ratio / 100)) - .Select(x => world.Map.CenterOfCell(x)); + .Select(world.Map.CenterOfCell); foreach (var position in positions) world.AddFrameEndTask(w => w.Add(new SpriteEffect(position, w, info.Image, info.Sequences.Random(w.LocalRandom), info.Palette))); diff --git a/OpenRA.Mods.Common/ActorExts.cs b/OpenRA.Mods.Common/ActorExts.cs index b86565d6e2..83c8f2a222 100644 --- a/OpenRA.Mods.Common/ActorExts.cs +++ b/OpenRA.Mods.Common/ActorExts.cs @@ -72,7 +72,7 @@ namespace OpenRA.Mods.Common public static void NotifyBlocker(this Actor self, IEnumerable positions) { - NotifyBlocker(self, positions.SelectMany(p => self.World.ActorMap.GetActorsAt(p))); + NotifyBlocker(self, positions.SelectMany(self.World.ActorMap.GetActorsAt)); } public static CPos ClosestCell(this Actor self, IEnumerable cells) diff --git a/OpenRA.Mods.Common/Lint/CheckChromeHotkeys.cs b/OpenRA.Mods.Common/Lint/CheckChromeHotkeys.cs index afea0a09c1..84a8fda3c4 100644 --- a/OpenRA.Mods.Common/Lint/CheckChromeHotkeys.cs +++ b/OpenRA.Mods.Common/Lint/CheckChromeHotkeys.cs @@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Lint foreach (var w in modData.ObjectCreator.GetTypesImplementing()) { - foreach (var m in w.GetMethods().Where(m => Utility.HasAttribute(m))) + foreach (var m in w.GetMethods().Where(Utility.HasAttribute)) { var p = m.GetParameters(); if (p.Length == 3 && p[0].ParameterType == typeof(MiniYamlNode) && p[1].ParameterType == typeof(Action) diff --git a/OpenRA.Mods.Common/Lint/CheckConditions.cs b/OpenRA.Mods.Common/Lint/CheckConditions.cs index 93e671a49e..fb55586e2d 100644 --- a/OpenRA.Mods.Common/Lint/CheckConditions.cs +++ b/OpenRA.Mods.Common/Lint/CheckConditions.cs @@ -42,19 +42,19 @@ namespace OpenRA.Mods.Common.Lint var properties = trait.GetType().GetProperties(); var fieldConsumed = fields - .Where(x => Utility.HasAttribute(x)) + .Where(Utility.HasAttribute) .SelectMany(f => LintExts.GetFieldValues(trait, f)); var propertyConsumed = properties - .Where(x => Utility.HasAttribute(x)) + .Where(Utility.HasAttribute) .SelectMany(p => LintExts.GetPropertyValues(trait, p)); var fieldGranted = fields - .Where(x => Utility.HasAttribute(x)) + .Where(Utility.HasAttribute) .SelectMany(f => LintExts.GetFieldValues(trait, f)); var propertyGranted = properties - .Where(x => Utility.HasAttribute(x)) + .Where(Utility.HasAttribute) .SelectMany(f => LintExts.GetPropertyValues(trait, f)); foreach (var c in fieldConsumed.Concat(propertyConsumed)) diff --git a/OpenRA.Mods.Common/Lint/CheckLocomotorReferences.cs b/OpenRA.Mods.Common/Lint/CheckLocomotorReferences.cs index 8828963bf7..2259f49a96 100644 --- a/OpenRA.Mods.Common/Lint/CheckLocomotorReferences.cs +++ b/OpenRA.Mods.Common/Lint/CheckLocomotorReferences.cs @@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Lint { foreach (var traitInfo in actorInfo.Value.TraitInfos()) { - var fields = Utility.GetFields(traitInfo.GetType()).Where(f => Utility.HasAttribute(f)); + var fields = Utility.GetFields(traitInfo.GetType()).Where(Utility.HasAttribute); foreach (var field in fields) { var locomotors = LintExts.GetFieldValues(traitInfo, field); diff --git a/OpenRA.Mods.Common/Lint/CheckNotifications.cs b/OpenRA.Mods.Common/Lint/CheckNotifications.cs index d0a847f4a1..265077eaa9 100644 --- a/OpenRA.Mods.Common/Lint/CheckNotifications.cs +++ b/OpenRA.Mods.Common/Lint/CheckNotifications.cs @@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Lint foreach (var traitInfo in actorInfo.Value.TraitInfos()) { var fields = Utility.GetFields(traitInfo.GetType()); - foreach (var field in fields.Where(x => Utility.HasAttribute(x))) + foreach (var field in fields.Where(Utility.HasAttribute)) { string type = null; var notificationReference = Utility.GetCustomAttributes(field, true).First(); diff --git a/OpenRA.Mods.Common/Lint/CheckSyncAnnotations.cs b/OpenRA.Mods.Common/Lint/CheckSyncAnnotations.cs index db6c2afb23..ac12b33a2b 100644 --- a/OpenRA.Mods.Common/Lint/CheckSyncAnnotations.cs +++ b/OpenRA.Mods.Common/Lint/CheckSyncAnnotations.cs @@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Lint const BindingFlags Flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly; while (type != null) { - if (((MemberInfo[])type.GetFields(Flags)).Concat(type.GetProperties(Flags)).Any(x => Utility.HasAttribute(x))) + if (((MemberInfo[])type.GetFields(Flags)).Concat(type.GetProperties(Flags)).Any(Utility.HasAttribute)) return true; type = type.BaseType; } diff --git a/OpenRA.Mods.Common/Lint/CheckVoiceReferences.cs b/OpenRA.Mods.Common/Lint/CheckVoiceReferences.cs index 77b8618ca7..d5fb202ccb 100644 --- a/OpenRA.Mods.Common/Lint/CheckVoiceReferences.cs +++ b/OpenRA.Mods.Common/Lint/CheckVoiceReferences.cs @@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Lint { foreach (var traitInfo in actorInfo.Value.TraitInfos()) { - var fields = Utility.GetFields(traitInfo.GetType()).Where(f => Utility.HasAttribute(f)); + var fields = Utility.GetFields(traitInfo.GetType()).Where(Utility.HasAttribute); foreach (var field in fields) { var voiceSets = LintExts.GetFieldValues(traitInfo, field); @@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.Lint foreach (var traitInfo in actorInfo.TraitInfos()) { - var fields = Utility.GetFields(traitInfo.GetType()).Where(f => Utility.HasAttribute(f)); + var fields = Utility.GetFields(traitInfo.GetType()).Where(Utility.HasAttribute); foreach (var field in fields) { var voices = LintExts.GetFieldValues(traitInfo, field); diff --git a/OpenRA.Mods.Common/MapGenerator/TilingPath.cs b/OpenRA.Mods.Common/MapGenerator/TilingPath.cs index b495243239..b5d091c92b 100644 --- a/OpenRA.Mods.Common/MapGenerator/TilingPath.cs +++ b/OpenRA.Mods.Common/MapGenerator/TilingPath.cs @@ -159,7 +159,7 @@ namespace OpenRA.Mods.Common.MapGenerator var templates = new List(); var segments = Start.Union(Inner).Union(End).ToHashSet(); foreach (var template in TemplatedTerrainInfo.Templates.Values.OrderBy(tti => tti.Id)) - if (template.Segments.Any(segment => segments.Contains(segment))) + if (template.Segments.Any(segments.Contains)) templates.Add(template); return templates; } diff --git a/OpenRA.Mods.Common/Traits/Attack/AttackGarrisoned.cs b/OpenRA.Mods.Common/Traits/Attack/AttackGarrisoned.cs index 735516cca6..3d0b7915b1 100644 --- a/OpenRA.Mods.Common/Traits/Attack/AttackGarrisoned.cs +++ b/OpenRA.Mods.Common/Traits/Attack/AttackGarrisoned.cs @@ -90,7 +90,7 @@ namespace OpenRA.Mods.Common.Traits : base(self, info) { Info = info; - coords = Exts.Lazy(() => self.Trait()); + coords = Exts.Lazy(self.Trait); armaments = new List(); muzzles = new List(); paxFacing = new Dictionary(); diff --git a/OpenRA.Mods.Common/Traits/BotModules/BotModuleLogic/MinelayerBotModule.cs b/OpenRA.Mods.Common/Traits/BotModules/BotModuleLogic/MinelayerBotModule.cs index ec2627e929..2b74474c33 100644 --- a/OpenRA.Mods.Common/Traits/BotModules/BotModuleLogic/MinelayerBotModule.cs +++ b/OpenRA.Mods.Common/Traits/BotModules/BotModuleLogic/MinelayerBotModule.cs @@ -140,7 +140,7 @@ namespace OpenRA.Mods.Common.Traits if (minelayers.Length == 0) return; - var enemies = world.Actors.Where(a => IsPreferredEnemyUnit(a)).ToArray(); + var enemies = world.Actors.Where(IsPreferredEnemyUnit).ToArray(); if (enemies.Length == 0) return; diff --git a/OpenRA.Mods.Common/Traits/BotModules/SquadManagerBotModule.cs b/OpenRA.Mods.Common/Traits/BotModules/SquadManagerBotModule.cs index d748aedf85..b6076d0037 100644 --- a/OpenRA.Mods.Common/Traits/BotModules/SquadManagerBotModule.cs +++ b/OpenRA.Mods.Common/Traits/BotModules/SquadManagerBotModule.cs @@ -553,14 +553,14 @@ namespace OpenRA.Mods.Common.Traits { unitsHangingAroundTheBase.Clear(); unitsHangingAroundTheBase.AddRange(FieldLoader.GetValue("UnitsHangingAroundTheBase", unitsHangingAroundTheBaseNode.Value) - .Select(a => self.World.GetActorById(a)).Where(a => a != null)); + .Select(self.World.GetActorById).Where(a => a != null)); } if (nodes.TryGetValue("ActiveUnits", out var activeUnitsNode)) { activeUnits.Clear(); activeUnits.UnionWith(FieldLoader.GetValue("ActiveUnits", activeUnitsNode.Value) - .Select(a => self.World.GetActorById(a)).Where(a => a != null)); + .Select(self.World.GetActorById).Where(a => a != null)); } if (nodes.TryGetValue("RushTicks", out var rushTicksNode)) diff --git a/OpenRA.Mods.Common/Traits/BotModules/Squads/Squad.cs b/OpenRA.Mods.Common/Traits/BotModules/Squads/Squad.cs index 3e53a89887..48660d98fa 100644 --- a/OpenRA.Mods.Common/Traits/BotModules/Squads/Squad.cs +++ b/OpenRA.Mods.Common/Traits/BotModules/Squads/Squad.cs @@ -174,7 +174,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads var unitsNode = yaml.NodeWithKeyOrDefault("Units"); if (unitsNode != null) squad.Units.UnionWith(FieldLoader.GetValue("Units", unitsNode.Value.Value) - .Select(a => squadManager.World.GetActorById(a))); + .Select(squadManager.World.GetActorById)); return squad; } diff --git a/OpenRA.Mods.Common/Traits/CaptureManager.cs b/OpenRA.Mods.Common/Traits/CaptureManager.cs index b9a40f8aa5..72fe2b1cd9 100644 --- a/OpenRA.Mods.Common/Traits/CaptureManager.cs +++ b/OpenRA.Mods.Common/Traits/CaptureManager.cs @@ -288,7 +288,7 @@ namespace OpenRA.Mods.Common.Traits bool IDisableEnemyAutoTarget.DisableEnemyAutoTarget(Actor self, Actor attacker) { - return info.PreventsAutoTarget && currentCaptors.Any(c => attacker.AppearsFriendlyTo(c)); + return info.PreventsAutoTarget && currentCaptors.Any(attacker.AppearsFriendlyTo); } } } diff --git a/OpenRA.Mods.Common/Traits/Cargo.cs b/OpenRA.Mods.Common/Traits/Cargo.cs index e8ed69b253..4ab82c10e7 100644 --- a/OpenRA.Mods.Common/Traits/Cargo.cs +++ b/OpenRA.Mods.Common/Traits/Cargo.cs @@ -123,7 +123,7 @@ namespace OpenRA.Mods.Common.Traits if (runtimeCargoInit != null) { cargo = runtimeCargoInit.Value.ToList(); - totalWeight = cargo.Sum(c => GetWeight(c)); + totalWeight = cargo.Sum(GetWeight); } else if (cargoInit != null) { @@ -135,7 +135,7 @@ namespace OpenRA.Mods.Common.Traits cargo.Add(unit); } - totalWeight = cargo.Sum(c => GetWeight(c)); + totalWeight = cargo.Sum(GetWeight); } else { @@ -147,7 +147,7 @@ namespace OpenRA.Mods.Common.Traits cargo.Add(unit); } - totalWeight = cargo.Sum(c => GetWeight(c)); + totalWeight = cargo.Sum(GetWeight); } facing = Exts.Lazy(self.TraitOrDefault); diff --git a/OpenRA.Mods.Common/Traits/EntersTunnels.cs b/OpenRA.Mods.Common/Traits/EntersTunnels.cs index d46edab808..df9b417394 100644 --- a/OpenRA.Mods.Common/Traits/EntersTunnels.cs +++ b/OpenRA.Mods.Common/Traits/EntersTunnels.cs @@ -140,7 +140,7 @@ namespace OpenRA.Mods.Common.Traits if (buildingInfo != null) { var footprint = buildingInfo.PathableTiles(target.Location); - if (footprint.All(c => self.World.ShroudObscures(c))) + if (footprint.All(self.World.ShroudObscures)) return false; } diff --git a/OpenRA.Mods.Common/Traits/Render/WithSpriteBarrel.cs b/OpenRA.Mods.Common/Traits/Render/WithSpriteBarrel.cs index d585cc5ac8..d5757b6b32 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithSpriteBarrel.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithSpriteBarrel.cs @@ -83,7 +83,7 @@ namespace OpenRA.Mods.Common.Traits.Render DefaultAnimation = new Animation(self.World, rs.GetImage(self), () => turreted.WorldOrientation.Yaw); DefaultAnimation.PlayRepeating(NormalizeSequence(self, Info.Sequence)); rs.Add(new AnimationWithOffset( - DefaultAnimation, () => BarrelOffset(), () => IsTraitDisabled, p => RenderUtils.ZOffsetFromCenter(self, p, 0))); + DefaultAnimation, BarrelOffset, () => IsTraitDisabled, p => RenderUtils.ZOffsetFromCenter(self, p, 0))); // Restrict turret facings to match the sprite turreted.QuantizedFacings = DefaultAnimation.CurrentSequence.Facings; diff --git a/OpenRA.Mods.Common/Traits/Sellable.cs b/OpenRA.Mods.Common/Traits/Sellable.cs index bdc9edce72..7290d5dba3 100644 --- a/OpenRA.Mods.Common/Traits/Sellable.cs +++ b/OpenRA.Mods.Common/Traits/Sellable.cs @@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Traits { this.self = self; this.info = info; - health = Exts.Lazy(() => self.TraitOrDefault()); + health = Exts.Lazy(self.TraitOrDefault); } public void ResolveOrder(Actor self, Order order) diff --git a/OpenRA.Mods.Common/Traits/Sound/AnnounceOnSeen.cs b/OpenRA.Mods.Common/Traits/Sound/AnnounceOnSeen.cs index 60d4599eff..47691932c7 100644 --- a/OpenRA.Mods.Common/Traits/Sound/AnnounceOnSeen.cs +++ b/OpenRA.Mods.Common/Traits/Sound/AnnounceOnSeen.cs @@ -44,7 +44,7 @@ namespace OpenRA.Mods.Common.Traits.Sound public AnnounceOnSeen(Actor self, AnnounceOnSeenInfo info) { Info = info; - radarPings = Exts.Lazy(() => self.World.WorldActor.Trait()); + radarPings = Exts.Lazy(self.World.WorldActor.Trait); } public void OnDiscovered(Actor self, Player discoverer, bool playNotification) diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/SupportPowerManager.cs b/OpenRA.Mods.Common/Traits/SupportPowers/SupportPowerManager.cs index e39d76a40d..33929a0669 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/SupportPowerManager.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/SupportPowerManager.cs @@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits Self = init.Self; DevMode = Self.Trait(); TechTree = Self.Trait(); - RadarPings = Exts.Lazy(() => Self.World.WorldActor.TraitOrDefault()); + RadarPings = Exts.Lazy(Self.World.WorldActor.TraitOrDefault); init.World.ActorAdded += ActorAdded; init.World.ActorRemoved += ActorRemoved; diff --git a/OpenRA.Mods.Common/Traits/World/CliffBackImpassabilityLayer.cs b/OpenRA.Mods.Common/Traits/World/CliffBackImpassabilityLayer.cs index 1a84a14a5b..1d278371ae 100644 --- a/OpenRA.Mods.Common/Traits/World/CliffBackImpassabilityLayer.cs +++ b/OpenRA.Mods.Common/Traits/World/CliffBackImpassabilityLayer.cs @@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Traits // All the map cells that visually overlap the current cell var testCells = w.Map.ProjectedCellsCovering(uv) - .SelectMany(puv => w.Map.Unproject(puv)); + .SelectMany(w.Map.Unproject); if (testCells.Any(x => x.V >= uv.V + 4)) w.Map.CustomTerrain[uv] = tileType; } diff --git a/OpenRA.Mods.Common/Traits/World/ControlGroups.cs b/OpenRA.Mods.Common/Traits/World/ControlGroups.cs index b9b537bfb5..cf3e9d614d 100644 --- a/OpenRA.Mods.Common/Traits/World/ControlGroups.cs +++ b/OpenRA.Mods.Common/Traits/World/ControlGroups.cs @@ -141,7 +141,7 @@ namespace OpenRA.Mods.Common.Traits foreach (var n in groupsNode.Value.Nodes) { var group = FieldLoader.GetValue(n.Key, n.Value.Value) - .Select(a => self.World.GetActorById(a)).Where(a => a != null); + .Select(self.World.GetActorById).Where(a => a != null); controlGroups[Exts.ParseInt32Invariant(n.Key)].AddRange(group); } } diff --git a/OpenRA.Mods.Common/Traits/World/Selection.cs b/OpenRA.Mods.Common/Traits/World/Selection.cs index 5dfcd0f2e9..c09381c752 100644 --- a/OpenRA.Mods.Common/Traits/World/Selection.cs +++ b/OpenRA.Mods.Common/Traits/World/Selection.cs @@ -191,7 +191,7 @@ namespace OpenRA.Mods.Common.Traits if (selectionNode != null) { var selected = FieldLoader.GetValue("Selection", selectionNode.Value.Value) - .Select(a => self.World.GetActorById(a)).Where(a => a != null); + .Select(self.World.GetActorById).Where(a => a != null); Combine(self.World, selected, false, false); } } diff --git a/OpenRA.Mods.Common/Traits/World/ShroudRenderer.cs b/OpenRA.Mods.Common/Traits/World/ShroudRenderer.cs index 413094652b..0855da3aad 100644 --- a/OpenRA.Mods.Common/Traits/World/ShroudRenderer.cs +++ b/OpenRA.Mods.Common/Traits/World/ShroudRenderer.cs @@ -303,7 +303,7 @@ namespace OpenRA.Mods.Common.Traits if (newShroud != null) { - cellVisibility = puv => newShroud.GetVisibility(puv); + cellVisibility = newShroud.GetVisibility; newShroud.OnShroudChanged += UpdateShroudCell; } else diff --git a/OpenRA.Mods.Common/Util.cs b/OpenRA.Mods.Common/Util.cs index 9d0370f98e..f0c7453d57 100644 --- a/OpenRA.Mods.Common/Util.cs +++ b/OpenRA.Mods.Common/Util.cs @@ -193,7 +193,7 @@ namespace OpenRA.Mods.Common public static IEnumerable AdjacentCells(World w, in Target target) { - var cells = target.Positions.Select(p => w.Map.CellContaining(p)).Distinct(); + var cells = target.Positions.Select(w.Map.CellContaining).Distinct(); return ExpandFootprint(cells, true); } diff --git a/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs index 02f56aad73..d4440b85ff 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs @@ -191,7 +191,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic } filenameInput = panel.Get("FILENAME_INPUT"); - filenameInput.OnTextEdited = () => ApplyFilter(); + filenameInput.OnTextEdited = ApplyFilter; filenameInput.OnEscKey = _ => { if (string.IsNullOrEmpty(filenameInput.Text)) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorEditLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorEditLogic.cs index 71b43962f4..e5d1ad63e6 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorEditLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorEditLogic.cs @@ -265,7 +265,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic slider.GetValue = () => so.GetValue(SelectedActor); slider.OnChange += value => so.OnChange(SelectedActor, value); - slider.OnChange += value => editorActionHandle.OnChange(value); + slider.OnChange += editorActionHandle.OnChange; var valueField = sliderContainer.GetOrNull("VALUE"); if (valueField != null) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Editor/MapEditorLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Editor/MapEditorLogic.cs index 03745c74fe..11bfd09da7 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Editor/MapEditorLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Editor/MapEditorLogic.cs @@ -48,9 +48,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic { var actionManager = world.WorldActor.Trait(); undoButton.IsDisabled = () => !actionManager.HasUndos(); - undoButton.OnClick = () => actionManager.Undo(); + undoButton.OnClick = actionManager.Undo; redoButton.IsDisabled = () => !actionManager.HasRedos(); - redoButton.OnClick = () => actionManager.Redo(); + redoButton.OnClick = actionManager.Redo; } } } diff --git a/OpenRA.Mods.Common/Widgets/Logic/Editor/MapEditorSelectionLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Editor/MapEditorSelectionLogic.cs index 238749b584..35d8499add 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Editor/MapEditorSelectionLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Editor/MapEditorSelectionLogic.cs @@ -110,7 +110,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic void CreateCategoryPanel(MapBlitFilters copyFilter, CheckboxWidget checkbox) { - checkbox.GetText = () => copyFilter.ToString(); + checkbox.GetText = copyFilter.ToString; checkbox.IsChecked = () => selectionFilters.HasFlag(copyFilter); checkbox.IsVisible = () => true; checkbox.OnClick = () => selectionFilters ^= copyFilter; diff --git a/OpenRA.Mods.Common/Widgets/Logic/Editor/MapOverlaysLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Editor/MapOverlaysLogic.cs index 5c4690743a..d4bdf6d672 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Editor/MapOverlaysLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Editor/MapOverlaysLogic.cs @@ -102,7 +102,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic foreach (var cat in allCategories) { var category = categoryTemplate.Clone(); - category.GetText = () => cat.ToString(); + category.GetText = cat.ToString; category.IsVisible = () => true; if (cat.HasFlag(MapOverlays.Grid)) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Editor/SaveMapLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Editor/SaveMapLogic.cs index af30a0dd49..8a83e979b2 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Editor/SaveMapLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Editor/SaveMapLogic.cs @@ -98,7 +98,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic continue; var checkbox = visOptionTemplate.Clone(); - checkbox.GetText = () => visibilityOption.ToString(); + checkbox.GetText = visibilityOption.ToString; checkbox.IsChecked = () => map.Visibility.HasFlag(visibilityOption); checkbox.OnClick = () => map.Visibility ^= visibilityOption; visibilityPanel.AddChild(checkbox); diff --git a/OpenRA.Mods.Common/Widgets/Logic/GameSaveBrowserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/GameSaveBrowserLogic.cs index 4cade90fd1..a410da7223 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/GameSaveBrowserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/GameSaveBrowserLogic.cs @@ -118,8 +118,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic saveWidgets.IsVisible = () => true; saveTextField = saveWidgets.Get("SAVE_TEXTFIELD"); - saveTextField.OnEnterKey = input => saveButton.HandleKeyPress(input); - saveTextField.OnEscKey = input => cancelButton.HandleKeyPress(input); + saveTextField.OnEnterKey = saveButton.HandleKeyPress; + saveTextField.OnEscKey = cancelButton.HandleKeyPress; } else { @@ -226,7 +226,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic } var savePaths = Directory.GetFiles(baseSavePath, "*.orasav", SearchOption.AllDirectories) - .OrderByDescending(p => File.GetLastWriteTime(p)) + .OrderByDescending(File.GetLastWriteTime) .ToList(); foreach (var savePath in savePaths) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverStatsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverStatsLogic.cs index 5381e5d919..400a75be28 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverStatsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverStatsLogic.cs @@ -196,8 +196,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic CreateStatsOption(SupportPowers, ObserverStatsPanel.SupportPowers, supportPowersPlayerTemplate, () => DisplayStats(SupportPowerStats)), CreateStatsOption(Combat, ObserverStatsPanel.Combat, combatPlayerTemplate, () => DisplayStats(CombatStats)), CreateStatsOption(Army, ObserverStatsPanel.Army, armyPlayerTemplate, () => DisplayStats(ArmyStats)), - CreateStatsOption(EarningsGraph, ObserverStatsPanel.Graph, null, () => IncomeGraph()), - CreateStatsOption(ArmyGraph, ObserverStatsPanel.ArmyGraph, null, () => ArmyValueGraph()), + CreateStatsOption(EarningsGraph, ObserverStatsPanel.Graph, null, IncomeGraph), + CreateStatsOption(ArmyGraph, ObserverStatsPanel.ArmyGraph, null, ArmyValueGraph), }; ScrollItemWidget SetupItem(StatsDropDownOption option, ScrollItemWidget template) @@ -352,7 +352,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var armyText = new CachedTransform(i => "$" + i.ToString(NumberFormatInfo.CurrentInfo)); template.Get("ARMY_VALUE").GetText = () => armyText.Update(stats.ArmyValue); - var visionText = new CachedTransform(i => Vision(i)); + var visionText = new CachedTransform(Vision); template.Get("VISION").GetText = () => player.Shroud.Disabled ? "100%" : visionText.Update(player.Shroud.RevealedCells); return template; @@ -520,7 +520,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var experienceText = new CachedTransform(i => i.ToString(NumberFormatInfo.CurrentInfo)); template.Get("EXPERIENCE").GetText = () => experienceText.Update(stats.Experience); - var actionsText = new CachedTransform(d => AverageOrdersPerMinute(d)); + var actionsText = new CachedTransform(AverageOrdersPerMinute); template.Get("ACTIONS_MIN").GetText = () => actionsText.Update(stats.OrderCount); return template; diff --git a/OpenRA.Mods.Common/Widgets/Logic/ReplayBrowserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/ReplayBrowserLogic.cs index 01b09bbeb7..3e310fe58d 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/ReplayBrowserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/ReplayBrowserLogic.cs @@ -793,7 +793,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var item = ScrollItemWidget.Setup(template, () => selectedReplay == replay, () => SelectReplay(replay), - () => WatchReplay()); + WatchReplay); replayState[replay] = new ReplayState { diff --git a/OpenRA.Mods.Common/Widgets/Logic/Settings/HotkeysSettingsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Settings/HotkeysSettingsLogic.cs index 9a82b6f5b4..27e86b1703 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Settings/HotkeysSettingsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Settings/HotkeysSettingsLogic.cs @@ -118,7 +118,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic contexts.UnionWith(hd.Contexts); filterInput = panel.Get("FILTER_INPUT"); - filterInput.OnTextEdited = () => InitHotkeyList(); + filterInput.OnTextEdited = InitHotkeyList; filterInput.OnEscKey = _ => { if (string.IsNullOrEmpty(filterInput.Text)) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Settings/InputSettingsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Settings/InputSettingsLogic.cs index 67cbad3f8b..83ad8c9abe 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Settings/InputSettingsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Settings/InputSettingsLogic.cs @@ -68,7 +68,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var mouseScrollDropdown = panel.Get("MOUSE_SCROLL_TYPE_DROPDOWN"); mouseScrollDropdown.OnMouseDown = _ => ShowMouseScrollDropdown(mouseScrollDropdown, gs); - mouseScrollDropdown.GetText = () => gs.MouseScroll.ToString(); + mouseScrollDropdown.GetText = gs.MouseScroll.ToString; var mouseControlDescClassic = panel.Get("MOUSE_CONTROL_DESC_CLASSIC"); mouseControlDescClassic.IsVisible = () => gs.UseClassicMouseStyle; @@ -113,7 +113,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic var zoomModifierDropdown = panel.Get("ZOOM_MODIFIER"); zoomModifierDropdown.OnMouseDown = _ => ShowZoomModifierDropdown(zoomModifierDropdown, gs); - zoomModifierDropdown.GetText = () => gs.ZoomModifier.ToString(); + zoomModifierDropdown.GetText = gs.ZoomModifier.ToString; SettingsUtils.AdjustSettingsScrollPanelLayout(scrollPanel); diff --git a/OpenRA.Mods.Common/Widgets/TextFieldWidget.cs b/OpenRA.Mods.Common/Widgets/TextFieldWidget.cs index ca0a798fb2..acc8572181 100644 --- a/OpenRA.Mods.Common/Widgets/TextFieldWidget.cs +++ b/OpenRA.Mods.Common/Widgets/TextFieldWidget.cs @@ -198,7 +198,7 @@ namespace OpenRA.Mods.Common.Widgets } case TextFieldType.Integer: - return new string(input.Where(c => char.IsDigit(c)).ToArray()); + return new string(input.Where(char.IsDigit).ToArray()); default: return input; diff --git a/OpenRA.Mods.D2k/Traits/Sandworm.cs b/OpenRA.Mods.D2k/Traits/Sandworm.cs index b223b53a68..2eee21818a 100644 --- a/OpenRA.Mods.D2k/Traits/Sandworm.cs +++ b/OpenRA.Mods.D2k/Traits/Sandworm.cs @@ -85,7 +85,7 @@ namespace OpenRA.Mods.D2k.Traits // If close enough, we don't care about other actors. var target = self.World.FindActorsInCircle(self.CenterPosition, WormInfo.IgnoreNoiseAttackRange) .WithPathFrom(self) - .Select(t => Target.FromActor(t)) + .Select(Target.FromActor) .FirstOrDefault(t => attackTrait.HasAnyValidWeapons(t)); if (target.Type == TargetType.Actor) diff --git a/OpenRA.Platforms.Default/ThreadedGraphicsContext.cs b/OpenRA.Platforms.Default/ThreadedGraphicsContext.cs index 8589cda373..5244ad680f 100644 --- a/OpenRA.Platforms.Default/ThreadedGraphicsContext.cs +++ b/OpenRA.Platforms.Default/ThreadedGraphicsContext.cs @@ -81,11 +81,11 @@ namespace OpenRA.Platforms.Default context.InitializeOpenGL(); doClear = () => { context.Clear(); return null; }; - doClearDepthBuffer = () => context.ClearDepthBuffer(); - doDisableDepthBuffer = () => context.DisableDepthBuffer(); - doEnableDepthBuffer = () => context.EnableDepthBuffer(); - doDisableScissor = () => context.DisableScissor(); - doPresent = () => context.Present(); + doClearDepthBuffer = context.ClearDepthBuffer; + doDisableDepthBuffer = context.DisableDepthBuffer; + doEnableDepthBuffer = context.EnableDepthBuffer; + doDisableScissor = context.DisableScissor; + doPresent = context.Present; getGLVersion = () => context.GLVersion; getCreateTexture = () => new ThreadedTexture(this, (ITextureInternal)context.CreateTexture()); getCreateFrameBuffer = @@ -659,7 +659,7 @@ namespace OpenRA.Platforms.Default setScaleFilter = value => texture.ScaleFilter = (TextureScaleFilter)value; getSize = () => texture.Size; setEmpty = tuple => { var t = ((int, int))tuple; texture.SetEmpty(t.Item1, t.Item2); }; - getData = () => texture.GetData(); + getData = texture.GetData; setData1 = tuple => { var t = ((byte[], int, int))tuple; texture.SetData(t.Item1, t.Item2, t.Item3); }; setData2 = tuple => { setData1(tuple); return null; }; setData3 = tuple => { var t = ((float[], int, int))tuple; texture.SetFloatData(t.Item1, t.Item2, t.Item3); };