BindableProps icon indicating copy to clipboard operation
BindableProps copied to clipboard

nullable `bool?` code generator produces BindableProperty `bool`

Open hifiguitarguy opened this issue 8 months ago • 1 comments

Describe the bug A nullable boolean bool? field is source-generated as a bool BindableProperty

To Reproduce

[BindableProp(DefaultBindingMode = (int)BindingMode.OneWay)]
private bool? isToggled;

Generated Code

public  static readonly BindableProperty IsToggledProperty = BindableProperty.Create(
    nameof(IsToggled),
    typeof(bool),
    typeof(MyCustomControl),
    default,
    (BindingMode)(int)BindingMode.OneWay,
    null,
    (bindable, oldValue, newValue) => 
                ((MyCustomControl)bindable).IsToggled = (bool?)newValue,
    null,
    null,
    null
);

Expected behavior

public  static readonly BindableProperty IsToggledProperty = BindableProperty.Create(
    nameof(IsToggled),
    typeof(bool?), //<----
    typeof(MyCustomControl),
    default,
    (BindingMode)(int)BindingMode.OneWay,
    null,
    (bindable, oldValue, newValue) => 
                ((MyCustomControl)bindable).IsToggled = (bool?)newValue,
    null,
    null,
    null
);

Your environment: .net 9.0 MAUI [email protected]

hifiguitarguy avatar Mar 24 '25 15:03 hifiguitarguy

Hi @hifiguitarguy Please update to version 1.5.1-beta and try. Let me know if it works. Thanks.

KafkaWannaFly avatar Apr 30 '25 15:04 KafkaWannaFly