Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot run Code Analysis Analyzer in Visual Studio 2015

I installed Microsoft.CodeAnalysis.CSharp.FxCopAnalyzers from nuget into a project.

enter image description here

The project it is installed into is an existing project, building against Framework 4.5.1.

Code Analysis is Enabled on the project...

enter image description here

... and I see CA warnings in the Build out put and the error window as expected, so I believe the ruleset to be valid.

However I can't seem to see out put from the analyzer, and I can't seem to find what this icon means in the documentation:

Analyzers

Right clicking on the Analyzers node and selecting Open Active Rule Set I can see the CA rules that the FxCop analyzer should be using:

Active Ruleset

Checking the location of the DLL, it's there in the nuget folder as expected:

enter image description here

like image 874
NikolaiDante Avatar asked Aug 24 '15 08:08

NikolaiDante


People also ask

How do I run a Visual Studio code analysis?

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

Where are code analysis results Visual Studio?

Code analysis will start executing in the background. You should see the message Running code analysis for <project> in the Visual Studio status bar towards the bottom-left corner. Once code analysis completes, the status message will change to Code analysis completed for <project>.

How do I disable 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.


2 Answers

This package hasn't been updated since January. I guess it's been replaced by

Microsoft.CodeAnalysis.FxCopAnalyzers

like image 192
wziska Avatar answered Oct 01 '22 08:10

wziska


You can right click on the Analyzers node and select Open Active Rule Set to see all of the analyzers enabled on your project. You can then modify this list and it will save those changes back to your project. If an analyzer isn't firing, then maybe it isn't enabled in your project.

If there is an anlayzer DLL that is missing, you can add it from the Analyzer node right click menu or via nuget packages (depending on where it comes from).

I have a post on my blog with more information on using analyzers in your project: https://johnkoerner.com/csharp/using-analyzers-in-your-projects/

like image 45
John Koerner Avatar answered Oct 01 '22 09:10

John Koerner