Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable Code Analysis in Visual Studio 2010 Professional?

Tags:

I can see that we can enable code analysis in Visual Studio Team Systems. But i am using Visual Studio 2010 Professional.

Do we have any option to enable code analysis in this version or can we integrate any tools like FxCop and StyleCop with this version for validating the code.

I am expecting my code should analysied the moment i build my solution.

If somebody aware of this, please share me some solution for this.

like image 355
kiran826 Avatar asked May 14 '10 11:05

kiran826


People also ask

How do I enable Code Analysis in Visual Studio?

Open the solution in Visual Studio. On the Analyze menu, select Configure Code Analysis for Solution. If necessary, expand Common Properties, and then select Code Analysis Settings.

How do I turn off Code Analysis in Visual Studio?

To open this page, right-click the project node in Solution Explorer and select Properties. Select the Code Analysis tab. To disable source analysis at build time, uncheck the Run on build option. To disable live source analysis, uncheck the Run on live analysis option.

What is Code Analysis in Visual Studio?

The Code Analysis feature of Visual Studio performs static code analysis to help developers identify potential design, globalization, interoperability, performance, security, and a host of other categories of potential problems.

How do I run a ReSharper Code Analysis?

ReSharper helps you resolve most of the discovered code issues automatically. All you need is to press Alt+Enter when the caret is on a code issue highlighted in the editor and check the suggested quick-fixes.


2 Answers

You can integrate FxCop via Commandline in the post-build event of the solution.

Download FxCop 1.36 and add following command into the post-build event:

"$(ProgramFiles)\Microsoft FxCop 1.36\FxCopCmd.exe" /c /p:"$(ProjectDir)\FxCop$(ConfigurationName).FxCop" /consolexsl:"$(ProgramFiles)\Microsoft FxCop 1.36\Xml\VSConsoleOutput.xsl" 

Via consolexsl parameter the output is formatted so that the output is included into you VisualStudio builderrors and -warnings.

We have created a FxCop file that specifies the rules with FxCop-Gui. That file is loaded in the command.

like image 185
Chris U Avatar answered Sep 27 '22 22:09

Chris U


Check out this comparison chart, built-in code analysis support gets checked starting in the Premium column.

like image 40
Hans Passant Avatar answered Sep 27 '22 22:09

Hans Passant