IMeterFactory.Create triggers false positive on IDisposable analysis #6912
Labels
Area-Microsoft.CodeAnalysis.NetAnalyzers
False_Negative
No diagnostic is reported for a problematic case
help wanted
The issue is up-for-grabs, and can be claimed by commenting
Analyzer
Diagnostic ID: CA2000:
Dispose objects before losing scope
Analyzer source
SDK: Built-in CA analyzers in .NET 8 SDK or later
Describe the bug
.NET 8 adds a new API IMeterFactory.Create which returns instances of type
Meter
. Although the returned Meter object implements IDisposable, the IMeterFactory retains responsibility for invoking Dispose() when the factory is disposed. However the analyzer believes that the caller has the responsibility to call Dispose() and triggers a warning incorrectly.Steps To Reproduce
Expected behavior
No warning CA2000
Actual behavior
Warning CA2000 is generated by the build
The text was updated successfully, but these errors were encountered: