JetBrains Rider 2026.1 Help

Code inspection: Possible violation of 'ValueRange'/'NonNegativeValue' attribute

This insepction reports an integer value that may violate a [ValueRange] or [NonNegativeValue] contract. JetBrains Rider tracks integer value ranges through control flow analysis and warns when an assignment or argument is outside the allowed interval.

The fix is to change the value or the surrounding logic so the assigned value stays within the declared range.

Example

using JetBrains.Annotations; class C { [NonNegativeValue] public int Bar { get; set; } public void M() { Bar = -1; } }
using JetBrains.Annotations; class C { [NonNegativeValue] public int Bar { get; set; } public void M() { Bar = 0; } }
30 March 2026