4

I'm writing a small application that uses log4net and a few other third-party libraries.

I'd like to run Visual Studio's code analysis on code I've written, but currently have about two thousand messages from log4net and the other libraries that I have no control over. For example, in this example image (Image of Visual Studio Code Analysis window), I want to keep the first and second messages (BfLicense is code I've written), but suppress the log4net messages.

Is there a way to suppress or ignore all messages from library references when running a code analysis? Ideally code analysis wouldn't run on the reference libraries at all, because it seems to slow down the analysis quite a bit.

After looking at the MSDN docs description of the GlobalSuppressions.cs file, and checking stackoverflow I couldn't find a way to have Visual Studio ignore external libraries, but I imagine this is a common issue others have, and so hope there is a good best practice I can follow.

Thanks in advance for any help you can offer.

P.S. These answers helped me understand some of the limitations of the GlobalSuppressions.cs file, but didn't fully answer my question:

Code analysis fails on project referencing obfuscated assembly.

How to suppress code analysis messages for all type members?

Kyle
  • 94
  • 5

1 Answers1

0

Thanks to jessehouwing for pointing me in the right direction. Attempting to recreate the issue in another project led to me realize that ILMerge was the root cause of the problem. The Code Analysis tool cannot determine what code is yours or not within the merged assembly. The solution is to run the code analysis on the unmerged assembly.

In fact - jessehouwing previously resolved this issue for another user in this question: In Visual Studio 2013 how do I limit code analysis to my code and not to referenced assemblies?

Community
  • 1
  • 1
Kyle
  • 94
  • 5