Can Visual Studio warn me when I forget to dispose an IDisposable object?

Visual Studio, by itself does not have this feature, but with CodeRush you can have design time warnings and refactorings to insert using blocks where needed.


If you turn on FxCop Design rules it will tell you when you don't implement IDisposable and you have members which implement IDisposable, like this:

class Program
{
    private DataTable NotDisposed;

    public Program()
    {
        NotDisposed = new DataTable();
    }
    static void Main()
    {
    }
}