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.
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.
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.
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()
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With