C# 用于反编译代码的 Visual Studio 或 Resharper 扩展

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14348648/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 11:32:11  来源:igfitidea点击:

Visual Studio or Resharper extension to decompile code

c#.netvisual-studioresharper

提问by Logan G.

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.

有谁知道可以反编译程序集并允许您在 Visual Studio 中查看给定类的代码的 Visual Studio 扩展,而不必离开 VS 并使用 ILSpy 或其他“外部”反射工具?我知道 Resharper 也有一个反射工具,但如果你能在 VS 中启动它会很好。

采纳答案by AakashM

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

我知道 Resharper 也有一个反射工具,但如果你能在 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.

你可以。将光标放在标识符上,选择ReSharper | Navigate | Navigate To...(VS 方案中的键盘快捷键是Alt+ `),然后选择Decompiled Sources

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

它使用与 dotPeek(独立工具)相同的反编译引擎。

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

请注意,在这样的反编译源中,您必须继续使用相同的导航方法来遵循定义,F12否则Ctrl+click 将返回对象浏览器。

回答by Tommaso Belluzzo

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

我建议您使用.NET Reflector,它具有用于程序集反编译的内置 VS 集成,并且比 Resharper 好得多。请查看此页面以获取更多知识。

回答by Andres

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

http://ilspy.net/是免费和开源的。并有一个 Visual Studio 插件。

回答by Timothy Gonzalez

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.

假设在类/方法处于焦点时按下 F12 的默认快捷键,您可以将 ReSharper 设置为自动反编译引用。这最终效果很好,就好像外部程序集引用与源解决方案中的任何其他类一样。

enter image description here

在此处输入图片说明

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

在聚焦时按 F12 时定向到的源示例 new HttpClient()

enter image description here

在此处输入图片说明

回答by Joe Sewell

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.

较新版本的 Visual Studio 2017 现在包括一项称为导航到反编译源的实验性功能。它要求您显式启用它(并重新启动 Visual Studio),但是一旦您这样做,您就可以看到您的代码引用的程序集的反编译源代码。

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.

例如,如果您将插入符号(文本光标)放在方法调用中的方法名称上并按下F12(默认情况下),它将在 IDE 中打开一个新选项卡,显示该方法的反编译源代码。微软表示这在幕后使用了 ILSpy,但这要方便得多,并且不需要你安装任何新的东西。