System.Text.Json 10.0

Last reviewed Sep 6, 2026

Export as PDF

Prompt Details

Prompt Composition

2prompts
  1. C# 14106 lines · 4.4K tokens
  2. System.Text.Json 10.057 lines · 1.8K tokens
Total163 lines · 6.1K tokens

CWE Coverage

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

Prompt Preview

Apply the C# 14 baseline first. These rules cover System.Text.Json 10.0 contracts, input models, polymorphism, converters, naming, numeric handling, depth, DOM use, source generation, output, and diagnostics.

Strict input contracts

  • Set JsonSerializerOptions.AllowDuplicateProperties=false at untrusted boundaries; its default is true, and divergent first-value versus last-value consumers can turn duplicate names into validation or signature bypasses.
  • Set UnmappedMemberHandling=JsonUnmappedMemberHandling.Disallow or apply [JsonUnmappedMemberHandling(JsonUnmappedMemberHandling.Disallow)] where extra fields must fail; the default Skip silently ignores them.
  • Review every [JsonExtensionData] property because it intentionally captures otherwise unmapped fields and can reintroduce overposting or ambiguous round trips.
  • Deserialize into narrow request DTOs and keep tenant, owner, role, status, price, discriminator, and audit fields out of writable contracts.
  • Mark required members with required or [JsonRequired], then perform semantic validation; presence does not make null, empty, out-of-range, or unauthorized values valid.

Constructor and naming behavior

  • Set RespectRequiredConstructorParameters=true when non-optional constructor parameters must be present; it is false by default unless the application enables the corresponding feature switch or selects JsonSerializerDefaults.Strict.
  • If enabling RespectNullableAnnotations, remember it checks only supported non-generic member annotations, not root values, generic collection elements, or