CA1512 - Auto fix suggestions introduce breaking edge case
- Dominant language
- C#
- Stars
- 3.2k
- Forks
- 1.3k
- PR merge metrics
- PR metrics pending
Description
**Version Used**: dotnet 10
**Steps to Reproduce**:
1. have code that uses ArgumentOutOfRangeException in a decimal less than zero check.
2. Use the auto fix IDE suggestions that convert it to ArgumentOutOfRangeException.ThrowIfNegative
3. Scenarios that have negative zero now throw the exception that were not thrown before
A minimal repro, with source-code provided, is ideal. Most compiler/language issues can be distilled into a snippet that can be pasted into [.NET Lab](https://lab.razor.fyi/#csharp).
https://lab.razor.fyi/#fZFNTgJBEIWDwUR7ZTxBLWHBDJi4QhYEjcGoGGXlyrKnZug4XY3dPfzEcAIv4FlceAhP4gFcmOE_GOhd1_vq1auUeN8X4s6axKIOpDv-LWZOcQIPY-dJ18X6L2iZNCXplWEXXBKTVXIH0dY68_ic0gZzrjBh47ySbrsStExETcZ07NQmdq34daPU7VnCSHGyrR500b24uhAyRedgvrF4EwAAzqNXEgZGRXCDikvlaXkm5i8iqTSmwJkmi95YaEC1_k-OiI1WPAcqtWpdLJkBWrDkstRDY-UTrrWs_MIQIkMO2HjwPWuGgAxkrbFLRMWludsZVMtzimkITZtkmth3Mt-J75ETuhhJ6ucnKTFqMovGcnktXRiC7xFY6qcoKe8HaSKC2FhoNWuntROogO-pPNNwNs1NQy28l0475ufXMMN2fEsJejWgRZDZ4hMxEVd70j0eHnz_fHx-JUfFp8Ko8Ac
**Diagnostic Id**: CA1512: Use ArgumentOutOfRangeException throw helper
**Expected Behavior**:
Replace < 0 checks with ArgumentOutOfRangeException.ThrowIfLessThan(arg, 0);
**Actual Behavior**:
replaces <0 checks on decimals with ArgumentOutOfRangeException.ThrowIfNegative(arg)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.