Skip to content

Implicit parameter conversion from integer to byte fails with source generated XAML #35396

@DJ4ddi

Description

@DJ4ddi

Description

When using a component property of type byte, its value cannot be assigned using source generated XAML. Instead, BindableObject logs a warning.

The same property works fine with XAMLC or runtime inflation.

Steps to Reproduce

  1. Create a component with a byte property:
public static readonly BindableProperty MyByteProperty = BindableProperty.Create(
  nameof(MyByte),
  typeof(byte),
  typeof(MyComponent),
  (byte)255);

public byte MyByte
{
  get => (byte)this.GetValue(MyByteProperty);
  set => this.SetValue(MyByteProperty, value);
}
  1. Use the component parameter in XAML: <MyComponent MyByte="150"/>
  2. Enable source generated XAML: <MauiXamlInflator>SourceGen</MauiXamlInflator>
  3. Initialize the outer component.

Expected: The property should have the configured value (150 in the example).
Actual: The property always has the default value (255 in the example).

Link to public reproduction project repository

No response

Version with bug

10.0.50

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

9.0.120 SR12

Affected platforms

Android, iOS

Affected platform versions

Any

Did you find any workaround?

Specify the data type explicitly:

<MyComponent.MyByte>
  <x:Byte>150</x:Byte>
</MyComponent.MyByte>

Relevant log output

Cannot convert 150 to type 'System.Byte'

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-xamlXAML, CSS, Triggers, Behaviorspartner/syncfusionIssues / PR's with Syncfusion collaborationplatform/androidplatform/ioss/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't working

    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