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: Suspicious type conversion or check

Last modified: 29 May 2024

This inspection reports type checks that never succeed because there are no inheritance or implementation relationships between the type of the object and the type it is tested against.

Unlike the compiler warning CS0184, which only detects situations where the object type is not directly derived from the tested type, this inspection detects a wider range of suspicious checks, taking into account all possible inheritance chains in your solution.

Heere is an example that illustrates the issue in a simple case: