-
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
Push diagnostic suppression filtering flag to feature levels #76849
base: main
Are you sure you want to change the base?
Push diagnostic suppression filtering flag to feature levels #76849
Conversation
@@ -128,7 +128,6 @@ private async Task ProduceTagsAsync( | |||
document, | |||
requestedSpan.Span.ToTextSpan(), | |||
diagnosticKind: _diagnosticKind, | |||
includeSuppressedDiagnostics: true, |
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.
Note: if a featuree passes includeSuppressedDiagnostics: true
, it needs no change. We always return all diagnostics by default, including suppressed ones.
@@ -69,7 +69,8 @@ public async Task TestHasSuccessfullyLoadedBeingFalse() | |||
|
|||
var diagnostics = await analyzer.GetDiagnosticsForIdsAsync( | |||
workspace.CurrentSolution, projectId: null, documentId: null, diagnosticIds: null, shouldIncludeAnalyzer: null, getDocuments: null, | |||
includeSuppressedDiagnostics: false, includeLocalDocumentDiagnostics: true, includeNonLocalDocumentDiagnostics: false, CancellationToken.None); | |||
includeLocalDocumentDiagnostics: true, includeNonLocalDocumentDiagnostics: false, CancellationToken.None); | |||
diagnostics = diagnostics.WhereAsArray(d => !d.IsSuppressed); |
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.
note: code that passes includeSuppressedDiagnostics: false
needs to filter the results. I do that for features. HOwever, for tests, it doesn't seem to have any impact on results. so for simplicity i'm not doing it.
@@ -69,7 +69,8 @@ public async Task TestHasSuccessfullyLoadedBeingFalse() | |||
|
|||
var diagnostics = await analyzer.GetDiagnosticsForIdsAsync( | |||
workspace.CurrentSolution, projectId: null, documentId: null, diagnosticIds: null, shouldIncludeAnalyzer: null, getDocuments: null, | |||
includeSuppressedDiagnostics: false, includeLocalDocumentDiagnostics: true, includeNonLocalDocumentDiagnostics: false, CancellationToken.None); |
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.
note: code that passes includeSuppressedDiagnostics: false needs to filter the results. I do that for features. HOwever, for tests, it doesn't seem to have any impact on results. so for simplicity i'm not doing it.
var diagnostics = await _diagnosticAnalyzerService.GetCachedDiagnosticsAsync( | ||
_workspace, documentId.ProjectId, documentId, includeLocalDocumentDiagnostics: true, | ||
includeNonLocalDocumentDiagnostics: true, cancellationToken).ConfigureAwait(false); | ||
return diagnostics.WhereAsArray(d => !d.IsSuppressed); |
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.
any place that previously passed includeSuppressedDiagnostics: false
into the service, now just filters the result.
Note: i wouldn't mind having this not be here, and pushignt his even higher all the way to the feature layer. but this is a simple starting step.
/// Flag indicating if suppressed diagnostics should be returned. | ||
/// </summary> | ||
[DataMember(Order = 0)] | ||
public bool ReportSuppressedDiagnostics; |
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.
not needed. they are always returned.
TextDocument document, TextSpan? range, DiagnosticKind diagnosticKind, CancellationToken cancellationToken) | ||
=> service.GetDiagnosticsForSpanAsync( | ||
document, range, | ||
diagnosticId: null, | ||
priorityProvider: new DefaultCodeActionRequestPriorityProvider(), | ||
diagnosticKind, isExplicit: false, cancellationToken); |
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.
any code that just passed the flag along just has it removed.
callback(diagnostic); | ||
} | ||
} | ||
|
||
private bool ShouldIncludeSuppressedDiagnostic(DiagnosticData diagnostic) | ||
=> IncludeSuppressedDiagnostics || !diagnostic.IsSuppressed; |
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.
this is what the flag was passed down all the way to do.
This flag was pushed all the way down to the compiler layer. But all the compiler uses it for is for filtering out diagnostics with the .IsSuppressed bit on it. This is a lot of scaffolding through lots of complex layers (including caching layers) only to just filter the diagnostics. There are not that many features that actually consume diagnostics, so we it's fine to just compute all the diagnostics like normal and have the filtering be at the feature level.