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

Disposables with same name in different action are not correctly marked in version 0.22 #45

Closed dscopra closed 7 years ago

dscopra commented 7 years ago
using System;
using System.IO;

namespace Disposeables {
    class Program {
        static void Main(string[] args) {
            Func<MemoryStream> openStream = () => new MemoryStream();
            Action action = () => {
                var stream = CreateDisposable(); //this is not disposed
            };
            Action action2 = () => {
                var stream = CreateDisposable();
                stream.Dispose();
            };
        }

        private static MemoryStream CreateDisposable() {
            return new MemoryStream();
        }
    }
}

image