Skip to content

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.

@ghost ghost added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Jan 22, 2025
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.

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.


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.

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.

}

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.

@CyrusNajmabadi CyrusNajmabadi marked this pull request as ready for review January 22, 2025 17:24
@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner January 22, 2025 17:24
@CyrusNajmabadi
Copy link
Member Author

@ToddGrun ptal.

project.Solution, project.Id, document.Id, diagnosticIds: null, shouldIncludeAnalyzer: null,
_includeSuppressedDiagnostics, includeLocalDocumentDiagnostics: true, _includeNonLocalDocumentDiagnostics, CancellationToken.None);
includeLocalDocumentDiagnostics: true, _includeNonLocalDocumentDiagnostics, CancellationToken.None);
dxs = dxs.WhereAsArray(d => _includeSuppressedDiagnostics || !d.IsSuppressed);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_includeSuppressedDiagnostics

another place where I think it would read easier to me to have the _includeSuppressedDiagnostics checked in an external if.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enh. this is tests. i'm fine with this.

Copy link
Contributor

@ToddGrun ToddGrun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

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.

3 participants