You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enable the following .NET code-quality analyzers, which modernize argument/state guard
clauses to the concise ThrowIf* helpers introduced in .NET 8:
CA1510 —
Use ArgumentNullException.ThrowIfNull instead of if (x is null) throw new ArgumentNullException(...).
CA1511 —
Use ArgumentException.ThrowIfNullOrEmpty instead of if (string.IsNullOrEmpty(x)) throw new ArgumentException(...).
CA1512 —
Use ArgumentOutOfRangeException.ThrowIf* (e.g. ThrowIfNegative, ThrowIfGreaterThan) instead of if (x < 0) throw new ArgumentOutOfRangeException(...).
CA1513 —
Use ObjectDisposedException.ThrowIf instead of if (disposed) throw new ObjectDisposedException(...).
Enabling them only requires setting their severity in .editorconfig:
# CA1510: Use ArgumentNullException.ThrowIfNulldotnet_diagnostic.CA1510.severity = error
# CA1511: Use ArgumentException.ThrowIfNullOrEmptydotnet_diagnostic.CA1511.severity = error
# CA1512: Use ArgumentOutOfRangeException.ThrowIf*dotnet_diagnostic.CA1512.severity = error
# CA1513: Use ObjectDisposedException.ThrowIfdotnet_diagnostic.CA1513.severity = error
Checklist
Add the four dotnet_diagnostic.CA151{0,1,2,3}.severity = error entries to .editorconfig.
Replace existing guard clauses with the corresponding ThrowIf* helpers.
Activity