DotNetAnalyzers/IDisposableAnalyzers

IDISP004 doesn't warn when `Task<>.FromResult(disposable)` is returned by a method, but does when `new ValueTask<>(disposable)` is returned.)

JeremyMorton opened this issue · 1 comments

Can returning a disposable object as the result of a ValueTask<> not raise this. returning a disposable object as the result of a Task<> already doesn't raise it.

Ah, I rarely use ValueTask so support is still limited, thanks for the issue!

When reporting issues minimal sample code reproducing the bug saves time for me.
Ideally something minimal like:

public ValueTask<IDisposable> M()
{
    var disposable = new Disposable();
    return new ValueTask<IDisposable>(disposable);
}

Also you mean IDISP001 right?