JetBrains Rider 2024.3 Help

Code inspection: Suspicious type conversion or check

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:

interface IPage{} class Post{} class Test { void Test(object page) { // No type in solution is inherited from both IPage and Post if (page is IPage and Post) Console.WriteLine("Valid page"); } }
Last modified: 29 May 2024