[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7EKVQC4B7VSWSX7T2PBP1YS":3,"skill-same:01M7EKVQC4B7VSWSX7T2PBP1YS":52},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":32,"commitSha":33,"skillDirectory":34,"forksCount":14,"repositoryHtmlUrl":35,"repositoryHomepageUrl":35,"ownerHtmlUrl":36,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":37,"install":38,"resources":51},"01M7EKVQC4B7VSWSX7T2PBP1YS","system-text-json-net11",null,"> 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\u003CT>()` and `JsonSerializerOptions.TryGetTypeInfo\u003CT>(out JsonTypeInfo\u003CT>? in","Mr-Nobody-Anonymous\u002FAll-skills","Mr-Nobody-Anonymous","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F184253119?v=4","01M7AEXFJHKTYQW5R0ZCQQTWFV","anonymous","01M7C00M3GQR4QKP9GZA42GFAK",0,"MIT","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fcloud\u002Fsystem-text-json-net11\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: system-text-json-net11\ndescription: \"> 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\u003CT>()` and `JsonSerializerOptions.TryGetTypeInfo\u003CT>(out JsonTypeInfo\u003CT>? in\"\ncategory: cloud\nversion: 1.0.0\ndisable-model-invocation: false\nrisk: low\nsource:\n  repository: \"microsoft\u002Fskills\"\n  commit: \"8f3b1a2c\"\n  path: \"plugins\u002Fdotnet11\u002Fskills\u002Fsystem-text-json-net11\u002FSKILL.md\"\n  license: \"MIT\"\n  imported_at: \"2026-09-20\"\n---\n# System.Text.Json — .NET 11\n\nThree APIs were added to `System.Text.Json` in .NET 11. This skill tells you exactly\nwhen to reach for each one, what to write, what **not** to write, and how to prove the\nresult runs. Do not describe these APIs to the user — apply them, then run the code and\nshow the output.\n\n| API | Replaces the pre-.NET-11 workaround of... |\n| --- | --- |\n| `JsonNamingPolicy.PascalCase` (static property) | writing a custom `JsonNamingPolicy` subclass or hand-annotating every member with `[JsonPropertyName]` |\n| `JsonSerializerOptions.GetTypeInfo\u003CT>()` | calling non-generic `GetTypeInfo(typeof(T))` and casting to `JsonTypeInfo\u003CT>` |\n| `JsonSerializerOptions.TryGetTypeInfo\u003CT>(out JsonTypeInfo\u003CT>? info)` | wrapping `GetTypeInfo` in `try`\u002F`catch` to probe availability |\n\n## Step 0 — Make the requested `net11.0` validation possible\n\nThese APIs only exist in the .NET 11 base class library. Before writing code:\n\n1. Run `dotnet --list-sdks` and confirm an SDK that can target `net11.0` is present — an\n   `11.x` SDK, or a later SDK with the `net11.0` targeting pack.\n2. If the user explicitly asks you to run the sample and no suitable SDK is installed,\n   use the official `dotnet-install` script to install the current .NET 11 SDK into a\n   temporary or project-local directory. Prefer the GA channel build. Use a preview only\n   when GA is not yet available or the user explicitly requested a preview. Do not require\n   administrator access, change the machine-wide `PATH`, or replace an installed SDK.\n3. Run the sample with that local `dotnet` executable. If download or execution is blocked,\n   still provide the complete `net11.0` program and report that it was **not run**. Never\n   substitute `net10.0`, a custom naming policy, or a different API and present that as\n   validation of the .NET 11 feature.\n\nUse the channel, not a guessed version. Try the GA channel first:\n\n```powershell\n$installScript = Join-Path $env:TEMP \"dotnet-install-$([guid]::NewGuid()).ps1\"\ntry {\n    Invoke-WebRequest -Uri 'https:\u002F\u002Fdot.net\u002Fv1\u002Fdotnet-install.ps1' -OutFile $installScript\n    & $installScript -Channel 11.0 -InstallDir .\\.dotnet\n    & .\\.dotnet\\dotnet.exe run --project \u003CPATH_TO_NET11_PROJECT>\n}\nfinally {\n    Remove-Item -LiteralPath $installScript -Force -ErrorAction SilentlyContinue\n}\n```\n\n```bash\ninstall_script=\"$(mktemp \"${TMPDIR:-\u002Ftmp}\u002Fdotnet-install.XXXXXX\")\"\ntrap 'rm -f \"$install_script\"' EXIT\ncurl -fsSL https:\u002F\u002Fdot.net\u002Fv1\u002Fdotnet-install.sh -o \"$install_script\"\nbash \"$install_script\" --channel 11.0 --install-dir .\u002F.dotnet\n.\u002F.dotnet\u002Fdotnet run --project \u003CPATH_TO_NET11_PROJECT>\n```\n\nBefore .NET 11 GA, retry the install with `-Quality preview` (PowerShell) or\n`--quality preview` (shell).\n\n## Decision table — symptom → do this → never do this\n\nMatch the user's request to a row, apply the **Do this** cell verbatim, and confirm the\n**Verify** column before you are done.\n\n| User asks for… | Do this (on `net11.0`) | Never do this | Verify |\n| --- | --- | --- | --- |\n| PascalCase JSON property names | `options.PropertyNamingPolicy = JsonNamingPolicy.PascalCase;` | define `class …: JsonNamingPolicy`; add per-member `[JsonPropertyName]`; string-case the names yourself | output JSON keys are PascalCase — e.g. `\"Name\"`, `\"Age\"` |\n| PascalCase dictionary keys | `options.DictionaryKeyPolicy = JsonNamingPolicy.PascalCase;` | set only `PropertyNamingPolicy`; pre-transform the dictionary; define a custom policy | dictionary keys such as `pendingOrders` become `\"PendingOrders\"` |\n| Strongly-typed metadata `JsonTypeInfo\u003CT>` | set `TypeInfoResolver = new DefaultJsonTypeInfoResolver()`, then `JsonTypeInfo\u003CT> ti = options.GetTypeInfo\u003CT>();` | `(JsonTypeInfo\u003CT>)options.GetTypeInfo(typeof(T))` | variable is typed `JsonTypeInfo\u003CT>`, no cast |\n| Probe whether metadata is resolved | `if (options.TryGetTypeInfo\u003CT>(out var ti)) { … } else { … }` | `try { options.GetTypeInfo\u003CT>(); } catch (…) { … }` | no `try`\u002F`catch`; both branches handled |\n\n## Rule 1 — PascalCase property names\n\n**When** the user wants JSON output whose property names are PascalCase (`Name`, `Age`)\nand asks for the built-in \u002F framework-provided way:\n\n1. Create or reuse a `JsonSerializerOptions` and set\n   `PropertyNamingPolicy = JsonNamingPolicy.PascalCase`.\n2. Serialize with those options.\n\nDo **not** write a `JsonNamingPolicy` subclass, do **not** add `[JsonPropertyName(\"…\")]`\nattributes to force casing, and do **not** upper-case the first letter of each name by\nhand. `JsonNamingPolicy.PascalCase` is the single correct answer on .NET 11.\n\n```csharp\n\u002F\u002F Console project (reflection enabled by default). To run this as a file-based app\n\u002F\u002F (dotnet run app.cs), also set TypeInfoResolver = new DefaultJsonTypeInfoResolver()\n\u002F\u002F — see \"Producing runnable output\" below.\nusing System.Text.Json;\n\nvar options = new JsonSerializerOptions\n{\n    PropertyNamingPolicy = JsonNamingPolicy.PascalCase\n};\nstring json = JsonSerializer.Serialize(new { name = \"Jane\", age = 30 }, options);\nConsole.WriteLine(json);\n\u002F\u002F {\"Name\":\"Jane\",\"Age\":30}\n```\n\n### Dictionary keys are a separate setting\n\n`PropertyNamingPolicy` does not transform `Dictionary\u003Cstring, TValue>` keys. For that\nrequest, set `DictionaryKeyPolicy`:\n\n```csharp\nvar options = new JsonSerializerOptions\n{\n    DictionaryKeyPolicy = JsonNamingPolicy.PascalCase\n};\nvar values = new Dictionary\u003Cstring, int>\n{\n    [\"pendingOrders\"] = 2,\n    [\"activeUsers\"] = 5\n};\nConsole.WriteLine(JsonSerializer.Serialize(values, options));\n\u002F\u002F {\"PendingOrders\":2,\"ActiveUsers\":5}\n```\n\n## Rule 2 — Strongly-typed `JsonTypeInfo\u003CT>`\n\n**When** the user wants type metadata back as `JsonTypeInfo\u003CT>` (not the non-generic\n`JsonTypeInfo` that needs a cast):\n\n1. Call `options.GetTypeInfo\u003CT>()` — it returns `JsonTypeInfo\u003CT>` directly.\n2. Assign it to a `JsonTypeInfo\u003CT>` variable and use it (e.g. pass it to\n   `JsonSerializer.Serialize`\u002F`Deserialize`).\n\nDo **not** call the non-generic `GetTypeInfo(Type)` overload and cast the result.\n\n> **Requires a resolver.** `GetTypeInfo\u003CT>()` throws `NotSupportedException`\n> (`NoMetadataForType`) unless the options have a `TypeInfoResolver` — set\n> `TypeInfoResolver = new DefaultJsonTypeInfoResolver()` for reflection-based apps, or use\n> a source-generated `JsonSerializerContext` for trimmed\u002FAOT apps.\n\n```csharp\n\u002F\u002F File-based app (run: dotnet run app.cs). In a .csproj project, remove this line and\n\u002F\u002F set \u003CTargetFramework>net11.0\u003C\u002FTargetFramework> in the project file instead.\n#:property TargetFramework=net11.0\n\nusing System.Text.Json;\nusing System.Text.Json.Serialization.Metadata;\n\nvar options = new JsonSerializerOptions\n{\n    TypeInfoResolver = new DefaultJsonTypeInfoResolver()\n};\n\nJsonTypeInfo\u003CPerson> typeInfo = options.GetTypeInfo\u003CPerson>();\nConsole.WriteLine(typeInfo.Type.Name); \u002F\u002F Person\n\nrecord Person(string Name, int Age);\n```\n\n## Rule 3 — Probe metadata without throwing\n\n**When** the user wants to check whether metadata for `T` is available and branch on it —\n*without* an exception being thrown when it is not:\n\n1. Call `options.TryGetTypeInfo\u003CT>(out var info)`.\n2. Handle the `true` branch (metadata resolved, use `info`) and the `false` branch\n   (not resolved) explicitly.\n\nDo **not** wrap `GetTypeInfo\u003CT>()` in `try`\u002F`catch` to detect the missing case — that is\nexactly the anti-pattern this API removes. `TryGetTypeInfo\u003CT>` returns `false` (instead of\nthrowing) when no resolver can produce metadata for `T`, which is precisely the case you\nwant to branch on.\n\n```csharp\n\u002F\u002F File-based app (run: dotnet run app.cs). In a .csproj project, remove this line and\n\u002F\u002F set \u003CTargetFramework>net11.0\u003C\u002FTargetFramework> in the project file instead.\n#:property TargetFramework=net11.0\n\nusing System.Text.Json;\nusing System.Text.Json.Serialization.Metadata;\n\n\u002F\u002F Configured with a resolver → metadata is available.\nvar configured = new JsonSerializerOptions\n{\n    TypeInfoResolver = new DefaultJsonTypeInfoResolver()\n};\nif (configured.TryGetTypeInfo\u003CPerson>(out JsonTypeInfo\u003CPerson>? info) && info is not null)\n{\n    Console.WriteLine($\"Resolved: {info.Type.Name}\"); \u002F\u002F Resolved: Person\n}\nelse\n{\n    Console.WriteLine(\"Type info not available\");\n}\n\n\u002F\u002F No resolver → TryGetTypeInfo returns false instead of throwing.\nvar empty = new JsonSerializerOptions();\nConsole.WriteLine(empty.TryGetTypeInfo\u003CPerson>(out _)); \u002F\u002F False\n\nrecord Person(string Name, int Age);\n```\n\n## Producing runnable output on `net11.0`\n\nThe task is not done until the program runs on `net11.0` and prints its JSON. Prefer a\nconsole **project** — reflection-based serialization works there out of the box. A\nfile-based app also works but has one important caveat (below).\n\nWhen the installed SDK cannot target `net11.0` and execution was requested, install an\nSDK locally with the official script and invoke it by full path. The install script is\nnon-administrative and does not persistently alter `PATH`.\n\n### Option A — console project (recommended)\n\nCreate a project whose `.csproj` contains `\u003CTargetFramework>net11.0\u003C\u002FTargetFramework>`,\nput the code in `Program.cs`, then run `dotnet run`. Confirm the process exits with code 0\nand prints the expected JSON.\n\n```csharp\nusing System.Text.Json;\n\nvar options = new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.PascalCase };\nConsole.WriteLine(JsonSerializer.Serialize(new { name = \"Jane\", age = 30 }, options));\n\u002F\u002F {\"Name\":\"Jane\",\"Age\":30}\n```\n\n### Option B — file-based app (quickest, one caveat)\n\nSave as `app.cs`, then run `dotnet run app.cs`; the first directive pins the framework.\n\n> **Caveat — file-based apps disable System.Text.Json reflection.** In a `dotnet run app.cs`\n> file-based app, `JsonSerializer.IsReflectionEnabledByDefault` is `false`, so plain\n> reflection serialization throws `NotSupportedException` (`NoMetadataForType`). Set an\n> explicit `TypeInfoResolver = new DefaultJsonTypeInfoResolver()` on the options (as below),\n> or use a source-generated `JsonSerializerContext`. A regular project does **not** need this.\n\n```csharp\n\u002F\u002F File-based app (run: dotnet run app.cs). In a .csproj project, remove this line and\n\u002F\u002F set \u003CTargetFramework>net11.0\u003C\u002FTargetFramework> in the project file instead.\n#:property TargetFramework=net11.0\n\nusing System.Text.Json;\nusing System.Text.Json.Serialization.Metadata;\n\nvar options = new JsonSerializerOptions\n{\n    PropertyNamingPolicy = JsonNamingPolicy.PascalCase,\n    TypeInfoResolver = new DefaultJsonTypeInfoResolver()\n};\nConsole.WriteLine(JsonSerializer.Serialize(new { name = \"Jane\", age = 30 }, options));\n\u002F\u002F {\"Name\":\"Jane\",\"Age\":30}\n```\n\n## Worked example — serialize with typed metadata + PascalCase\n\nThe record below uses lowercase member names on purpose, so the PascalCase policy\nvisibly rewrites them in the output:\n\n```csharp\n\u002F\u002F File-based app (run: dotnet run app.cs). In a .csproj project, remove this line and\n\u002F\u002F set \u003CTargetFramework>net11.0\u003C\u002FTargetFramework> in the project file instead.\n#:property TargetFramework=net11.0\n\nusing System.Text.Json;\nusing System.Text.Json.Serialization.Metadata;\n\nvar options = new JsonSerializerOptions\n{\n    PropertyNamingPolicy = JsonNamingPolicy.PascalCase,\n    TypeInfoResolver = new DefaultJsonTypeInfoResolver()\n};\n\nJsonTypeInfo\u003CPerson> typeInfo = options.GetTypeInfo\u003CPerson>();\nstring json = JsonSerializer.Serialize(new Person(\"Jane\", 30), typeInfo);\nConsole.WriteLine(json);\n\u002F\u002F {\"Name\":\"Jane\",\"Age\":30}\n\nrecord Person(string name, int age);\n```\n\n## Validation checklist\n\nBefore reporting success, confirm every applicable box:\n\n- [ ] The project or file-based app targets `net11.0` (visible in the `.csproj` or the\n      `#:property TargetFramework=net11.0` directive).\n- [ ] PascalCase requests use `JsonNamingPolicy.PascalCase` — no custom `JsonNamingPolicy`\n      subclass and no per-member `[JsonPropertyName]` attributes just to change casing.\n- [ ] Dictionary-key requests set `DictionaryKeyPolicy`, not only `PropertyNamingPolicy`.\n- [ ] Typed-metadata requests use the generic `GetTypeInfo\u003CT>()` — no cast of a\n      non-generic `JsonTypeInfo` — and the options set a `TypeInfoResolver` (e.g.\n      `DefaultJsonTypeInfoResolver`) so the call doesn't throw `NoMetadataForType`.\n- [ ] Probing requests use `TryGetTypeInfo\u003CT>(out …)` — no `try`\u002F`catch` around\n      `GetTypeInfo`.\n- [ ] The program was actually run (`dotnet run …`), exited 0, and its printed JSON shows\n      the expected property names (e.g. `\"Name\"`, `\"Age\"`).\n- [ ] If a **file-based app** (`dotnet run app.cs`) is used, every `JsonSerializerOptions`\n      sets a `TypeInfoResolver` — file-based apps disable reflection so plain serialization\n      throws `NoMetadataForType` without one.\n\n## Common pitfalls\n\n| Pitfall | Fix |\n| --- | --- |\n| Hand-rolling a `class … : JsonNamingPolicy` for PascalCase | Delete it; set `PropertyNamingPolicy = JsonNamingPolicy.PascalCase`. |\n| Adding `[JsonPropertyName(\"Name\")]` to every member to force casing | Remove the attributes; the naming policy handles all members at once. |\n| Casting `(JsonTypeInfo\u003CT>)options.GetTypeInfo(typeof(T))` | Call the generic `options.GetTypeInfo\u003CT>()`; no cast needed. |\n| `try { options.GetTypeInfo\u003CT>(); } catch (…) { … }` to test availability | Replace with `if (options.TryGetTypeInfo\u003CT>(out var info)) { … }`. |\n| `NotSupportedException` \u002F `NoMetadataForType` from `GetTypeInfo\u003CT>()` | The options have no resolver. Set `TypeInfoResolver = new DefaultJsonTypeInfoResolver()` (reflection) or a source-generated `JsonSerializerContext` (trim\u002FAOT). |\n| `NoMetadataForType` even for a plain `Serialize` in a `dotnet run app.cs` file-based app | File-based apps disable STJ reflection. Add `TypeInfoResolver = new DefaultJsonTypeInfoResolver()`, or run it as a normal project instead. |\n| Leaving the app on the SDK's default TFM | Pin `net11.0` explicitly so the .NET 11 APIs resolve and the output shows the target. |\n| Claiming success without running | Run `dotnet run` and paste the actual JSON output; the target is a working, executed program. |\n\n## More info\n\n- [JsonNamingPolicy class](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fapi\u002Fsystem.text.json.jsonnamingpolicy) — built-in naming policies including `PascalCase`\n- [JsonSerializerOptions.GetTypeInfo](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fapi\u002Fsystem.text.json.jsonserializeroptions.gettypeinfo) — typed and non-typed metadata access\n- [JsonTypeInfo\\\u003CT\\>](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fapi\u002Fsystem.text.json.serialization.metadata.jsontypeinfo-1) — strongly-typed serialization metadata\n- [DefaultJsonTypeInfoResolver](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fapi\u002Fsystem.text.json.serialization.metadata.defaultjsontypeinforesolver) — reflection-based resolver required by `GetTypeInfo`\u002F`TryGetTypeInfo`\n- [File-based apps](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fcore\u002Fsdk\u002Ffile-based-apps) — `dotnet run app.cs` and the `#:property` directive\n","# System.Text.Json — .NET 11\n\nThree APIs were added to `System.Text.Json` in .NET 11. This skill tells you exactly\nwhen to reach for each one, what to write, what **not** to write, and how to prove the\nresult runs. Do not describe these APIs to the user — apply them, then run the code and\nshow the output.\n\n| API | Replaces the pre-.NET-11 workaround of... |\n| --- | --- |\n| `JsonNamingPolicy.PascalCase` (static property) | writing a custom `JsonNamingPolicy` subclass or hand-annotating every member with `[JsonPropertyName]` |\n| `JsonSerializerOptions.GetTypeInfo\u003CT>()` | calling non-generic `GetTypeInfo(typeof(T))` and casting to `JsonTypeInfo\u003CT>` |\n| `JsonSerializerOptions.TryGetTypeInfo\u003CT>(out JsonTypeInfo\u003CT>? info)` | wrapping `GetTypeInfo` in `try`\u002F`catch` to probe availability |\n\n## Step 0 — Make the requested `net11.0` validation possible\n\nThese APIs only exist in the .NET 11 base class library. Before writing code:\n\n1. Run `dotnet --list-sdks` and confirm an SDK that can target `net11.0` is present — an\n   `11.x` SDK, or a later SDK with the `net11.0` targeting pack.\n2. If the user explicitly asks you to run the sample and no suitable SDK is installed,\n   use the official `dotnet-install` script to install the current .NET 11 SDK into a\n   temporary or project-local directory. Prefer the GA channel build. Use a preview only\n   when GA is not yet available or the user explicitly requested a preview. Do not require\n   administrator access, change the machine-wide `PATH`, or replace an installed SDK.\n3. Run the sample with that local `dotnet` executable. If download or execution is blocked,\n   still provide the complete `net11.0` program and report that it was **not run**. Never\n   substitute `net10.0`, a custom naming policy, or a different API and present that as\n   validation of the .NET 11 feature.\n\nUse the channel, not a guessed version. Try the GA channel first:\n\n```powershell\n$installScript = Join-Path $env:TEMP \"dotnet-install-$([guid]::NewGuid()).ps1\"\ntry {\n    Invoke-WebRequest -Uri 'https:\u002F\u002Fdot.net\u002Fv1\u002Fdotnet-install.ps1' -OutFile $installScript\n    & $installScript -Channel 11.0 -InstallDir .\\.dotnet\n    & .\\.dotnet\\dotnet.exe run --project \u003CPATH_TO_NET11_PROJECT>\n}\nfinally {\n    Remove-Item -LiteralPath $installScript -Force -ErrorAction SilentlyContinue\n}\n```\n\n```bash\ninstall_script=\"$(mktemp \"${TMPDIR:-\u002Ftmp}\u002Fdotnet-install.XXXXXX\")\"\ntrap 'rm -f \"$install_script\"' EXIT\ncurl -fsSL https:\u002F\u002Fdot.net\u002Fv1\u002Fdotnet-install.sh -o \"$install_script\"\nbash \"$install_script\" --channel 11.0 --install-dir .\u002F.dotnet\n.\u002F.dotnet\u002Fdotnet run --project \u003CPATH_TO_NET11_PROJECT>\n```\n\nBefore .NET 11 GA, retry the install with `-Quality preview` (PowerShell) or\n`--quality preview` (shell).\n\n## Decision table — symptom → do this → never do this\n\nMatch the user's request to a row, apply the **Do this** cell verbatim, and confirm the\n**Verify** column before you are done.\n\n| User asks for… | Do this (on `net11.0`) | Never do this | Verify |\n| --- | --- | --- | --- |\n| PascalCase JSON property names | `options.PropertyNamingPolicy = JsonNamingPolicy.PascalCase;` | define `class …: JsonNamingPolicy`; add per-member `[JsonPropertyName]`; string-case the names yourself | output JSON keys are PascalCase — e.g. `\"Name\"`, `\"Age\"` |\n| PascalCase dictionary keys | `options.DictionaryKeyPolicy = JsonNamingPolicy.PascalCase;` | set only `PropertyNamingPolicy`; pre-transform the dictionary; define a custom policy | dictionary keys such as `pendingOrders` become `\"PendingOrders\"` |\n| Strongly-typed metadata `JsonTypeInfo\u003CT>` | set `TypeInfoResolver = new DefaultJsonTypeInfoResolver()`, then `JsonTypeInfo\u003CT> ti = options.GetTypeInfo\u003CT>();` | `(JsonTypeInfo\u003CT>)options.GetTypeInfo(typeof(T))` | variable is typed `JsonTypeInfo\u003CT>`, no cast |\n| Probe whether metadata is resolved | `if (options.TryGetTypeInfo\u003CT>(out var ti)) { … } else { … }` | `try { options.GetTypeInfo\u003CT>(); } catch (…) { … }` | no `try`\u002F`catch`; both branches handled |\n\n## Rule 1 — PascalCase property names\n\n**When** the user wants JSON output whose property names are PascalCase (`Name`, `Age`)\nand asks for the built-in \u002F framework-provided way:\n\n1. Create or reuse a `JsonSerializerOptions` and set\n   `PropertyNamingPolicy = JsonNamingPolicy.PascalCase`.\n2. Serialize with those options.\n\nDo **not** write a `JsonNamingPolicy` subclass, do **not** add `[JsonPropertyName(\"…\")]`\nattributes to force casing, and do **not** upper-case the first letter of each name by\nhand. `JsonNamingPolicy.PascalCase` is the single correct answer on .NET 11.\n\n```csharp\n\u002F\u002F Console project (reflection enabled by default). To run this as a file-based app\n\u002F\u002F (dotnet run app.cs), also set TypeInfoResolver = new DefaultJsonTypeInfoResolver()\n\u002F\u002F — see \"Producing runnable output\" below.\nusing System.Text.Json;\n\nvar options = new JsonSerializerOptions\n{\n    PropertyNamingPolicy = JsonNamingPolicy.PascalCase\n};\nstring json = JsonSerializer.Serialize(new { name = \"Jane\", age = 30 }, options);\nConsole.WriteLine(json);\n\u002F\u002F {\"Name\":\"Jane\",\"Age\":30}\n```\n\n### Dictionary keys are a separate setting\n\n`PropertyNamingPolicy` does not transform `Dictionary\u003Cstring, TValue>` keys. For that\nrequest, set `DictionaryKeyPolicy`:\n\n```csharp\nvar options = new JsonSerializerOptions\n{\n    DictionaryKeyPolicy = JsonNamingPolicy.PascalCase\n};\nvar values = new Dictionary\u003Cstring, int>\n{\n    [\"pendingOrders\"] = 2,\n    [\"activeUsers\"] = 5\n};\nConsole.WriteLine(JsonSerializer.Serialize(values, options));\n\u002F\u002F {\"PendingOrders\":2,\"ActiveUsers\":5}\n```\n\n## Rule 2 — Strongly-typed `JsonTypeInfo\u003CT>`\n\n**When** the user wants type metadata back as `JsonTypeInfo\u003CT>` (not the non-generic\n`JsonTypeInfo` that needs a cast):\n\n1. Call `options.GetTypeInfo\u003CT>()` — it returns `JsonTypeInfo\u003CT>` directly.\n2. Assign it to a `JsonTypeInfo\u003CT>` variable and use it (e.g. pass it to\n   `JsonSerializer.Serialize`\u002F`Deserialize`).\n\nDo **not** call the non-generic `GetTypeInfo(Type)` overload and cast the result.\n\n> **Requires a resolver.** `GetTypeInfo\u003CT>()` throws `NotSupportedException`\n> (`NoMetadataForType`) unless the options have a `TypeInfoResolver` — set\n> `TypeInfoResolver = new DefaultJsonTypeInfoResolver()` for reflection-based apps, or use\n> a source-generated `JsonSerializerContext` for trimmed\u002FAOT apps.\n\n```csharp\n\u002F\u002F File-based app (run: dotnet run app.cs). In a .csproj project, remove this line and\n\u002F\u002F set \u003CTargetFramework>net11.0\u003C\u002FTargetFramework> in the project file instead.\n#:property TargetFramework=net11.0\n\nusing System.Text.Json;\nusing System.Text.Json.Serialization.Metadata;\n\nvar options = new JsonSerializerOptions\n{\n    TypeInfoResolver = new DefaultJsonTypeInfoResolver()\n};\n\nJsonTypeInfo\u003CPerson> typeInfo = options.GetTypeInfo\u003CPerson>();\nConsole.WriteLine(typeInfo.Type.Name); \u002F\u002F Person\n\nrecord Person(string Name, int Age);\n```\n\n## Rule 3 — Probe metadata without throwing\n\n**When** the user wants to check whether metadata for `T` is available and branch on it —\n*without* an exception being thrown when it is not:\n\n1. Call `options.TryGetTypeInfo\u003CT>(out var info)`.\n2. Handle the `true` branch (metadata resolved, use `info`) and the `false` branch\n   (not resolved) explicitly.\n\nDo **not** wrap `GetTypeInfo\u003CT>()` in `try`\u002F`catch` to detect the missing case — that is\nexactly the anti-pattern this API removes. `TryGetTypeInfo\u003CT>` returns `false` (instead of\nthrowing) when no resolver can produce metadata for `T`, which is precisely the case you\nwant to branch on.\n\n```csharp\n\u002F\u002F File-based app (run: dotnet run app.cs). In a .csproj project, remove this line and\n\u002F\u002F set \u003CTargetFramework>net11.0\u003C\u002FTargetFramework> in the project file instead.\n#:property TargetFramework=net11.0\n\nusing System.Text.Json;\nusing System.Text.Json.Serialization.Metadata;\n\n\u002F\u002F Configured with a resolver → metadata is available.\nvar configured = new JsonSerializerOptions\n{\n    TypeInfoResolver = new DefaultJsonTypeInfoResolver()\n};\nif (configured.TryGetTypeInfo\u003CPerson>(out JsonTypeInfo\u003CPerson>? info) && info is not null)\n{\n    Console.WriteLine($\"Resolved: {info.Type.Name}\"); \u002F\u002F Resolved: Person\n}\nelse\n{\n    Console.WriteLine(\"Type info not available\");\n}\n\n\u002F\u002F No resolver → TryGetTypeInfo returns false instead of throwing.\nvar empty = new JsonSerializerOptions();\nConsole.WriteLine(empty.TryGetTypeInfo\u003CPerson>(out _)); \u002F\u002F False\n\nrecord Person(string Name, int Age);\n```\n\n## Producing runnable output on `net11.0`\n\nThe task is not done until the program runs on `net11.0` and prints its JSON. Prefer a\nconsole **project** — reflection-based serialization works there out of the box. A\nfile-based app also works but has one important caveat (below).\n\nWhen the installed SDK cannot target `net11.0` and execution was requested, install an\nSDK locally with the official script and invoke it by full path. The install script is\nnon-administrative and does not persistently alter `PATH`.\n\n### Option A — console project (recommended)\n\nCreate a project whose `.csproj` contains `\u003CTargetFramework>net11.0\u003C\u002FTargetFramework>`,\nput the code in `Program.cs`, then run `dotnet run`. Confirm the process exits with code 0\nand prints the expected JSON.\n\n```csharp\nusing System.Text.Json;\n\nvar options = new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.PascalCase };\nConsole.WriteLine(JsonSerializer.Serialize(new { name = \"Jane\", age = 30 }, options));\n\u002F\u002F {\"Name\":\"Jane\",\"Age\":30}\n```\n\n### Option B — file-based app (quickest, one caveat)\n\nSave as `app.cs`, then run `dotnet run app.cs`; the first directive pins the framework.\n\n> **Caveat — file-based apps disable System.Text.Json reflection.** In a `dotnet run app.cs`\n> file-based app, `JsonSerializer.IsReflectionEnabledByDefault` is `false`, so plain\n> reflection serialization throws `NotSupportedException` (`NoMetadataForType`). Set an\n> explicit `TypeInfoResolver = new DefaultJsonTypeInfoResolver()` on the options (as below),\n> or use a source-generated `JsonSerializerContext`. A regular project does **not** need this.\n\n```csharp\n\u002F\u002F File-based app (run: dotnet run app.cs). In a .csproj project, remove this line and\n\u002F\u002F set \u003CTargetFramework>net11.0\u003C\u002FTargetFramework> in the project file instead.\n#:property TargetFramework=net11.0\n\nusing System.Text.Json;\nusing System.Text.Json.Serialization.Metadata;\n\nvar options = new JsonSerializerOptions\n{\n    PropertyNamingPolicy = JsonNamingPolicy.PascalCase,\n    TypeInfoResolver = new DefaultJsonTypeInfoResolver()\n};\nConsole.WriteLine(JsonSerializer.Serialize(new { name = \"Jane\", age = 30 }, options));\n\u002F\u002F {\"Name\":\"Jane\",\"Age\":30}\n```\n\n## Worked example — serialize with typed metadata + PascalCase\n\nThe record below uses lowercase member names on purpose, so the PascalCase policy\nvisibly rewrites them in the output:\n\n```csharp\n\u002F\u002F File-based app (run: dotnet run app.cs). In a .csproj project, remove this line and\n\u002F\u002F set \u003CTargetFramework>net11.0\u003C\u002FTargetFramework> in the project file instead.\n#:property TargetFramework=net11.0\n\nusing System.Text.Json;\nusing System.Text.Json.Serialization.Metadata;\n\nvar options = new JsonSerializerOptions\n{\n    PropertyNamingPolicy = JsonNamingPolicy.PascalCase,\n    TypeInfoResolver = new DefaultJsonTypeInfoResolver()\n};\n\nJsonTypeInfo\u003CPerson> typeInfo = options.GetTypeInfo\u003CPerson>();\nstring json = JsonSerializer.Serialize(new Person(\"Jane\", 30), typeInfo);\nConsole.WriteLine(json);\n\u002F\u002F {\"Name\":\"Jane\",\"Age\":30}\n\nrecord Person(string name, int age);\n```\n\n## Validation checklist\n\nBefore reporting success, confirm every applicable box:\n\n- [ ] The project or file-based app targets `net11.0` (visible in the `.csproj` or the\n      `#:property TargetFramework=net11.0` directive).\n- [ ] PascalCase requests use `JsonNamingPolicy.PascalCase` — no custom `JsonNamingPolicy`\n      subclass and no per-member `[JsonPropertyName]` attributes just to change casing.\n- [ ] Dictionary-key requests set `DictionaryKeyPolicy`, not only `PropertyNamingPolicy`.\n- [ ] Typed-metadata requests use the generic `GetTypeInfo\u003CT>()` — no cast of a\n      non-generic `JsonTypeInfo` — and the options set a `TypeInfoResolver` (e.g.\n      `DefaultJsonTypeInfoResolver`) so the call doesn't throw `NoMetadataForType`.\n- [ ] Probing requests use `TryGetTypeInfo\u003CT>(out …)` — no `try`\u002F`catch` around\n      `GetTypeInfo`.\n- [ ] The program was actually run (`dotnet run …`), exited 0, and its printed JSON shows\n      the expected property names (e.g. `\"Name\"`, `\"Age\"`).\n- [ ] If a **file-based app** (`dotnet run app.cs`) is used, every `JsonSerializerOptions`\n      sets a `TypeInfoResolver` — file-based apps disable reflection so plain serialization\n      throws `NoMetadataForType` without one.\n\n## Common pitfalls\n\n| Pitfall | Fix |\n| --- | --- |\n| Hand-rolling a `class … : JsonNamingPolicy` for PascalCase | Delete it; set `PropertyNamingPolicy = JsonNamingPolicy.PascalCase`. |\n| Adding `[JsonPropertyName(\"Name\")]` to every member to force casing | Remove the attributes; the naming policy handles all members at once. |\n| Casting `(JsonTypeInfo\u003CT>)options.GetTypeInfo(typeof(T))` | Call the generic `options.GetTypeInfo\u003CT>()`; no cast needed. |\n| `try { options.GetTypeInfo\u003CT>(); } catch (…) { … }` to test availability | Replace with `if (options.TryGetTypeInfo\u003CT>(out var info)) { … }`. |\n| `NotSupportedException` \u002F `NoMetadataForType` from `GetTypeInfo\u003CT>()` | The options have no resolver. Set `TypeInfoResolver = new DefaultJsonTypeInfoResolver()` (reflection) or a source-generated `JsonSerializerContext` (trim\u002FAOT). |\n| `NoMetadataForType` even for a plain `Serialize` in a `dotnet run app.cs` file-based app | File-based apps disable STJ reflection. Add `TypeInfoResolver = new DefaultJsonTypeInfoResolver()`, or run it as a normal project instead. |\n| Leaving the app on the SDK's default TFM | Pin `net11.0` explicitly so the .NET 11 APIs resolve and the output shows the target. |\n| Claiming success without running | Run `dotnet run` and paste the actual JSON output; the target is a working, executed program. |\n\n## More info\n\n- [JsonNamingPolicy class](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fapi\u002Fsystem.text.json.jsonnamingpolicy) — built-in naming policies including `PascalCase`\n- [JsonSerializerOptions.GetTypeInfo](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fapi\u002Fsystem.text.json.jsonserializeroptions.gettypeinfo) — typed and non-typed metadata access\n- [JsonTypeInfo\\\u003CT\\>](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fapi\u002Fsystem.text.json.serialization.metadata.jsontypeinfo-1) — strongly-typed serialization metadata\n- [DefaultJsonTypeInfoResolver](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fapi\u002Fsystem.text.json.serialization.metadata.defaultjsontypeinforesolver) — reflection-based resolver required by `GetTypeInfo`\u002F`TryGetTypeInfo`\n- [File-based apps](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fcore\u002Fsdk\u002Ffile-based-apps) — `dotnet run app.cs` and the `#:property` directive\n",{"name":5,"risk":24,"source":25,"version":30,"category":31,"description":7,"disable-model-invocation":20},"low",{"path":26,"commit":27,"license":15,"repository":28,"imported_at":29},"plugins\u002Fdotnet11\u002Fskills\u002Fsystem-text-json-net11\u002FSKILL.md","8f3b1a2c","microsoft\u002Fskills","2026-09-20","1.0.0","cloud","main","2d1750717747097b602acf30bd09a7cbd4b4c6ea","awesome_skills\u002Fcloud\u002Fsystem-text-json-net11","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous","2026-11-09 11:45:36",{"source":8,"skillName":5,"commands":39,"prompt":49,"zipAvailable":50},[40,43,46],{"tool":41,"command":42},"npx","npx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill system-text-json-net11",{"tool":44,"command":45},"bunx","bunx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill system-text-json-net11",{"tool":47,"command":48},"pnpm","pnpm dlx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill system-text-json-net11","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fcloud\u002Fsystem-text-json-net11\u002FSKILL.md",true,[],[53,61,68,75,82,89],{"skillNo":54,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":60},"01M7FFFZPC2025JQQHPHDX154J","dei-assessment","Assess diversity, equity, and inclusion with metrics. TRIGGERS - Use when user needs help with dei-assessment related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fdei-assessment\u002FSKILL.md",[],[],"2026-11-16 10:05:34",{"skillNo":62,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":60},"01M7FFFWN8H4WA7A6Y398QKB6J","dei-action-plan","Create DEI action plans with goals and initiatives. TRIGGERS - Use when user needs help with dei-action-plan related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fdei-action-plan\u002FSKILL.md",[],[],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":60},"01M7FFFSHTM0QZRVZ2NRJTJ0PY","culture-fit-assessment","Design culture add assessment processes. TRIGGERS - Use when user needs help with culture-fit-assessment related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fculture-fit-assessment\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":60},"01M7FFFMA12RKEQA38KHJSXXPS","cowork-to-code-bridge","Use an already-installed, independently verified cowork-to-code bridge to run narrowly approved actions on the user's own macOS, Linux, or WSL2 machine through a local file queue.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcowork-to-code-bridge\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":60},"01M7FFFH1F6M8YRGW5V487GH1K","counter-offer-response","Draft counter-offer responses for retention. TRIGGERS - Use when user needs help with counter-offer-response related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcounter-offer-response\u002FSKILL.md",[],[],{"skillNo":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":60},"01M7FFFDGEHV8Y7J9N40HZXW52","continuous-feedback-system","Design continuous feedback systems. TRIGGERS - Use when user needs help with continuous-feedback-system related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcontinuous-feedback-system\u002FSKILL.md",[],[]]