/// <summary> /// Returns the single statement in a block if it has no nested statements. /// If it has nested statements, and the surrounding block was removed, it could be ambiguous, /// e.g. if (...) { if (...) return null; } else return ""; /// Unbundling the middle if statement would bind the else to it, rather than the outer if statement /// </summary> public static StatementSyntax UnpackNonNestedBlock(this BlockSyntax block) { return(block.Statements.Count == 1 && !block.ContainsNestedStatements() ? block.Statements[0] : block); }