Open
Description
Requires MMF-2568 to be implementable.
S3966 currently covers two main categories of double disposal.
1.
public void DisposedTwice()
{
var d = new Disposable();
d.Dispose();
d.Dispose(); // Noncompliant {{Resource 'd' has already been disposed explicitly or implicitly through a using statement. Please remove the redundant disposal.}}
}
public void Disposed_UsingStatement()
{
using (var d = new Disposable()) // Noncompliant {{Resource 'd = new Disposable()' has already been disposed explicitly or implicitly through a using statement. Please remove the redundant disposal.}}
{
d.Dispose();
}
}
The issue would be clearer for the user if in the case of Using
statement, we'd raise in d.Dispose
(as primary or secondary location).
Activity