[XSG] avoid generating CB twice#32242
Merged
StephaneDelcroix merged 1 commit intomainfrom Oct 31, 2025
Merged
Conversation
After some measurment, XSG took 25s on Xaml.UnitTests. code behind file were generated twice. generating once only shave 10s (40%) of XSG time
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR optimizes the XAML Source Generator (XSG) by eliminating duplicate code-behind file generation, reducing build time by approximately 40% (from 25s to 15s) in Xaml.UnitTests. The key change is refactoring the pipeline to generate code-behind files once and reuse them, rather than generating them twice in separate pipeline stages.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| Controls.Xaml.UnitTests.csproj | Enables analyzer reporting to support performance measurement |
| GeneratorHelpers.cs | Refactors GetSyntaxTree to GetSource, returning source code and diagnostics instead of parsed syntax trees |
| CodeBehindGenerator.cs | Reorganizes the pipeline to generate code once in GetSource, then parse and add to compilation in a separate stage |
simonrozsival
approved these changes
Oct 31, 2025
StephaneDelcroix
added a commit
that referenced
this pull request
Nov 3, 2025
fix symbol logic resolution to avoid looping too much building the Xaml.UnitTests, sourcegen times Oct 27: 24,163s Oct 29: 16,139s (#32242) today : 1,363s That's a speedup of 95%, and it now takes less time so tourcegen than to XamlC
StephaneDelcroix
added a commit
that referenced
this pull request
Nov 3, 2025
fix symbol logic resolution to avoid looping too much building the Xaml.UnitTests, sourcegen times Oct 27: 24,163s Oct 29: 16,139s (#32242) today : 1,363s That's a speedup of 95%, and it now takes less time so tourcegen than to XamlC
StephaneDelcroix
added a commit
that referenced
this pull request
Nov 4, 2025
* [XSG] Speed up build times fix symbol logic resolution to avoid looping too much building the Xaml.UnitTests, sourcegen times Oct 27: 24,163s Oct 29: 16,139s (#32242) today : 1,363s That's a speedup of 95%, and it now takes less time so tourcegen than to XamlC * don't keep the cache as a static * use INamedTypeSymbol
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Description of Change
After some measurement, XSG took 25s on Xaml.UnitTests. code behind file were generated twice. generating once only shave 10s (40%) of XSG time