Disposable field should be disposed

TypeName DisposableFieldShouldBeDisposed
CheckId BC1003
Category Usage
Breaking NonBreaking

This rule is meant to replace the Microsoft-provided DisposableFieldsShouldBeDisposed rule. This rule differs from the similar Microsoft-provided rule in two important ways:
  1. It is more aggressive when identifying disposable fields. (See https://connect.microsoft.com/VisualStudio/feedback/details/485291/typesthatowndisposablefieldsshouldbedisposable-rule-ca1001-is-too-permissive for details.)
  2. It does not exclude an IComponent field from consideration unless there is a disposed IContainer field in the class. (N.B.: The rule does not check whether the IComponent field is added to a disposed IContainer.)
  3. It allows configuration of a list of methods which are used as disposition helpers. Passing a field value as any argument (including as an argument of a parameter array) of one of these methods will be considered equivalent to invoking that field's Dispose() method directly.

See the documentation for the DisposableFieldsShouldBeDisposed rule for problem and fix details.

Last edited Feb 25, 2010 at 2:38 AM by calinoiu, version 3


No comments yet.