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

Stop loading ISourceGenerators within VS entirely. #72835

Merged
merged 17 commits into from
Apr 2, 2024

Conversation

CyrusNajmabadi
Copy link
Member

No description provided.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 2, 2024
@CyrusNajmabadi CyrusNajmabadi changed the title WIP: SG oop part 3. Stop loading ISourceGenerators within VS entirely. Apr 2, 2024
@CyrusNajmabadi CyrusNajmabadi marked this pull request as ready for review April 2, 2024 20:11
@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner April 2, 2024 20:11
{
using var connection = CreateConnection<TService>(callbackTarget: null);
return await connection.TryInvokeAsync(compilationState, projectId, invocation, cancellationToken).ConfigureAwait(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.

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);
Copy link
Member Author

@CyrusNajmabadi CyrusNajmabadi Apr 2, 2024

Choose a reason for hiding this comment

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

Pretty self-explanatory.

{
using var generators = TemporaryArray<ISourceGenerator>.Empty;
var generatorToAnalyzerReference = ImmutableDictionary.CreateBuilder<ISourceGenerator, AnalyzerReference>();
private static readonly ConditionalWeakTable<ProjectState, SourceGeneratorMap> s_projectStateToSourceGeneratorsMap = new();
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 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();
Copy link
Member Author

Choose a reason for hiding this comment

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

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();
Copy link
Contributor

Choose a reason for hiding this comment

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

ConditionalWeakTable

Would it be possible to only have a single CWT and only access the SourceGeneratorMap part of the tuple when OOP?

Copy link
Member Author

Choose a reason for hiding this comment

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

tried, but it started getting very ugly/allocy

@CyrusNajmabadi CyrusNajmabadi merged commit fd07bdb into dotnet:main Apr 2, 2024
27 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Apr 2, 2024
@CyrusNajmabadi CyrusNajmabadi deleted the sgOnlyOop3 branch April 2, 2024 23:30
@CyrusNajmabadi
Copy link
Member Author

@jasonmalinowski For review when you get back.

@dibarbet dibarbet modified the milestones: Next, 17.11 P1 Apr 29, 2024
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants