Skip to content

Conversation

@jfversluis
Copy link
Member

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

@jfversluis jfversluis added this to the .NET 10.0-rc2 milestone Aug 19, 2025
Copilot AI review requested due to automatic review settings August 19, 2025 08:19
@jfversluis jfversluis requested a review from a team as a code owner August 19, 2025 08:19
@jfversluis jfversluis added the area-xaml XAML, CSS, Triggers, Behaviors label Aug 19, 2025
Copy link
Contributor

Copilot AI left a 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

This reverts commit 475f6e6.
Comment on lines +410 to +413
public static string FormatInvariant(object value, bool quoted = false)
{
return SymbolDisplay.FormatPrimitive(value, quoteStrings: quoted, useHexadecimalNumbers: false);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
}

@jfversluis jfversluis merged commit 0081d68 into net10.0 Aug 20, 2025
145 of 151 checks passed
@jfversluis jfversluis deleted the xaml-sg-conv-dots branch August 20, 2025 18:28
@jfversluis
Copy link
Member Author

/backport to release/10.0.1xx-rc1

@github-actions
Copy link
Contributor

Started backporting to release/10.0.1xx-rc1: https://github.com/dotnet/maui/actions/runs/17125129430

@github-actions github-actions bot locked and limited conversation to collaborators Sep 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-xaml XAML, CSS, Triggers, Behaviors

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants