Skip to content

Latest commit

 

History

History
68 lines (52 loc) · 1.45 KB

IDISP022.md

File metadata and controls

68 lines (52 loc) · 1.45 KB

IDISP022

Call this.Dispose(false)

Topic Value
Id IDISP022
Severity Warning
Enabled True
Category IDisposableAnalyzers.Correctness
Code FinalizerAnalyzer

Description

Call this.Dispose(false).

Motivation

public class C : IDisposable
{
    ~C()
    {
        this.Dispose(true); // should be false here.
    }

    public void Dispose()
    {
        this.Dispose(true);
    }

    private void Dispose(bool disposing)
    {
        ...
    }
}

How to fix violations

ADD HOW TO FIX VIOLATIONS HERE

Configure severity

Via ruleset file.

Configure the severity per project, for more info see MSDN.

Via #pragma directive.

#pragma warning disable IDISP022 // Call this.Dispose(false)
Code violating the rule here
#pragma warning restore IDISP022 // Call this.Dispose(false)

Or put this at the top of the file to disable all instances.

#pragma warning disable IDISP022 // Call this.Dispose(false)

Via attribute [SuppressMessage].

[System.Diagnostics.CodeAnalysis.SuppressMessage("IDisposableAnalyzers.Correctness", 
    "IDISP022:Call this.Dispose(false)", 
    Justification = "Reason...")]