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 ContextDisposable to tracking types #153

Open BADF00D opened 3 years ago

BADF00D commented 3 years ago

Prerequisites

Description

When a disposable is added to a ContextDisposable, it should no longer be marked as undisposed.

Source Code

public class Some : IDisposable

    {
        public readonly System.IDisposable Disposable = new System.IO.MemoryStream();
        private readonly System.IDisposable _contextDisposable;

        public Some()
        {
            _contextDisposable = new System.Reactive.Disposables.ContextDisposable(
                System.Threading.SynchronizationContext.Current, Disposable);
        }

        public void Dispose()
        {
            _contextDisposable?.Dispose();
        }
    }

Screenshot

image