Is there a tool that can automatically fix StyleCop and FxCop rules, rather than manually fixing thousands of warning and errors?
There must be one, it is such a good business opportunity!
Is there a tool that can automatically fix StyleCop and FxCop rules, rather than manually fixing thousands of warning and errors?
There must be one, it is such a good business opportunity!
Running Stylecop for the first time usually most of the errors thrown in my experience are the ones connected with code-formatting.
I used two tools to reorganize the code to match the Stylecop rules:
The first one became my preference; it's command line tool, I added this to custom tools in Visual Studio. The second one is a plugin for Visual Studio, therefore it was quite convenient to work with single files.
As already mentioned, there are some tools that try to fix some Stylecop errors, but in my opinion they worked quite poorly, therefore I abandoned using them and can't recommend any.
I don't think there are tools for FxCop, and I'm not convinced there should be..
StyleCop maybe (for some violations) - there are tons of code formatters.
FxCop no (that I am aware of).
ReSharper can help with its code cleanup and refactorings, but it's not going to magically fix all FxCop violations (although it will point out and help to fix some issues).
FxCop issues are similar to design patterns; they generally require thought to determine the proper way to apply the solution. In some cases the violation may not apply, and can be suppressed. You can also tune FxCop rules to your particular needs; the standard rules were intended for distributed frameworks and libraries, and are not universal. The majority of them are very, very good suggestions, though.
Some tools which I use to fix the stylecop fix issues are,
Hope it helps :)
StyleCopAutoFix is a console application that will automatically fix StyleCop violations related to missing (or unnecessary) empty lines. It is free an open-source.
While the scope of the violations it fixes is fairly limited, it fix them in a safe way (it is unlikely it will break your code or change the behavior). These violations are also the most common ones.
If you use Visual Studio, I also recommend to run this script : https://gist.github.com/JayBazuzi/9e0de544cdfe0c7a4358. It automatically auto format all code of all files in a solution.
On projects I ran this application (and the VS script above) it fixes up to 60% of all violations.
Disclaimer : I am the author of this.
StyleCopFixer is the tool that automatically fix StyleCop exceptions within Visual Studio IDE.
There is a (relatively) new Visual Studio extension on the block (StyleCopAid) - give it a try:
https://visualstudiogallery.msdn.microsoft.com/505d2931-143f-4055-b7dd-a5d7c95bb085
Among other things - fixes ordering rules, suppresses some messages, and has an undo option.
Update from July 2018: "The tool supports Visual Studio 2010, 2012, and 2013 versions."