rrmanzano / maui-bindableproperty-generator

Source generator that automatically transforms fields into BindableProperties that can be used in MAUI
MIT License
132 stars 10 forks source link

Add custom attributes #22

Open tranb3r opened 9 months ago

tranb3r commented 9 months ago

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.

rrmanzano commented 9 months ago

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