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 for tuple syntax #146

Open BADF00D opened 4 years ago

BADF00D commented 4 years ago

Prerequisites

Description

If an IDisposable is returned within TupleSyntax

Source Code

namespace Test
{
    class MyClass
    {
        public static (object, IDisposable) Create() => (new object(), new MemoryStream()); //should not yield warning

        public static (object, IDisposable) Create2()//should not yield warning
        {
            return (new object(), new MemoryStream());
        }

        public static (object, IDisposable) Create3()//should not yield warning
        {
            var mem = new MemoryStream();
            return (new object(), mem);
        }

        public MyClass()
        {
            var tpl = Create();//should yield a new warning about contained IDisposable
            var (item1, disposable) = Create();//should yield a warning
        }
    }
}

Screenshot

image