| Property | Value |
|---|---|
| Severity | Warning |
| Category | Roslyn Utilities |
| Code fix | No |
| Analyzer | Al1220UseGuardForThrowIfAnalyzer |
| Enabled by default | Yes |
The BCL throw helpers on ArgumentNullException, ArgumentException, and ArgumentOutOfRangeException — and the Microsoft.Shared.Diagnostics.Throw.If* helpers from Microsoft Agent Framework — only throw; they don't return the validated value, so they can't be used in expressions, member initialisers, or chained validation. The Guard.* helpers from ANcpLua.Roslyn.Utilities return the validated value, share the same [CallerArgumentExpression] parameter-name machinery, and compose. Covers BCL ThrowIfNull / NullOrEmpty / NullOrWhiteSpace and the seven ArgumentOutOfRangeException.ThrowIf* helpers, plus MAF Throw.IfNull / IfNullOrMemberNull / IfNullOrEmpty / IfNullOrWhitespace / IfZero / IfLessThan / IfGreaterThan / IfLessThanOrEqual / IfGreaterThanOrEqual / IfOutOfRange. Cold-path-only Throw.ArgumentNullException / ArgumentOutOfRangeException / ArgumentException / InvalidOperationException are intentionally out of scope — they don't validate, just throw. Banned in qyl-aligned projects via BannedSymbols.txt; this analyzer carries the matching auto-fix.