All errors are at the moment the same: an IDisposable is not disposed. But there are different types of errors:
Anonymous objects:
public void AnonymousObjectFromObjectCreationNotDisposed(){
new MemoryStream();
}
public void AnonymousObjectFromMethodInvokationNotDisposed(){
Create();
}
private MemoryStream Create(){
return new MomoryStream();
}
Local objects:
public void LocalObjectFromObjectCreationNotDisposed(){
var memoryStream = new MemoryStream();
}
public void LocalObjectFromMethodInvokationNotDisposed(){
Create();
}
private MemoryStream Create(){
return new MemoryStream();
}
Fields:
private MemoryStream _undisposedField= new MemoryStream();
private MemoryStream _memoryStream;
public void Method(){
_memoryStream = new MemoryStream();
}
Properties:
private MemoryStream UndisposedProperty => new MemoryStream();
private MemoryStream _undisposedProperty ;
public void Method(){
_undisposedProperty = new MemoryStream();
}
All errors are at the moment the same: an IDisposable is not disposed. But there are different types of errors:
Anonymous objects:
Local objects:
Fields:
Properties: