0

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

limeniye
  • 31
  • 1
  • 6

1 Answers1

0

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.

Daniel
  • 15,944
  • 2
  • 54
  • 60
  • Thank you for your answer. I tried it with C# 10 and C# 11. I builded project and selected C# 10 at Il Spy. But attributes is hidden. If I understood you well it happens because has a compling from C# 11 to C# 4. But why? – limeniye Apr 30 '23 at 20:53