Why IlSpy doesn't show me AsyncStateMachine attribute

109 views Asked by At

If I'am selecting C# 4.0 it shows me the following code structure:

enter image description here

But when I'am selecting the C# 5.0 I see the following result: enter image description here

All checkboxes in Option -> Decompiler is checked: enter image description here

I'am expecting that it should be the same

1

There are 1 answers

1
Daniel On

The AsyncStateMachine attribute is automatically generated by the C# compiler. When you re-compile the "C# 5" version of the decompiled code, the compiler will add back the "missing" attributes.

Thus, ILSpy either shows the "C# 4" low-level view (what async/await compiles to), or the "C# 5" high-level view (what the original source code was). It would be a weird mixture between the two if you could see all attributes, but with the original async/await in the method body.