Warning code issues for the IDisposable pattern
September 14th, 2012
Here are two code issues of the warning type that might be helpful in detecting objects of a class that have not undisposed. Such objects may lead to temporary unmanaged resource leaks.
Class should implement IDisposable
Cause:
This issue appears when a class contains fields that implement IDisposable, but the class itself does NOT implement IDisposable.
Sample:
How to fix:
- Apply the Implement IDisposable code fix.
Fields should be disposed
Cause:
This issue appears when fields implementing IDisposable are inside a class that also implements IDisposable, but those fields are NOT disposed.
Sample:
How to fix:
- Apply the Dispose Fields code fix: