views:

862

answers:

2

Does anyone have settings for Visual Studio, in XML or a .vssettings-file, that is compatible with StyleCop?

I've used the book Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries for guidance on what Microsoft finds to be the correct way to format C# and set my Visual Studio-settings accordingly.

But when I use "Format Document" in Visual Studio, StyleCop will fire on all cylinders and complains on all sorts of things.

Some errors even seems impossible to set in the settings. Like curly braces should be on a new line, if something spans for more than one row.

+2  A: 

It costs money, but someone made a ReSharper plugin for StyleCop. Thanks for posting the question, I'd never heard of StyleCop before.

MatthewMartin
+2  A: 

StyleCop for ReSharper would certainly help:

StyleCop for ReSharper is now feature complete in that is has reached feature parity with StyleCop 4.3.

There are 148 StyleCop rules.

  • 38 of these must be fixed manually (normally because you have to type descriptive text or rename variables).
  • Of the remaining 110 rules 58 are fixed by R# Code Cleanup (silent mode).
  • Of the 52 now remaining we have Code Cleanup rules that fix all of them automatically.

We also provide 106 Quick Fixes that provide in place context menu fixes for violations for the 110 rules that can be fixed automatically

We also ship a "StyleCop friendly ReSharper Code Style Sharing Settings file" which configures ReSharper to automatically format code in a StyleCop friendly manner.

HowardvanRooijen
Good enough. Doesn't really solve the problem described in the question, but it probably as close as you can get.
Seb Nilsson