Compare compiled .NET assemblies?

2019-01-08 08:51发布

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

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?

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

6条回答
迷人小祖宗
2楼-- · 2019-01-08 09:34

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

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

  • 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 Search by Diff Panel

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

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.

查看更多
乱世女痞
3楼-- · 2019-01-08 09:47

One more option is LibCheck from Microsoft.

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.

Here is an article with screenshots.

查看更多
The star\"
4楼-- · 2019-01-08 09:51

Ways to Compare .NET Assemblies suggests

Commercial:

Free:

查看更多
贼婆χ
5楼-- · 2019-01-08 09:52

Java has a nice one: Semantic Diff Utilities

查看更多
爷、活的狠高调
6楼-- · 2019-01-08 09:54

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:

  • Created two folders to hold disassembled source files.
  • Used the Reflector's Export option (from context menu) to generate source files from each DLL in the folders created in previous step.
  • Used the free DiffMerge tool to compare two directories; the tools showed me the modified files and the difference.

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

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.

查看更多
Emotional °昔
7楼-- · 2019-01-08 09:58

Two ways.

You could ILDASM and diff with classic tools.

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

[Piece to C# bloaters..]

查看更多
登录 后发表回答