Skip to content

CA2000 needs to be emitted when type has Dispose method #3305

@lostmsu

Description

@lostmsu

Analyzer package

Microsoft.CodeAnalysis.FxCopAnalyzers

Package Version

v2.9.8 (Latest)

Diagnostic ID

CA2000

Repro steps

ref struct Disposable { public void Dispose(){} }
void Do(){ var x = new Disposable(); }

Expected behavior

CA2000 for x

Actual behavior

No CA2000 for x

Notes

C# 8.0 added ability for using block and statement to call Dispose method by name when the type does not implement IDisposable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugThe product is not behaving according to its current intended designhelp wantedThe issue is up-for-grabs, and can be claimed by commenting

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions