C# – FxCop and Code Analysis in Visual Studio 2013

ccode analysisfxcopvisual-studio-2013

I want to do code analysis in my project and I am using Visual Studio 2013. I can see a Analyze tab which will help to do the code analysis. So my questions is below

  • Should I install FxCop or shall I continue using the inbuilt Code Analysis from Visual Studio?
  • Does FxCop provide any other advantages than code analysis from Visual Studio?

Just found a post here, but I am not sure whether to use Fxcop or not?

http://michaelsync.net/2014/07/19/status-of-fxcop-code-analysis

Best Answer

(Disclaimer: I worked on Visual Studio at Microsoft, though not on the C# or CIL/FxCop teams and I have no inside knowledge of their work)

My understanding is that the Code Analysis engine in Visual Studio 2013 (under the Analyze menu) is essentially the same engine as used in FxCop, except built-in to Visual Studio and MSBuild (which makes build analysis easier to automate). VS2013 uses the old "hand-written" native C# and VB.NET compilers.

Visual Studio 2015 ("VS 14") uses the new "Roslyn" compiler set and its analysis engine is different. The blog article you linked to makes this clear:

we’re proving out our new Roslyn-based diagnostics by reimplementing the high-value, low-false-positive FxCop rules using Roslyn. We haven’t yet decided when to pull the switch and officially swap out the IL-based FxCop rules for rules built on Roslyn, but the new live analysis engine will be built into the C#/VB compilers in VS “14”

...from that, it's said that VS2015 includes the old FxCop rules in addition to new Roslyn-based rules, but the less reliable FxCop CIL-based rules have been replaced with Roslyn rules.