From 19fde51a109a49f694c8a2e4b1625c34cabe823a Mon Sep 17 00:00:00 2001 From: Kirill Osenkov Date: Sat, 5 Oct 2024 20:26:12 -0700 Subject: [PATCH] Support hidden severity for analyzers and code fixes Without this, you can't fix diagnostics such as --diagnostics VSTHRD111 --severity hidden --- src/BuiltInTools/dotnet-format/Commands/FormatCommandCommon.cs | 3 ++- src/BuiltInTools/dotnet-format/FixSeverity.cs | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/BuiltInTools/dotnet-format/Commands/FormatCommandCommon.cs b/src/BuiltInTools/dotnet-format/Commands/FormatCommandCommon.cs index 64548392e484..9814c416fba3 100644 --- a/src/BuiltInTools/dotnet-format/Commands/FormatCommandCommon.cs +++ b/src/BuiltInTools/dotnet-format/Commands/FormatCommandCommon.cs @@ -17,7 +17,7 @@ internal static class FormatCommandCommon internal const int UnableToLocateMSBuildExitCode = 3; private static string[] VerbosityLevels => new[] { "q", "quiet", "m", "minimal", "n", "normal", "d", "detailed", "diag", "diagnostic" }; - private static string[] SeverityLevels => new[] { "info", "warn", "error" }; + private static string[] SeverityLevels => new[] { "info", "warn", "error", "hidden" }; public static readonly Argument SlnOrProjectArgument = new Argument(Resources.SolutionOrProjectArgumentName) { @@ -290,6 +290,7 @@ internal static DiagnosticSeverity GetSeverity(string? severity) FixSeverity.Error => DiagnosticSeverity.Error, FixSeverity.Warn => DiagnosticSeverity.Warning, FixSeverity.Info => DiagnosticSeverity.Info, + FixSeverity.Hidden => DiagnosticSeverity.Hidden, _ => throw new ArgumentOutOfRangeException(nameof(severity)), }; } diff --git a/src/BuiltInTools/dotnet-format/FixSeverity.cs b/src/BuiltInTools/dotnet-format/FixSeverity.cs index 47b719bda074..8ea9fc094a36 100644 --- a/src/BuiltInTools/dotnet-format/FixSeverity.cs +++ b/src/BuiltInTools/dotnet-format/FixSeverity.cs @@ -7,5 +7,6 @@ public static class FixSeverity public const string Error = "error"; public const string Warn = "warn"; public const string Info = "info"; + public const string Hidden = "hidden"; } }