-
Notifications
You must be signed in to change notification settings - Fork 834
feat: Enable partial code gen with invalid XAML - Lvl 2 #21837
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 when invalid XAML is encountered, allowing the generator to continue processing other files and report diagnostics instead of stopping completely. The main approach involves refactoring the XAML parser and generator to catch exceptions, store them as parsing/generation errors, and emit them as diagnostics while still generating valid C# code for valid portions.
Key Changes
- Refactored XAML parsing to capture errors without stopping generation
- Changed exception types and added
XamlGenerationExceptionfor generation errors - Modified data structures (
XamlObjectDefinition,XamlMemberDefinition,XamlFileDefinition) to records with immutable properties - Added error collection mechanism in
XamlFileGeneratorwithSafeBuildmethods - Updated compatibility shims location from
Extensions/to_Compat/
Reviewed Changes
Copilot reviewed 26 out of 55 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
XamlFileParser.cs |
Refactored to catch parsing exceptions and store them in XamlFileDefinition.ParsingError |
XamlFileGenerator.cs |
Added error collection with SafeBuild wrappers to catch generation exceptions |
XamlCodeGeneration.cs |
Updated to process all files and collect errors instead of failing fast |
XamlParsingException.cs |
Simplified to implement IXamlLocation with non-nullable properties |
XamlGenerationException.cs |
New exception type for generation-time errors |
XamlObjectDefinition.cs |
Changed to sealed record with immutable properties and init-only collections |
XamlMemberDefinition.cs |
Changed to sealed class with readonly properties |
XamlFileDefinition.cs |
Changed to sealed record implementing IXamlLocation with ParsingError property |
XamlGlobalStaticResourcesMap.cs |
Refactored constructor to build map internally |
IXamlLocation.cs |
Added FilePath property, changed LinePosition to readonly |
| Compat files | Moved from Extensions/ to _Compat/ directory with updated conditional compilation |
| Test files | New test output files demonstrating partial generation with errors |
Given_Parser.cs |
New tests validating error handling behavior |
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-21837/docs/index.html |
|
|
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-21837/docs/index.html |
ac23e3a to
b502c84
Compare
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 11 out of 11 changed files in this pull request and generated 19 comments.
src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs
Show resolved
Hide resolved
src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.Errors.cs
Outdated
Show resolved
Hide resolved
src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs
Outdated
Show resolved
Hide resolved
src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs
Outdated
Show resolved
Hide resolved
src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs
Show resolved
Hide resolved
src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs
Show resolved
Hide resolved
src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs
Show resolved
Hide resolved
src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs
Show resolved
Hide resolved
src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs
Show resolved
Hide resolved
src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs
Outdated
Show resolved
Hide resolved
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-21837/docs/index.html |
|
|
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-21837/docs/index.html |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-21837/wasm-skia-net9/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.
Pull Request Overview
Copilot reviewed 12 out of 69 changed files in this pull request and generated 3 comments.
src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.Errors.cs
Outdated
Show resolved
Hide resolved
src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs
Show resolved
Hide resolved
src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs
Show resolved
Hide resolved
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-21837/docs/index.html |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-21837/wasm-skia-net9/index.html |
|
@Mergifyio backport release/stable/6.4 |
✅ Backports have been createdDetails
|
carldebilly
left a comment
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.
LGTM
|
The build 183043 found UI Test snapshots differences: Details
|
|
|
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-21837/wasm-skia-net9/index.html |
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-21837/docs/index.html |
|
The build 183141 found UI Test snapshots differences: Details
|
…6.4/pr-21837 feat: Enable partial code gen with invalid XAML - Lvl 2 (backport #21837)
closes #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.Other information ℹ️
Same as #21834 but with additional fixes