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.

IDISP0013 should not warn when not using the disposable

See original GitHub issue
namespace RoslynSandbox
{
    using System.IO;
    using System.Threading.Tasks;

    public class Foo
    {
        public static Task FooAsync()
        {
            using (var stream = File.OpenRead(string.Empty))
            {
                return Task.Delay(0);
            }
        }
    }
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
AArnottcommented, May 9, 2018

We frequently use the using block for its try/finally ability where the using expression doesn’t directly get used by the code within the block.

1reaction
JohanLarssoncommented, May 9, 2018

Not sure how to write this rule as it can be:

using (Lock())
{
    return Task.Delay(0);
}

Where we probably want to await.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Easily Tell if Your Disposable Vape Is Almost Empty
That's rare with one-use disposables, but if your disposable is rechargeable, make sure you stop using it when the vapor starts to diminish...
Read more >
Are Disposable Vapes Safe?
The aerosol produced by disposable vapes that contain more nicotine than the legal limit (or other chemicals) can be harmful when inhaled over ......
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