Disabling StyleCop rules

Visual StudioStylecop

Visual Studio Problem Overview


I'm using StyleCop. But there a couple of rules I want to ignore, for instance using this. in front of class members.

How do I turn off a StyleCop rule. I've looked but can't find how to do it.

Visual Studio Solutions


Solution 1 - Visual Studio

In your StyleCop install, there's a Settings.StyleCop file. You can edit this to turn off rules globally. Drag that file onto the Settings Editor executable in that file to edit it.

You can also put copies of the settings file into your projects to override the global settings.

If you're using Visual Studio integration and not just MSBuild integration, you should be able to get to the settings editor on a per-project basis by right clicking on your project and choosing StyleCop Settings or something like that.

Solution 2 - Visual Studio

Stylecop is configurable at Project level. Manage rules easily using graphical interface instead of editing settings file.(Some time in some versions mentioned as Stylecop settings)

You should see a search/Find Option once you select the settings option as in the below image.

Ex: If you want to remove a rule where // comments are not allowed and //// are allowed by stylecop, then search for stylecop rule id. In this case it is SA1005. You can see this in the warnings section when you run stylecop in your project. Find with key word SA1005 and you should see that in result section. Just uncheck.

enter image description here

You can manage rules as below

enter image description here

Solution 3 - Visual Studio

That specific rule is under Readability Rules - Member Access - SA1101: PrefixLocalCallsWithThis.

If you turn that off it should stop screaming at you... I had to do it. Stylecop has been giving me a headache.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAJMView Question on Stackoverflow
Solution 1 - Visual StudiobdukesView Answer on Stackoverflow
Solution 2 - Visual StudioKurkulaView Answer on Stackoverflow
Solution 3 - Visual StudioDeadlyChambersView Answer on Stackoverflow