C
C#•2mo ago
nathanAjacobs

CommunityToolkit.MVVM ObservableProperty and JsonIgnore

I have an observable property like so:
[ObservableProperty]
private string _online;
[ObservableProperty]
private string _online;
Is there any way to specify that the generated property be ignored for json serialization?
5 Replies
Petris
Petris•2mo ago
You can also just do:
[JsonIgnore]
[ObservableProperty]
private partial string Online { get; set; }
[JsonIgnore]
[ObservableProperty]
private partial string Online { get; set; }
333fred
333fred•2mo ago
Only if you're using C# preview Sergio isn't supporting partial property generation without field
Nasdack
Nasdack•2mo ago
without field?
333fred
333fred•2mo ago
The feature

Did you find this page helpful?