Is there any C# decompiler that can show the coding almost identically to how it was written?

喜你入骨 提交于 2019-12-25 19:31:03

问题


I've been using reflector to decompile a couple simple c# apps but I notice that though code is being decompiled, I still can't see things as they were written on VS. I think this is the way it is as the compiler replaces human instructions by machine code. However I thought I would give it a try and ask it on here. Maybe there is a decompiler that can decompile and show the coding almost identically to the original code.


回答1:


That is impossible, since there are lots of ways to get the same IL from different code. For example, there is no way to know if an extension method was called fluent-style vs explicit on the declaring type. There is no way to know if LINQ vs regular code was used. All manner of implicit operations may or may not be there. Removed code may or may not have been there. Many primitives (including enums) up-to-and-including 4 bytes are indistinguishable once they are IL.

If you want the actual code, legally obtain the original code.




回答2:


Existing .Net decompilers generally decompile to the best of their ability.

You appear to be asking for variable names and line formatting, which for obvious reasons are not compiled to IL.




回答3:


There are several. I currently use JustDecompile found here http://www.telerik.com/products/decompiler.aspx?utm_source=twitter&utm_medium=sm&utm_campaign=ad

[Edit]
An alternative is .NET Reflector found here: http://www.reflector.net/
I believe there is a free version of it, but didn't take time to look.




回答4:


Basically, no. There are often many ways to arrive at the same IL code, and there's no way at all for a decompiler to know which was used.




回答5:


No, nor should there ever be. Things like comments and unreachable code would just add bloat with absolutely zero benefit. The very best you can ever do is approximate the compiled code.



来源:https://stackoverflow.com/questions/8379204/is-there-any-c-sharp-decompiler-that-can-show-the-coding-almost-identically-to-h

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!