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

Dispose after last usage introduces error #121

Closed BADF00D closed 5 years ago

BADF00D commented 5 years ago

Prerequisites

Description

When using CodeFix "Dispose after last usage", the dispose call is introduced before the last usage.

Source Code

namespace Test
{
    public class DisposeAfterLastUsageDoesNotWork
    {
        public async Task Do()
        {
            var fac = new MemoryStream();
            var bytesRead = await fac.ReadAsync(new byte[10], 0, 10);
            Console.WriteLine(bytesRead);
        }
    }
}

Screenshot

upkWLot4PF