Force ReSharper to use StyleCop settings for code cleanup

ptkvsk picture ptkvsk · Sep 19, 2012 · Viewed 13.4k times · Source

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.

Answer

Mightymuke picture Mightymuke · Dec 3, 2012

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.