CodeQL queries 1.23

Skip to end of metadata
Go to start of metadata

Finds conditional expressions of the form '... ? ... : ...' where the types of the resulting expressions differ.

import csharp

from ConditionalExpr e
where
  e.getThen().stripImplicitCasts() != e.getElse().stripImplicitCasts() and
  not e.getThen().getType() instanceof NullType and
  not e.getElse().getType() instanceof NullType
select e