-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not skip emit if errors are suppressed #34174
Changes from 1 commit
22f872d
8224c6d
be6f079
d705714
849a1cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -434,6 +434,18 @@ internal bool ReportErrors(IEnumerable<Diagnostic> diagnostics, TextWriter conso | |
private bool ReportErrors(DiagnosticBag diagnostics, TextWriter consoleOutput, ErrorLogger errorLoggerOpt) | ||
=> ReportErrors(diagnostics.ToReadOnly(), consoleOutput, errorLoggerOpt); | ||
|
||
internal static bool HasUnsuppressedErrors(DiagnosticBag diagnostics) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The name threw me off here a bit. Felt like has not fake error. Consider a more positive term like HasReal/ReportedError. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suppressions may or may not be reported. A warning elevated to an error isn't a "real" error to me. This is the most accurate term I can think of. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It looks like this method is supposed to be called after the filtering is applied to content of the bag. It doesn't look like this happens for every call site. #Closed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure it matters. Since you can't suppress an error that was originally an error, it shouldn't make a difference. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @AlekseyTs Did this address your concern? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I do not think it did. If we haven't done filtering, we didn't have a chance to apply warn as error, correct? In reply to: 266674162 [](ancestors = 266674162) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, if it doesn't matter at many call sites, as you are saying. Then why adjusting those call sites? In reply to: 266677762 [](ancestors = 266677762,266674162) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's correct. I guess I might be thinking of a different scenario: my intention was only to use this helper as a "bailout" mechanism to stop compilation, meaning that not catching errors as early as possible may affect how soon compilation stops but not affect semantic guarantees. Did you find a place where I'm not doing that? |
||
{ | ||
foreach (var diag in diagnostics.AsEnumerableWithoutResolution()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Why without resolution? What if we there is a lazy diagnostics that becomes an error after resolution? #Closed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My understanding is that the next line causes resolution (checks severity) anyways. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Then why pretend that we do not resolve? In reply to: 266165592 [](ancestors = 266165592) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll let Andy respond, but my assumption in reading the PR was to avoid extra processing which There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it was for perf and the places I was looking at it I thought it was safe because we always realized diagnostics later, but it's not particularly worth the risk. I've changed it to resolve. |
||
{ | ||
if (IsReportedError(diag)) | ||
{ | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
/// <summary> | ||
/// Returns true if the diagnostic is an error that should be reported. | ||
/// </summary> | ||
|
@@ -648,7 +660,7 @@ private void CompileAndEmit( | |
|
||
// Print the diagnostics produced during the parsing stage and exit if there were any errors. | ||
compilation.GetDiagnostics(CompilationStage.Parse, includeEarlierStages: false, diagnostics, cancellationToken); | ||
if (diagnostics.HasAnyErrors()) | ||
if (HasUnsuppressedErrors(diagnostics)) | ||
{ | ||
return; | ||
} | ||
|
@@ -674,7 +686,7 @@ private void CompileAndEmit( | |
} | ||
|
||
compilation.GetDiagnostics(CompilationStage.Declare, includeEarlierStages: false, diagnostics, cancellationToken); | ||
if (diagnostics.HasAnyErrors()) | ||
if (HasUnsuppressedErrors(diagnostics)) | ||
{ | ||
return; | ||
} | ||
|
@@ -786,7 +798,7 @@ private void CompileAndEmit( | |
{ | ||
using (var win32ResourceStreamOpt = GetWin32Resources(MessageProvider, Arguments, compilation, diagnostics)) | ||
{ | ||
if (diagnostics.HasAnyErrors()) | ||
if (HasUnsuppressedErrors(diagnostics)) | ||
{ | ||
return; | ||
} | ||
|
@@ -882,7 +894,7 @@ private void CompileAndEmit( | |
} | ||
} | ||
|
||
if (diagnostics.HasAnyErrors()) | ||
if (HasUnsuppressedErrors(diagnostics)) | ||
{ | ||
return; | ||
} | ||
|
@@ -902,7 +914,7 @@ private void CompileAndEmit( | |
if (analyzerExceptionDiagnostics != null) | ||
{ | ||
diagnostics.AddRange(analyzerExceptionDiagnostics); | ||
if (analyzerExceptionDiagnostics.HasAnyErrors()) | ||
if (HasUnsuppressedErrors(analyzerExceptionDiagnostics)) | ||
{ | ||
return; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
using System.Collections.Immutable; | ||
using System.ComponentModel; | ||
using System.Diagnostics; | ||
using System.Diagnostics.Contracts; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Reflection; | ||
|
@@ -1370,13 +1371,15 @@ internal bool FilterAndAppendDiagnostics(DiagnosticBag accumulator, IEnumerable< | |
continue; | ||
} | ||
|
||
|
||
var filtered = Options.FilterDiagnostic(d); | ||
agocke marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (filtered == null || | ||
(!reportSuppressedDiagnostics && filtered.IsSuppressed)) | ||
{ | ||
continue; | ||
} | ||
else if (filtered.Severity == DiagnosticSeverity.Error) | ||
else if (filtered.Severity == DiagnosticSeverity.Error && | ||
!filtered.IsSuppressed) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I see that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It looks like previous There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are respecting the option. If that option is false we won't set In other words, And reporting is just a completely different option that controls whether or not the diagnostic is output to the log at all. |
||
{ | ||
hasError = true; | ||
} | ||
|
@@ -2578,7 +2581,7 @@ internal CommonPEModuleBuilder CheckOptionsAndCreateModuleBuilder( | |
} | ||
} | ||
|
||
if (diagnostics.HasAnyErrors()) | ||
if (CommonCompiler.HasUnsuppressedErrors(diagnostics)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Have we done filtering to get suppression state? #Closed |
||
{ | ||
return null; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is the windows path here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There technically isn't one, but I'm running an exe, which only works on Windows desktop and needed a reason.