Install any skill in seconds. Free to start, no credit card required.
Get Started Free →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
Use this skill ↓26% 48%+22 ptsof test cases passed
Passed 11 of 23 test cases with the skill, and 6 of 23 without it.
I want to call `JsonSerializer.Serialize` in .NET 11 by passing a strongly typed `JsonTypeInfo<Product>` metadata instance directly instead of passing `JsonSerializerOptions`. Show how to obtain `JsonTypeInfo<Product>` from options and pass it into `JsonSerializer.Serialize`.
The code obtains type metadata using options.GetTypeInfo<Product>().
3 of 3 safety checks passed
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.
| API | Replaces 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 |
net11.0 validation possibleThese APIs only exist in the .NET 11 base class library. Before writing code:
dotnet --list-sdks and confirm an SDK that can target net11.0 is present — an
11.x SDK, or a later SDK with the net11.0 targeting pack.dotnet-install script to install the current .NET 11 SDK into a
temporary or project-local directory. Prefer the GA channel build. Use a preview only
when GA is not yet available or the user explicitly requested a preview. Do not require
administrator access, change the machine-wide PATH, or replace an installed SDK.dotnet executable. If download or execution is blocked,
still provide the complete net11.0 program and report that it was not run. Never
substitute net10.0, a custom naming policy, or a different API and present that as
validation of the .NET 11 feature.Use the channel, not a guessed version. Try the GA channel first:
$installScript = Join-Path $env:TEMP "dotnet-install-$([guid]::NewGuid()).ps1"
try {
Invoke-WebRequest -Uri 'https://dot.net/v1/dotnet-install.ps1' -OutFile $installScript
& $installScript -Channel 11.0 -InstallDir .\.dotnet
& .\.dotnet\dotnet.exe run --project <PATH_TO_NET11_PROJECT>
}
finally {
Remove-Item -LiteralPath $installScript -Force -ErrorAction SilentlyContinue
Skills that do similar work, with their benchmark result.
Next to this one in the catalogue, plus more from the same author.