CodeQL queries 1.25
Skip to end of metadata
Go to start of metadata

Finds switch statements with a missing enum constant case and no default case.

import csharp

from SwitchStmt switch, Enum enum, EnumConstant missing
where
  switch.getCondition().getType() = enum and
  missing.getDeclaringType() = enum and
  not switch.getAConstCase().getExpr() = missing.getAnAccess() and
  not exists(switch.getDefaultCase())
select switch