COM Classes Exceptions

It looks like the interface created by .Net for COM classes does not seem to conform to the FxCop rules. Here are some of the exceptions I am getting for the simple class below:

Error, Certainty 95, forIdentifiersShouldNotContainUnderscores
"Remove all underscores from type '_ProverLinkEventArgs'."

Error, Certainty 95, forIdentifiersShouldHaveCorrectPrefix
"Prefix interface name '_ProverLinkEventArgs' with 'I'."

CriticalError, Certainty 95, forIdentifiersShouldNotHaveIncorrectSuffix
"Rename 'isr.IO.Provers.ProverLinkEventArgs+_ProverLinkEventArgs' so that it does not end in 'EventArgs'."

NestedTypesShouldNotBeVisible
Do not nest type 'isr.IO.Provers.ProverLinkEventArgs+_ProverLinkEventArgs'

Any idea for how to get around these exceptions?

David

<ComClass(ProverLinkEventArgs.ClassId, ProverLinkEventArgs.InterfaceId, ProverLinkEventArgs.EventsId),System.Runtime.InteropServices.ProgId("isr.IO.Provers.ProverLinkEventArgs"),Serializable(), System.Runtime.InteropServices.ComVisible(True)>PublicClass ProverLinkEventArgs

Inherits System.EventArgs

#Region " COM GUID Values "

' These GUID values provide the COM identity for this class
' and its COM interfaces. If you change them, existing
' clients will no longer be able to access the class.
PublicConst ClassIdAsString = "EBE49BA8-0440-4DD0-91AC-B1CE1DBE9F95"
PublicConst InterfaceIdAsString = "F7F21C4D-3115-4E92-882C-73CDEE1BB60F"
PublicConst EventsIdAsString = "8AACE1E6-B45C-4409-BDBB-B09A66D0A325"

#EndRegion

#Region " Constructors and Destructors "
''' <summary>Because this class is COM Creatable, we provide a default constructoreven though this is unlikely to be used.</summary>
'''--
PublicSubNew()
MyBase.New()
EndSub

''' <summary>Constructs this class.</summary>
''' <param name="sendingProverLink">A reference to the sending
''' prover link.</param>
''' <remarks>Use this constructor to instantiate this class and specify the event message, type and id.</remarks>
'''--
PublicSubNew(ByVal sendingProverLinkAs ProverLink)
' instantiate the base class
MyBase.New()
' now set the member properties.
_sendingProverLink = sendingProverLink
EndSub

''' <summary>Construct event arguments for the calling prover link with
''' a specific message.</summary>
''' <param name="sendingProverLink">A reference to the sending prover link.</param>
'''--
PublicSubNew(ByVal sendingProverLinkAs ProverLink,ByVal messageAsString)
' instantiate the base class
MyBase.New()
' now set the member properties.
_sendingProverLink = sendingProverLink
_statusMessage = message
EndSub

#EndRegion

#Region " Properties "
Private _sendingProverLinkAs ProverLink
''' <summary>This property specifies a reference to the sending prover link.</summary>
''' <value><c>SendingProverLink</c> is a ProverLink property.</value>
'''--
<System.Runtime.InteropServices.ComVisible(True)>PublicProperty SendingProverLink()As ProverLink
Get
Return _sendingProverLink
EndGet
Set(ByVal valueAs ProverLink)
_sendingProverLink = value
EndSet
EndProperty

Private _statusMessageAsString
''' <summary>Holds the status message of the event arguments.</summary>
''' <value><c>StatusMessage</c> is a ProverLink property.</value>
'''--
<System.Runtime.InteropServices.ComVisible(True)>PublicProperty StatusMessage()AsString
Get
Return _statusMessage
EndGet
Set(ByVal valueAsString)
_statusMessage = value
EndSet
EndProperty
#EndRegion

EndClass

[19598 byte] By [DavidHary] at [2008-2-19]
# 1
David, is this for v1.1 or v2.0 of the framework?

Michael

MichaelFanning-MS at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Visual Studio Code Analysis and Code Metrics...
# 2

It turns out that the VB compiler automatically generates COM interfaces for classes marked with Microsoft.VisualBasic.ComClassAttribute and it makes the interface a nested public type of the ComClass. You could work around this by not using ComClassAttribute, and declaring the ComVisible interface interface yourself, and then make the class implement the interface. Anyhow, this is noise since the compiler is generating it, and we'll fix it soon.

Thanks for reporting this,
Nick

NickGuerrera-MS at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Visual Studio Code Analysis and Code Metrics...
# 3
Michale, This is v 1.1 of the framework. David
DavidHary at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Visual Studio Code Analysis and Code Metrics...

Visual Studio Team System

Site Classified