-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Always use dot separators in XAML SG converters #31225
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 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
This reverts commit 475f6e6.
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
src/Controls/tests/SourceGen.UnitTests/KnownTypeConvertersTests.cs
Outdated
Show resolved
Hide resolved
| public static string FormatInvariant(object value, bool quoted = false) | ||
| { | ||
| return SymbolDisplay.FormatPrimitive(value, quoteStrings: quoted, useHexadecimalNumbers: false); | ||
| } |
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.
| 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); | |
| } |
|
/backport to release/10.0.1xx-rc1 |
|
Started backporting to release/10.0.1xx-rc1: https://github.com/dotnet/maui/actions/runs/17125129430 |
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