Skip to content

[XSG] avoid generating CB twice#32242

Merged
StephaneDelcroix merged 1 commit intomainfrom
dev/stdelc/xsg-perf
Oct 31, 2025
Merged

[XSG] avoid generating CB twice#32242
StephaneDelcroix merged 1 commit intomainfrom
dev/stdelc/xsg-perf

Conversation

@StephaneDelcroix
Copy link
Contributor

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

After some measurment, XSG took 25s on Xaml.UnitTests. code behind file
were generated twice. generating once only shave 10s (40%) of XSG time
@StephaneDelcroix StephaneDelcroix added this to the .NET 10 SR1 milestone Oct 28, 2025
Copilot AI review requested due to automatic review settings October 28, 2025 10:46
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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

@StephaneDelcroix StephaneDelcroix changed the base branch from net10.0 to main October 29, 2025 11:09
@StephaneDelcroix StephaneDelcroix merged commit 0d9a596 into main Oct 31, 2025
168 checks passed
@StephaneDelcroix StephaneDelcroix deleted the dev/stdelc/xsg-perf branch October 31, 2025 10:12
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
@PureWeen PureWeen added the area-xaml XAML, CSS, Triggers, Behaviors label Nov 11, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Dec 12, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-xaml XAML, CSS, Triggers, Behaviors

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants