I installed Microsoft.CodeAnalysis.CSharp.FxCopAnalyzers from nuget into a project.
The project it is installed into is an existing project, building against Framework 4.5.1.
Code Analysis is Enabled on the project...
... 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:
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:
Checking the location of the DLL, it's there in the nuget folder as expected:
In Solution Explorer, select the project. On the Analyze menu, select Run Code Analysis on [Project Name].
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>.
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.
This package hasn't been updated since January. I guess it's been replaced by
Microsoft.CodeAnalysis.FxCopAnalyzers
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/
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