| TypeName | DisposableFieldNotDisposedAnalyzer |
| Check Id | CC0033 |
| Category | Usage |
| Severity | Warning |
A type has a disposable field (a field that implements IDisposable). This field
is being assigned on the type construction by constructing a new object. It is very
likely that the enclosing type owns the object and should then dispose it,
implementing IDisposible itself (if it does not yet implement yet).
Assuming class D implements IDisposable:
class TypeName
{
private D field = new D();
}A code fix will be presented to you that will transform the code, it will implement
IDisposable if the type has not implemented it yet, and add a call do Dispose
on the field.
class TypeName : System.IDisposable
{
private D field = new D();
public void Dispose()
{
field.Dispose();
}
}
SuppressFinalizeTBD