C# 14

Last reviewed Oct 11, 2026

Export as PDF

Prompt Details

Prompt Composition

1prompt
  1. C# 14106 lines · 4.4K tokens

CWE Coverage

  • 20
  • 22
  • 59
  • 78
  • 89
  • 94
  • 117
  • 190
  • 208
  • 209
  • 214
  • 257
  • 295
  • 323
  • 327
  • 338
  • 362
  • 367
  • 378
  • 426
  • 502
  • 532
  • 611
  • 674
  • 759
  • 770
  • 772
  • 775
  • 798
  • 915
  • 916
  • 918
  • 1333
  • 1395

Prompt Preview

Apply these rules to C# 14, including framework adapters, generated code, serializers, interop layers, and background work. Nullable annotations, generic constraints, and static types are design controls, not substitutes for validating runtime data at each trust boundary.

Compiler and type safety

  • Set <Nullable>enable</Nullable> project-wide, and don't let file-level #nullable disable hide warnings at request, configuration, serialization, or identity boundaries.
  • Pin the warning wave with <WarningLevel>; since the .NET 7 SDK its default follows <AnalysisLevel>, which defaults to the target framework and selects both warning waves and the CA analyzer set. Fail CI on compiler and CA warnings with -warnaserror or equivalent MSBuild policy.
  • Turn on security analyzers with <AnalysisModeSecurity>All</AnalysisModeSecurity>: no Security-category CA rule warns by default in .NET 10, including CA2100, CA2300, CA2326, CA3003, CA3006, CA3075, CA5350, CA5359, and CA5394, so -warnaserror alone enforces none. A compound <AnalysisLevel> such as latest-recommended silently overrides AnalysisModeSecurity, so then set <AnalysisLevelSecurity> to that version with -all, such as 10-all or latest-all. Suppress a finding only at the reviewed call site with a written reason, never by lowering the category.
  • Avoid the null-forgiving operator on request, configuration, lookup, deserialization, and authentication results.
  • Model validated identifiers, paths, URLs, and security states as distinct types, not interchangeable strings, and match closed security