Is there a StyleCop/FxCop autofixing tool? [closed

2020-02-18 15:18发布

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!

9条回答
一纸荒年 Trace。
2楼-- · 2020-02-18 15:25

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..

查看更多
Root(大扎)
3楼-- · 2020-02-18 15:28

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.

查看更多
Deceive 欺骗
4楼-- · 2020-02-18 15:32

Some tools which I use to fix the stylecop fix issues are,

  1. CodeMaid ( Free one open source)
  2. GhostDoc (Already suggested in earlier replies in the same post.You need to buy this, comes with a limited 14 days trial edition)
  3. StyleCopFixer ( Already suggested in earlier replies in the same post.Free one, comes as an extension to VS2010)

Hope it helps :)

查看更多
干净又极端
5楼-- · 2020-02-18 15:32

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.

查看更多
何必那么认真
6楼-- · 2020-02-18 15:40

StyleCopFixer is the tool that automatically fix StyleCop exceptions within Visual Studio IDE.

查看更多
冷血范
7楼-- · 2020-02-18 15:41

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."

查看更多
登录 后发表回答