Skip to content

Gendarme.Rules.Design.DisposableTypesShouldHaveFinalizerRule(git)

Sebastien Pouliot edited this page Mar 2, 2011 · 1 revision

DisposableTypesShouldHaveFinalizerRule

Assembly: Gendarme.Rules.Design
Version: git

Description

This rule will fire for types which implement System.IDisposable, contain native fields such as System.IntPtr, System.UIntPtr, and System.Runtime.InteropServices.HandleRef, but do not define a finalizer.

Examples

Bad example:

class NoFinalizer {
    IntPtr field;
}

Good example:

class HasFinalizer {
    IntPtr field;
    ~HasFinalizer ()
    {
        UnmanagedFree (field);
    }
}

Source code

You can browse the latest source code of this rule on github.com

Clone this wiki locally