Remove XamlControlsResourcesV2 rewrite#22940
Conversation
|
|
Co-authored-by: MartinZikmund <1075116+MartinZikmund@users.noreply.github.com>
f13adad to
59f5599
Compare
There was a problem hiding this comment.
Pull request overview
This PR removes a legacy special-case in the XAML source generator that rewrote Microsoft.UI.Xaml.Controls.XamlControlsResources to XamlControlsResourcesV2, aligning generated code with the actual type referenced in XAML now that V1 is no longer supported.
Changes:
- Removed the
XamlControlsResources -> XamlControlsResourcesV2rewrite inXamlFileGenerator.BuildTypedResourceDictionary(). - Added a generator test covering typed
XamlControlsResourcesusage in a merged dictionary. - Updated/added expected generated output snapshots for the new test case.
Reviewed changes
Copilot reviewed 2 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs | Drops the hard-coded rewrite and always emits new <typed ResourceDictionary>() for typed dictionaries. |
| src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_ResourceDictionary.cs | Adds a regression test ensuring XamlControlsResources is instantiated (not rewritten). |
| src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/Given_ResourceDictionary/WhTyXaCoReReDi/XamlCodeGenerator_MyResourceDictionary_92716e07ff456818f6d4125e055d4d57.cs | Snapshot: verifies emitted new global::Microsoft.UI.Xaml.Controls.XamlControlsResources() in merged dictionaries. |
| src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/Given_ResourceDictionary/WhTyXaCoReReDi/XamlCodeGenerator_GlobalStaticResources.cs | Snapshot: expected generated GlobalStaticResources for the new test case. |
| src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/Given_ResourceDictionary/WhTyXaCoReReDi/XamlCodeGenerator_LocalizationResources.cs | Snapshot: expected localization metadata output for the new test case. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22940/wasm-skia-net9/index.html |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22940/wasm-skia-net9/index.html |
|
|
GitHub Issue: Closes #22824
PR Type:
🔄 Refactoring (no functional changes, no api changes)
What is the current behavior? 🤔
The XAML source generator in
XamlFileGenerator.BuildTypedResourceDictionary()special-casesXamlControlsResourcesand rewrites it toXamlControlsResourcesV2in generated C#:This was needed when V1/V2 coexisted. V1 is gone;
XamlControlsResourcesalready forces Version2 and initializes bothFluentThemeandFluentTheme.v2static resources.What is the new behavior? 🚀
XamlControlsResourcesreferences in XAML now generatenew XamlControlsResources()like any other typedResourceDictionarysubclass.XamlControlsResourcesV2is kept as-is for backward compatibility with existing C# references.PR Checklist ✅
Please check if your PR fulfills the following requirements:
Screenshots Compare Test Runresults.Other information ℹ️
No functional change —
XamlControlsResourcesconstructor already callsUno.UI.FluentTheme.v2.GlobalStaticResources.Initialize()/RegisterDefaultStyles()/RegisterResourceDictionariesBySource()in itsUpdateSource()path, identical to whatXamlControlsResourcesV2does.