Skip to content

CA2000 - False positives #1404

Closed
Closed
@MrMikeJJ

Description

@MrMikeJJ

Analyzer package

Microsoft.CodeQuality.Analyzers

Analyzer

CA2000: Dispose Objects Before Losing Scope

Repro steps

  1. Follow https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2000-dispose-objects-before-losing-scope for example good code
    2a) Allow IDE0017 to be applied - Object initialization can be simplified - on the temporary object
    or
    2b) Add a catch statement
    or
    2c) Encapsulate the return object (unsure if this is a false positive or a real positive

Expected behavior

CA2000 not to be reported

Actual behavior

CA2000 is reported

Sample code file attached.
CA2000.txt

Since i think it is 2 (potentially 3) false positives, but all on the same rule, i didn't know if you would want me to report them grouped together, or as a separate report for each. Sorry if i shouldn't have grouped them.

thanks
Mike

(And thanks for Roslyn and the Analyzers - they are great :))

Metadata

Metadata

Assignees

Labels

BugThe product is not behaving according to its current intended designDataFlowFalse_PositiveA diagnostic is reported for non-problematic caseUrgency-Soon

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions