Description
UseGuard.NotNegative() instead of verbose negative-check and throw patterns.
Bad Code
Good Code
Properties
- Category: Roslyn Utilities
- Severity: Warning
- Enabled by default: True
- Code fix available: True
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Use Guard.NotNegative() instead of verbose if (x < 0) throw patterns
Guard.NotNegative() instead of verbose negative-check and throw patterns.
public void SetCount(int count)
{
if (count < 0)
throw new ArgumentOutOfRangeException(nameof(count));
}
public void SetCount(int count)
{
Guard.NotNegative(count);
}
dotnet_diagnostic.AL0048.severity = warning
Was this page helpful?
