-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Vs 2015 C# Anonymouse & Lambda Methods decompile bugg Fixing #637
Comments
Why not send a pull request? |
This is a known problem of ILSpy, see issue #502, nobody officially working on supporting it though, I think most of their work is on the new decompiler branch If you are going to do work on VS2015/Roslyn please make sure that you don't break decompilation of older assemblies, people will still need to decompile code from before VS2015/Roslyn. I've been myself hotfixing things here and there to be able to read VS 2015 code, you can see it over at my fork - its far from complete, but it helps I also made a fix to the delegate decompiler, which is different from yours, so you may want to compare your solution to this commit to check how much the results differ. (And yes I'm planning to make a pull request and push back my fixes if the ilspy maintainers are interested, but I still want to get some more fixes working first.) |
Hi |
I have some experimental ideas on that branch, but I'm no longer working on them. |
Note: dnSpy is a fork of ILSpy. |
I wrote this code to work around the fact that none of the current decompilers handles Roslyn code generation correctly,First I wrote to code for dnSpy, but because I'm too familiar to using ILSpy I applied the patch to it, I went to fixed the code generation for (async , await) methods but, It was a bit harder to understand how the code generation is done, in order to reverse it , so I "let it go". |
The newdecompiler branch was merged to master recently. |
[Solution is Attached]
I noticted that vs 2015 C# compiler changed the way that they build the anonymouse methods, which lead to that non of any decompiler decompiles them okey, for Example
It's Decompiled to :
So I tried hard to fix it, by:
1- remove unnececary checking for the delegate init.
2- remove all decompiler generated variables (arg_27_0,...) and replace their usage with their init Values.
I attached a Picture that demonstate the issue and the fixed version.
I noticed another buggy thing in the picture, i applied the patch on ILSpy2.2 and dnSpy1.1.1
the condition [where tag != 0] in the Linq Expression in ILSpy2.2 became
[where tag > 0] but in dnSpy It decompiled ok.
My patch is :
1- modifying
ilspy2.2src\ICSharpCode.Decompiler\Ast\Transforms\DelegateConstruction.cs:HandleAnonymousMethod
Fist four Lines of HandleAnonymousMethod Function I repalced them with
2- Define new IAstTransform [VS2015Anon] and add it to the PipeLine after DelegateConstruction
3- VS2015AnonTransform Code
The text was updated successfully, but these errors were encountered: