BADF00D / DisposableFixer

This is a Visual Studio Extension and NuGet package that should identify and fix problems as memleaks while using IDisposables.
Other
35 stars 7 forks source link

Add support to detect hidden disposable in async code #128

Closed BADF00D closed 4 years ago

BADF00D commented 5 years ago

Prerequisites

Description

If returning Task and object is an IDisposable, there should be an warning for hidden disposables.

Source Code

using System.IO;
using System.Threading;
using System.Threading.Tasks;

namespace DisposableFixer.Test
{
    internal class MyClass
    {
        public async Task<object> Create(CancellationToken cancel)
        {
            var mem = new MemoryStream();
            await Task.Delay(1, cancel);
            return mem;
        }
    }
}

Screenshot

image