Skip to content

Use base accessors for unannotated setter-only JSON overrides - #136798

Closed
RutulPatel8 wants to merge 1 commit into
dotnet:mainfrom
RutulPatel8:fix/json-setter-only-override-96996
Closed

RutulPatel8 wants to merge 1 commit into
dotnet:mainfrom
RutulPatel8:fix/json-setter-only-override-96996

Conversation

@RutulPatel8

Copy link
Copy Markdown
Contributor

Fixes #96996

A setter-only property override has no getter in its own metadata. Both the reflection resolver and source generator selected that override and lost the public getter supplied by the base property, so serialization omitted it.

For unannotated setter-only overrides, let the base property supply the contract. Its virtual setter still dispatches to the override, while its getter remains available for serialization. Explicit attributes on an override continue to be processed as before.

Add a regression covering serialization and deserialization with both reflection and a generated context.

Validation: targeted regression passed; 206 PropertyVisibilityTestsDynamic cases and 62 JsonSerializerContextTests cases passed on net481.

@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Nov 1, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-system-text-json
See info in area-owners.md if you want to be subscribed.

@eiriktsarpalis

Copy link
Copy Markdown
Member

Thanks, but I would rather we didn't take this change. The virtual member handling logic has historically been very sensitive to introducing important breaking changes and is also the source of many bugs. Any attempt to touch this code should look at addressing all issues addressed in #73255 holistically, including potentially exploring possible intentional breaking changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-System.Text.Json community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

System.Text.Json ignores properties that override the setter only.

2 participants