DotPeek: cannot see compiler-generated code

627 views Asked by At
  1. I have my library with one file that contains:
public class SomeClassWithAwait
{
    public async Task<int> MethodAsync()
    {
        return await Task.Run(() => 1 + 1);
    }
} 
  1. I turn on the feature "Show compiler-generated Code".
  2. I see changes in "Assembly Explorer", for example - state machine for await. But I cannot see changes in the file. I see only async\await as before when I turn on feature from step 2.

What I tried: close\open file, close\open dotPeek, rebuild library in release\debug mode.

Version dotPeek: 2020.2.2 build on 2020-09-09 (latest for today).

Any ideas?


UPDATED

About "Use sources from symbol files when available" feature: Still doesn't work for me, I got this:

public async Task<int> MethodAsync()
{
  int num = await Task.Run<int>((Func<int>) (() => 2));
  return num;
}

So, I still have async/await.

2

There are 2 answers

1
Thomas Weller On

Uncheck "Use sources from symbol files when available". Then close the window with the code and reopen it.

Use sources from symbol files

1
igiona On

Try to open the decompiled source: Right click on a class -> Decompiled Sources

dotPeek will show the await/async state machine instead of the "async/await" statements.

dotPeek Screenshot

See also the official documentation: https://www.jetbrains.com/help/decompiler/Navigation_and_Search__Navigate_from_Here__Decompiled_Code.html