FxCop CA2000 Warning in UserControls

Posted by esjr on Stack Overflow See other posts from Stack Overflow or by esjr
Published on 2010-06-10T23:27:05Z Indexed on 2010/06/10 23:33 UTC
Read the original article Hit count: 360

Filed under:
|
|

Running FxCop on a WebProject that contains a UserControl will result in a CA2000 Warning (Call System.IDisposable.Dispose on object) for every ServerControl (Label, TextBox,...) in that UserControl.

I understand why this would happen.
Replacing the 'offending' ServerControls with a PlaceHolder and then adding the Controls in code (Using...End Using) might be a way around that, but it is not always an option.
But, if they are not 'kosher' why have ServerControls you can drop in your ascx/aspx in the first place ?
Am I missing something ?

If, like in my case, you inherit a sizeable collection of fairly complex UserControls, do I now add every 'offending' Control to the GlobalSupperssions file (that's a lot of mind numbing right-clicking) ?
I do not want to suppress all CA2000 warnings since it makes perfect sense to fix them, but not in the case of ServerControls in UserControls.

© Stack Overflow or respective owner

Related posts about .NET

Related posts about fxcop