diff --git a/Src/CSharpier.Tests/FormattingTests/TestFiles/InvocationExpressions.cst b/Src/CSharpier.Tests/FormattingTests/TestFiles/InvocationExpressions.cst index 1ca4d24ff..9f83edc81 100644 --- a/Src/CSharpier.Tests/FormattingTests/TestFiles/InvocationExpressions.cst +++ b/Src/CSharpier.Tests/FormattingTests/TestFiles/InvocationExpressions.cst @@ -114,6 +114,33 @@ class ClassName secondParameter___________________________ ); + this.CallMethod( + firstParameter____________________________, + secondParameter___________________________ + ) + .CallMethod( + firstParameter____________________________, + secondParameter___________________________ + ); + + string.CallMethod( + firstParameter____________________________, + secondParameter___________________________ + ) + .CallMethod( + firstParameter____________________________, + secondParameter___________________________ + ); + + o.CallMethod( + firstParameter____________________________, + secondParameter___________________________ + ) + .CallMethod( + firstParameter____________________________, + secondParameter___________________________ + ); + SomeObject? .CallMethod(parameter_______________________________________________________________) .ToArray(); diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ArgumentList.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ArgumentList.cs index 20abfd64c..a6392f001 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ArgumentList.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ArgumentList.cs @@ -5,6 +5,8 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters { public static class ArgumentList { + // TODO I think this indent logic can move into the FlattenAndPrintNodes method + // then hopefully it can share it with ShouldMergeFirstTwoGroups public static Doc Print(ArgumentListSyntax node) { return Doc.Group( @@ -13,7 +15,16 @@ public static Doc Print(ArgumentListSyntax node) node.Parent is InvocationExpressionSyntax { - Expression: IdentifierNameSyntax, + Expression: IdentifierNameSyntax + or MemberAccessExpressionSyntax + { + Expression: ThisExpressionSyntax + or PredefinedTypeSyntax + or IdentifierNameSyntax + { + Identifier: { Text: { Length: <= 4 } } + } + }, Parent: { Parent: InvocationExpressionSyntax } }, ArgumentListLike.Print( diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InvocationExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InvocationExpression.cs index 9cca37a59..519b09f26 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InvocationExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InvocationExpression.cs @@ -566,37 +566,6 @@ context.Operation is IInvocationOperation invocation TestProjectName, LanguageNames.CSharp ); - - // maybe things < 4 should merge? looks super bad when it is a single character - // but what about when they are on something like - var someLongName = cfg.CallMethod() - .CallMethod()o - new MapperConfiguration( - cfg => - { - cfg - .CreateProjection() - .IncludeMembers( - s => s.InnerSources.FirstOrDefault(), - s => s.OtherInnerSources.FirstOrDefault() - ); - cfg - .CreateProjection(MemberList.None) - .ForMember( - d => d.Details, - o => o.MapFrom(s => s.InnerSourceDetails.FirstOrDefault()) - ); - cfg - .CreateProjection(MemberList.None) - .ForMember( - d => d.OtherDetails, - o => o.MapFrom(s => s.OtherInnerSourceDetails.FirstOrDefault()) - ); - cfg.CreateProjection(); - cfg.CreateProjection(); - } - ); - } }