question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IDISP003: False positive in cycle when IDisposable is declared outside the loop

See original GitHub issue

Piece

class SomeClass
    {
        void SomeMethod()
        {
            Stream stream;
            foreach (var i in Enumerable.Range(int.MinValue, int.MaxValue))
            {
                using (stream = new MemoryStream())
                {
                    // Do work.
                }
            }
        }
    }

Screenshot

Screenshot

Interactive verification

Proof

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
JohanLarssoncommented, Feb 17, 2020

Thanks for reporting!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found