Always use dot separators in XAML SG converters#31225
Merged
jfversluis merged 5 commits intonet10.0from Aug 20, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a culture-specific formatting issue in XAML source generators where decimal/double values could be written with comma separators instead of dots, causing invalid syntax. The fix ensures all numeric values in generated code use invariant culture formatting with dot separators.
- Adds
ToString(CultureInfo.InvariantCulture)calls to all numeric value interpolations in converter methods - Affects geometric types (Rect, Point, Thickness, CornerRadius), layout types (FlexBasis, GridLength), and shape coordinates
- Maintains consistency with the existing parsing logic that already uses invariant culture
4c8212b to
194b1b1
Compare
Use SymbolDisplay.FormatPrimitive
b8c982b to
475f6e6
Compare
StephaneDelcroix
previously approved these changes
Aug 19, 2025
This reverts commit 475f6e6.
src/Controls/tests/SourceGen.UnitTests/KnownTypeConvertersTests.cs
Outdated
Show resolved
Hide resolved
StephaneDelcroix
requested changes
Aug 20, 2025
src/Controls/tests/SourceGen.UnitTests/KnownTypeConvertersTests.cs
Outdated
Show resolved
Hide resolved
src/Controls/tests/SourceGen.UnitTests/KnownTypeConvertersTests.cs
Outdated
Show resolved
Hide resolved
src/Controls/tests/SourceGen.UnitTests/KnownTypeConvertersTests.cs
Outdated
Show resolved
Hide resolved
simonrozsival
approved these changes
Aug 20, 2025
Comment on lines
+410
to
+413
| public static string FormatInvariant(object value, bool quoted = false) | ||
| { | ||
| return SymbolDisplay.FormatPrimitive(value, quoteStrings: quoted, useHexadecimalNumbers: false); | ||
| } |
Contributor
There was a problem hiding this comment.
Suggested change
| public static string FormatInvariant(object value, bool quoted = false) | |
| { | |
| return SymbolDisplay.FormatPrimitive(value, quoteStrings: quoted, useHexadecimalNumbers: false); | |
| } | |
| extension(SymbolDisplay) | |
| { | |
| public static string FormatPrimitive(object value, bool quotedStrings = false) => SymbolDisplay.FormatPrimitive(value, quotedStrings, false); | |
| } |
Member
Author
|
/backport to release/10.0.1xx-rc1 |
Contributor
|
Started backporting to release/10.0.1xx-rc1: https://github.com/dotnet/maui/actions/runs/17125129430 |
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.
We did parse the values with invariant culture, but didn't take that into account when writing the values. This could cause decimal/double values to be written with comma's, which in turn causes invalid syntax. This change makes sure that we always use the dot separator.
Fixes #31142