diff --git a/Src/CSharpier.Tests/FormattingTests/TestFiles/cs/MemberChain_PropertiesConsistent.test b/Src/CSharpier.Tests/FormattingTests/TestFiles/cs/MemberChain_PropertiesConsistent.test index 9811a5ed0..22452adda 100644 --- a/Src/CSharpier.Tests/FormattingTests/TestFiles/cs/MemberChain_PropertiesConsistent.test +++ b/Src/CSharpier.Tests/FormattingTests/TestFiles/cs/MemberChain_PropertiesConsistent.test @@ -1,5 +1,8 @@ -var someVariable = someObject.Property.CallMethod( - someValue => someValue.SomeProperty == someOtherValue___________________________ +var someVariable = + someObject____________.Property_______________.CallMethod______________________(); + +var someVariable = someObject.Property.CallMethod(someValue => + someValue.SomeProperty == someOtherValue___________________________ ); var someVariable = someObject @@ -7,8 +10,8 @@ var someVariable = someObject .CallMethod(someValue => someValue.SomeProperty == someOtherValue___________________________); var someVariable = someObject - .Property.CallMethod( - someValue => someValue.SomeProperty == someOtherValue___________________________ + .Property.CallMethod(someValue => + someValue.SomeProperty == someOtherValue___________________________ ) .CallMethod(); @@ -25,8 +28,8 @@ var someVariable = this.Property.CallMethod(someValue => var someVariable = this.Property() .CallMethod(someValue => someValue.SomeProperty == someOtherValue___________________________); -var someVariable = this.Property.CallMethod( - someValue => someValue.SomeProperty == someOtherValue___________________________ +var someVariable = this.Property.CallMethod(someValue => + someValue.SomeProperty == someOtherValue___________________________ ) .CallMethod(); diff --git a/Src/CSharpier.Tests/FormattingTests/TestFiles/cs/MemberChains.test b/Src/CSharpier.Tests/FormattingTests/TestFiles/cs/MemberChains.test index f5e326105..86d8d5412 100644 --- a/Src/CSharpier.Tests/FormattingTests/TestFiles/cs/MemberChains.test +++ b/Src/CSharpier.Tests/FormattingTests/TestFiles/cs/MemberChains.test @@ -242,5 +242,8 @@ class ClassName someThing_______________________ .Property!.CallMethod__________________() .CallMethod__________________(); + + IEnumerable valueProviderFactories = + new ModelBinderAttribute_______().GetValueProviderFactories(config); } } diff --git a/Src/CSharpier.Tests/FormattingTests/TestFiles/cs/SimpleLambdaExpressions.test b/Src/CSharpier.Tests/FormattingTests/TestFiles/cs/SimpleLambdaExpressions.test index 8abb07f9c..57bd8bbc9 100644 --- a/Src/CSharpier.Tests/FormattingTests/TestFiles/cs/SimpleLambdaExpressions.test +++ b/Src/CSharpier.Tests/FormattingTests/TestFiles/cs/SimpleLambdaExpressions.test @@ -114,10 +114,11 @@ public class ClassName || t.OtherLongColumn________________________________ ); - this.Select_________________________________________( - superLongName________________________________ => true + Select______________________________________(superLongName_________________________ => + true ); - this.Select_________________________________________(selector: static longName________ => + + this.Select_________________________________(selector: static longName_____________ => true ); @@ -149,5 +150,12 @@ public class ClassName return someOtherLongName__________________; } ); + + this.Where______________________________________( + selector: static longName_________________ => + { + return Method(x => x.Prop); + } + ); } } diff --git a/Src/CSharpier/SyntaxPrinter/ArgumentListLikeSyntax.cs b/Src/CSharpier/SyntaxPrinter/ArgumentListLikeSyntax.cs index c6f0bac79..6bdea9420 100644 --- a/Src/CSharpier/SyntaxPrinter/ArgumentListLikeSyntax.cs +++ b/Src/CSharpier/SyntaxPrinter/ArgumentListLikeSyntax.cs @@ -9,47 +9,37 @@ public static Doc Print( FormattingContext context ) { - var docs = new List { Token.Print(openParenToken, context) }; + var lambdaId = Guid.NewGuid(); - switch (arguments) + var args = arguments switch { - case [{ Expression: SimpleLambdaExpressionSyntax lambda } arg]: - { - docs.Add( + [{ Expression: SimpleLambdaExpressionSyntax lambda } arg] + => Doc.Concat( Doc.GroupWithId( - "LambdaArguments", + $"LambdaArguments{lambdaId}", Doc.Indent( Doc.SoftLine, Argument.PrintModifiers(arg, context), SimpleLambdaExpression.PrintHead(lambda, context) ) ), - Doc.IndentIfBreak( + Doc.IfBreak( + Doc.Indent(Doc.Group(SimpleLambdaExpression.PrintBody(lambda, context))), SimpleLambdaExpression.PrintBody(lambda, context), - "LambdaArguments" + $"LambdaArguments{lambdaId}" ), lambda.Body is BlockSyntax or ObjectCreationExpressionSyntax or AnonymousObjectCreationExpressionSyntax - ? Doc.IfBreak(Doc.SoftLine, Doc.Null, "LambdaArguments") + ? Doc.IfBreak(Doc.SoftLine, Doc.Null, $"LambdaArguments{lambdaId}") : Doc.SoftLine - ); - break; - } - case [ - { - Expression: ParenthesizedLambdaExpressionSyntax - { - ParameterList.Parameters.Count: 0, - Block: { } - } lambda - } arg - ]: - { - docs.Add( + ), + [{ Expression: ParenthesizedLambdaExpressionSyntax lambda } arg] + when lambda is { ParameterList.Parameters: [], Block: { } } + => Doc.Concat( Doc.GroupWithId( - "LambdaArguments", + $"LambdaArguments{lambdaId}", Doc.Indent( Doc.SoftLine, Argument.PrintModifiers(arg, context), @@ -58,27 +48,25 @@ or AnonymousObjectCreationExpressionSyntax ), Doc.IndentIfBreak( ParenthesizedLambdaExpression.PrintBody(lambda, context), - "LambdaArguments" + $"LambdaArguments{lambdaId}" ), - Doc.IfBreak(Doc.SoftLine, Doc.Null, "LambdaArguments") - ); - break; - } - default: - { - docs.Add( + Doc.IfBreak(Doc.SoftLine, Doc.Null, $"LambdaArguments{lambdaId}") + ), + [_, ..] + => Doc.Concat( Doc.Indent( Doc.SoftLine, SeparatedSyntaxList.Print(arguments, Argument.Print, Doc.Line, context) ), Doc.SoftLine - ); - break; - } - } - - docs.Add(Token.Print(closeParenToken, context)); + ), + _ => Doc.Null + }; - return Doc.Concat(docs); + return Doc.Concat( + Token.Print(openParenToken, context), + args, + Token.Print(closeParenToken, context) + ); } } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SimpleLambdaExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SimpleLambdaExpression.cs index 414c0aa95..9428be21e 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SimpleLambdaExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SimpleLambdaExpression.cs @@ -4,7 +4,7 @@ internal static class SimpleLambdaExpression { public static Doc Print(SimpleLambdaExpressionSyntax node, FormattingContext context) { - return Doc.Concat(PrintHead(node, context), PrintBody(node, context)); + return Doc.Group(PrintHead(node, context), PrintBody(node, context)); } public static Doc PrintHead(SimpleLambdaExpressionSyntax node, FormattingContext context) @@ -25,7 +25,7 @@ public static Doc PrintBody(SimpleLambdaExpressionSyntax node, FormattingContext ObjectCreationExpressionSyntax or AnonymousObjectCreationExpressionSyntax => Doc.Group(" ", Node.Print(node.Body, context)), - _ => Doc.Indent(Doc.Group(Doc.Line, Node.Print(node.Body, context))) + _ => Doc.Indent(Doc.Line, Node.Print(node.Body, context)) }; } }