IDISP003: False positive in cycle when IDisposable is declared outside the loop
See original GitHub issuePiece
class SomeClass
{
void SomeMethod()
{
Stream stream;
foreach (var i in Enumerable.Range(int.MinValue, int.MaxValue))
{
using (stream = new MemoryStream())
{
// Do work.
}
}
}
}
Screenshot
Interactive verification
Issue Analytics
- State:
- Created 4 years ago
- Comments:7
Top Results From Across the Web
False-positive: Fix this implementation of IDisposable to ...
If your class contains a finalizer, i.e. destructor, the rule checks if its content is a single invocation of Dispose(false) .
Read more >CA1063: Implement IDisposable correctly (code analysis)
Learn about code analysis rule CA1063: Implement IDisposable ... The false positives are due to a breaking change in the C# compiler.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for reporting!
https://www.nuget.org/packages/IDisposableAnalyzers/3.4.10