Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force ReSharper to use StyleCop settings for code cleanup

I saw similar questions but was unable to find the answer, even though some of them were marked as answered. I'm using ReSharper 6.1.1 and StyleCop 4.7.11.0. I put Settings.StyleCop file in the my solution's root folder. I unchecked documentation rules, so StyleCop settings look like this:

enter image description here

I even set "Do not merge with other settings files" option.

Then I open my solution, go to ReSharper -> Cleanup and delete current StyleCop preset. enter image description here

Then I save and reopen ReSharper settings and go to Tools -> StyleCop and click "Reset C# code style options" button. enter image description here

Then I save and reopen ReSharper settings again. I can see new CodeCleanup preset "StyleCop" and I suppose that this preset MUST be in sync with my Settings.StyleCop file. But it's not, Documentation section is still checked: enter image description here

So, what am I doing wrong? PS: sorry for a lot of pictures, but I do believe that they clarify my question.

like image 838
ptkvsk Avatar asked Sep 19 '12 10:09

ptkvsk


People also ask

How do I set rules in ReSharper?

You can look it up on the Code Editing | [Language] | Formatting Style page of ReSharper options ( Alt+R, O ) or alternatively, you can select a code block where the desired rule applies, press Alt+Enter , and choose Format selection | Configure.

How do I open StyleCop settings editor?

The Settings. StyleCop file can be opened from the Explorer and edited through a GUI. If that doesn't work, try dragging the Settings file onto an application called StyleCopSettingsEditor.exe which is installed in your StyleCop Program Files folder.

How do you code cleanup?

Right-click on the project or solution name in Solution Explorer, select Analyze and Code Cleanup, and then select Run Code Cleanup.

How do I turn off StyleCop rule?

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.


1 Answers

That is correct functionality. The ReSharper code cleanup styles are saved in the ReSharper settings file, and the StyleCop rules in the StyleCop settings file. They provide slightly different functionality in that the ReSharper plugin cleans up your code, while StyleCop simply checks your code. You have a point in that they perhaps should reference the same settings, but that isn't how it currently works.

I'm sure there is an explanation why (ie, they may have designed it to allow you to clean up the code but not enforce the rules), but that's probably best asked on the StyleCop website.

like image 58
Mightymuke Avatar answered Nov 02 '22 19:11

Mightymuke