Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FindAllReferences should handle Dispose referenced in using and foreach statements #28228

Closed
jcouv opened this issue Jun 30, 2018 · 3 comments
Closed
Labels
Area-IDE Feature - Async Streams Async Streams Feature - enhanced using Using pattern and declaration
Milestone

Comments

@jcouv
Copy link
Member

jcouv commented Jun 30, 2018

See comment in ComputeImplicitReferenceConflictsAsync: // TODO: handle Dispose for using statement and Add methods for collection initializers.

Note, if this done at the same time or after C# 8.0, FAR should also account for DisposeAsync in async-foreach and async-dispose statements.

Relates to #28230

@jcouv jcouv added the Area-IDE label Jun 30, 2018
@jcouv jcouv added this to the Unknown milestone Jun 30, 2018
@jcouv jcouv changed the title FindAllReferences should handle Dispose referenced in using statements FindAllReferences should handle Dispose referenced in using and foreach statements Jun 30, 2018
@jcouv
Copy link
Member Author

jcouv commented May 10, 2019

We should also handle the using declaration statement and the asynchronous variants of using statements and declarations.

I'm expecting Dispose and DisposeAsync to be referenced

using System;
using System.Threading.Tasks;

class C : IAsyncDisposable

{
    async Task M()
    {
        await using (var x = new C())
        {
        }

        await using var x2 = new C();
    }
    public ValueTask DisposeAsync() => throw new NotImplementedException();
}

class C2 : IDisposable
{
    void M()
    {
        using (var x = new C2())
        {
        }

        using var x2 = new C2();

    }
    public void Dispose() => throw new NotImplementedException();
}

@CyrusNajmabadi
Copy link
Member

@jcouv is there an api the compiler exposes to see what Dispose method a using binds to?

@CyrusNajmabadi
Copy link
Member

Dupe of #34107

@CyrusNajmabadi CyrusNajmabadi closed this as not planned Won't fix, can't repro, duplicate, stale Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Feature - Async Streams Async Streams Feature - enhanced using Using pattern and declaration
Projects
None yet
Development

No branches or pull requests

2 participants