I was wondering if there was an addon that could detect and create a warning (or error) if it detects the creation of an IDisposable object that is never disposed.
I looked through Resharper’s docs but didn’t see anything that looked like what I was wanting.
edit – To be more specific, I should have said a Local variable that implements IDisposable, but is never Disposed.
For instance, a Pen is created in a paint method, but not disposed with after the drawing is done.
This has been turned on and off a few times in FxCop. Its current state is on again, at least for the version that comes with VS2010. It generates CA2000 on this code:
Beware that the reliability of this warning isn’t great, it is a difficult problem to solve.