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

Receive LocalVariableNotDiposed when field is not disposed #122

Closed BADF00D closed 5 years ago

BADF00D commented 5 years ago

Prerequisites

Description

When I assign a field/property via await Expression, I get a local variable not disposed, but I should get an field not disposed.

Source Code

namespace SomeNamespace
{
    public class SomeClass
    {
        private MemoryStream _mem;

        public async Task Do()
        {
            _mem = await Create();
        }
        public Task<MemoryStream> Create()
        {
            return Task.FromResult(new MemoryStream());
        }
    }
}

Screenshot

image

BADF00D commented 5 years ago

Version with property.

namespace SomeNamespace
{
    public class SomeClass
    {
        private MemoryStream Mem { get; set; }

        public async Task Do()
        {
            Mem = await Create();
        }
        public Task<MemoryStream> Create()
        {
            return Task.FromResult(new MemoryStream());
        }
    }
}

Screenshot: image