maui-bindableproperty-generator icon indicating copy to clipboard operation
maui-bindableproperty-generator copied to clipboard

Add custom attributes

Open tranb3r opened this issue 1 year ago • 1 comments

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.

tranb3r avatar Dec 14 '23 10:12 tranb3r

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

rrmanzano avatar Dec 20 '23 19:12 rrmanzano