CodeQL library for C#
codeql/csharp-all 0.9.1 (changelog, source)
Search

Member predicate SwitchStmt::getStmt

Gets the ith statement in the body of this switch statement.

Example:

switch (x) {
  case "abc":              // i = 0
    return 0;
  case int i when i > 0:   // i = 1
    return 1;
  case string s:           // i = 2
    Console.WriteLine(s);
    return 2;              // i = 3
  default:                 // i = 4
    return 3;              // i = 5
}

Note that each non-default case is a labeled statement, so the statement that follows is a child of the labeled statement, and not the switch block.

Stmt getStmt(int i)