I started messing around with FXCop against some of my assemblies and noticed something interesting that I’m trying to wrap my head around.
“Types that declare disposable members
should also implement IDisposable. If
the type does not own any unmanaged
resources, do not implement a
finalizer on it.”
I have my own class that contains some controls that in turn inherit from System.Web.UI.WebControls.Button. It’s not complaining about my inherited buttons, but the class that wraps them is.
What’s the impact or danger here?
What’s the nature of the class that contains the buttons?
Normally I would only expect a class that’s a composite control to have other controls as members. Such a class would normally inherit directly or indirectly from System.Web.UI.CompositeControl or System.Web.UI.WebControl, and the controls you have as members should be added to the Controls collection.
Doing so will ensure they are disposed properly and should get rid of the FxCop warning.
Post more details of the class in question if this doesn’t help.