[x] I have verified that I am running the latest version of DisposableFixer: 1.1.0
[x] I have searched open and closed issues to ensure it has not already been reported
Description
An undisposed local variable within a func that is created as parameter in a MethodInvocation is not marked as disposed, when the result of the MethodInvocation is return directly. If the result is stoed in another local variable, the undisposed local variable is correctly marked as not disposed.
Source Code
Incorrect: Not marked as disposed:
namespace MyNamespace {
public class Dummy {
public object Create() {
return Do(
() => {
var memoryStream = new System.IO.MemoryStream();
return 0;
});
}
private IDisposable Do(Func<int> someFunc) {
return new MemoryStream();
}
}
}
Correct:
namespace MyNamespace {
public class Dummy {
public object Create() {
var x = Do(
() => {
var memoryStream = new System.IO.MemoryStream();
return 0;
});
return x;
}
private IDisposable Do(Func<int> someFunc) {
return new MemoryStream();
}
}
}
Prerequisites
Description
An undisposed local variable within a func that is created as parameter in a MethodInvocation is not marked as disposed, when the result of the MethodInvocation is return directly. If the result is stoed in another local variable, the undisposed local variable is correctly marked as not disposed.
Source Code
Incorrect: Not marked as disposed:
Correct: