Proposal: RegisterPreCompilationSourceOutput API for Incremental Generators#82680
Closed
chsienki wants to merge 1 commit into
Closed
Proposal: RegisterPreCompilationSourceOutput API for Incremental Generators#82680chsienki wants to merge 1 commit into
chsienki wants to merge 1 commit into
Conversation
Adds a new incremental source generator API that allows generators to produce source added to the initial compilation before compilation-dependent phases execute. This enables generators to produce source that is visible to other generators' standard phases and to the compilation itself. Key changes: - New PreCompilationSourceProductionContext (no diagnostics, no compilation) - RegisterPreCompilationSourceOutput overloads on IncrementalGeneratorInitializationContext - Two-pass execution in GeneratorDriver: pre-compilation pass then standard pass - DriverStateTable.Builder defers Compilation/SyntaxStore until after pre-compilation - InputNode wraps _getInput exceptions as UserFunctionException for clean error handling - AbstractSourceOutputNode base class shared by SourceOutputNode and PreCompilationSourceOutputNode - New RSEXPERIMENTAL007 experimental feature ID - 25 comprehensive tests covering functionality, caching, error handling, and step tracking Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
60dba0f to
1dcf462
Compare
Contributor
|
This PR modifies public API files. Please follow the instructions at https://github.com/dotnet/roslyn/blob/main/docs/contributing/API%20Review%20Process.md for ensuring all public APIs are reviewed before merging. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a proposal document for a new
RegisterPreCompilationSourceOutputAPI for incremental source generators.The document proposes a new incremental generator API that allows generators to produce source that is added to the initial compilation while reading from non-compilation inputs (additional files, parse options, analyzer config).
The primary motivation is Razor performance: this API eliminates the need for Razor to create an intermediate compilation for cross-file binding, reducing compilation phases from 3 to 2 and yielding roughly 50% performance improvement.
Secondary benefits include cross-generator type visibility and configurable post-initialization outputs.
See
docs/features/pre-compilation-source-outputs.mdfor the full proposal.