From b77bbf8640b7e5f43af719878edce3c2617e6ec9 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Sun, 27 Jun 2021 16:16:17 +0100 Subject: [PATCH] Enable CA1812 (#15674) [CA1812: Avoid uninstantiated internal classes](https://docs.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1812) --- .globalconfig | 2 +- .../commands/utility/Join-String.cs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.globalconfig b/.globalconfig index c995b37d7a..7f8beba3a7 100644 --- a/.globalconfig +++ b/.globalconfig @@ -346,7 +346,7 @@ dotnet_diagnostic.CA1810.severity = none # CA1812: Avoid uninstantiated internal classes # https://docs.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1812 -dotnet_diagnostic.CA1812.severity = none +dotnet_diagnostic.CA1812.severity = warning # CA1813: Avoid unsealed attributes # https://docs.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1813 diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Join-String.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Join-String.cs index 16243fcf6a..0aebabe94c 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Join-String.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Join-String.cs @@ -4,6 +4,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; using System.Management.Automation; @@ -159,6 +160,10 @@ namespace Microsoft.PowerShell.Commands.Utility } } + [SuppressMessage( + "Microsoft.Performance", + "CA1812:AvoidUninstantiatedInternalClasses", + Justification = "Class is instantiated through late-bound reflection")] internal class JoinItemCompleter : IArgumentCompleter { public IEnumerable CompleteArgument(