Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Tuesday, February 16, 2016 5:49 PM
I have a solution that contains a 3rd party .VB source file that I'm not allowed to change. That file is generating hundreds of Code Analysis messages. How do I tell Code Analysis to skip the entire file?
Thanks
Win7
VS2013
VB.NET
All replies (7)
Monday, February 22, 2016 10:56 AM âś…Answered
Hi j_u_s_t_i_n,
Maybe you could share us more information about the real "code analyze" in your side, do you use the real code analyze tool in the VS2013?
If you use the above tool for a project, we often use the GlobalSuppressions file:
But you said that you use the runsettings file, is it related to the unit test project? You want to Exclude assembly from code coverage, am I right?
Maybe you could get useful information from the follow documents:
https://msdn.microsoft.com/en-us/library/jj635153.aspx
Best Regards,
Jack
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.
Tuesday, February 16, 2016 6:19 PM | 1 vote
[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]See this msdn link: https://msdn.microsoft.com/en-US/library/ms244717%28v=vs.120%29.aspx
And this msdn on ExcludeFromCodeCoverage: https://msdn.microsoft.com/en-us/library/dd537628%28v=vs.120%29.aspx
Thursday, February 18, 2016 2:17 AM
My attempt at trying that failed. It built fine, but it didn't affect the number of Code Analysis warnings.
Here's the top of the module:
Option Strict Off
Option Explicit On
Imports System.Diagnostics.CodeAnalysis
<ExcludeFromCodeCoverage()>
Module ModuleNameHere
...
Thursday, February 18, 2016 7:46 AM
How about trying with the complete NameSpace?
Also and maybe firstly: are your running VS2013 Premium or Ultimate? it seems exclude is not available for other versions....
Also reading the msdn it says everything except Module don't know if this intentional or not....: "Add the attribute System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage to any of the following code elements: class, struct, method, property, property setter or getter, event"
Have you tried to insert ExludeFromCodeCoverage at the top of a method to see if it is really excluded?
There is another way with a .runsettings file that has xml code specifying the CodeAnalysis run.
Have you looked at this msdn for that method of controlling CA? (https://msdn.microsoft.com/en-us/library/jj159530%28v=vs.120%29.aspx)
It seems that the runsettings method is more powerful and doesn't require modifying the source file.
Thursday, February 18, 2016 8:40 PM
The .runsettings method looks perfect, but I can't get it to work. I specified the module name in this section.
<!-- Match the path of the source files in which each method is defined: -->
<Sources>
<Exclude>
Under the Test menu, I set it to use my .runsettings file, but it doesn't seem to have any effect.
Wednesday, March 2, 2016 2:05 AM
Let me start by saying, I'm completely new to Code Analysis.
Yes, I have the settings in your pic. When I right-click on the message in the Code Analysis view, Suppress Message => In Suppression File, I get this error: The selected message could not be suppressed.
The source file I want to ignore is a horrendous 3rd party file that I'm not really authorized to change.
Wednesday, March 2, 2016 8:38 AM
Hi j_u_s_t_i_n,
>>I get this error: The selected message could not be suppressed. The source file I want to ignore is a horrendous 3rd party file that I'm not really authorized to change.
Maybe you could test it in other VS machine, if it still has this issue, I think that it would have a limitation for this 3rd party file.
>>Suppress Message => In Suppression File
But it really is the correct step for us to suppress message for code analyze warnings like the following screen shot. Of course, we could also suppress message in the source file like the screen shot 2.
If the above two ways have the same issue in your side, maybe it really has a limitation for this 3rd party file.
Best Regards,
Jack
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.