C# 13
Last reviewed Oct 11, 2026
Prompt Details
Prompt Composition
1prompt
- C# 13112 lines · 4.2K tokens
CWE Coverage
- 20
- 22
- 59
- 78
- 79
- 89
- 94
- 117
- 190
- 208
- 209
- 214
- 257
- 295
- 323
- 327
- 328
- 338
- 362
- 367
- 426
- 502
- 532
- 611
- 636
- 639
- 759
- 770
- 772
- 798
- 829
- 862
- 915
- 916
- 918
- 922
- 1333
- 1395
Prompt Preview
Apply these rules to C# 13 on .NET 9 before framework prompts.
Versions and builds
- Target
net9.0to select C# 13, or set<LangVersion>13</LangVersion>. Never uselatest,latestMajor,preview, or force C# 13 onto older frameworks. - Run/redeploy every newest .NET 9 runtime/SDK servicing release: Microsoft patches on Patch Tuesdays and supports only each release's latest patch. Framework-dependent apps adopt installed patches on restart; self-contained, Native AOT, and container builds require rebuild, republish, redeploy. Leave
RuntimeFrameworkVersionunset: self-contained publishing otherwise uses exactly that runtime instead of the SDK's newest known patch. Migrate before support ends November 10, 2026. - Rebuild line-following images (
mcr.microsoft.com/dotnet/aspnet:9.0, ormcr.microsoft.com/dotnet/runtime-deps:9.0for self-contained/Native AOT) withdocker build --pull, or bot-updated digests. Request SDK lines in CI (actions/setup-dotnetdotnet-version: 9.0.x), or useglobal-json-fileforglobal.jsonpins copied from .NET release notes. Use build-failing placeholders for unverifiable exact versions. - Check runtimes separately from NuGet audit. In CI, fail when the built image's runtime (
dotnet --list-runtimes, or self-containedEnvironment.Version) predates .NET 9 metadata'slatest-runtime. Scan built images; rundotnet sdk checkon builders. It compares SDKs only within feature bands; if an advisory has no fix in your band, move to a listed fixed band. - Enable
<Nullable>enable</Nullable>,<WarningLevel>9</WarningLevel>