Open lucastheisen opened 3 years ago
Is there any update on this issue? Would appreciate if any update can be provided regarding this. Is this issue fixed but the NuGet package isn't pushed yet as this seem to be open since 2021?
I am also interested in an update on this issue. we have many false positives in our app that we would like cleaned up with the fix to this issue.
Any update on this issue is appreciated. Thank you!
I don't believe any fix is currently planned here. The current CA2000 behavior was largely derived from legacy FxCop. We've had a hard time making any alterations to the behavior without causing regressions (performance or functional) for some of our larger enterprise customers. For better or worse, the request we kept getting is essentially "we understand it has limitations, but those limitations are predictable so please don't make any changes to them". It should be possible to implement a targeted DiagnosticSuppressor
specific to your project which understands how to automatically suppress CA2000 when it gets reported on one of your known fluent APIs.
Analyzer
Diagnostic ID: CA2000:
Dispose objects before losing scope
Analyzer source
SDK: Built-in CA analyzers in .NET 5 SDK or later
Version: SDK 5.0.401
Describe the bug
I created a
Stream
wrapper for addingIProgress
support. It has fluent style registration for the reporters:However, when consumed using the fluent approach:
It will trigger this finding because it is not detecting that the stream returned by
.Add[Read|Write]ProgressReporter
is the same object.I can work around it by separating into two commands:
But this has other downsides. I could ignore the warning at every consumption site, but that also has a huge downside to usability for consumers.
Steps To Reproduce
this
Expected behavior
No warning
Actual behavior
CA2000
Additional context