ReSharper
 
Get ReSharper
Get your hands on the new features ahead of the release by joining the Early Access Program for ReSharper 2025.1! Learn more

Code inspection: Heuristically unreachable case according to integer analysis

Last modified: 11 February 2024

This inspection reports cases of switch statements that will never be executed according to the results of integer value analysis. The inspection only works if Analyze integer arithmetic is enabled on the Code Inspection | Settings page of ReSharper options Alt+R, O.

Here is an example of annotating the method parameter with [NonNegativeValueAttribute] to refine the analysis within the method body. Knowing that the parameter is non-negative, ReSharper can report redundant cases: