Dave Hary

I have a questions about message suppression. Some message suppressions fail to supress when tagging the element, such as this one:

Code Block
<CODEANALYSIS.SUPPRESSMESSAGE(< FONT>

<CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")> _

Public Event ProofAborted(ByVal sender As Object, ByVal e As ProverEventArgs)

But work on the module level:

Code Block

<Module: codeanalysis.SuppressMessage("Microsoft.Design", _

"CA1034:NestedTypesShouldNotBeVisible", Scope:="type", _

Target:="isr.Provers.ProverBank+ProofAbortedEventHandler")>

But not on the assembly level:

Code Block

<Assembly: CodeAnalysis.SuppressMessage("Microsoft.Design", _

"CA1034:NestedTypesShouldNotBeVisible", Scope:="Assembly")>

Is these something incorrect in the first and third code segments

This is with FX Cop 1.36 beta 2.

Thanks

David



Re: Visual Studio Code Analysis and Code Metrics Message suppression question

Todd King - MSFT

Your first suppression is not working because you put it on an event rather than a nested type (I'm guessing you meant to put it on the ProofAbortedEventHandler type).

Your third suppression is not working because you set the scope to "Assembly" rather than "Type".

-Todd




Re: Visual Studio Code Analysis and Code Metrics Message suppression question

Dave Hary

On this first one, note that they event handler seems to be a figment of the compiler. This means that this exception cannot be handled other then by exclusion, right

On the third one, is there a way to extend the exclusion throught the assembly.

Also, I am confused as to the import of the Scope argument. If target points to a type, what information is the scope adding

Thanks

David





Re: Visual Studio Code Analysis and Code Metrics Message suppression question

Todd King - MSFT

Which version of FxCop are you using In 1.36 we tried to identify compiler and auto generated code and filter those targets out so FxCop would not fire on them. You're right if the ProofAbortedEventHandler type is auto generated then the only way you can suppress that message is through a module or assembly level attribute.

Upon looking at your 3rd suppression more closely I realize that you also left out the target property as well. To clarify there is no difference between a module level suppression and an assembly level suppression (unless you have a multi module assembly, these links can help explain what that is http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=2087203&SiteID=1 http://blogs.msdn.com/junfeng/archive/2005/02/12/371683.aspx). The assembly/module level suppression simply means you can suppress a particular target with out having to attach the suppression attribute to the target itself (this comes in handy for situations like you have with the auto generated ProofAbortedEventHandler type). There is no way to use a assembly/module level suppression to suppress all the instances of a particular rule in the assembly/module. Assembly/module level suppression attributes simply let you suppress a particular violation on a particular target without having to attach the attribute to the target itself.

To answer your other question I believe the scope argument makes it easier for us to identify the scope of the target defined in the attribute. I'm afraid our assembly/module level attributes are not very user friendly. We never really intended for users to be hand editing these suppression attributes, the prefered way to make these attributes is to let FxCop generate these suppression attributes for you.

-Todd






Re: Visual Studio Code Analysis and Code Metrics Message suppression question

Dave Hary

Todd,

I am using 1.36.

"I'm afraid our assembly/module level attributes are not very user friendly. We never really intended for users to be hand editing these suppression attributes, the prefered way to make these attributes is to let FxCop generate these suppression attributes for you."

The FxCop generated exception code as currently implemented needs some work. Hopefully you'll get to it soon.

Thanks

David





Re: Visual Studio Code Analysis and Code Metrics Message suppression question

Todd King - MSFT

Could you be more specific about exactly what is broken about the FxCop suppression attribute generation If you would like to file bugs against FxCop you can use the Microsoft connect page (https://connect.microsoft.com/VisualStudio).

-Todd






Re: Visual Studio Code Analysis and Code Metrics Message suppression question

Dave Hary

Todd,

That is not a bug but rather adding support for VB.Net for the Copy As... right click menu item, which you suggested my be coming for VS10 at the earliest.

David