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

Enable more analyzers for code style consistency and prevent other common mistakes #1590

Open
manfred-brands opened this issue Jan 2, 2025 · 1 comment
Assignees
Labels

Comments

@manfred-brands
Copy link
Member

We should enable both Microsoft.NetAnalyzers and StyleCop.Analyzers to align the code and keep it consistent.

Some files still contain tabs. We should get a warning and fix that. Some are even mixed mode (Options.cs)
Fields only set in the constructor should be marked readonly.
Properties only set in the constructor should only have a get, not a (private) set
Structures types should be marked readonly where possible.
Classes should be sealed if not meant to be extensible.
Use expression bodies for properties if single-lined.
...

We can enable rules as you see fit.

@CharliePoole
Copy link
Member

@manfred-brands I'm in favor of adding the Microsoft.NetAnalyzers. Do you want to take a shot at setting it up with some set of rules to start with? All the stuff you mention is fine for me.

To a large extent, however, I don't like to have too many stylistic rules. To be clear, my experience, before I retired, was working with groups of highly competent developers who were able to read and code using a variety of styles without confusion. That may bias me and I'm happy to talk about it.

@manfred-brands manfred-brands self-assigned this Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants