Adding custom attributes to ObservableProperty #992
AlanMDicks
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have been using the custom attributes on ObservableProperty for Json serialization successfully for a while. Like this:
I am checking out the latest releases and updated to .NET 9, MVVM toolkit (8.3.2), lang version preview etc. I am getting the following message:
'property' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'field'. All attributes in this block will be ignored.
I can see this is still a valid approach from the docs:
https://learn.microsoft.com/en-us/dotnet/communitytoolkit/mvvm/generators/observableproperty
I have had a look around but can't see what I am doing wrong, or have I missed something in the latest releases.
Update: When I checked the source generated code for this property I could see the JsonIgnore attribute had been added so I got too hung up on the message and when I ran the code it worked and excluded the property in the json output. So this appears to be an erroneous warning.
Beta Was this translation helpful? Give feedback.
All reactions