System.Text.Json should handle attributes in virtual or shadowed properties consistently #73255
Open
Description
Currently, System.Text.Json suffers from a few consistency/reliability bugs when it comes to consuming attributes defined in virtual/shadowed property hierarchies. These also manifest as divergences between reflection-based and source generated contract resolution semantics. We should try to fix as many of these as possible and expand our test coverage in this space. It might be the case that we need to introduce strategic breaking changes if absolutely necessary.
Provisional list of customer reported issues:
- JsonPropertyName inheritance perserve the parent member #51165
- JsonIgnore attribute is not inherited in overridden properties #50078
- The 'new' modifier doesn't always work with [JsonIgnore] #59675
- System.Text.Json ignores properties that override the setter only. #96996
- STJ fast-path generator does not always deduplicate shadowed members correctly. #98634
- Source generator in System.Text.Json does not handle shadowed members correctly #97621
- Serialization of properties from inherited interfaces vs abstract base classes #41749
- Serializing type which hides inherited property with both properties ignored throws ArgumentException #66900
- Default value for optional ctor params should be used when matching prop is ignored #60082
- System.Text.Json source generator fails for covariant properties when [JsonIgnore] is specified #63443
- Adding JsonIgnoreAttribute to
new
property fails with ArgumentException #76268