[XSG] Fix FlexBasis source generator to emit float literals#32696
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a compilation error in the XAML source generator where FlexBasis constructor calls were emitting double literals instead of float literals. The FlexBasis constructor expects float parameters, but the source generator was generating numeric values without the 'f' suffix, causing implicit conversion issues.
Key Changes
- Added 'f' suffix to numeric literals in FlexBasisConverter.cs for both percentage and absolute values
- Added comprehensive unit tests covering percentage, decimal, and integer FlexBasis values
- Verified culture-independent code generation across en-US, fr-FR, and de-DE locales
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Controls/src/SourceGen/TypeConverters/FlexBasisConverter.cs | Added 'f' suffix to float literals on lines 33 and 39, ensuring generated code matches FlexBasis constructor signature |
| src/Controls/tests/SourceGen.UnitTests/FlexLayoutTests.cs | Added comprehensive test coverage for FlexLayout.Basis with percentage/decimal/integer values, plus tests for Grow/Shrink properties and culture-independence |
Contributor
Author
|
/rebase |
72e6447 to
e0fabbf
Compare
simonrozsival
previously approved these changes
Nov 18, 2025
Fixes #32680 The FlexBasis constructor expects float parameters, but the source generator was emitting double literals without the 'f' suffix, causing compilation errors. Changes: - Added 'f' suffix to FlexBasis numeric literals in FlexBasisConverter - Added comprehensive unit tests for FlexLayout properties The fix follows the same pattern used in ColorConverter and matches how primitive float values are handled in NodeSGExtensions.
- Add tests for all FlexLayout-specific attached properties - Add tests for Wrap, Direction, Basis, Grow, Shrink, AlignSelf, and Order - Add tests for layout invalidation when properties change - Improve test coverage for FlexLayout code generation scenarios
e0fabbf to
954dacb
Compare
simonrozsival
approved these changes
Nov 18, 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.
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Description of Change
Fixes #32680
The FlexBasis constructor expects
floatparameters, but the source generator was emittingdoubleliterals without the 'f' suffix, causing compilation errors when using XAML source generation with FlexLayout.Basis.Before (broken):
After (fixed):
Changes
FlexBasisConverter.cs: Added
fsuffix to numeric literals on lines 33 and 39FlexLayout.Basis="33%"→new FlexBasis(0.33f, true)FlexLayout.Basis="0.5"→new FlexBasis(0.5f, false)FlexLayout.Basis="100"→new FlexBasis(100f, false)FlexLayoutTests.cs: Added comprehensive unit tests for FlexLayout properties
Assert.Equal(expected, generated, ignoreLineEndingDifferences: true)to verify complete generated codePattern
The fix follows the same pattern used in:
ColorConverter.cs(line 25) which addsfsuffix to color component valuesNodeSGExtensions.cs(line 357) which handlesSystem.SinglewithFsuffixIssues Fixed
Fixes #32680