-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Prettier style trailing commas #1284
Conversation
…s and list patterns
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good so far! Thanks for taking this on.
The one big piece missing, is making sure SyntaxNodeComparer
doesn't report the added/removed comma as a warning along with adding some tests in SyntaxNodeComparerTests
.
I'm hoping the logic can go into one of the methods in SyntaxNodeComparer
that compares lists.
I guess it's ok to just omit the last separator (expression count - 1) when comparing the separators of the original node and the formatted node!? |
Yeah that seems good enough, I don't see the csharpier code somehow being so screwed up that it replaces the last comma with a different separator.... and if it did then I don't think we could actually generate a syntax tree from the result. |
# Conflicts: # Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InitializerExpression.cs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work on all the tests, thanks for the contribution!
This pull request addresses the issue described in Issue #668 and Issue #1285 .
A flag UsePrettierStyleTrailingCommas is introduced which ensures a trailing comma for anonymous object/collection/initializer/switch expressions, list patterns and enum declarations in the case a line break occurs.
I hope the implementation of the feature isn't too invasive. Obviously it would be easier to implement the feature non-configurable.
I'm not sure how to deal with the tests, for now I enabled the flag and adjusted the corresponding tests.
Thanks for any feedback!