Source profileQuality 93/100

dotnet/skills/plugins/dotnet11/skills/system-text-json-net11/SKILL.md

system-text-json-net11

Imperative guidance for the System.Text.Json APIs added in .NET 11: the built-in `JsonNamingPolicy.PascalCase` naming policy, and the strongly-typed `JsonSerializerOptions.GetTypeInfo<T>()` and `JsonSerializerOptions.TryGetTypeInfo<T>(out JsonTypeInfo<T>? info)` metadata accessors. USE FOR: serializing or deserializing JSON in a net11.0-or-later project when you need PascalCase JSON property names without writing a custom naming policy, a strongly-typed `JsonTypeInfo<T>` instead of the non-gener

Source repository stars
5,248
Declared platforms
0
Static risk flags
0
Last source update
2026-08-26
Source checked
2026-08-26

Decision brief

What it does: where it fits

Three APIs were added to System.Text.Json in .NET 11. This skill tells you exactly when to reach for each one, what to write, what not to write, and how to prove the result runs. Do not describe these APIs to the user — apply them, then run the code and show the output.

Best for

    Not for

    • Tasks that require unconfirmed production actions or broad system permissions.
    • Environments where the pinned source and install steps cannot be inspected.

    Compatibility matrix

    Platform support, with evidence labels

    PlatformStatusEvidenceWhat to check
    CodexNot declaredNo explicit evidencePortability before use
    Claude CodeNot declaredNo explicit evidencePortability before use
    CursorNot declaredNo explicit evidencePortability before use
    Gemini CLINot declaredNo explicit evidencePortability before use
    Open the compatibility checker

    Installation

    Inspect first. Install second.

    The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.

    Source-detected install commandSource
    npx skills add https://github.com/dotnet/skills --skill "plugins/dotnet11/skills/system-text-json-net11"
    Safe inspection promptEditorial

    Inspect the Agent Skill "system-text-json-net11" from https://github.com/dotnet/skills/blob/1b896e91feb0f613cb54a914f1efd2897810ae02/plugins/dotnet11/skills/system-text-json-net11/SKILL.md at commit 1b896e91feb0f613cb54a914f1efd2897810ae02. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.

    Workflow

    What the source asks the agent to do

    1. 01

      Step 0 — Confirm you can target .NET 11

      These APIs only exist in the .NET 11 base class library. Before writing code:

      Run dotnet --list-sdks and confirm an SDK that can target net11.0 is present — anIf no such SDK is available, stop: tell the user these APIs require targetingThese APIs only exist in the .NET 11 base class library. Before writing code:
    2. 02

      Decision table — symptom → do this → never do this

      Match the user's request to a row, apply the Do this cell verbatim, and confirm the Verify column before you are done.

      Match the user's request to a row, apply the Do this cell verbatim, and confirm the Verify column before you are done.
    3. 03

      Rule 1 — PascalCase property names

      When the user wants JSON output whose property names are PascalCase (Name, Age) and asks for the built-in / framework-provided way:

      Create or reuse a JsonSerializerOptions and setSerialize with those options.When the user wants JSON output whose property names are PascalCase (Name, Age) and asks for the built-in / framework-provided way:
    4. 04

      Rule 2 — Strongly-typed JsonTypeInfo

      When the user wants type metadata back as JsonTypeInfo (not the non-generic JsonTypeInfo that needs a cast):

      Call options.GetTypeInfo() — it returns JsonTypeInfo directly.Assign it to a JsonTypeInfo variable and use it (e.g. pass it toWhen the user wants type metadata back as JsonTypeInfo (not the non-generic JsonTypeInfo that needs a cast):
    5. 05

      Rule 3 — Probe metadata without throwing

      When the user wants to check whether metadata for T is available and branch on it — without an exception being thrown when it is not:

      Call options.TryGetTypeInfo(out var info).Handle the true branch (metadata resolved, use info) and the false branchWhen the user wants to check whether metadata for T is available and branch on it — without an exception being thrown when it is not:

    Permission review

    Static risk signals and limitations

    No configured static risk pattern was detected

    This is not proof of safety. Runtime behavior, indirect dependencies, and hidden external systems are outside the static scan.

    Evidence record

    Why each signal appears

    EvidenceSourceComputedTestedEditorial
    SignalValueEvidence typeMeaning
    Quality score93/100ComputedDocumentation, specificity, maintenance, and trust rules
    Repository stars5,248SourceRepository attention, not individual Skill quality
    Compatibility0 platformsSourceDeclared in the catalog source record
    Usage guideautomated source guideEditorialGenerated or reviewed according to the visible evidence level

    Pinned source

    Provenance and original SKILL.md

    Repository
    dotnet/skills
    Skill path
    plugins/dotnet11/skills/system-text-json-net11/SKILL.md
    Commit
    1b896e91feb0f613cb54a914f1efd2897810ae02
    License
    MIT
    Collected
    2026-08-26
    Default branch
    main
    View the original SKILL.md

    System.Text.Json — .NET 11

    Three APIs were added to System.Text.Json in .NET 11. This skill tells you exactly when to reach for each one, what to write, what not to write, and how to prove the result runs. Do not describe these APIs to the user — apply them, then run the code and show the output.

    APIReplaces the pre-.NET-11 workaround of...
    JsonNamingPolicy.PascalCase (static property)writing a custom JsonNamingPolicy subclass or hand-annotating every member with [JsonPropertyName]
    JsonSerializerOptions.GetTypeInfo<T>()calling non-generic GetTypeInfo(typeof(T)) and casting to JsonTypeInfo<T>
    JsonSerializerOptions.TryGetTypeInfo<T>(out JsonTypeInfo<T>? info)wrapping GetTypeInfo in try/catch to probe availability

    Step 0 — Confirm you can target .NET 11

    These APIs only exist in the .NET 11 base class library. Before writing code:

    1. Run dotnet --list-sdks and confirm an SDK that can target net11.0 is present — an 11.x SDK, or any later SDK (12.x+) that has the net11.0 targeting pack installed.
    2. If no such SDK is available, stop: tell the user these APIs require targeting net11.0 (on the .NET 11 SDK or later) and cannot compile on net10.0 or earlier. Do not fall back to a custom implementation and pretend it is the new API.

    Decision table — symptom → do this → never do this

    Match the user's request to a row, apply the Do this cell verbatim, and confirm the Verify column before you are done.

    User asks for…Do this (on net11.0)Never do thisVerify
    PascalCase JSON property namesoptions.PropertyNamingPolicy = JsonNamingPolicy.PascalCase;define class …: JsonNamingPolicy; add per-member [JsonPropertyName]; string-case the names yourselfoutput JSON keys are PascalCase — e.g. "Name", "Age"
    Strongly-typed metadata JsonTypeInfo<T>set TypeInfoResolver = new DefaultJsonTypeInfoResolver(), then JsonTypeInfo<T> ti = options.GetTypeInfo<T>();(JsonTypeInfo<T>)options.GetTypeInfo(typeof(T))variable is typed JsonTypeInfo<T>, no cast
    Probe whether metadata is resolvedif (options.TryGetTypeInfo<T>(out var ti)) { … } else { … }try { options.GetTypeInfo<T>(); } catch (…) { … }no try/catch; both branches handled

    Rule 1 — PascalCase property names

    When the user wants JSON output whose property names are PascalCase (Name, Age) and asks for the built-in / framework-provided way:

    1. Create or reuse a JsonSerializerOptions and set PropertyNamingPolicy = JsonNamingPolicy.PascalCase.
    2. Serialize with those options.

    Do not write a JsonNamingPolicy subclass, do not add [JsonPropertyName("…")] attributes to force casing, and do not upper-case the first letter of each name by hand. JsonNamingPolicy.PascalCase is the single correct answer on .NET 11.

    // Console project (reflection enabled by default). To run this as a file-based app
    // (dotnet run app.cs), also set TypeInfoResolver = new DefaultJsonTypeInfoResolver()
    // — see "Producing runnable output" below.
    using System.Text.Json;
    
    var options = new JsonSerializerOptions
    {
        PropertyNamingPolicy = JsonNamingPolicy.PascalCase
    };
    string json = JsonSerializer.Serialize(new { name = "Jane", age = 30 }, options);
    Console.WriteLine(json);
    // {"Name":"Jane","Age":30}
    

    Rule 2 — Strongly-typed JsonTypeInfo<T>

    When the user wants type metadata back as JsonTypeInfo<T> (not the non-generic JsonTypeInfo that needs a cast):

    1. Call options.GetTypeInfo<T>() — it returns JsonTypeInfo<T> directly.
    2. Assign it to a JsonTypeInfo<T> variable and use it (e.g. pass it to JsonSerializer.Serialize/Deserialize).

    Do not call the non-generic GetTypeInfo(Type) overload and cast the result.

    Requires a resolver. GetTypeInfo<T>() throws NotSupportedException (NoMetadataForType) unless the options have a TypeInfoResolver — set TypeInfoResolver = new DefaultJsonTypeInfoResolver() for reflection-based apps, or use a source-generated JsonSerializerContext for trimmed/AOT apps.

    // File-based app (run: dotnet run app.cs). In a .csproj project, remove this line and
    // set <TargetFramework>net11.0</TargetFramework> in the project file instead.
    #:property TargetFramework=net11.0
    
    using System.Text.Json;
    using System.Text.Json.Serialization.Metadata;
    
    var options = new JsonSerializerOptions
    {
        TypeInfoResolver = new DefaultJsonTypeInfoResolver()
    };
    
    JsonTypeInfo<Person> typeInfo = options.GetTypeInfo<Person>();
    Console.WriteLine(typeInfo.Type.Name); // Person
    
    record Person(string Name, int Age);
    

    Rule 3 — Probe metadata without throwing

    When the user wants to check whether metadata for T is available and branch on it — without an exception being thrown when it is not:

    1. Call options.TryGetTypeInfo<T>(out var info).
    2. Handle the true branch (metadata resolved, use info) and the false branch (not resolved) explicitly.

    Do not wrap GetTypeInfo<T>() in try/catch to detect the missing case — that is exactly the anti-pattern this API removes. TryGetTypeInfo<T> returns false (instead of throwing) when no resolver can produce metadata for T, which is precisely the case you want to branch on.

    // File-based app (run: dotnet run app.cs). In a .csproj project, remove this line and
    // set <TargetFramework>net11.0</TargetFramework> in the project file instead.
    #:property TargetFramework=net11.0
    
    using System.Text.Json;
    using System.Text.Json.Serialization.Metadata;
    
    // Configured with a resolver → metadata is available.
    var configured = new JsonSerializerOptions
    {
        TypeInfoResolver = new DefaultJsonTypeInfoResolver()
    };
    if (configured.TryGetTypeInfo<Person>(out JsonTypeInfo<Person>? info) && info is not null)
    {
        Console.WriteLine($"Resolved: {info.Type.Name}"); // Resolved: Person
    }
    else
    {
        Console.WriteLine("Type info not available");
    }
    
    // No resolver → TryGetTypeInfo returns false instead of throwing.
    var empty = new JsonSerializerOptions();
    Console.WriteLine(empty.TryGetTypeInfo<Person>(out _)); // False
    
    record Person(string Name, int Age);
    

    Producing runnable output on net11.0

    The task is not done until the program runs on net11.0 and prints its JSON. Prefer a console project — reflection-based serialization works there out of the box. A file-based app also works but has one important caveat (below).

    Option A — console project (recommended)

    Create a project whose .csproj contains <TargetFramework>net11.0</TargetFramework>, put the code in Program.cs, then run dotnet run. Confirm the process exits with code 0 and prints the expected JSON.

    using System.Text.Json;
    
    var options = new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.PascalCase };
    Console.WriteLine(JsonSerializer.Serialize(new { name = "Jane", age = 30 }, options));
    // {"Name":"Jane","Age":30}
    

    Option B — file-based app (quickest, one caveat)

    Save as app.cs, then run dotnet run app.cs; the first directive pins the framework.

    Caveat — file-based apps disable System.Text.Json reflection. In a dotnet run app.cs file-based app, JsonSerializer.IsReflectionEnabledByDefault is false, so plain reflection serialization throws NotSupportedException (NoMetadataForType). Set an explicit TypeInfoResolver = new DefaultJsonTypeInfoResolver() on the options (as below), or use a source-generated JsonSerializerContext. A regular project does not need this.

    // File-based app (run: dotnet run app.cs). In a .csproj project, remove this line and
    // set <TargetFramework>net11.0</TargetFramework> in the project file instead.
    #:property TargetFramework=net11.0
    
    using System.Text.Json;
    using System.Text.Json.Serialization.Metadata;
    
    var options = new JsonSerializerOptions
    {
        PropertyNamingPolicy = JsonNamingPolicy.PascalCase,
        TypeInfoResolver = new DefaultJsonTypeInfoResolver()
    };
    Console.WriteLine(JsonSerializer.Serialize(new { name = "Jane", age = 30 }, options));
    // {"Name":"Jane","Age":30}
    

    Worked example — serialize with typed metadata + PascalCase

    The record below uses lowercase member names on purpose, so the PascalCase policy visibly rewrites them in the output:

    // File-based app (run: dotnet run app.cs). In a .csproj project, remove this line and
    // set <TargetFramework>net11.0</TargetFramework> in the project file instead.
    #:property TargetFramework=net11.0
    
    using System.Text.Json;
    using System.Text.Json.Serialization.Metadata;
    
    var options = new JsonSerializerOptions
    {
        PropertyNamingPolicy = JsonNamingPolicy.PascalCase,
        TypeInfoResolver = new DefaultJsonTypeInfoResolver()
    };
    
    JsonTypeInfo<Person> typeInfo = options.GetTypeInfo<Person>();
    string json = JsonSerializer.Serialize(new Person("Jane", 30), typeInfo);
    Console.WriteLine(json);
    // {"Name":"Jane","Age":30}
    
    record Person(string name, int age);
    

    Validation checklist

    Before reporting success, confirm every applicable box:

    • The project or file-based app targets net11.0 (visible in the .csproj or the #:property TargetFramework=net11.0 directive).
    • PascalCase requests use JsonNamingPolicy.PascalCase — no custom JsonNamingPolicy subclass and no per-member [JsonPropertyName] attributes just to change casing.
    • Typed-metadata requests use the generic GetTypeInfo<T>() — no cast of a non-generic JsonTypeInfo — and the options set a TypeInfoResolver (e.g. DefaultJsonTypeInfoResolver) so the call doesn't throw NoMetadataForType.
    • Probing requests use TryGetTypeInfo<T>(out …) — no try/catch around GetTypeInfo.
    • The program was actually run (dotnet run …), exited 0, and its printed JSON shows the expected property names (e.g. "Name", "Age").
    • If a file-based app (dotnet run app.cs) is used, every JsonSerializerOptions sets a TypeInfoResolver — file-based apps disable reflection so plain serialization throws NoMetadataForType without one.

    Common pitfalls

    PitfallFix
    Hand-rolling a class … : JsonNamingPolicy for PascalCaseDelete it; set PropertyNamingPolicy = JsonNamingPolicy.PascalCase.
    Adding [JsonPropertyName("Name")] to every member to force casingRemove the attributes; the naming policy handles all members at once.
    Casting (JsonTypeInfo<T>)options.GetTypeInfo(typeof(T))Call the generic options.GetTypeInfo<T>(); no cast needed.
    try { options.GetTypeInfo<T>(); } catch (…) { … } to test availabilityReplace with if (options.TryGetTypeInfo<T>(out var info)) { … }.
    NotSupportedException / NoMetadataForType from GetTypeInfo<T>()The options have no resolver. Set TypeInfoResolver = new DefaultJsonTypeInfoResolver() (reflection) or a source-generated JsonSerializerContext (trim/AOT).
    NoMetadataForType even for a plain Serialize in a dotnet run app.cs file-based appFile-based apps disable STJ reflection. Add TypeInfoResolver = new DefaultJsonTypeInfoResolver(), or run it as a normal project instead.
    Leaving the app on the SDK's default TFMPin net11.0 explicitly so the .NET 11 APIs resolve and the output shows the target.
    Claiming success without runningRun dotnet run and paste the actual JSON output; the target is a working, executed program.

    More info

    Frequently asked questions

    What to verify before installation and use

    What does the system-text-json-net11 source document cover?

    Three APIs were added to System.Text.Json in .NET 11. This skill tells you exactly when to reach for each one, what to write, what not to write, and how to prove the result runs. Do not describe these APIs to the user — apply them, then run the code and show the output.

    How do I install system-text-json-net11?

    The source record exposes this install command: npx skills add https://github.com/dotnet/skills --skill "plugins/dotnet11/skills/system-text-json-net11". Inspect the command and pinned source before running it.