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

Analysis of integer values (integral arithmetic)

Last modified: 30 September 2024

JetBrains Rider 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: JetBrains Rider 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.