-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Cache based on project state not project. #77141
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
Conversation
| { | ||
| private HostAnalyzerInfo GetOrCreateHostAnalyzerInfo(Project project, ProjectAnalyzerInfo projectAnalyzerInfo) | ||
| private HostAnalyzerInfo GetOrCreateHostAnalyzerInfo( | ||
| SolutionState solution, ProjectState project, ProjectAnalyzerInfo projectAnalyzerInfo) |
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: 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> |
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.
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(); |
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.
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.
done.
...r/Protocol/Features/Diagnostics/EngineV2/DiagnosticIncrementalAnalyzer.CompilationManager.cs
Outdated
Show resolved
Hide resolved
...erver/Protocol/Features/Diagnostics/EngineV2/DiagnosticIncrementalAnalyzer_GetDiagnostics.cs
Outdated
Show resolved
Hide resolved
| _projectToForceAnalysisData.TryAdd(project, box); | ||
| Contract.ThrowIfFalse(_projectToForceAnalysisData.TryGetValue(project, out box)); | ||
| _projectToForceAnalysisData.TryAdd(projectState, box); | ||
| Contract.ThrowIfFalse(_projectToForceAnalysisData.TryGetValue(projectState, out box)); |
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.
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.
Yeah. I didn't care much :-)
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.
Changed to only do this if we can't get the value.
ToddGrun
left a comment
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.
![]()
|
|
||
| public async Task<ImmutableArray<DiagnosticData>> ForceAnalyzeProjectAsync(Project project, CancellationToken cancellationToken) | ||
| { | ||
| var projectState = project.State; |
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.
| Microsoft.CodeAnalysis.Diagnostics.AnalyzerFileReference.GetGenerators(System.String) | ||
| Microsoft.CodeAnalysis.Diagnostics.AnalyzerFileReference.GetGeneratorsForAllLanguages | ||
| Microsoft.CodeAnalysis.Diagnostics.AnalyzerFileReference.GetHashCode | ||
| Microsoft.CodeAnalysis.Diagnostics.AnalyzerFileReference.ToString |
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 idea what's up with this? I have this local change too.
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.
ToString was added with the AnalyzerAssemblyRedirector API. Tomas has a PR to fix this up.
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.