Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Can Microsoft.CodeAnalysis.FxCopAnalyzers be configured for .Net Core? #1118

Closed
ChristophB125 opened this issue Mar 15, 2017 · 2 comments

Comments

@ChristophB125
Copy link

ChristophB125 commented Mar 15, 2017

Analyzer package

Microsoft.CodeAnalysis.FxCopAnalyzers (latest stable release 1.1.0)

Question

How can one configure the warnings?
Visual Studio 2017 provides no functionality to either run or configure Code Analysis at all and I can only get CA warnings when I build via command line due to #1117 . If there is no UI for it, at least some other way to configure it would be great.

@mavasani
Copy link
Contributor

@ChristophB125 - FXCop analyzer can be added and configured for .NET core projects.

  1. Install analyzers: You can add a nuget package reference to the analyzer package, and they should light up for your project.
  2. Configure rules: You can manually add a CodeAnalysisRuleSet property to the project file and specify a ruleset that configures FXCop rules. You can also explicitly specify /warnaserror:<ruleId> or /nowarn:<ruleId> on the command line or specify these IDs in the Build property page to escalate/suppress warnings.
  3. SuppressMessage: You can use regular SuppressMessageAttribute to suppress any analyzer warnings - if it doesn't work, kindly open an issue on https://github.com/dotnet/roslyn/issues/new

@ChristophB125
Copy link
Author

ChristophB125 commented Mar 15, 2017

Thanks for the info.
I managed to get CA working, manually specify the ruleset in the csproj and also suppress some warnings either in code or ruleset file.
However, on .Net Core some CA warnings do not get triggered correctly (e.g. CA1012 does not get triggered and CA2213 gets triggered in a case where only CA1001 should have been triggered).
I created this and this issue for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants