Document System.Text.Json features in .NET 11 - #55467
eiriktsarpalis wants to merge 18 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d38be7f-79b2-4e2a-9eb4-f7266c6ca5ac
There was a problem hiding this comment.
Pull request overview
This pull request updates System.Text.Json documentation for .NET 11 by adding new conceptual coverage (notably C# union serialization) and refreshing several existing articles and .NET 11 “What’s new” content to reflect new APIs and behaviors.
Changes:
- Adds a new conceptual article that documents C# union serialization and customization.
- Updates existing
System.Text.Jsonguidance to cover .NET 11 features across polymorphism, source generation, supported types, naming, ignore behavior, schema export, extension data, and writer reuse. - Updates .NET 11 library highlights content, navigation, and snippets to reference and demonstrate the new features.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/standard/serialization/system-text-json/use-utf8jsonwriter.md | Adds writer reuse guidance via Utf8JsonWriter.Reset(...) and AI usage frontmatter. |
| docs/standard/serialization/system-text-json/union-types.md | New article describing C# union serialization, classification, and source generation. |
| docs/standard/serialization/system-text-json/supported-types.md | Expands supported types coverage (JSON Lines, IReadOnlySet<T>, numeric types, and F# DU notes) and updates wording. |
| docs/standard/serialization/system-text-json/source-generation-modes.md | Updates source-generation guidance for non-public members/constructors and clarifies fast-path limitations. |
| docs/standard/serialization/system-text-json/reflection-vs-source-generation.md | Refreshes comparison text and adds a note about F# discriminated unions being reflection-only. |
| docs/standard/serialization/system-text-json/polymorphism.md | Adds closed-hierarchy inference guidance and open generic derived-type registration guidance. |
| docs/standard/serialization/system-text-json/immutability.md | Updates constructor binding guidance (including by-ref parameters, init-only behavior, and non-public support). |
| docs/standard/serialization/system-text-json/ignore-properties.md | Adds new section documenting type-level ignore conditions and precedence rules. |
| docs/standard/serialization/system-text-json/handle-overflow.md | Updates extension-data guidance (including IReadOnlyDictionary materialization and JsonObject flattening). |
| docs/standard/serialization/system-text-json/extract-schema.md | Updates schema exporter doc and adds new numeric converter/schema notes. |
| docs/standard/serialization/system-text-json/customize-properties.md | Adds PascalCase policy entry and documents per-type/member naming policy via attribute. |
| docs/standard/serialization/system-text-json/custom-contracts.md | Adds strongly typed GetTypeInfo<T>/TryGetTypeInfo<T> guidance and references union contract kind. |
| docs/standard/serialization/system-text-json/converters-how-to.md | Updates open generic converter guidance and clarifies behavior/error notes. |
| docs/fundamentals/toc.yml | Adds navigation entry for the new “Serialize union types” article. |
| docs/core/whats-new/dotnet-11/snippets/csharp/Libraries.cs | Updates/extends .NET 11 snippet code to match new features and examples. |
| docs/core/whats-new/dotnet-11/overview.md | Updates the .NET 11 overview bullet for System.Text.Json improvements. |
| docs/core/whats-new/dotnet-11/libraries.md | Reworks the System.Text.Json improvements section to align with the expanded .NET 11 documentation set. |
Suppressed comments (2)
docs/standard/serialization/system-text-json/polymorphism.md:610
- This open-generic polymorphism example declares
Base<T>andDerived<T>using semicolon-terminatedclassdeclarations, which doesn't compile. Use empty bodies ({ }) for the type declarations.
[JsonDerivedType(typeof(Derived<>), "derived")]
public class Base<T>;
public class Derived<T> : Base<T>;
docs/standard/serialization/system-text-json/supported-types.md:134
- This heading uses a gerund ("Streaming"), which conflicts with the repo's Markdown style guidance to avoid gerunds in headings. Consider reverting to the previous non-gerund heading text.
##### Streaming deserialization
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Corrected class definitions for Shape, Circle, and Square. Updated heading from 'Streaming serialization' to 'Stream serialization'. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d38be7f-79b2-4e2a-9eb4-f7266c6ca5ac
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d38be7f-79b2-4e2a-9eb4-f7266c6ca5ac
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d38be7f-79b2-4e2a-9eb4-f7266c6ca5ac
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d38be7f-79b2-4e2a-9eb4-f7266c6ca5ac
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d38be7f-79b2-4e2a-9eb4-f7266c6ca5ac
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d38be7f-79b2-4e2a-9eb4-f7266c6ca5ac
|
Hi @gewarren, please don't merge this yet. The initial PR is slop output that copilot created on my behalf. Let me get a few rounds of review on this first. |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d38be7f-79b2-4e2a-9eb4-f7266c6ca5ac
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d38be7f-79b2-4e2a-9eb4-f7266c6ca5ac
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d38be7f-79b2-4e2a-9eb4-f7266c6ca5ac
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d38be7f-79b2-4e2a-9eb4-f7266c6ca5ac
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d38be7f-79b2-4e2a-9eb4-f7266c6ca5ac
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d38be7f-79b2-4e2a-9eb4-f7266c6ca5ac
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d38be7f-79b2-4e2a-9eb4-f7266c6ca5ac
|
@gewarren I'm all done, feel free to proceed with another round of review. |
Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
|
@BillWagner Can you reapprove? |
Summary
Documents the 15
System.Text.Jsonwork items tracked by #55465. The change adds a conceptual article for C# union serialization, expands polymorphism and source-generation guidance, updates the supported-type and customization references, and completes the .NET 11 library highlights.Fixes #55465
Content source breakdown
Eventexample is newly generated and was verified on .NET 11 RC1 ({"$type":"Created","Id":42}). The Web-default quoted-number caveat adapts the blog's union-deserialization discussion. TheJsonSchemaExporteranyOfnote is newly generated from runtime tests and .NET 11 RC1 output, not from the blog's ASP.NET Core OpenAPI examples. No prose was copied verbatim.Stream, andPipeWriterbehavior follows the implementation tests.BFloat16,Decimal32,Decimal64, andDecimal128.IReadOnlyDictionarymaterialization andJsonObjectflattening.IReadOnlySet<T>Utf8JsonWriter.ResetoptionsExpert review notes
All modified Markdown identifies the work as
ai-assisted.The new union article, structural-classifier behavior, closed-hierarchy RC1 APIs, and new numeric converters warrant focused API-owner review. The locally available .NET 11 Preview 7 SDK predates some of those merged/backported APIs, so their descriptions and examples were checked against the corresponding runtime tests and API proposals rather than executed against that SDK. The union, polymorphism, naming, ignore, extension-data, collection, metadata, writer, JSONL, C#, Visual Basic, and F# examples that Preview 7 contains were compiled or executed locally.
Validation
docs/core/whats-new/dotnet-11/snippets/csharp/snippets.csproj: build succeeded with .NET SDK11.0.100-preview.7and 0 warnings.IReadOnlySet<T>, generic metadata lookup, writer reset, by-reference constructors, and JSON Lines output."Point"and{"$type":"Circle","radius":3.14}for the documented discriminated union.git diff --checkcompleted without errors.Internal previews
Toggle expand/collapse
Build report