Last post Apr 12, 2020 05:45 PM by TechAspirant
Member
10 Points
38 Posts
Apr 11, 2020 02:27 PM|TechAspirant|LINK
I am having Asp.Net Core 3.1 Application, And After changing DataMember to JsonPropertyName Getting error as below
[JsonPropertyName("filterFlags")] public List<FilterType> FilterStatus { get; set; }
All-Star
53001 Points
23596 Posts
Apr 11, 2020 02:49 PM|mgebhard|LINK
Can you clarify what you are doing? The [DataMember] attribute is found in .NET and usually related to SOAP/XML serialization. [JsonPropertyName] is new to .NET Core 3.+.
48500 Points
18071 Posts
Apr 12, 2020 10:28 AM|PatriceSc|LINK
Hi,
This is actually a code analysis rule: https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2227?view=vs-2019
Do you want to expose this list or to allow assigning another list to this property?
Apr 12, 2020 05:45 PM|TechAspirant|LINK
I solved this by suppressing the error CA227 in my case
Member
10 Points
38 Posts
ASP.NET Core 3.1 :JsonPropertyName Error
Apr 11, 2020 02:27 PM|TechAspirant|LINK
I am having Asp.Net Core 3.1 Application, And After changing DataMember to JsonPropertyName Getting error as below
<div>Error CA2227 Change 'FilterStatus' to be read-only by removing the property setter.</div>All-Star
53001 Points
23596 Posts
Re: ASP.NET Core 3.1 :JsonPropertyName Error
Apr 11, 2020 02:49 PM|mgebhard|LINK
Can you clarify what you are doing? The [DataMember] attribute is found in .NET and usually related to SOAP/XML serialization. [JsonPropertyName] is new to .NET Core 3.+.
All-Star
48500 Points
18071 Posts
Re: ASP.NET Core 3.1 :JsonPropertyName Error
Apr 12, 2020 10:28 AM|PatriceSc|LINK
Hi,
This is actually a code analysis rule: https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2227?view=vs-2019
Do you want to expose this list or to allow assigning another list to this property?
Member
10 Points
38 Posts
Re: ASP.NET Core 3.1 :JsonPropertyName Error
Apr 12, 2020 05:45 PM|TechAspirant|LINK
I solved this by suppressing the error CA227 in my case