-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Move code that retrieves source generators to running in OOP only #72825
Conversation
// We don't have any source generators. Trivially bail out. | ||
var compilationWithGeneratedFiles = compilationWithoutGeneratedFiles; | ||
return (compilationWithGeneratedFiles, TextDocumentStates<SourceGeneratedDocumentState>.Empty, generatorInfo.Driver); | ||
} |
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.
this code was running on the host side no matter what. we do not want that. that basically loads and caches the SourceGenerators info locally, which means (due to .net fx limitations) that it is effectively fixed. Note: i intend to get rid of ProjectState.SourceGenerators entirely as an api. But this will be a series of small refactorings.
This PR was just an easy example of how to make things better.
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.
@jasonmalinowski For review when you get back. |
This will be part of a series of PRs. The main purpose here is to get all calls to ProjectState.SourceGenerators and AnalyzerReference.GetGenerators to run in OOP only. By doing that, we don't even have to load it in VS and we don't have to worry about the .net fx loading semantics for generators (versus the .net core semantics, which can reload generators).
Example of where this matters. Imagine if a user starts with an AnalyzerReference with no source generators in it, but then replaces those (while VS is running) with references that do have source-generators in them. With teh current code, because we loaded the generators within VS, and then checked if we had any, we'll always stay in teh state where we think we have none. However, by moving these loads/checks to OOP, we can realistically reload the reference/generators and then now know that we should be running generators on a particular project.