Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing some edge cases for initializers #344

Merged
merged 4 commits into from
Jul 10, 2021
Merged

Conversation

belav
Copy link
Owner

@belav belav commented Jul 9, 2021

closes #335
closes #336

Copy link
Collaborator

@shocklateboy92 shocklateboy92 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woah... it's been a while!
LGTM.

InvocationExpressionSyntax
or ParenthesizedLambdaExpressionSyntax
or ObjectCreationExpressionSyntax
or ElementAccessExpressionSyntax
or ArrayCreationExpressionSyntax
or InitializerExpressionSyntax
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be redundant since you're including it above anyway.

@@ -21,10 +21,20 @@ string groupId
return Print(node, groupId);
}

private static Doc Print(InitializerExpressionSyntax node, string? groupId)
public static Doc PrintWithLine(InitializerExpressionSyntax node)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: I think stuff like PrintWithLine and PrintWithConditionalSpace might be better placed inlined at the call site rather than have special functions for one-off use cases.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to move the logic for PrintWithLine into InitializerExpression itself.
And because PrintWithConditionalSpace ended up not using the Doc.Group, the logic for that could be inlined in ObjectCreationExpression.
Much nicer this way!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

@belav
Copy link
Owner Author

belav commented Jul 10, 2021

Woah... it's been a while!

Don't worry, I was just on a long vacation. I'll fill up your inbox with new PRs soon!

@belav belav merged commit 38d70b1 into master Jul 10, 2021
@belav belav deleted the more-initializer-edge-cases branch July 10, 2021 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ObjectInitializer keeping brace on same line ObjectInitializer in CollectionInitializer breaking
3 participants