Skip to content

[XSG] NaN value in XAML generates invalid code #33532

@StephaneDelcroix

Description

@StephaneDelcroix

Description

When a XAML file contains NaN as a value (e.g., Padding="NaN"), the XAML Source Generator generates invalid C# code using bare NaN instead of double.NaN.

Steps to Reproduce

  1. Create a XAML file with:
<Button Padding="NaN" />
  1. Build with XSG (MauiXamlInflator=SourceGen)

Expected Behavior

Generated code should use double.NaN:

button.Padding = new Thickness(double.NaN);

Actual Behavior

Generated code uses bare NaN:

button.Padding = new Thickness(NaN);

This results in:

error CS0103: The name 'NaN' does not exist in the current context

Affected File

src/Controls/samples/Controls.Sample/Pages/Controls/ButtonPage.xaml line 196

Workaround

Set the file to use Runtime inflator:

<MauiXaml Update="Pages/Controls/ButtonPage.xaml" Inflator="Runtime" />

Metadata

Metadata

Type

No fields configured for Bug.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions