Home > Code Analysis > Warning code issues for the IDisposable pattern

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:

CodeRush Class should implement IDisposable

How to 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:

CodeRush Fields should be disposed

How to fix:

CodeRush Dispose Fields preview

—–
Products: CodeRush Pro
Versions: 12.1 and up
VS IDEs: 2008 and up
Updated: Sep/14/2012
ID: C185

Similar Posts: