Skip to content

Gendarme.Rules.Design.TypesWithDisposableFieldsShouldBeDisposableRule(2.10)

Sebastien Pouliot edited this page Jan 22, 2011 · 3 revisions

TypesWithDisposableFieldsShouldBeDisposableRule

Assembly: Gendarme.Rules.Design
Version: 2.10

Description

This rule will fire if a type contains disposable fields but does not implement System.IDisposable.

Examples

Bad examples:

class DoesNotImplementIDisposable {
    IDisposable field;
}
class AbstractDispose : IDisposable {
    IDisposable field;
    // the field should be disposed in the type that declares it
    public abstract void Dispose ();
}

Good example:

class Dispose : IDisposable {
    IDisposable field;
    public void Dispose ()
    {
        field.Dispose ();
    }
}
Clone this wiki locally