From bf960b6eaec25d0ce921a18cba104adb10be14a8 Mon Sep 17 00:00:00 2001 From: RoosterDragon Date: Sun, 19 Feb 2023 12:37:03 +0000 Subject: [PATCH] Fix IDE0120 --- .editorconfig | 3 +++ OpenRA.Game/Map/Map.cs | 2 +- .../Traits/Render/ProductionIconOverlayManager.cs | 2 +- OpenRA.Mods.Common/Traits/Render/WithProductionIconOverlay.cs | 4 ++-- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.editorconfig b/.editorconfig index 3afbeaf1a5..d0b321b7d3 100644 --- a/.editorconfig +++ b/.editorconfig @@ -210,6 +210,9 @@ dotnet_diagnostic.IDE0082.severity = warning # Remove unnecessary equality operator. dotnet_diagnostic.IDE0100.severity = warning +# Simplify LINQ expression. +dotnet_diagnostic.IDE0120.severity = warning + # Naming rule violation. dotnet_diagnostic.IDE1006.severity = warning diff --git a/OpenRA.Game/Map/Map.cs b/OpenRA.Game/Map/Map.cs index 8f0a295f26..2dd665d8d4 100644 --- a/OpenRA.Game/Map/Map.cs +++ b/OpenRA.Game/Map/Map.cs @@ -748,7 +748,7 @@ namespace OpenRA public byte[] SavePreview() { var actorTypes = Rules.Actors.Values.Where(a => a.HasTraitInfo()); - var actors = ActorDefinitions.Where(a => actorTypes.Where(ai => ai.Name == a.Value.Value).Any()); + var actors = ActorDefinitions.Where(a => actorTypes.Any(ai => ai.Name == a.Value.Value)); var positions = new List<(MPos Position, Color Color)>(); foreach (var actor in actors) { diff --git a/OpenRA.Mods.Common/Traits/Render/ProductionIconOverlayManager.cs b/OpenRA.Mods.Common/Traits/Render/ProductionIconOverlayManager.cs index a86049273a..78e9f1e3fb 100644 --- a/OpenRA.Mods.Common/Traits/Render/ProductionIconOverlayManager.cs +++ b/OpenRA.Mods.Common/Traits/Render/ProductionIconOverlayManager.cs @@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Traits.Render public virtual void RulesetLoaded(Ruleset rules, ActorInfo ai) { - if (rules.Actors[SystemActors.Player].TraitInfos().Where(piom => piom != this && piom.Type == Type).Any()) + if (rules.Actors[SystemActors.Player].TraitInfos().Any(piom => piom != this && piom.Type == Type)) throw new YamlException($"Multiple 'ProductionIconOverlayManager's with type '{Type}' exist."); } diff --git a/OpenRA.Mods.Common/Traits/Render/WithProductionIconOverlay.cs b/OpenRA.Mods.Common/Traits/Render/WithProductionIconOverlay.cs index 7762337555..9aa88c838d 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithProductionIconOverlay.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithProductionIconOverlay.cs @@ -27,10 +27,10 @@ namespace OpenRA.Mods.Common.Traits.Render { foreach (var type in Types) { - if (!rules.Actors[SystemActors.Player].TraitInfos().Where(piom => piom.Type == type).Any()) + if (!rules.Actors[SystemActors.Player].TraitInfos().Any(piom => piom.Type == type)) throw new YamlException($"A 'ProductionIconOverlayManager' with type '{type}' doesn't exist."); - if (ai.TraitInfos().Where(wpio => wpio != this && wpio.Types.Contains(type)).Any()) + if (ai.TraitInfos().Any(wpio => wpio != this && wpio.Types.Contains(type))) throw new YamlException($"Multiple 'WithProductionIconOverlay's with type '{type}' exist on the actor."); } }