Skip to content

Commit

Permalink
Make sure new object does not space brace
Browse files Browse the repository at this point in the history
closes #461
  • Loading branch information
belav committed Oct 25, 2021
1 parent 2e0eb3a commit efddb53
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public class ClassName
private SomeObject SomeLongerName = new SomeObject(
"lkjasdflkjasdfkljaskldjf",
"klasldkfaksdfasdfkjasdklf"
) {
)
{
Property1 = 1,
Property2 = 2
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public class ClassName
public ClassName WithComplexConstructor = new ClassName(
"parameter1",
new ClassName("parameter1", "parameter2") { Property1 = true }
) {
)
{
Property1 = true
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@ public static class ObjectCreationExpression
{
public static Doc Print(ObjectCreationExpressionSyntax node)
{
var groupId = Guid.NewGuid().ToString();

return Doc.Group(
Token.PrintWithSuffix(node.NewKeyword, " "),
Node.Print(node.Type),
node.ArgumentList != null
? Doc.GroupWithId(
groupId,
? Doc.Group(
ArgumentListLike.Print(
node.ArgumentList.OpenParenToken,
node.ArgumentList.Arguments,
Expand All @@ -24,10 +21,7 @@ public static Doc Print(ObjectCreationExpressionSyntax node)
)
: Doc.Null,
node.Initializer != null
? Doc.Concat(
node.ArgumentList != null ? Doc.IfBreak(" ", Doc.Line, groupId) : Doc.Line,
InitializerExpression.Print(node.Initializer)
)
? Doc.Concat(Doc.Line, InitializerExpression.Print(node.Initializer))
: Doc.Null
);
}
Expand Down

0 comments on commit efddb53

Please sign in to comment.