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

Await using declarations in top scope is not supported #2353

Closed
yyjdelete opened this issue Mar 24, 2021 · 0 comments
Closed

Await using declarations in top scope is not supported #2353

yyjdelete opened this issue Mar 24, 2021 · 0 comments
Labels
Bug Decompiler The decompiler engine itself
Milestone

Comments

@yyjdelete
Copy link
Contributor

Input code

    public async Task XXX1(IAsyncDisposable a)
    {
        await using var b = a;
        a = null;
        Console.WriteLine(b);
    }
    public async Task XXX3(IAsyncDisposable a)
    {
        await using (var b = a)
        {
            a = null;
            Console.WriteLine(b);
        }
    }

Erroneous output

Seems roslyn will produce different IL for them, and the first one will not be recognized as await using.

public async Task XXX1(IAsyncDisposable a)
{
	IAsyncDisposable b = a;
	object obj = null;
	int num = 0;
	try
	{
		a = null;
		Console.WriteLine(b);
		num = 1;
	}
	catch (object obj2)
	{
		obj = obj2;
	}
	if (b != null)
	{
		await b.DisposeAsync();
	}
	object obj3 = obj;
	if (obj3 != null)
	{
		ExceptionDispatchInfo.Capture((obj3 as Exception) ?? throw obj3).Throw();
	}
	if (num != 1)
	{
	}
}

public async Task XXX3(IAsyncDisposable a)
{
	await using IAsyncDisposable b = a;
	a = null;
	Console.WriteLine(b);
}

Details

  • Product in use: ILSpy
  • Version in use: 7.0.0.6433-preview3
@yyjdelete yyjdelete added Bug Decompiler The decompiler engine itself labels Mar 24, 2021
@siegfriedpammer siegfriedpammer added this to the v7.0-rc milestone Mar 28, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 7, 2021
ElektroKill added a commit to dnSpyEx/ILSpy that referenced this issue Aug 11, 2021
… support for rethrow in async exception handlers, fix await catch/finally patterns for complex methods.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Decompiler The decompiler engine itself
Projects
None yet
Development

No branches or pull requests

2 participants