[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7D0QNWPN05AZ1MYR7SH78WA":3,"skill-same:01M7D0QNWPN05AZ1MYR7SH78WA":45},{"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":25,"commitSha":26,"skillDirectory":27,"forksCount":14,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":30,"install":31,"resources":44},"01M7D0QNWPN05AZ1MYR7SH78WA","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>? info)` metadata accessors. USE ONLY when the user is targeting net11.0 or later and needs PascalCase JSON property or dictionary-key names without writing a custom naming policy, a strongly-typed `JsonTypeInfo\u003CT>` instead of the non-generic `JsonTypeInfo`, or a no-throw way to probe whether a type's serialization metadata is resolved. DO NOT USE when the target is earlier than net11.0, the requested behavior uses an established pre-net11 naming policy, or the user explicitly selected another JSON library.","itsmejay18\u002FAI-Skills-for-My-Development-Stack","itsmejay18","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F167779943?v=4","01M7CZRFC6DDZA5V2CX8WDSZED","Jay Jemino Ababon ","01M7CZRFCVRNW1SFHSQXEJ3CQN",0,"MIT","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F02-CSharp-WPF-Desktop-Development\u002Fsystem-text-json-net11\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: system-text-json-net11\ndescription: >\n  Imperative guidance for the System.Text.Json APIs added in .NET 11: the built-in\n  `JsonNamingPolicy.PascalCase` naming policy, and the strongly-typed\n  `JsonSerializerOptions.GetTypeInfo\u003CT>()` and\n  `JsonSerializerOptions.TryGetTypeInfo\u003CT>(out JsonTypeInfo\u003CT>? info)`\n  metadata accessors.\n  USE ONLY when the user is targeting net11.0 or later and needs\n  PascalCase JSON property or dictionary-key names without writing a custom naming policy, a strongly-typed\n  `JsonTypeInfo\u003CT>` instead of the non-generic `JsonTypeInfo`, or a no-throw way to probe\n  whether a type's serialization metadata is resolved.\n  DO NOT USE when the target is earlier than net11.0, the requested behavior uses an\n  established pre-net11 naming policy, or the user explicitly selected another JSON library.\nlicense: MIT\n---\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,"license":15,"description":24},"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>? info)` metadata accessors. USE ONLY when the user is targeting net11.0 or later and needs PascalCase JSON property or dictionary-key names without writing a custom naming policy, a strongly-typed `JsonTypeInfo\u003CT>` instead of the non-generic `JsonTypeInfo`, or a no-throw way to probe whether a type's serialization metadata is resolved. DO NOT USE when the target is earlier than net11.0, the requested behavior uses an established pre-net11 naming policy, or the user explicitly selected another JSON library.\n","main","30954af1dcd1a74b63f05deb2e2c41e5ecae4a82","02-CSharp-WPF-Desktop-Development\u002Fsystem-text-json-net11","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack","https:\u002F\u002Fgithub.com\u002Fitsmejay18","2026-09-18 16:06:36",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add itsmejay18\u002FAI-Skills-for-My-Development-Stack --skill system-text-json-net11",{"tool":37,"command":38},"bunx","bunx skills add itsmejay18\u002FAI-Skills-for-My-Development-Stack --skill system-text-json-net11",{"tool":40,"command":41},"pnpm","pnpm dlx skills add itsmejay18\u002FAI-Skills-for-My-Development-Stack --skill system-text-json-net11","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F02-CSharp-WPF-Desktop-Development\u002Fsystem-text-json-net11\u002FSKILL.md",true,[],[46,53,60,67,74,81],{"skillNo":47,"name":48,"nameZh":6,"description":49,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":50,"categories":51,"keywords":52,"publishedAt":19},"01M7D2RKBHPZ3E1RNN5DWHT550","vectorization","Design, implement, optimize, and review SIMD code in .NET. USE FOR: vectorizing scalar loops with TensorPrimitives, Vector64\u002F128\u002F256\u002F512, or platform hardware intrinsics; reviewing existing SIMD code, including Vector\u003CT>, for contract equivalence, tail handling, memory safety, portability, fallbacks, and measured performance. DO NOT USE FOR: performance work unrelated to SIMD or vectorization.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Fvectorization\u002FSKILL.md",[],[],{"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":19},"01M7D2RDJ7RN3QK8GJR0QTER1D","resolve-project-references","Guide for interpreting ResolveProjectReferences time in MSBuild performance summaries. Activate when ResolveProjectReferences appears as the most expensive target and developers are trying to optimize it directly. Explains that the reported time includes wait time for dependent project builds and is misleading. Guides users to focus on task self-time instead. Do not activate for general build performance -- use build-perf-diagnostics instead.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Fresolve-project-references\u002FSKILL.md",[],[],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":19},"01M7D2R1H2GTNZYHG9YRX3JDQW","optimizing-ef-core-queries","Optimize and improve the performance of slow Entity Framework Core (EF Core) queries: make them generate less SQL, make fewer database round-trips, and return results faster. Use whenever an EF Core or DbContext query or data-access path is slow or should be made faster — whether or not EF Core owns the database schema. For EF Core, not Dapper or raw ADO.NET.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Foptimizing-ef-core-queries\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":19},"01M7D2QREG04W1YT0NEBHEW5C9","microbenchmarking","Activate this skill when BenchmarkDotNet (BDN) is involved in the task — creating, running, configuring, or reviewing BDN benchmarks. Also activate when microbenchmarking .NET code would be useful and BenchmarkDotNet is the likely tool. Consider activating when answering a .NET performance question requires measurement and BenchmarkDotNet may be needed. Covers microbenchmark design, BDN configuration and project setup, how to run BDN microbenchmarks efficiently and effectively, and using BDN for side-by-side performance comparisons. Do NOT use for profiling\u002Ftracing .NET code (dotnet-trace, PerfView), production telemetry, or load\u002Fstress testing (Crank, k6).","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Fmicrobenchmarking\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":19},"01M7D2QGE175XWPZVACVH2868Z","incremental-build","Guide for optimizing MSBuild incremental builds. USE FOR: builds slower than expected on subsequent runs, 'nothing changed but it rebuilds anyway', diagnosing why targets re-execute unnecessarily, fixing broken no-op builds. Covers 8 common causes: missing Inputs\u002FOutputs on custom targets, volatile properties in output paths (timestamps\u002FGUIDs), file writes outside tracked Outputs, missing FileWrites registration, glob changes, Visual Studio Fast Up-to-Date Check (FUTDC) issues. Key diagnostic: look for 'Building target completely' vs 'Skipping target' in binlog. DO NOT USE FOR: first-time build slowness (use build-perf-baseline), parallelism issues (use build-parallelism), evaluation-phase slowness (use eval-performance), non-MSBuild build systems.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Fincremental-build\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":19},"01M7D2Q1DQTC6K49R73WQTTPSB","eval-performance","Guide for diagnosing and improving MSBuild project evaluation performance. USE FOR: builds slow before any compilation starts, high evaluation time in binlog analysis, expensive glob patterns walking large directories (node_modules, .git, bin\u002Fobj), deep import chains (>20 levels), preprocessed output >10K lines indicating heavy evaluation, property functions with file I\u002FO ($([System.IO.File]::ReadAllText(...))), multiple evaluations per project. Covers the 5 MSBuild evaluation phases, glob optimization via DefaultItemExcludes, import chain analysis with \u002Fpp preprocessing. DO NOT USE FOR: compilation-time slowness (use build-perf-diagnostics), incremental build issues (use incremental-build), non-MSBuild build systems.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Feval-performance\u002FSKILL.md",[],[]]