From b1a37303779fca774b3150efcba419384466efaf Mon Sep 17 00:00:00 2001 From: xtqqczze Date: Thu, 29 Oct 2020 15:10:58 +0000 Subject: [PATCH] Enable CA1827: Do not use Count() or LongCount() when Any() can be used https://docs.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1827 --- .globalconfig | 2 +- .../engine/Modules/ModuleCmdletBase.cs | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.globalconfig b/.globalconfig index f283635034e..1caa06afd82 100644 --- a/.globalconfig +++ b/.globalconfig @@ -292,7 +292,7 @@ dotnet_diagnostic.CA1825.severity = suggestion dotnet_diagnostic.CA1826.severity = suggestion # CA1827: Do not use Count() or LongCount() when Any() can be used -dotnet_diagnostic.CA1827.severity = suggestion +dotnet_diagnostic.CA1827.severity = warning # CA1828: Do not use CountAsync() or LongCountAsync() when AnyAsync() can be used dotnet_diagnostic.CA1828.severity = suggestion diff --git a/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs b/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs index 29cc066324f..7bf014dd64c 100644 --- a/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs +++ b/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs @@ -3213,7 +3213,7 @@ internal PSModuleInfo LoadModuleManifest( newManifestInfo.Prefix = resolvedCommandPrefix; } - if (newManifestInfo.FileList == null || newManifestInfo.FileList.LongCount() == 0) + if (newManifestInfo.FileList == null || !newManifestInfo.FileList.Any()) { if (fileList != null) { @@ -3224,7 +3224,7 @@ internal PSModuleInfo LoadModuleManifest( } } - if (newManifestInfo.ModuleList == null || newManifestInfo.ModuleList.LongCount() == 0) + if (newManifestInfo.ModuleList == null || !newManifestInfo.ModuleList.Any()) { if (moduleList != null) { @@ -3235,7 +3235,7 @@ internal PSModuleInfo LoadModuleManifest( } } - if (newManifestInfo.CompatiblePSEditions == null || newManifestInfo.CompatiblePSEditions.LongCount() == 0) + if (newManifestInfo.CompatiblePSEditions == null || !newManifestInfo.CompatiblePSEditions.Any()) { if (compatiblePSEditions != null) { @@ -3248,7 +3248,7 @@ internal PSModuleInfo LoadModuleManifest( newManifestInfo.ProcessorArchitecture = requiredProcessorArchitecture; } - if (newManifestInfo.RequiredAssemblies == null || newManifestInfo.RequiredAssemblies.LongCount() == 0) + if (newManifestInfo.RequiredAssemblies == null || !newManifestInfo.RequiredAssemblies.Any()) { if (assemblyList != null) { @@ -3259,7 +3259,7 @@ internal PSModuleInfo LoadModuleManifest( } } - if (newManifestInfo.Scripts == null || newManifestInfo.Scripts.LongCount() == 0) + if (newManifestInfo.Scripts == null || !newManifestInfo.Scripts.Any()) { if (scriptsToProcess != null) {