Skip to content

Conversation

@CyrusNajmabadi
Copy link
Member

The ensures that we only drop the info if the project (or any of its dependencies) change. It will not get dropped if docs/projects outside of its project-cone change.

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner February 10, 2025 20:56
@ghost ghost added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Feb 10, 2025
{
private HostAnalyzerInfo GetOrCreateHostAnalyzerInfo(Project project, ProjectAnalyzerInfo projectAnalyzerInfo)
private HostAnalyzerInfo GetOrCreateHostAnalyzerInfo(
SolutionState solution, ProjectState project, ProjectAnalyzerInfo projectAnalyzerInfo)
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: this follows the pattern of using 'solution/project' as the name of hte 'State' instance instead of 'solutionState/projectState'. We only use the latter if we have code that uses both at the same time.

/// SolutionState has the data for Analyzers computed prior to Projects being added, and then never changes.
/// Practically, solution analyzers are the core Roslyn analyzers themselves we distribute, or analyzers shipped
/// by vsix (not nuget). These analyzers do not get loaded after changing *until* VS restarts.
/// </remarks>
Copy link
Member Author

Choose a reason for hiding this comment

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

subtle, but important point.

/// next caller.
/// </summary>
private static readonly ConditionalWeakTable<Project, StrongBox<(ImmutableArray<DiagnosticAnalyzer> analyzers, CompilationWithAnalyzersPair? compilationWithAnalyzersPair)>> s_projectToCompilationWithAnalyzers = new();
private static readonly ConditionalWeakTable<ProjectState, StrongBox<(ImmutableArray<DiagnosticAnalyzer> analyzers, CompilationWithAnalyzersPair? compilationWithAnalyzersPair)>> s_projectToCompilationWithAnalyzers = new();
Copy link
Contributor

Choose a reason for hiding this comment

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

ProjectState

comment above needs update

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

_projectToForceAnalysisData.TryAdd(project, box);
Contract.ThrowIfFalse(_projectToForceAnalysisData.TryGetValue(project, out box));
_projectToForceAnalysisData.TryAdd(projectState, box);
Contract.ThrowIfFalse(_projectToForceAnalysisData.TryGetValue(projectState, out box));
Copy link
Contributor

Choose a reason for hiding this comment

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

Contract.ThrowIfFalse(_projectToForceAnalysisData.TryGetValue(projectState, out box));

nit: seems like this could limited to only be done if the TryAdd returned false.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah. I didn't care much :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed to only do this if we can't get the value.

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:


public async Task<ImmutableArray<DiagnosticData>> ForceAnalyzeProjectAsync(Project project, CancellationToken cancellationToken)
{
var projectState = project.State;
Copy link
Contributor

Choose a reason for hiding this comment

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

projectState

not needed anymore then?

Did we want to move this CWT to static?

Microsoft.CodeAnalysis.Diagnostics.AnalyzerFileReference.GetGenerators(System.String)
Microsoft.CodeAnalysis.Diagnostics.AnalyzerFileReference.GetGeneratorsForAllLanguages
Microsoft.CodeAnalysis.Diagnostics.AnalyzerFileReference.GetHashCode
Microsoft.CodeAnalysis.Diagnostics.AnalyzerFileReference.ToString
Copy link
Contributor

Choose a reason for hiding this comment

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

Any idea what's up with this? I have this local change too.

Copy link
Member

Choose a reason for hiding this comment

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

ToString was added with the AnalyzerAssemblyRedirector API. Tomas has a PR to fix this up.

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.

4 participants