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

Remove 'state set' concept for diagnostic analysis subsystem. #77121

Merged
merged 25 commits into from
Feb 10, 2025

Conversation

CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi commented Feb 8, 2025

Followup to #77113

This was just a class wrapping a DiagnosticAnalyzer and a bool saying if it was a host-analyzer or not. It's just much simpler and cleaner to pass around DiagnosticAnalyzers and occasionally call to a separate helper to determine if it is a host analyzer or not.

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner February 8, 2025 18:40
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Analyzers untriaged Issues and PRs which have not yet been triaged by a lead labels Feb 8, 2025

private sealed class HostAnalyzerStateSets
private sealed class HostAnalyzerInfo
Copy link
Member Author

Choose a reason for hiding this comment

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

view with whitespace off. this moved up one level of nesting so other callers could talk directly to this.

// return existing state sets
// No need to use _projectAnalyzerStateMapGuard during reads of _projectAnalyzerStateMap
return _projectAnalyzerStateMap.Values.SelectManyAsArray(e => e.StateSetMap.Values);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

never called.

@CyrusNajmabadi
Copy link
Member Author

@dibarbet ptal

@CyrusNajmabadi CyrusNajmabadi marked this pull request as draft February 8, 2025 18:57
@CyrusNajmabadi CyrusNajmabadi marked this pull request as ready for review February 9, 2025 01:34
@CyrusNajmabadi
Copy link
Member Author

@dibarbet @JoeRobich This is ready for review.

@CyrusNajmabadi
Copy link
Member Author

@ToddGrun ptal

@@ -59,8 +61,8 @@ internal partial class DiagnosticAnalyzerService
// </summary>
async Task<CompilationWithAnalyzersPair?> CreateCompilationWithAnalyzersAsync()
{
var projectAnalyzers = stateSets.SelectAsArray(s => !s.IsHostAnalyzer, s => s.Analyzer);
var hostAnalyzers = stateSets.SelectAsArray(s => s.IsHostAnalyzer, s => s.Analyzer);
var projectAnalyzers = analyzers.WhereAsArray(static (s, info) => !info.IsHostAnalyzer(s), hostAnalyzerInfo);
Copy link
Contributor

Choose a reason for hiding this comment

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

var projectAnalyzers = analyzers.WhereAsArray(static (s, info) => !info.IsHostAnalyzer(s), hostAnalyzerInfo);

mentioned this after one of the earlier PRs had already been merged, but the projectAnalyzers/hostAnalyzers arrays appear to be intermediary arrays used only once, and the WhereAsArray conditions to create the filtered versions could be slightly modified to not need the intermediary arrays.

Copy link
Member Author

Choose a reason for hiding this comment

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

yup. can likely go through improve more here.

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:

/// Creates a new project state sets.
/// </summary>
private ProjectAnalyzerStateSets CreateProjectStateSets(Project project)
private ProjectAnalyzerInfo CreateProjectAnalyzerInfo(Project project)
Copy link
Member

Choose a reason for hiding this comment

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

nit - maybe male a local function inside UpdateProjectAnalyzerInfoAsync?

Copy link
Member Author

Choose a reason for hiding this comment

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

yup. i have a followup that changes a lot of these cases to local functions.

@CyrusNajmabadi CyrusNajmabadi merged commit 329bb90 into dotnet:main Feb 10, 2025
25 checks passed
@CyrusNajmabadi CyrusNajmabadi deleted the removeStateSet branch February 10, 2025 19:58
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Analyzers 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