Switch to balanced source generator execution in VSCode with refresh support#82330
Open
dibarbet wants to merge 2 commits intodotnet:mainfrom
Open
Switch to balanced source generator execution in VSCode with refresh support#82330dibarbet wants to merge 2 commits intodotnet:mainfrom
dibarbet wants to merge 2 commits intodotnet:mainfrom
Conversation
and add refresh support
85ab061 to
176e003
Compare
dibarbet
commented
Feb 7, 2026
| Description = "Controls when source generators are executed.", | ||
| Required = false, | ||
| // Balanced mode requires additional client side support (to trigger refreshes), so by default run in automatic to ensure tool scenarios without client support run generators. | ||
| DefaultValueFactory = _ => SourceGeneratorExecutionPreference.Automatic, |
Member
Author
There was a problem hiding this comment.
this seemed like a sane default if not provided to allow tools to work more easily. In VSCode we explicitly pass this and pick Balanced as the default there
dibarbet
commented
Feb 7, 2026
| DefaultValueFactory = _ => false, | ||
| }; | ||
|
|
||
| var sourceGeneratorExecutionOption = new Option<SourceGeneratorExecutionPreference>("--sourceGeneratorExecutionPreference") |
Member
Author
There was a problem hiding this comment.
While we do have support live option changes, source generator execution preference does not support live modification, so this is passed in as a CLI arg.
8f8bbe3 to
73a7d5f
Compare
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.
Client side PR: dotnet/vscode-csharp#8970
In VS we switched to balanced source gen execution a while back (#73618) to avoid perf issues with running generators on every keystroke. This ports the same change to VSCode.
Also added a small benchmark to compare perf between balanced and automatic. Balanced shows an improvement in cpu and allocations, even with an extremely simple generator.