-
Notifications
You must be signed in to change notification settings - Fork 834
feat: Enable partial code gen with invalid XAML #21834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 enables partial code generation to continue when invalid XAML is encountered, rather than stopping at the first error. The implementation captures parsing exceptions in a ParsingError property on XamlFileDefinition and allows the generation process to continue for other valid files.
Key Changes
- Modified XAML parsing to catch and store exceptions rather than throwing them
- Changed
XamlFileDefinitionto a record class with aParsingErrorproperty to track parsing failures - Updated code generation flow to process files individually, catching errors per-file instead of failing globally
- Improved immutability of XAML definition classes by converting fields to readonly properties
Reviewed Changes
Copilot reviewed 10 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| XamlFileParser.cs | Refactored parsing to catch exceptions and store them in ParsingError; changed parsing methods to use ref parameters; improved error messages |
| XamlFileDefinition.cs | Converted to record class; added ParsingError property; made SourceLink required; removed manual Equals(object) override |
| XamlCodeGeneration.cs | Changed error handling to process exceptions via diagnostics instead of returning empty list; wrapped individual generation steps in try-catch; created XamlSource record type |
| XamlObjectDefinition.cs | Made class sealed; converted fields to readonly properties; added constructor overload; improved debugger display |
| XamlMemberDefinition.cs | Made class sealed; removed nullable owner parameter; converted fields to readonly properties |
| XamlGlobalStaticResourcesMap.cs | Changed to use primary constructor; made BuildResourceDictionaryMap static and private |
| IXamlLocation.cs | Made LinePosition property readonly |
| Given_Parser.cs | Updated test to expect generation continues with invalid XAML (no missing InitializeComponent) |
| RequiredAttribute.cs, Nullable.cs, IsExternalInit.cs | Added compatibility polyfills for C# language features |
| SourceGeneratorHelpers.projitems | Updated file paths for compatibility files; added RequiredAttribute |
src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs
Outdated
Show resolved
Hide resolved
src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileParser.cs
Outdated
Show resolved
Hide resolved
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-21834/docs/index.html |
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-21834/docs/index.html |
1 similar comment
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-21834/docs/index.html |
5c243d2 to
235fc12
Compare
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-21834/docs/index.html |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-21834/wasm-skia-net9/index.html |
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-21834/docs/index.html |
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-21834/docs/index.html |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-21834/wasm-skia-net9/index.html |
|
The build 182860 found UI Test snapshots differences: Details
|
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 23 out of 52 changed files in this pull request and generated 1 comment.
src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlObjectDefinition.cs
Show resolved
Hide resolved
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-21834/wasm-skia-net9/index.html |
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-21834/docs/index.html |
|
The build 182880 found UI Test snapshots differences: Details
|
|
@Mergifyio backport release/stable/6.4 |
✅ Backports have been createdDetails
|
…6.4/pr-21834 feat: Enable partial code gen with invalid XAML (backport #21834)
linked #21838
linked https://github.com/unoplatform/uno.hotdesign/issues/5418
✨ Feature
Enable partial code gen with invalid XAML
What is the current behavior? 🤔
Code gen stop as soon as an invalid XAML file is encountered
What is the new behavior? 🚀
Generation continue as long as possible while reporting
DiagnosticsPR Checklist ✅
Screenshots Compare Test Runresults.