in my .net project(Target Framework 4.7), in code analysis tab, I see Run on build was checked. so am able to see some FxCop warnings. but when I checked nuGet packages, I see that Microsoft.CodeAnalysis.FxCopAnalyzers is not installed. so my first question is when FxCopAnalyzers nuget package is not installed, how are the warnings showing up?
Moving now, when I upgraded to VS2019, I get below error
Warning CA0507 Post-build Code Analysis (FxCopCmd.exe) has been deprecated in favor of FxCop analyzers
so I googled and found that FxCopAnalyzers are no longer supported and are replaced with Microsoft.CodeAnalysis.NetAnalyzers.
I did the steps mentioned here https://github.com/dotnet/roslyn-analyzers
installed the package
did this to the project file by editing it in notepad.

the Warning CA050 is gone now, but I don't get any warnings that was coming before. I was expecting Microsoft.CodeAnalysis.NetAnalyzers to generate the same set of warning that was coming before(even thouugh i dont know how it was coming). What am I missing? am not sure if Microsoft.CodeAnalysis.NetAnalyzers is even doing its job.
Thanks in Advance.
I have too little reputation to comment. I recommend reading this: https://learn.microsoft.com/en-us/visualstudio/code-quality/net-analyzers-faq?view=vs-2019
TLDR: FxCop when used as a Roslyn analyzer is not the same analyzer as FxCop in Visual Studio (legacy FxCop). Some rules from legacy FxCop are not present in newer FxCop.
For a list of rules that have not been ported, see below:
https://learn.microsoft.com/en-us/visualstudio/code-quality/fxcop-unported-rules-may-get-ported?view=vs-2019
https://learn.microsoft.com/en-us/visualstudio/code-quality/fxcop-unported-deprecated-rules?view=vs-2019
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