Visual Studio or Resharper extension to decompile code

前提是你 提交于 2020-04-08 00:05:17

问题


Does anyone know of a Visual Studio extension that will decompile assemblies and allows you to view code in Visual Studio for a given class instead of having to leave VS and use ILSpy or other "external" reflection tools? I Know Resharper also has a reflection tool but it would be nice if you could kick it off within VS.


回答1:


I Know Resharper also has a reflection tool but it would be nice if you could kick it off within VS.

You can. With the cursor on an identifier, choose ReSharper | Navigate | Navigate To... (the keyboard shortcut in the VS scheme is Alt+`), and choose Decompiled Sources.

This uses the same decompilation engine as dotPeek, the standalone tool.

Note that within such a decompiled source, you must continue to use this same navigation method to follow definitions, as F12 or Ctrl+click will go back to the Object Browser.




回答2:


Newer versions of Visual Studio 2017 now include an experimental feature called navigation to decompiled sources. It requires you to explicitly enable it (and restart Visual Studio), but once you do, you can see decompiled source code for assemblies your code references.

For instance, if you put your caret (text cursor) over the name of a method in a method call and press F12 (by default) it will open a new tab right in the IDE that shows the decompiled source code for that method. Microsoft says this uses ILSpy behind the scenes, but this is a lot more convenient and doesn't require you installing anything new.




回答3:


Assuming the default short-cut keys where pressing F12 while a class/method is in-focus, you can set ReSharper to automatically decompile the reference. This ends up working great and it's as if the external assembly reference was like any other class in your source solution.

Example of source you are directed to when pressing F12 while focused on new HttpClient()




回答4:


I suggest you to use .NET Reflector which has a built-in VS integration for assemblies decompilation and is far, far better than Resharper. Have a look at this page for further knowledge.




回答5:


http://ilspy.net/ is free and Open Source. And has a plugin for Visual Studio.



来源:https://stackoverflow.com/questions/14348648/visual-studio-or-resharper-extension-to-decompile-code

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