Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio or Resharper extension to decompile code

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.

like image 760
LiquaFoo Avatar asked Jan 15 '13 23:01

LiquaFoo


4 Answers

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.

like image 57
Joe Sewell Avatar answered Sep 21 '22 09:09

Joe Sewell


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.

like image 21
AakashM Avatar answered Sep 23 '22 09:09

AakashM


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.

enter image description here

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

enter image description here

like image 12
Timothy Gonzalez Avatar answered Sep 23 '22 09:09

Timothy Gonzalez


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.

like image 6
Tommaso Belluzzo Avatar answered Sep 22 '22 09:09

Tommaso Belluzzo