-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add guideline for trailing commas in initializers #467
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
base: main
Are you sure you want to change the base?
Conversation
Added guideline to include trailing commas in multi-line initializers to avoid MA0007 warnings.
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.
Pull request overview
This PR adds a C# formatting guideline to include trailing commas in multi-line initializers to avoid MA0007 analyzer warnings from the Meziantou.Analyzer tooling.
- Adds a single formatting guideline to the existing C# instruction file
| - Use pattern matching and switch expressions wherever possible. | ||
| - Use `nameof` instead of string literals when referring to member names. | ||
| - Ensure that XML doc comments are created for any public APIs. When applicable, include `<example>` and `<code>` documentation in the comments. | ||
| - Add a trailing comma after the last value in multi-line arrays, collection initializers, object initializers, and enum declarations to prevent MA0007 warnings. |
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.
I'm unfamiliar with this warning - it does not appear to be part of the Roslyn analyser stack
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.
Correct, it is from another famous C# analyser, https://github.com/meziantou/Meziantou.Analyzer
https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0007.md
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.
Ah ok. I'll admit to not being familiar with that analayzer stack.
Given that, I think this is a little overly specific for the generate C# instructions, especially as it's only one of the nearly 200 analyzer rules in that nuget package. I would suggest creating a dedicated instructions file that people can optionally layer in if they are using that analyzer too.
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.
what should be the name of the file of the instruction?
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.
meziantou-analuzer-rules.instructions.md would probably make sense
Added guideline to include trailing commas in multi-line initializers to avoid MA0007 warnings.
Pull Request Checklist
npm startand verified thatREADME.mdis up to date.Description
Type of Contribution
Additional Notes
Added guideline to include trailing commas in multi-line initializers to avoid MA0007 warnings.
By submitting this pull request, I confirm that my contribution abides by the Code of Conduct and will be licensed under the MIT License.