Skip to content

Commit

Permalink
Merge pull request #655 from sharwell/set-severity
Browse files Browse the repository at this point in the history
Use ReportDiagnostic.Default where analyzers are already enabled by default
  • Loading branch information
sharwell authored Nov 9, 2020
2 parents c120f8c + 7112c69 commit 27667f1
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1201,14 +1201,21 @@ protected virtual Project ApplyCompilationOptions(Project project)
foreach (var diagnostic in analyzer.SupportedDiagnostics)
{
// make sure the analyzers we are testing are enabled
supportedDiagnosticsSpecificOptions[diagnostic.Id] = diagnostic.DefaultSeverity switch
if (diagnostic.IsEnabledByDefault)
{
DiagnosticSeverity.Hidden => ReportDiagnostic.Hidden,
DiagnosticSeverity.Info => ReportDiagnostic.Info,
DiagnosticSeverity.Warning => ReportDiagnostic.Warn,
DiagnosticSeverity.Error => ReportDiagnostic.Error,
_ => throw new InvalidOperationException(),
};
supportedDiagnosticsSpecificOptions[diagnostic.Id] = ReportDiagnostic.Default;
}
else
{
supportedDiagnosticsSpecificOptions[diagnostic.Id] = diagnostic.DefaultSeverity switch
{
DiagnosticSeverity.Hidden => ReportDiagnostic.Hidden,
DiagnosticSeverity.Info => ReportDiagnostic.Info,
DiagnosticSeverity.Warning => ReportDiagnostic.Warn,
DiagnosticSeverity.Error => ReportDiagnostic.Error,
_ => throw new InvalidOperationException(),
};
}
}
}

Expand Down

0 comments on commit 27667f1

Please sign in to comment.