Skip to content

Allow non-metadata JSON property names with a leading dollar sign - #135776

Merged
eiriktsarpalis merged 1 commit into
dotnet:mainfrom
eiriktsarpalis:eiriktsarpalis-json-metadata-property-names
Oct 21, 2026
Merged

eiriktsarpalis merged 1 commit into
dotnet:mainfrom
eiriktsarpalis:eiriktsarpalis-json-metadata-property-names

Conversation

@eiriktsarpalis

Copy link
Copy Markdown
Member

System.Text.Json rejects all property names starting with $ when reference preservation or polymorphic deserialization is enabled, even when those names do not conflict with metadata.

Use the existing exact-name metadata classifier instead. Recognized metadata properties retain their validation, while unrelated $-prefixed names are processed as ordinary properties. When a custom type discriminator name is configured, $type is an ordinary property rather than metadata.

Updated the reference-handling documentation and regression coverage for mapped properties, dictionary keys, extension data, parameterized constructors, escaped names, case-sensitive matching, and out-of-order metadata. Debug and Release builds succeeded. All five serializer and source-generation test projects passed for both .NET and .NET Framework, with no failures.

Resolves #79482

Note

This pull request was created with GitHub Copilot.

Use exact metadata-name matching instead of rejecting all dollar-prefixed properties. Update regression coverage and reference-handling documentation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6a4bf4d8-af7e-42b6-bb96-64c74b24e259
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 4 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.

@blowdart

Copy link
Copy Markdown
Contributor

🎉

@eiriktsarpalis
eiriktsarpalis merged commit 6828eb2 into dotnet:main Oct 21, 2026
90 of 92 checks passed
@eiriktsarpalis
eiriktsarpalis deleted the eiriktsarpalis-json-metadata-property-names branch October 21, 2026 19:38
@gregsdennis

Copy link
Copy Markdown
Contributor

@eiriktsarpalis was the subscribers list cleared? I didn't get a notification for this.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot use Properties with $-character when reading System.Text.Json metadata.

4 participants