Skip to content

[XSG] Edge-case type conversions (Padding="NaN") not handled correctly #33871

@StephaneDelcroix

Description

@StephaneDelcroix

Description

XAML Source Generator (XSG) may not correctly handle edge-case type conversions such as Padding="NaN".

Reproduction

<Button
    Text="Button"
    HorizontalOptions="Start"
    Background="LightGray"
    Padding="NaN"/>

This uses NaN as a special value for the Thickness type converter to indicate "use default/unset padding".

Affected File

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

Additional Context

The same file also uses a custom converter with string-to-color conversion:

<converters:BoolToCustomValueConverter 
    x:Key="BoolToColorConverter"
    ValueIfTrue="Green"
    ValueIfFalse="Red"/>

This may also be related to the parsing issue.

Workaround

Use Inflator="Runtime" for the affected XAML file.

Context

Discovered while enabling XSG on more projects in #33524.

Metadata

Metadata

Labels

s/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering TriagexsgXaml sourceGen

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions