Skip to content

About

dnSpyEx extension: compare two .NET assemblies and port symbol names between versions.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

dnSpy.Extension.AssemblyDiff

A dnSpyEx extension to compare two .NET assemblies and port symbol names between versions. It's inspired by BinDiff, which do the same for native binaries.

Features

  • Compares two loaded assemblies and matches their methods in three passes:
    1. Identical IL — the method body is normalized (member references become full names, branch targets become relative offsets) and hashed, so builds with different metadata tokens still match. Only hashes that are unique on both sides are used.
    2. Same signature — same declaring type, name, parameter types, return type and staticness.
    3. Similar — Jaccard similarity of normalized instruction sequences, only between methods with the same shape (parameter count, return type, staticness) and a compatible size.
  • Shows matched, added and removed methods, grouped by status.
  • Ports names: copies the old method names to the matching methods of the new assembly, so renamed or obfuscated symbols are restored. By default only obfuscated names (method_12, sub_40A1C0, single letters, ...) are overwritten; uncheck Only obfuscated names to overwrite every name.
  • Compares the newest file as the new version even if the old one is selected.

Usage

  1. Open the old and the new assembly in dnSpy.
  2. Select one of them in the assembly explorer.
  3. Edit → Assembly Diff: Compare Assemblies..., the tree view context menu, or Ctrl+Alt+D.
  4. Pick the two assemblies in the Old / New combo boxes and press Compare.
  5. Check the names you want to port and press Port names.
  6. Save with File → Save Module. The extension modifies the in-memory module directly, so dnSpy's undo/redo history and the modified (*) marker don't know about these changes; the normal Save Module command still writes the current module to disk.

Double click a row to select the method in the assembly explorer.

How matching works

The IL hash ignores things that change between builds (metadata tokens, branch target addresses) but keeps everything that describes behavior (opcodes, member full names, strings, constants, relative branch distances). That's why unchanged methods match even when they were renamed or moved in the metadata tables.

Limitations

  • Only methods with a body are compared. Fields, properties, events and types are not matched (yet), so their names are not ported.
  • "Similar" matching is a heuristic; review those rows before porting names. Identical IL and same signature matches are exact.
  • Changes made by this extension are not part of dnSpy's undo history.
  • Renaming public/protected methods can break other assemblies that reference them by name.

Building

You need the .NET 10 SDK and a dnSpyEx installation (or build output) to compile against. Point DnSpyDir to the directory that contains dnSpy.Contracts.DnSpy.dll, dnlib.dll, etc. (the bin directory of a dnSpyEx installation):

dotnet build src/dnSpy.Extension.AssemblyDiff -c Release -p:DnSpyDir="<path to dnSpy bin directory>"

DnSpyDir defaults to dnSpy next to the repository root. The build copies the extension to <DnSpyDir>/Extensions/dnSpy.Extension.AssemblyDiff/; pass -p:DeployToDnSpy=false to skip that step.

Installation

Copy dnSpy.Extension.AssemblyDiff.x.dll to the bin/Extensions/dnSpy.Extension.AssemblyDiff directory of your dnSpy installation. The extension targets net10.0-windows and is meant for the .NET build of dnSpyEx 6.6.0 or newer.

Credits

  • BinDiff and
  • BinDiff-NG: structural comparison and symbol porting on newer IDA versions.
  • dnSpyEx, the host application.

License

GPL-3.0-or-later, same as dnSpyEx. See LICENSE.txt.

About

dnSpyEx extension: compare two .NET assemblies and port symbol names between versions.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages