Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FxCop and Code Analysis in Visual 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

like image 810
Midhun Murali Avatar asked Aug 04 '15 06:08

Midhun Murali


People also ask

What is FxCop tool used for?

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.

What is FxCop and StyleCop?

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.

How do I install FxCop?

Make a sensibly named folder for the FxCop setup file to go into, for example, create a folder called C:\Downloads\Microsoft\FxCop\Setup. 13. Right-click on the “WinSDK_FxCopSetup.exe + gobbledygook” file and select Copy. Copy the“WinSDK_FxCopSetup.exe + Guid” file into C:\Downloads\Microsoft\FxCop\Setup folder.

How do I see code analysis results in Visual Studio?

In Solution Explorer, select the project. On the Analyze menu, select Run Code Analysis on [Project Name].


1 Answers

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

like image 69
Dai Avatar answered Oct 21 '22 08:10

Dai