Stop loading ISourceGenerators within VS entirely.#72835
Stop loading ISourceGenerators within VS entirely.#72835CyrusNajmabadi merged 17 commits intodotnet:mainfrom
Conversation
| { | ||
| using var connection = CreateConnection<TService>(callbackTarget: null); | ||
| return await connection.TryInvokeAsync(compilationState, projectId, invocation, cancellationToken).ConfigureAwait(false); | ||
| } |
There was a problem hiding this comment.
helper overload for the case where we're asking about a particular project in the context of a particular SolutionCompilationState (first time we've needed to do that).
| /// Whether or not the specified <paramref name="projectId"/> has source generators or not. | ||
| /// </summary> | ||
| ValueTask<bool> HasGeneratorsAsync( | ||
| Checksum solutionChecksum, ProjectId projectId, CancellationToken cancellationToken); |
There was a problem hiding this comment.
Pretty self-explanatory.
| { | ||
| using var generators = TemporaryArray<ISourceGenerator>.Empty; | ||
| var generatorToAnalyzerReference = ImmutableDictionary.CreateBuilder<ISourceGenerator, AnalyzerReference>(); | ||
| private static readonly ConditionalWeakTable<ProjectState, SourceGeneratorMap> s_projectStateToSourceGeneratorsMap = new(); |
There was a problem hiding this comment.
this was a simpler way to organize the existing information. ProjectState already has the language and analyzerreferences. It's also what callers already pass in. And it's a green node which rarely changes. Note: if it does change, we'll 'recompute' the SGs, but end up finding the same set, since the AnalyzerRef objects themselves cache and return the same instances.
| /// process (if present) and having it make the determination, without the host necessarily loading generators | ||
| /// itself. | ||
| /// </summary> | ||
| private static readonly ConditionalWeakTable<ProjectState, AsyncLazy<bool>> s_hasSourceGeneratorsMap = new(); |
There was a problem hiding this comment.
new to this PR.
| /// process (if present) and having it make the determination, without the host necessarily loading generators | ||
| /// itself. | ||
| /// </summary> | ||
| private static readonly ConditionalWeakTable<ProjectState, AsyncLazy<bool>> s_hasSourceGeneratorsMap = new(); |
There was a problem hiding this comment.
tried, but it started getting very ugly/allocy
src/Workspaces/Core/Portable/Workspace/Solution/SolutionCompilationState_SourceGenerators.cs
Show resolved
Hide resolved
src/Workspaces/Core/Portable/Workspace/Solution/SolutionCompilationState_SourceGenerators.cs
Show resolved
Hide resolved
src/Workspaces/Core/Portable/Workspace/Solution/SolutionCompilationState_SourceGenerators.cs
Outdated
Show resolved
Hide resolved
|
@jasonmalinowski For review when you get back. |
No description provided.