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

this.Property.Dispose() is not recognized #89

Closed Khaos66 closed 6 years ago

Khaos66 commented 6 years ago

Prerequisites

Description

When a IDisposable-property is disposed with this.Property?.Dispose() this is not recognized and the DF0022 warning is generated for that property. The "this." prefix is mandatory by our convention. With VS 15.8.0: formating code (CTRL+E,CTRL+D) adds the "this." prefix automatically.

Source Code

   public class Dummy : IDisposable
    {
        public ManualResetEvent MRE { get; }
            = new ManualResetEvent(false);

        public void Dispose()
        {
            this.MRE?.Dispose();
        }
    }
BADF00D commented 6 years ago

I could verify the problem, thanks for reporting!

BADF00D commented 6 years ago

Will be part of release 1.1.1.