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

DisplayClass not removed #1858

Closed
greenozon opened this issue Dec 10, 2019 · 2 comments
Closed

DisplayClass not removed #1858

greenozon opened this issue Dec 10, 2019 · 2 comments
Labels
Bug C# Decompiler The decompiler engine itself

Comments

@greenozon
Copy link

ILSpy version 6.0.0.5450-preview1

goto method DirectoryCopy()
you'll see something like

<>c__DisplayClass2_2 CS$<>8__locals0 = default(<>c__DisplayClass2_2);
....

https://www.sendspace.com/file/ol1dwq

@greenozon
Copy link
Author

also method
private async void Check()

@siegfriedpammer siegfriedpammer added Bug C# Decompiler The decompiler engine itself labels Mar 3, 2020
@siegfriedpammer siegfriedpammer modified the milestone: v6.0-preview4 May 15, 2020
@dgrunwald
Copy link
Member

dgrunwald commented Aug 8, 2020

Method DirectoryCopy is broken; there are code paths (e.g. sourceDirName.Length > 260) where the compiler-generated display class variable is accessed without ever being initialized --> compiler-generated code throws NullReferenceException.
That should never happen for compiler-generated display class variables. ILSpy needs to emit code that preserves the potential NullReferenceException, which means it needs to keep the display class around.
Possible a bug in whichever compiler was used to build this assembly?

Check() looks like something that we could fix in our transform. (it already decompiles cleanly if "Always inline local variables" is enabled)

ElektroKill added a commit to dnSpyEx/ILSpy that referenced this issue Aug 11, 2021
…tain copies of display-class variables.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug C# Decompiler The decompiler engine itself
Projects
None yet
Development

No branches or pull requests

3 participants