Wikipedia says that StyleCop "checks C# code for conformance to StyleCop's recommended coding styles and a subset of Microsoft's .NET Framework Design Guidelines". Frankly, I don't agree with some of their coding guidelines and I actually want to line for the exact OPPOSITE of what they recommend; for example, opening braces on the same line as if/while/for statements, and class variables must begin with underscore. StyleCop doesn't provide these rules as they're not "recommended". Is there an equivalent linting tool that does let me enforce these?

  • StyleCop is "opinionated" about C# style because those are the styles that traditional C# developers are used to - however, last time I checked it was possible to change all the rules in a settings file and share with the rest of your team May 21, 2020 at 11:11

2 Answers 2


You can adjust all StyleCop rules to your liking, the modifications are stored in the Settings.StyleCop file. Because StyleCop searches upwards in the directory hierarchy for this file, you can easily use the same settings for all your projects.

To change styles, just right click the project in the solution explorer and select "StyleCop Settings":

enter image description here

EDIT: After rereading your question I see that this doesn't answer your question, you do not only want to deactivate the rule (no underscores allowed), you want to add your own new rule (underscores required). Nevertheless I leave the answer, maybe it helps someone other.


I would recommend to use the newer Roslyn-based analyzers for all your code and drop the standalone StyleCop entirely, this way you get full build-time integration and configurable warning levels, among other things.

For this, I recommend to replace the original StyleCop by the new StyleCop analyzers. You can configure them on a pe-project basis and have them run on each compile, in addition to have live edit errors shown. They also allow to configure its rules and disable every control you don't want.

In addition, by using Roslyn analyzers you can also install any third-party ones and even write your own if you really want to. For the particular case of variables begining with an underscore I can find it here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.