Repository navigation
fix: Allow Key property in XAML for KeyboardAccelerator - #22362
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in the XAML source generator where all properties named "Key" were being filtered out, which incorrectly excluded legitimate properties like KeyboardAccelerator.Key in addition to the x:Key XAML directive.
Changes:
- Modified the property filtering logic to only exclude
x:Key(XAML directive) by checking both the property name and namespace - Added a comprehensive source generator test to verify
KeyboardAccelerator.Keyproperty can be set in XAML
Reviewed changes
Copilot reviewed 2 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs | Updated GetExtendedProperties method to check namespace when filtering "Key" properties, allowing regular Key properties while still excluding x:Key directives |
| src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_Parser.cs | Added test case When_KeyboardAccelerator_Key_Property to verify the fix works correctly |
| src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/Given_Parser/WhKeAcKePr/XamlCodeGenerator_MainPage_d6cd66944958ced0c513e0a04797b51d.cs | Expected generated code output showing Key property is correctly initialized |
| src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/Given_Parser/WhKeAcKePr/XamlCodeGenerator_LocalizationResources.cs | Generated localization resources metadata file |
| src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Out/Given_Parser/WhKeAcKePr/XamlCodeGenerator_GlobalStaticResources.cs | Generated global static resources file |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22362/wasm-skia-net9/index.html |
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-22362/docs/index.html |
358d8b4 to
389c6ef
Compare
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22362/wasm-skia-net9/index.html |
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-22362/docs/index.html |
|
|
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-22362/docs/index.html |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22362/wasm-skia-net9/index.html |
|
|
The XAML source generator was incorrectly filtering out all properties named "Key", which was intended to exclude x:Key directive but also excluded legitimate properties like KeyboardAccelerator.Key. Changed the filter to only exclude Key when it has the XAML namespace (x:Key), allowing regular Key properties to be generated. Co-Authored-By: Claude Opus 4.5 <[email protected]>
389c6ef to
8f7d262
Compare
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22362/wasm-skia-net9/index.html |
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-22362/docs/index.html |
|
|
|
@Mergifyio backport release/stable/6.5 |
✅ Backports have been createdDetails
|
…6.5/pr-22362 fix: Allow `Key` property in XAML for `KeyboardAccelerator` (backport #22362)
GitHub Issue: closes #22094
PR Type: 🐞 Bugfix
What is the current behavior? 🤔
The XAML source generator was incorrectly filtering out all properties named "Key", which was intended to exclude x:Key directive but also excluded legitimate properties like KeyboardAccelerator.Key.
Changed the filter to only exclude Key when it has the XAML namespace (x:Key), allowing regular Key properties to be generated.
What is the new behavior? 🚀
PR Checklist ✅
Please check if your PR fulfills the following requirements:
Screenshots Compare Test Runresults.Other information ℹ️