maui-bindableproperty-generator
maui-bindableproperty-generator copied to clipboard
Add custom attributes
In some cases, it might be useful to have some custom attributes over the generated properties.
[AutoBindable]
[property: JsonRequired]
[property: JsonPropertyName("name")]
private readonly string? _username;
This would generate a Username
property, with those two [JsonRequired]
and [JsonPropertyName("name")]
attributes over it.
For information, this feature is already supported by CommunityToolkit.Mvvm
in its ObservableProperty
source generator.
https://learn.microsoft.com/en-us/dotnet/communitytoolkit/mvvm/generators/observableproperty#adding-custom-attributes
I think it would be a great addition to BindableProperty
source generator.
Hi @tranb3r totally agree, that implementation is on my to-do list. I am working on an internal refactor to use "SyntaxFactory" instead of "String building". This change will not affect the final result or how it should be implemented, but this is important to be able to add this new feature