From 9ad853fabf2e6332f13704a2d3a77673b7e808f6 Mon Sep 17 00:00:00 2001 From: Bela VanderVoort Date: Wed, 16 Jun 2021 17:26:41 -0500 Subject: [PATCH] Break long attributes consistently (#312) closes #257 --- .../AttributeList/AttributeLists.cst | 19 ++++++++++++++++--- .../ObnoxiousEdgeCases/ObnoxiousEdgeCases.cst | 6 ++++-- .../StringLiteral/StringLiterals.cst | 3 ++- .../SyntaxNodePrinters/AttributeList.cs | 7 ++++--- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/Src/CSharpier.Tests/TestFiles/AttributeList/AttributeLists.cst b/Src/CSharpier.Tests/TestFiles/AttributeList/AttributeLists.cst index e62354098..88efa79b6 100644 --- a/Src/CSharpier.Tests/TestFiles/AttributeList/AttributeLists.cst +++ b/Src/CSharpier.Tests/TestFiles/AttributeList/AttributeLists.cst @@ -45,9 +45,11 @@ class ClassName // leading before class class ClassTwo { } - [BigLongAttributeWhatHappensHmmmmmmmmmmmmmmmmmmmmmmmmmmmmm( - "11111111111111111111111111", - "22222222222222222222222222")] + [LongAttributeWithParametersBreaking( + "someValue_____________", + "someValue_____________", + "someValue_____________" + )] void LongAttribute() { } public void MethodName([FromBody] SomeParameter parameter) @@ -63,3 +65,14 @@ class ClassName return; } } + +[ + LongAttributeWithParametersBreaking( + "someValue_____________", + "someValue_____________", + "someValue_____________" + ), + AnotherAttribute +] +public class ClassName { } + diff --git a/Src/CSharpier.Tests/TestFiles/ObnoxiousEdgeCases/ObnoxiousEdgeCases.cst b/Src/CSharpier.Tests/TestFiles/ObnoxiousEdgeCases/ObnoxiousEdgeCases.cst index c3851d5e9..ddb81ee36 100644 --- a/Src/CSharpier.Tests/TestFiles/ObnoxiousEdgeCases/ObnoxiousEdgeCases.cst +++ b/Src/CSharpier.Tests/TestFiles/ObnoxiousEdgeCases/ObnoxiousEdgeCases.cst @@ -3,7 +3,8 @@ class ClassName { public static object? FormatValue<[DynamicallyAccessedMembers( - DynamicallyAccessedMemberTypes.All)] + DynamicallyAccessedMemberTypes.All + )] T>(T value, CultureInfo? culture = null) { } public readonly StackObjectPool AddAccountClaimsPrincipalFactory<[DynamicallyAccessedMembers( - DynamicallyAccessedMemberTypes.PublicConstructors)] + DynamicallyAccessedMemberTypes.PublicConstructors + )] TAccountClaimsPrincipalFactory>( this IRemoteAuthenticationBuilder builder ) where TAccountClaimsPrincipalFactory : AccountClaimsPrincipalFactory => diff --git a/Src/CSharpier.Tests/TestFiles/StringLiteral/StringLiterals.cst b/Src/CSharpier.Tests/TestFiles/StringLiteral/StringLiterals.cst index 9b0650f88..fc184a6b9 100644 --- a/Src/CSharpier.Tests/TestFiles/StringLiteral/StringLiterals.cst +++ b/Src/CSharpier.Tests/TestFiles/StringLiteral/StringLiterals.cst @@ -1,6 +1,7 @@ [assembly: System.Copyright( @"(C)"" -2009")] +2009" +)] class ClassName { private string bothLineEndingsPersist = @"\r\n \n"; diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/AttributeList.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/AttributeList.cs index a0f2c5ffd..c81389355 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/AttributeList.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/AttributeList.cs @@ -55,9 +55,10 @@ public static Doc Print(AttributeListSyntax node) Node.Print(attributeArgumentNode.Expression) ), Doc.Line - ), - Token.Print(attributeNode.ArgumentList.CloseParenToken) - ) + ) + ), + Doc.SoftLine, + Token.Print(attributeNode.ArgumentList.CloseParenToken) ); }, Doc.Line