Description
UseGuard.NotZero() instead of verbose zero-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.NotZero() instead of verbose if (x == 0) throw patterns
Guard.NotZero() instead of verbose zero-check and throw patterns.
public void Divide(int divisor)
{
if (divisor == 0)
throw new ArgumentException("Cannot be zero", nameof(divisor));
}
public void Divide(int divisor)
{
Guard.NotZero(divisor);
}
dotnet_diagnostic.AL0047.severity = warning
Was this page helpful?
