CommunityToolkit / dotnet

.NET Community Toolkit is a collection of helpers and APIs that work for all .NET developers and are agnostic of any specific UI platform. The toolkit is maintained and published by Microsoft, and part of the .NET Foundation.
https://docs.microsoft.com/dotnet/communitytoolkit/?WT.mc_id=dotnet-0000-bramin
Other
2.99k stars 294 forks source link

Mvvm ObservableProperty With Private Setters #729

Closed yueyinqiu closed 1 year ago

yueyinqiu commented 1 year ago

Overview

Currently, if there is a field attributed as [ObservableProperty], the source generator will generate a property with a public setter and a public getter. I'm wondering if there is a way to have an observable property with a private setter, since some of them might only be affected by something inside the view models, and the views should never have the access.

Usage example

[ObservableProperty(SetterAccessibility = Accessibilities.Private)]
private string? name;

Breaking change?

No

Additional context

Actually I'm not really familiar with the mvvm pattern. So if there are any problem, please forgive me and let me know about that. Thanks a lot!

Help us help you

Yes, I'd like to be assigned to work on this item

yueyinqiu commented 1 year ago

oh that's duplicated, i'm so sorry