Disable a warning

Is there any way to disable a specific warning. For example, in one of my classes are re-implement System.ICloneable.Clone. After doing so I now get a warning that states, "'System.ICloneable.Clone' from 'implements System.ICloneable' is already implemented by the base class 'XXX'. Re-implementation of function assumed." Is there any way to remove this warning from the Error List?

Thanks,
Lance

[409 byte] By [ljlevend] at [2008-2-4]
# 1
Short of hand-editing the .vbproj file, no (there is no way to do it through the IDE).

<NoWarn>42015,42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>

If you do this, please be careful as this is indeed a valid warning. Consider the following code snippet:

Module Module1
Sub Main()
Dim b As New Base
Dim d As New Derived
Dim bd As Base = TryCast(d, Base)
Dim bc As Object = d.Clone
Dim bdc As Object = bd.Clone
End Sub

Public Class Base
Implements ICloneable

Public
Function Clone() As Object Implements System.ICloneable.Clone
Return New Base
End Function
End Class

Public Class Derived
Inherits Base
Implements ICloneable

Public Shadows Function Clone() As Object Implements System.ICloneable.Clone
Return New Derived
End Function
End Class

End Module

What type of object would you expect bdc to be after running this application?

(Hint - it will *not* be of type Derived, even though the object bd is referencing is of type Derived)

A better pattern is for the base class's ICloneable.Clone method to call a protected overridable CloneInternal method that does the real work.

Best regards,
Johan Stenberg

JohanStenberg at 2007-9-8 > top of Msdn Tech,Visual Basic,Visual Basic IDE...
# 2
Hi Johan,

I have a similar problem, except it's a warning to do with CLS-compliancy due to using a Docking control (by Weifen Luo) which is not CLS-compliant. So I get:

frmX is not CLS-Compliant because it derives from 'DockContent', which is not CLS-compliant.

I don't think there's anything I can do to fix the code to make it CLS-compliant, so really I just want to disable that specific warning.

So I edited the .vbproj to add Error ID 40026 (as per: ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_vbalr/html/debcd5e4-75e7-4b14-a6cc-18f1009fe52c.htm
) to the NoWarn section but unfortunately the warning is still showing up after saving the vbproj, reloading and rebuilding...

(I know it's possible to do this by editing the AssemblyInfo by marking the CLSCompliant attribute as false, but I was wondering if it was possible to just suppress the warning?)

Any ideas?

weirdbeardmt at 2007-9-8 > top of Msdn Tech,Visual Basic,Visual Basic IDE...