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

Inkorrekt error message when using await #86

Closed BADF00D closed 6 years ago

BADF00D commented 6 years ago

Prerequisites

Description

When awaiting a IDisposable that is not disposed, the error message is "DF0001 - Undisposed anonymous object." but in this case it is a undisposed local variable. This error only occures when assigning result of await to an local variable declared before.

Source Code

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

namespace DisFixerTest.Issue
{
    internal class Program
    {
        public async void Test()
        {
            MemoryStream mem;
            mem = await Create();
        }

        private Task<MemoryStream> Create()
        {
            return Task.FromResult(new MemoryStream());
        }
    }
}

Screenshot

BADF00D commented 6 years ago

Will be part of next release (probably 1.0.1)