I used previously StyleCop + FxCop on my Visual Studio's projects. But now I am testing Visual Studio Code Analysis tool, which is easier to integrate into MSBuild, and I have found that this tools analyses some of the rules of both FxCop and StyleCop.
Is this tool a full replacement for both FxCop and StyleCop or does it just implement some of their rules?
StyleCop is a source code analysis tool that provides developers with an effective way to follow C# coding standards. FxCop runs against the compiled binaries as a way to understand and enforce the.NET Framework Guidelines for managed code assemblies.
StyleCop used to be a Visual Studio plugin and a NuGet package. You can still use this in Visual Studio 2019, but the current recommended way to use StyleCop is to use the Roslyn-based analyzers.
FxCop provides a tool to help developers to follow their company's coding standards. FxCop does code analysis to check whether the new code is compliant with the coding standards and naming conventions followed by the company. FxCop will ensure that the specified rules are used in the source code.
Go to Tools –> FxCop analyze your code and because we checked “Use Output window” in External Tools dialog, result should appear in Visual Studio output window. Works with any managed assembly created in . NET language that run on Microsoft . NET Framework.
Visual Studio includes FxCop + more.
From the developer blog of FxCop:
Sorry about my ignorance, but I assume FxCop is completely separate from the Code Analysis in VSTS? More specifically, I assume that if I install the new version of FxCop, VSTS will not take advantage (no shared code?)? If this is the case, any idea when these changes will make it into VSTS code analysis? Thanks!
That's correct, they are different products, however they do have a common engine. Visual Studio 2008 SP1 already comes with the same fixes and analysis (plus a little bit more), so there is no need to 'update' Visual Studio with the latest FxCop.
A developer blog also gave the exact rules which are in each.
As for StyleCop, it's independent of VS Code Analysis as described in this blog post, which links to Jader Dias' post.
My understanding is that Visual Studio Code Analysis is basically a slightly modified version of FxCop. From my experience they are almost the same thing (in fact I believe Code Analysis uses the FxCop executable behind the scenes).
Although there is overlap between FxCop/CodeAnalysis and StyleCop; FxCop tends to focus more on design rules and StyleCop is focusing on coding style (casing, white space, indents, etc).
Also FxCop analyzes the IL while StyleCop analyzes the source code directly. This imposes a different set of restrictions on what rules they can each enforce.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With