C# 13

Last reviewed Oct 11, 2026

Export as PDF

Prompt Details

Prompt Composition

1prompt
  1. 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.0 to select C# 13, or set <LangVersion>13</LangVersion>. Never use latest, 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 RuntimeFrameworkVersion unset: 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, or mcr.microsoft.com/dotnet/runtime-deps:9.0 for self-contained/Native AOT) with docker build --pull, or bot-updated digests. Request SDK lines in CI (actions/setup-dotnet dotnet-version: 9.0.x), or use global-json-file for global.json pins 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-contained Environment.Version) predates .NET 9 metadata's latest-runtime. Scan built images; run dotnet sdk check on 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>