.NET Assembly Diff / Compare Tool - What's available? [closed]

早过忘川 提交于 2019-11-27 13:10:05

The tool NDepend offers many features to handle .NET code diff.

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


Many code rules that constraint diff and evolution are proposed. They can be a good start to write your own ones or adapt them to your needs. For example look at the rule:

Types that used to be 100% covered but not anymore

// <Name>Types that used to be 100% covered but not anymore</Name>
warnif count > 0
from t in JustMyCode.Types where 
   t.IsPresentInBothBuilds() &&
   t.OlderVersion().PercentageCoverage == 100 &&
   t.PercentageCoverage < 100
let culpritMethods = t.Methods.Where(m => m.PercentageCoverage < 100)
select new {t, t.PercentageCoverage, culpritMethods }

or also:


To get started with NDepend compare capabilities, have a look at the documentation:

Disclaimer: I work for NDepend

You can use ILDasm to generate il source from an assembly. IL source is basically a text file, so you can compare two il files using standard text diff tools. Interpreting the IL sources may not necessary, if you use the reported diffs as an indication where to look further.

ILSpy can decompile an assmembly out to a tidy directory structure. Do this for each of your assemblies and you can use a diff tool of your choice to see what has changed.

Diego Jancic

This is sort of a duplicated question, to this one.

As mentioned in the other one, there's a free & open source tool called BitDiffer. It's amazing, it can compare entire builds or single DLLs and it shows the namespace hierarchy to easily find what changed.

Jason Evans

I believe there is a Reflector addon for that at http://www.codeplex.com/reflectoraddins called diff. You can try that.

The diff addin for reflector is great! Ive been using it for years.

I made a small tool specifically for comparing Assemblies in a certain way. I had two assemblies which were basically the same except the IL in the methods was slightly different and one had some NOPs spread throughout. The C# code was almost identical for them, but the IL was clearly quite different. I tried using ILDasm and comparing the generated output with TortoiseMerge/WinDiff, but it had so many false differences that it was useless. The NOPs really messed with the output since it changed branch addresses and such and basically produced a difference on every line of each method.

So, I built a small tool called ILDump. It's BSD licensed. It is capable of trimming out NOPs, using "smart" label renaming so that code that is the same, but shifted by a NOP, it won't be detected as a difference by Diff programs, and it also only prints out significant labels(ie, ones that are branched/switched to). It also can sort methods so that two assemblies that were "created" in a different way won't be caught as a difference.

It's definitely not perfect, it doesn't handle any thing but dumping out each method's IL, and there is no hope of round tripping. The reason I created it was to make reading a method's IL easier(it's smart labeling makes it significantly easier to track branches), and so that I could run it through a program like TortoiseMerge or WinDiff and it not say there is a difference on every line of code.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!