[XSG] report diagnostic if we can't Add#31462
Merged
jfversluis merged 1 commit intonet10.0from Sep 3, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR improves error reporting in the XAML Source Generator (XSG) by adding diagnostic reporting when content cannot be added to an element that lacks a ContentPropertyAttribute. The change aligns the source generator's error handling with the existing build tasks behavior.
Key Changes
- Enhanced error diagnostics in the source generator to report when content cannot be set on elements without ContentPropertyAttribute
- Updated unit tests to verify the new diagnostic reporting functionality
- Cleaned up commented code and preprocessor directives
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/Controls/src/SourceGen/Visitors/SetPropertiesVisitor.cs | Added diagnostic reporting for missing ContentPropertyAttribute and removed commented legacy code |
| src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs | Removed extraneous whitespace |
| src/Controls/tests/Xaml.UnitTests/Issues/Bz43694.rt.xaml.cs | Updated test to verify diagnostic generation and removed preprocessor conditionals |
| src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj | Removed commented MauiXamlEnableDiagnostics configuration |
| src/Controls/tests/SourceGen.UnitTests/InitializeComponent/SimplifyOnPlatform.cs | Removed trailing whitespace |
| // throw new BuildException(BuildExceptionCode.ContentPropertyAttributeMissing, node, null, ((IElementNode)parentNode).XmlType.Name); | ||
| else | ||
| { | ||
| var location = LocationCreate(Context.ProjectItem.RelativePath!, (IXmlLineInfo)node, ((IElementNode)parentNode).XmlType.Name); |
There was a problem hiding this comment.
The method LocationCreate is being called but it's not defined in this class or imported. This will cause a compilation error.
Contributor
Author
There was a problem hiding this comment.
I challenge you on this one, copilot
simonrozsival
approved these changes
Sep 3, 2025
jfversluis
approved these changes
Sep 3, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Change
[XSG] report diagnostic if we can't Add