提交 e4a27cf4 编写于 作者: M Manish Vasani

Adjust unsuppressed error check and doc comments.

上级 a1859bf8
...@@ -560,18 +560,19 @@ internal bool ReportDiagnostics(IEnumerable<DiagnosticInfo> diagnostics, TextWri ...@@ -560,18 +560,19 @@ internal bool ReportDiagnostics(IEnumerable<DiagnosticInfo> diagnostics, TextWri
=> ReportDiagnostics(diagnostics.Select(info => Diagnostic.Create(info)), consoleOutput, errorLoggerOpt); => ReportDiagnostics(diagnostics.Select(info => Diagnostic.Create(info)), consoleOutput, errorLoggerOpt);
/// <summary> /// <summary>
/// Returns true if there are any diagnostics in the bag which have default severity error and are /// Returns true if there are any error diagnostics in the bag which cannot be suppressed and
/// not marked "suppressed". Note: does NOT do filtering, so it may return false if a /// are guaranteed to break the build.
/// Only diagnostics which have default severity error and are tagged as NotConfigurable fall in this bucket.
/// This includes all compiler error diagnostics and specific analyzer error diagnostics that are marked as not configurable by the analyzer author.
/// Note: does NOT do filtering, so it may return false if a
/// non-error diagnostic were later elevated to an error through filtering (e.g., through /// non-error diagnostic were later elevated to an error through filtering (e.g., through
/// warn-as-error). This is meant to be a check if there are any "real" errors, in the bag /// warn-as-error).
/// since diagnostics with default "error" severity can never be suppressed or reduced
/// below error severity.
/// </summary> /// </summary>
internal static bool HasUnsuppressedErrors(DiagnosticBag diagnostics) internal static bool HasUnsuppressedErrors(DiagnosticBag diagnostics)
{ {
foreach (var diag in diagnostics.AsEnumerable()) foreach (var diag in diagnostics.AsEnumerable())
{ {
if (diag.DefaultSeverity == DiagnosticSeverity.Error && !diag.IsSuppressed) if (diag.IsUnsuppressedError())
{ {
return true; return true;
} }
......
...@@ -1347,7 +1347,7 @@ internal void CompleteCompilationEventQueue_NoLock() ...@@ -1347,7 +1347,7 @@ internal void CompleteCompilationEventQueue_NoLock()
/// </summary> /// </summary>
/// <param name="accumulator">Bag to which filtered diagnostics will be added.</param> /// <param name="accumulator">Bag to which filtered diagnostics will be added.</param>
/// <param name="incoming">Diagnostics to be filtered.</param> /// <param name="incoming">Diagnostics to be filtered.</param>
/// <returns>True if there were no errors.</returns> /// <returns>True if there are no unsuppressed errors (i.e., no errors which fail compilation).</returns>
internal bool FilterAndAppendAndFreeDiagnostics(DiagnosticBag accumulator, ref DiagnosticBag incoming) internal bool FilterAndAppendAndFreeDiagnostics(DiagnosticBag accumulator, ref DiagnosticBag incoming)
{ {
bool result = FilterAndAppendDiagnostics(accumulator, incoming.AsEnumerableWithoutResolution(), exclude: null); bool result = FilterAndAppendDiagnostics(accumulator, incoming.AsEnumerableWithoutResolution(), exclude: null);
...@@ -1378,8 +1378,7 @@ internal bool FilterAndAppendDiagnostics(DiagnosticBag accumulator, IEnumerable< ...@@ -1378,8 +1378,7 @@ internal bool FilterAndAppendDiagnostics(DiagnosticBag accumulator, IEnumerable<
{ {
continue; continue;
} }
else if (filtered.DefaultSeverity == DiagnosticSeverity.Error && else if (filtered.IsUnsuppressedError())
!filtered.IsSuppressed)
{ {
hasError = true; hasError = true;
} }
......
...@@ -559,6 +559,14 @@ internal virtual bool IsNotConfigurable() ...@@ -559,6 +559,14 @@ internal virtual bool IsNotConfigurable()
{ {
return AnalyzerManager.HasNotConfigurableTag(this.CustomTags); return AnalyzerManager.HasNotConfigurableTag(this.CustomTags);
} }
/// <summary>
/// Returns true if this is an error diagnostic which cannot be suppressed and is guaranteed to break the build.
/// Only diagnostics which have default severity error and are tagged as NotConfigurable fall in this bucket.
/// This includes all compiler error diagnostics and specific analyzer error diagnostics that are marked as not configurable by the analyzer author.
/// </summary>
internal bool IsUnsuppressedError()
=> DefaultSeverity == DiagnosticSeverity.Error && IsNotConfigurable();
} }
/// <summary> /// <summary>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册