diff --git a/Src/CSharpier.Tests/CSharpier.Tests.csproj b/Src/CSharpier.Tests/CSharpier.Tests.csproj
index 21867ef58..f73a005bb 100644
--- a/Src/CSharpier.Tests/CSharpier.Tests.csproj
+++ b/Src/CSharpier.Tests/CSharpier.Tests.csproj
@@ -5,19 +5,19 @@
true
-
-
-
-
-
+
+
+
+
+
-
-
-
+
+
+
-
+
diff --git a/Src/CSharpier.Tests/FormattingTests/TestFiles/QueryExpressions.cst b/Src/CSharpier.Tests/FormattingTests/TestFiles/QueryExpressions.cst
index 8e3ffee83..5c66b6d3d 100644
--- a/Src/CSharpier.Tests/FormattingTests/TestFiles/QueryExpressions.cst
+++ b/Src/CSharpier.Tests/FormattingTests/TestFiles/QueryExpressions.cst
@@ -73,6 +73,21 @@ class ClassName
CustCount____________________________ = g.Count()
};
+ var complexQuerySupportsNewLines =
+ from c in customers
+
+ let d = c
+
+ where d != null
+
+ join c1 in customers1 on c1 equals c
+
+ group c by c.Country into g
+
+ orderby g.Count() ascending
+
+ select new { Country = g.Key, CustCount = g.Count() };
+
var asyncQuery = await
from c in customers
from u in users
diff --git a/Src/CSharpier.Tests/FormattingTests/TestFiles/QueryExpressions_RemoveSpaces.cst b/Src/CSharpier.Tests/FormattingTests/TestFiles/QueryExpressions_RemoveSpaces.cst
new file mode 100644
index 000000000..fae4cf9d1
--- /dev/null
+++ b/Src/CSharpier.Tests/FormattingTests/TestFiles/QueryExpressions_RemoveSpaces.cst
@@ -0,0 +1,20 @@
+var complexQuerySupportsNewLines =
+ from c in customers
+
+
+ let d = c
+
+
+ where d != null
+
+
+ join c1 in customers1 on c1 equals c
+
+
+ group c by c.Country into g
+
+
+ orderby g.Count() ascending
+
+
+ select new { Country = g.Key, CustCount = g.Count() };
diff --git a/Src/CSharpier.Tests/FormattingTests/TestFiles/QueryExpressions_RemoveSpaces.expected.cst b/Src/CSharpier.Tests/FormattingTests/TestFiles/QueryExpressions_RemoveSpaces.expected.cst
new file mode 100644
index 000000000..99f5bfd76
--- /dev/null
+++ b/Src/CSharpier.Tests/FormattingTests/TestFiles/QueryExpressions_RemoveSpaces.expected.cst
@@ -0,0 +1,14 @@
+var complexQuerySupportsNewLines =
+ from c in customers
+
+ let d = c
+
+ where d != null
+
+ join c1 in customers1 on c1 equals c
+
+ group c by c.Country into g
+
+ orderby g.Count() ascending
+
+ select new { Country = g.Key, CustCount = g.Count() };
diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/GroupClause.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/GroupClause.cs
index 415f5fdf3..939e5f0dd 100644
--- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/GroupClause.cs
+++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/GroupClause.cs
@@ -5,6 +5,7 @@ internal static class GroupClause
public static Doc Print(GroupClauseSyntax node, FormattingContext context)
{
return Doc.Concat(
+ ExtraNewLines.Print(node),
Token.PrintWithSuffix(node.GroupKeyword, " ", context),
Node.Print(node.GroupExpression, context),
" ",
diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/JoinClause.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/JoinClause.cs
index b6502e371..8774cc072 100644
--- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/JoinClause.cs
+++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/JoinClause.cs
@@ -4,26 +4,29 @@ internal static class JoinClause
{
public static Doc Print(JoinClauseSyntax node, FormattingContext context)
{
- return Doc.Group(
- Token.PrintWithSuffix(node.JoinKeyword, " ", context),
- node.Type != null ? Doc.Concat(Node.Print(node.Type, context), " ") : Doc.Null,
- Token.PrintWithSuffix(node.Identifier, " ", context),
- Token.PrintWithSuffix(node.InKeyword, " ", context),
- Node.Print(node.InExpression, context),
- Doc.Indent(
- Doc.Line,
- Token.PrintWithSuffix(node.OnKeyword, " ", context),
- Node.Print(node.LeftExpression, context),
- " ",
- Token.PrintWithSuffix(node.EqualsKeyword, " ", context),
- Node.Print(node.RightExpression, context),
- node.Into != null
- ? Doc.Concat(
- Doc.Line,
- Token.PrintWithSuffix(node.Into.IntoKeyword, " ", context),
- Token.Print(node.Into.Identifier, context)
- )
- : Doc.Null
+ return Doc.Concat(
+ ExtraNewLines.Print(node),
+ Doc.Group(
+ Token.PrintWithSuffix(node.JoinKeyword, " ", context),
+ node.Type != null ? Doc.Concat(Node.Print(node.Type, context), " ") : Doc.Null,
+ Token.PrintWithSuffix(node.Identifier, " ", context),
+ Token.PrintWithSuffix(node.InKeyword, " ", context),
+ Node.Print(node.InExpression, context),
+ Doc.Indent(
+ Doc.Line,
+ Token.PrintWithSuffix(node.OnKeyword, " ", context),
+ Node.Print(node.LeftExpression, context),
+ " ",
+ Token.PrintWithSuffix(node.EqualsKeyword, " ", context),
+ Node.Print(node.RightExpression, context),
+ node.Into != null
+ ? Doc.Concat(
+ Doc.Line,
+ Token.PrintWithSuffix(node.Into.IntoKeyword, " ", context),
+ Token.Print(node.Into.Identifier, context)
+ )
+ : Doc.Null
+ )
)
);
}
diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/LetClause.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/LetClause.cs
index 32e623db9..d45bb7107 100644
--- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/LetClause.cs
+++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/LetClause.cs
@@ -5,6 +5,7 @@ internal static class LetClause
public static Doc Print(LetClauseSyntax node, FormattingContext context)
{
return Doc.Concat(
+ ExtraNewLines.Print(node),
Token.PrintWithSuffix(node.LetKeyword, " ", context),
Token.PrintWithSuffix(node.Identifier, " ", context),
Token.PrintWithSuffix(node.EqualsToken, " ", context),
diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/OrderByClause.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/OrderByClause.cs
index f2805695b..2f506a8cf 100644
--- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/OrderByClause.cs
+++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/OrderByClause.cs
@@ -5,6 +5,7 @@ internal static class OrderByClause
public static Doc Print(OrderByClauseSyntax node, FormattingContext context)
{
return Doc.Concat(
+ ExtraNewLines.Print(node),
Token.Print(node.OrderByKeyword, context),
SeparatedSyntaxList.Print(
node.Orderings,
diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SelectClause.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SelectClause.cs
index fb42c6f57..6df48a02d 100644
--- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SelectClause.cs
+++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SelectClause.cs
@@ -5,6 +5,7 @@ internal static class SelectClause
public static Doc Print(SelectClauseSyntax node, FormattingContext context)
{
return Doc.Concat(
+ ExtraNewLines.Print(node),
Token.PrintWithSuffix(node.SelectKeyword, " ", context),
Node.Print(node.Expression, context)
);
diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/WhereClause.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/WhereClause.cs
index f79dff199..33b2f522a 100644
--- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/WhereClause.cs
+++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/WhereClause.cs
@@ -4,9 +4,12 @@ internal static class WhereClause
{
public static Doc Print(WhereClauseSyntax node, FormattingContext context)
{
- return Doc.Group(
- Token.Print(node.WhereKeyword, context),
- Doc.Indent(Doc.Line, Node.Print(node.Condition, context))
+ return Doc.Concat(
+ ExtraNewLines.Print(node),
+ Doc.Group(
+ Token.Print(node.WhereKeyword, context),
+ Doc.Indent(Doc.Line, Node.Print(node.Condition, context))
+ )
);
}
}