diff --git a/Src/CSharpier.Tests/FormattingTests/TestFiles/TryStatements.cst b/Src/CSharpier.Tests/FormattingTests/TestFiles/TryStatements.cst index cf3507c3e..ea1c257b6 100644 --- a/Src/CSharpier.Tests/FormattingTests/TestFiles/TryStatements.cst +++ b/Src/CSharpier.Tests/FormattingTests/TestFiles/TryStatements.cst @@ -22,6 +22,9 @@ class ClassName try { } catch { } + try { } + finally { } + try { throw null; @@ -52,5 +55,14 @@ class ClassName { return; } + + try + { + //something + } + finally + { + // do something + } } } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TryStatement.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TryStatement.cs index e2f540a16..f9055dfe7 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TryStatement.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TryStatement.cs @@ -17,7 +17,7 @@ public static Doc Print(TryStatementSyntax node) AttributeLists.Print(node, node.AttributeLists), Token.Print(node.TryKeyword), Block.Print(node.Block), - Doc.HardLine, + node.Catches.Any() ? Doc.HardLine : Doc.Null, Doc.Join(Doc.HardLine, node.Catches.Select(CatchClause.Print)) }; if (node.Finally != null)