static bool IsInSwitchContext(AstNode node) { var n = node; while (n != null && !(n is EntityDeclaration)) { if (n is SwitchStatement) { return true; } if (n is BlockStatement) { return false; } n = n.Parent; } return false; }