-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[XSG] double cast on Add #31367
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
[XSG] double cast on Add #31367
Conversation
fixes 3 failing tests related to OnPlatform
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 fixes a code generation issue in the XAML source generator related to double casting when adding items to collections. The fix addresses 3 failing tests that were experiencing issues with OnPlatform functionality by properly handling intermediate implicit conversions during collection item addition.
- Removes conditional compilation directives from test methods that were limiting test parameter values
- Adds logic to detect and handle double implicit conversions in the source generator's Add method
- Ensures proper casting chain when adding items to collections that require intermediate type conversions
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Controls/tests/Xaml.UnitTests/Issues/Maui4509.xaml.cs | Removes conditional compilation blocks from OnPlatform test methods |
| src/Controls/tests/Xaml.UnitTests/Issues/Maui24900.xaml.cs | Removes conditional compilation blocks from OnPlatform test method |
| src/Controls/src/SourceGen/Visitors/SetPropertiesVisitor.cs | Adds double implicit conversion detection and intermediate casting logic |
| //look for intermediate implicit casts | ||
| string cast = string.Empty; | ||
| if (HasDoubleImplicitConversion(context.Variables[valueNode].Type, itemType, context, out var conv)) | ||
| cast = "(" + conv!.ReturnType.ToFQDisplayString() + ")"; |
Copilot
AI
Aug 27, 2025
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.
The method HasDoubleImplicitConversion is called but not defined in this file or visible in the diff. This will cause a compilation error unless this method exists elsewhere in the class or is imported.
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.
get out, Copilot, you're drunk
| //look for intermediate implicit casts | ||
| string cast = string.Empty; | ||
| if (HasDoubleImplicitConversion(context.Variables[valueNode].Type, itemType, context, out var conv)) | ||
| cast = "(" + conv!.ReturnType.ToFQDisplayString() + ")"; |
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.
| cast = "(" + conv!.ReturnType.ToFQDisplayString() + ")"; | |
| cast = $"({conv!.ReturnType.ToFQDisplayString()})"; |
Description of Change
fixes 3 failing tests related to OnPlatform