Skip to content
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

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

CyrusNajmabadi
Copy link
Member

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.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Jan 22, 2025
@@ -128,7 +128,6 @@ private async Task ProduceTagsAsync(
document,
requestedSpan.Span.ToTextSpan(),
diagnosticKind: _diagnosticKind,
includeSuppressedDiagnostics: true,
Copy link
Member Author

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);
Copy link
Member Author

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);
Copy link
Member Author

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);
Copy link
Member Author

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;
Copy link
Member Author

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);
Copy link
Member Author

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;
Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead VSCode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy