Making ReSharper Play Nice With StyleCop

posted on 23 Jan 2009 | Tools | Visual Studio

I've been toying with StyleCop more and more as of late and ran into some situations where ReSharper and StyleCop were fighting each other over code formatting issues. Some manual tweaking reduced the problems, but it got me curious. So I did some research and uncovered a wonderful tool, StyleCop for ReSharper.

StyleCop for ReSharper is a ReSharper 4.1 plug-in that allows Microsoft StyleCop to be run as you type, generating real-time syntax highlighting of violations. StyleCop for ReSharper also contains a collection of Quick-Fixes and Code Clean-Up Modules to help you easily fix StyleCop code styling violations.

StyleCop for ReSharper also comes with a ReSharper Code Style Settings File which you can import into ReSharper to make ReSharper's auto formatting features compliant with StyleCop's recommendations. If you don't want to import a whole code style settings file and would rather just tweak some specific formatting settings that are responsible for most of StyleCop's complaints about ReSharper, I recommend reading these 2 blog posts at Hock Blogs:

Navigating around the StyleCop for ReSharper project page on CodePlex also turns up a lot of additional useful information:

All in all, I'm enjoying this ReSharper plug-in. It has taken a lot of the pain out of being compliant with StyleCop's rules.