Closed BADF00D closed 7 years ago
All three MemoryStreams should be marked as not disposed.
using System;
using System.IO;
namespace DisFixerTest.ObjectCreation {
class ObjectCreationInUsingBlock {
public ObjectCreationInUsingBlock() {
using(var memStream = new MemoryStream())
{
new MemoryStream(); //this should be marked as not disposed
var tmp = new MemoryStream(); //this should be marked as not disposed
var tmp2 = Create();//this should be marked as not disposed
}
}
private IDisposable Create() {
return new MemoryStream();
}
}
}
All these MemoryStreamCreations inside the using block should be marked as not disposed, like the second example shows.