C# 比较编译的 .NET 程序集?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/652432/
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-04 11:55:09  来源:igfitidea点击:

Compare compiled .NET assemblies?

c#.netvb.netdebuggingreverse-engineering

提问by Danny G

Are there any good programs out there to compare to compile .NET assemblies?

有没有什么好的程序可以与编译 .NET 程序集进行比较?

For example I have HelloWorld.dll (1.0.0.0) and HelloWorld.dll (2.0.0.0), and I want to compare differences how can I do this?

例如我有 HelloWorld.dll (1.0.0.0) 和 HelloWorld.dll (2.0.0.0),我想比较差异我该怎么做?

I know I can use .NET Reflector and use the Assembly Diff plugin. Are there any other good tools out there to do this?

我知道我可以使用 .NET Reflector 并使用 Assembly Diff 插件。有没有其他好的工具可以做到这一点?

采纳答案by Daniel LeCheminant

Ways to Compare .NET Assembliessuggests

比较 .NET 程序集的方法建议

Commercial:

商业的:

Free:

自由:

回答by rama-jka toti

Two ways.

两种方式。

You could ILDASM and diff with classic tools.

您可以使用经典工具进行 ILDASM 和 diff。

Or you could use NDepends, which will cost for that feature.

或者您可以使用 NDepends,这将花费该功能。

[Piece to C# bloaters..]

[片到 C# 膨胀..]

回答by Jonathan Parker

Java has a nice one: Semantic Diff Utilities

Java 有一个不错的:语义差异实用程序

回答by Alek Davis

I just had to compare two revisions of the same DLL, which had the same version (I needed to implement a small hotfix, and deploy the DLL in production, but I wanted to make sure that no other changes leaked into code). Ideally, I would want the Assemby Diff add-in to show me the difference, but it does not work (it thinks that I'm comparing a DLL to itself). So this is what I did:

我只需要比较具有相同版本的同一个 DLL 的两个修订版(我需要实现一个小的修补程序,并在生产中部署 DLL,但我想确保没有其他更改泄漏到代码中)。理想情况下,我希望 Assemby Diff 加载项向我展示差异,但它不起作用(它认为我正在将 DLL 与其自身进行比较)。所以这就是我所做的:

  • Created two folders to hold disassembled source files.
  • Used the Reflector's Exportoption (from context menu) to generate source files from each DLL in the folders created in previous step.
  • Used the free DiffMergetool to compare two directories; the tools showed me the modified files and the difference.
  • 创建了两个文件夹来保存反汇编的源文件。
  • 使用Reflector导出选项(从上下文菜单)从上一步创建的文件夹中的每个 DLL 生成源文件。
  • 使用免费的DiffMerge工具比较两个目录;工具向我展示了修改后的文件和差异。

It's a bit kludgy, but seems to work. I wish the Assembly Diff add-in worked, though.

这有点笨拙,但似乎有效。不过,我希望 Assembly Diff 加载项能够正常工作。

UPDATE: The latest version of the Assembly Diff add-in is supposed to fix the issue of comparing two versions of the same assembly. Give it a try.

更新:Assembly Diff 加载项的最新版本应该解决比较同一程序集的两个版本的问题。试一试。

回答by Patrick from NDepend team

The tool NDependoffers many features to handle .NET code diff. Disclaimer: I am one of the developer of the tool.

工具NDepend提供了许多功能来处理 .NET 代码差异。免责声明:我是该工具的开发者之一

The panel Search by Changeis dedicated to browse assemblies code diff. Notice that:

Search by Change面板专用于浏览程序集代码差异。请注意:

  • You can plug to NDepend any code diff tool used by the menu Compare older and newer version of source file
  • If you don't have the source code, only the raw assemblies, there is the option Compare older and newer version disassembled with Reflector
  • 您可以将菜单比较旧版本和新版本的源文件使用的任何代码差异工具插入 NDepend
  • 如果您没有源代码,只有原始程序集,则可以选择使用 Reflector 反汇编来比较旧版本和新版本

NDepend Search by Diff Panel

NDepend 按差异面板搜索

Notice also in the screenshot that a CQLinq code queryis generated to browse the diff.

还要注意在屏幕截图中生成了一个CQLinq 代码查询来浏览差异。

from m in Application.Methods 
where m.CodeWasChanged() 
select new { m, m.NbLinesOfCode }

Many others default diff queries and rules are proposed by default, that will let you browse .NET code diff in a smart way.

许多其他默认差异查询和规则是默认提出的,这将让您以智能方式浏览 .NET 代码差异。

回答by Eugene

One more option is LibCheckfrom Microsoft.

一种选择是来自 Microsoft 的LibCheck

Pretty old console tool for just getting public API diff. I could not run without debugging and retargeting to a more recent .net version. However, it gave me very clear output and I am going to use it later.

非常旧的控制台工具,用于获取公共 API 差异。如果没有调试和重定向到更新的 .net 版本,我就无法运行。但是,它给了我非常清晰的输出,我稍后会使用它。

Here is an articlewith screenshots.

这是一篇带有截图的文章