From 67aa0cdede383bfeb8e8b8d3d06ff2833531bac5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Tue, 6 Sep 2022 18:08:25 +0200 Subject: [PATCH] Avoid Count() when Any() could be used (CA1827) --- .editorconfig | 3 +++ .../UtilityCommands/ExtractSettingsDocsCommand.cs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index 7fc0d48e29..e761cbe1a6 100644 --- a/.editorconfig +++ b/.editorconfig @@ -156,6 +156,9 @@ dotnet_diagnostic.CA1825.severity = warning # Do not use Enumerable methods on indexable collections. Instead use the collection directly. dotnet_diagnostic.CA1826.severity = warning +# Count() is used where Any() could be used instead to improve performance. +dotnet_diagnostic.CA1827.severity = warning + # Use string.Contains(char) instead of string.Contains(string) with single characters. dotnet_diagnostic.CA1847.severity = warning diff --git a/OpenRA.Mods.Common/UtilityCommands/ExtractSettingsDocsCommand.cs b/OpenRA.Mods.Common/UtilityCommands/ExtractSettingsDocsCommand.cs index 0cbe3a2ad2..a8472d7242 100644 --- a/OpenRA.Mods.Common/UtilityCommands/ExtractSettingsDocsCommand.cs +++ b/OpenRA.Mods.Common/UtilityCommands/ExtractSettingsDocsCommand.cs @@ -59,7 +59,7 @@ namespace OpenRA.Mods.Common.UtilityCommands foreach (var section in sections.OrderBy(s => s.Key)) { var fields = section.Value.GetType().GetFields(); - if (fields.Length > 0 && fields.Where(field => field.GetCustomAttributes(false).Length > 0).Count() > 0) + if (fields.Any(field => field.GetCustomAttributes(false).Length > 0)) Console.WriteLine($"## {section.Key}"); else Console.WriteLine();