Analysis of integer values (integral arithmetic)

Last modified: 30 September 2024

ReSharper can track the flow of integer values through your code and report redundant or possibly erroneous statements. It supports all C# integral numeric typesint, uint, byte, sbyte, short, ushort, long, and ulong — and warns you about the following issues:

  • relational/equality operators that always evaluate to true or false,

  • unreachable switch cases checking int values,

  • meaningless arithmetic operations, such as multiplication by 1 or addition of 0 (except literals or constants: ReSharper assumes that expressions like x + 0 are intentional),

  • possible int overflows,

  • possible division by 0,

  • possible errors in invocations of System.Math methods,

  • the above issues in enumeration types with the corresponding underlying types.