From 9863b9ee8440f24faa59a28bc97014ecbc3beac2 Mon Sep 17 00:00:00 2001 From: Bela VanderVoort Date: Sat, 26 Oct 2024 20:06:24 -0500 Subject: [PATCH] get implicit object creation consistent with explicit creation (#1366) closes #1364 --- .../TestFiles/cs/InitializerExpressions.test | 40 ++++++++++++++++--- Src/CSharpier/SyntaxPrinter/RightHandSide.cs | 5 --- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/Src/CSharpier.Tests/FormattingTests/TestFiles/cs/InitializerExpressions.test b/Src/CSharpier.Tests/FormattingTests/TestFiles/cs/InitializerExpressions.test index 19be407df..19cc7a121 100644 --- a/Src/CSharpier.Tests/FormattingTests/TestFiles/cs/InitializerExpressions.test +++ b/Src/CSharpier.Tests/FormattingTests/TestFiles/cs/InitializerExpressions.test @@ -250,9 +250,39 @@ class ClassName { }; } - private SomeObject someObject = - new(someLongParameter___________________) - { - SomeProperty = someLongValue____________________________, - }; + SomeObject someObject = new() + { + Property = longValue_______________________________________________________________________, + }; + + SomeObject someObject = new SomeObject + { + Property = longValue_______________________________________________________________________, + }; + + SomeObject someObject = new(someLongParameter___________________) + { + Property = longValue_______________________________________________________________________, + }; + + SomeObject someObject = new SomeObject(someLongParameter___________________) + { + Property = longValue_______________________________________________________________________, + }; + + SomeObject someObject = new( + someLongParameter___________________, + someLongParameter___________________ + ) + { + Property = longValue_______________________________________________________________________, + }; + + SomeObject someObject = new SomeObject( + someLongParameter___________________, + someLongParameter___________________ + ) + { + Property = longValue_______________________________________________________________________, + }; } diff --git a/Src/CSharpier/SyntaxPrinter/RightHandSide.cs b/Src/CSharpier/SyntaxPrinter/RightHandSide.cs index 29f15af56..5fa39669f 100644 --- a/Src/CSharpier/SyntaxPrinter/RightHandSide.cs +++ b/Src/CSharpier/SyntaxPrinter/RightHandSide.cs @@ -118,14 +118,9 @@ or ConditionalExpressionSyntax WhenFalse: ConditionalExpressionSyntax, WhenTrue: not ConditionalExpressionSyntax } - or ImplicitObjectCreationExpressionSyntax { Parent: EqualsValueClauseSyntax } or InterpolatedStringExpressionSyntax - // TODO ditch fluid? - // or InvocationExpressionSyntax or IsPatternExpressionSyntax or LiteralExpressionSyntax - // TODO ditch fluid? - // or MemberAccessExpressionSyntax or StackAllocArrayCreationExpressionSyntax or QueryExpressionSyntax => Layout.BreakAfterOperator, _ => Layout.Fluid,