AL0003: Don't divide by constant zero
Integers and Decimal should never be divided by the constant 0 as this causes a DivideByZeroException at runtime.
When it triggers
// Error: Division by constant zero will throw DivideByZeroException
int result = x / 0; // AL0003
decimal d = amount / 0; // AL0003
int mod = x % 0; // AL0003
Why this matters
Division by zero with integers or decimals throws DivideByZeroException at runtime. This is always a bug when the divisor is a constant zero.
Note: Floating-point division by zero does not throw; it produces infinity or NaN.
How to fix
Remove the dead code or fix the logic:
int result = x / divisor; // Use a variable that can be validated
if (divisor != 0)
result = x / divisor;
Configuration
[*.cs]
dotnet_diagnostic.AL0003.severity = error