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

Member predicate SwitchStmt::getCase

Gets the ith case 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;
  default:                 // i = 3
    return 3;
}

Note that this reorders the default case to always be at the end.

CaseStmt getCase(int i)