You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A bit of a rare corner case, but the serializer isn't currently handling properties that only override the setter:
using System.Text.Json;stringjson= JsonSerializer.Serialize(new Derived {X=42});
Console.WriteLine(json);// {}publicclassBase{publicvirtualintX{get;set;}}publicclassDerived:Base{publicoverrideintX{set=>base.X =value;}}
This is because the serializer only inspects the signature of the override, but it should instead try to honor the signature of the base definition. Impacts both reflection and source generated serializers.
The text was updated successfully, but these errors were encountered:
Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis
See info in area-owners.md if you want to be subscribed.
Issue Details
A bit of a rare corner case, but the serializer isn't currently handling properties that only override the setter:
using System.Text.Json;stringjson= JsonSerializer.Serialize(new Derived {X=42});
Console.WriteLine(json);// {}publicclassBase{publicvirtualintX{get;set;}}publicclassDerived:Base{publicoverrideintX{set=>base.X =value;}}
This is because the serializer only inspects the signature of the override, but it should instead try to honor the signature of the base definition. Impacts both reflection and source generated serializers.
Author:
eiriktsarpalis
Assignees:
-
Labels:
area-System.Text.Json
Milestone:
-
eiriktsarpalis
added
enhancement
Product code improvement that does NOT require public API changes/additions
bug
and removed
untriaged
New issue has not been triaged by the area owner
enhancement
Product code improvement that does NOT require public API changes/additions
labels
Jan 15, 2024
eiriktsarpalis
changed the title
System.Text.Json ignored properties that override the setter only.
System.Text.Json ignores properties that override the setter only.
Jan 15, 2024
A bit of a rare corner case, but the serializer isn't currently handling properties that only override the setter:
This is because the serializer only inspects the signature of the override, but it should instead try to honor the signature of the base definition. Impacts both reflection and source generated serializers.
The text was updated successfully, but these errors were encountered: