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

Async methods returning ValueTask are not decompiled #1651

Closed
jasonmeisel opened this issue Aug 20, 2019 · 4 comments · Fixed by #1652
Closed

Async methods returning ValueTask are not decompiled #1651

jasonmeisel opened this issue Aug 20, 2019 · 4 comments · Fixed by #1652
Labels
Async Bug C# Decompiler The decompiler engine itself

Comments

@jasonmeisel
Copy link

When I right click an assembly and "save code" to create a project, it doesn't output the generated classes and methods that async methods reference.

I can see the generated code if I turn on "show all types and members", but it doesn't save the code to files. I get the same result using the ilspycmd utility.

Is it possible to output the generated code as well, so it generates a functional csproj?

@siegfriedpammer
Copy link
Member

Actually the async state machine should be transformed back into a compilable method. Would you be able to provide the assembly, so that we can take a look and fix the problem? Thank you very much!

@jasonmeisel
Copy link
Author

I attempted to create a simple repro assembly, but in that assembly you were correct - it decompiled into an async method! This was the case unless I switched the C# version to 4.0 (pre-async), and then it output the generated code. In fact, then it also saved the generated code using "save code" 😁

The assembly I'm trying to decompile is System.Private.CoreLib.dll from https://github.com/dotnet/coreclr/tree/master/src/System.Private.CoreLib. In it, System.IO.FileStream.DisposeAsyncCore was having the issue (among others).

Luckily, switching the version to 4.0 on that assembly also fixes the issue! So there's definitely a bug in that it's not decompiling back to async correctly (and references the generated code it doesn't actually output) when set to 7.0 or 8.0 with that assembly. However, this work-around works for me 👍

@siegfriedpammer siegfriedpammer changed the title Save async/generated code? Async methods returning ValueTask are not decompiled Aug 20, 2019
@siegfriedpammer siegfriedpammer added Async Bug C# Decompiler The decompiler engine itself labels Aug 20, 2019
@siegfriedpammer
Copy link
Member

Example: System.Private.CoreLib.dll from .NET Core 3.0 preview 7 or later.
Method: System.IO.FileStream.DisposeAsyncCore

@dgrunwald
Copy link
Member

ValueTask depends on the "Generalized async return types" C# 7 feature, which ILSpy does not implement yet. See language support status: #829

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Async Bug C# Decompiler The decompiler engine itself
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants