Skip to content

Latest commit

 

History

History
26 lines (15 loc) · 1.07 KB

File metadata and controls

26 lines (15 loc) · 1.07 KB

CL006 — Unbound options class

  • Severity: Error
  • Confidence: follows the resolution of the binding site

What it finds

An options class registered via services.Configure<T>(configuration.GetSection("…")) (or bound via Bind/Get<T>) whose section does not exist in any configuration source.

Why it matters

Binding to a missing section does not throw — it silently produces an options instance with default values. The failure surfaces wherever a default 0, null or false finally breaks something.

Semantics

A section "exists" when any configuration source (base or any environment file) contains the section key itself or any key beneath it. A section that exists only in one environment is not CL006 — cross-environment gaps are CL002 territory. If no configuration was scanned at all, the rule is silent.

Example

services.Configure<AuditOptions>(config.GetSection("Audit")); // CL006 if no source has an Audit section

How to fix

Add the section to the configuration, or fix the section name in the registration.