From 9247ccc8d8b247b68207552833faa8fce9e71249 Mon Sep 17 00:00:00 2001 From: Josef Pihrt Date: Tue, 23 Apr 2024 21:10:54 +0200 Subject: [PATCH] Fix --severity-level (#1449) --- ChangeLog.md | 1 + src/Workspaces.Core/Diagnostics/CodeAnalyzer.cs | 6 +++--- src/Workspaces.Core/Extensions/Extensions.cs | 3 --- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index d01f44d805..4275a182f0 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - [CLI] Fix loading of `slnf` files ([PR](https://github.com/dotnet/roslynator/pull/1447)) +- [CLI] Fix `--severity-level` ([PR](https://github.com/dotnet/roslynator/pull/1449)) ## [4.12.1] - 2024-04-15 diff --git a/src/Workspaces.Core/Diagnostics/CodeAnalyzer.cs b/src/Workspaces.Core/Diagnostics/CodeAnalyzer.cs index 2b33de202e..88f9c9b329 100644 --- a/src/Workspaces.Core/Diagnostics/CodeAnalyzer.cs +++ b/src/Workspaces.Core/Diagnostics/CodeAnalyzer.cs @@ -203,8 +203,7 @@ private IEnumerable FilterDiagnostics(IEnumerable diagno { foreach (Diagnostic diagnostic in diagnostics) { - if (diagnostic.IsEffective(Options, project.CompilationOptions, cancellationToken) - && (Options.ReportNotConfigurable || !diagnostic.Descriptor.CustomTags.Contains(WellKnownDiagnosticTags.NotConfigurable))) + if (diagnostic.IsEffective(Options, project.CompilationOptions, cancellationToken)) { if (diagnostic.Descriptor.CustomTags.Contains(WellKnownDiagnosticTags.Compiler)) { @@ -222,7 +221,8 @@ private IEnumerable FilterDiagnostics(IEnumerable diagno } } } - else + else if (Options.ReportNotConfigurable + || !diagnostic.Descriptor.CustomTags.Contains(WellKnownDiagnosticTags.NotConfigurable)) { yield return diagnostic; } diff --git a/src/Workspaces.Core/Extensions/Extensions.cs b/src/Workspaces.Core/Extensions/Extensions.cs index 74ba99b1ce..7cc8c3bb90 100644 --- a/src/Workspaces.Core/Extensions/Extensions.cs +++ b/src/Workspaces.Core/Extensions/Extensions.cs @@ -448,9 +448,6 @@ public static ConsoleColors GetColors(this WorkspaceDiagnosticKind kind) if (!codeAnalysisOptions.IsSupportedDiagnosticId(diagnostic.Id)) return false; - if (diagnostic.Descriptor.CustomTags.Contains(WellKnownDiagnosticTags.Compiler)) - return true; - SyntaxTree? tree = diagnostic.Location.SourceTree; ReportDiagnostic reportDiagnostic = diagnostic.Descriptor.GetEffectiveSeverity(tree, compilationOptions, cancellationToken);