Skip to content

Compare assemblies with our own engine and drop vendored JustAssembly - #68

Merged
Mpdreamz merged 2 commits into
mainfrom
engine
Nov 14, 2026
Merged

Mpdreamz merged 2 commits into
mainfrom
engine

Conversation

@Mpdreamz

Copy link
Copy Markdown
Contributor

The comparison now runs on a port of JustAssembly onto System.Reflection.Metadata, so src/assembly-differ/lib and its eight vendored dlls are gone. Every report comes out exactly as before.

Prompt summary: The tool is being dusted off: new subcommands, first releases that do not fail, and pull request comments and labels. This step replaces the engine first, so that later fixes land on code that can be built and changed. The hidden diff command must keep behaving the same, so the old engine's output is the specification.

Why

The dlls in lib came from the unmerged public-types branch of nullean/JustAssembly, an archived fork. They were built in 2020 for .NET Framework 4.5 and no source in any branch rebuilds them. They also bring a fork of Mono.Cecil and a 1 MB decompiler that the comparison only used to format names.

What

A port, not a rewrite

Engine/ reproduces JustAssembly's comparers: the same sorted merge, the same order of checks and the same visibility rules. It reads metadata with System.Reflection.Metadata and decodes signatures into a small type tree. That tree renders the way Mono.Cecil spells a type, which orders members and names attribute constructors, and the way JustDecompile's C# writer does, which the reports show. JustAssembly's quirks stay, because changing a report is a change to the contract. A type that became less visible is still reported as more visible, since JustAssembly subtracted byte-backed enum values and the result wrapped around. Nested types are still named .Name.

A corpus written by the old engine

The first commit adds a generator for old and new versions of a library. It covers classes, structs, interfaces, enums and delegates, generics with variance, nested types, by-ref parameters, indexers, events, operators, explicit implementations, attributes and every accessibility. 400 seeds are checked to compile. The old engine's output for 100 of them, in every format, is snapshotted before the engine changes. The new engine reproduces all 100.

Comparing with another build

ReferenceTests runs this build and another one on further generated versions and requires the same output in every format. It runs only when ASSEMBLY_DIFFER_REFERENCE names the other build's dll. Against the build from #67, 3000 seeds came out the same. With the visibility quirk removed on purpose, 24 of 300 failed.

Real packages

Both builds diffed seven real package upgrades from nuget.org in xml and github-comment, with the same output: Proc, NuGet.Versioning, Newtonsoft.Json, System.Text.Json, Microsoft.Extensions.DependencyInjection.Abstractions, CsCheck and System.Collections.Immutable. The native-AOT build publishes without trimming or AOT warnings, and ./build.sh smokeaot passes.

Verify

mise run test
# compare with the build from main, on 1000 generated versions
git worktree add /tmp/ad-main origin/main && (cd /tmp/ad-main && dotnet build src/assembly-differ -c Release -f net11.0)
ASSEMBLY_DIFFER_REFERENCE=/tmp/ad-main/src/assembly-differ/bin/Release/net11.0/assembly-differ.dll ASSEMBLY_DIFFER_SEEDS=1000 \
  dotnet test --project tests/assembly-differ.Tests -c Release --treenode-filter '/*/*/ReferenceTests/*'

Out of scope: The engine lives in the tool's assembly and its types are public, because the exporters are. A separate library package comes with the snapshot package, after the API settles. The tool's own API diff against its last release reports Major, because that assembly's public types moved. It is a tool, not a library, so nothing references them.

Stack: 2 of the dusting-off series, on top of #67.

🤖 Generated with Claude Code

@Mpdreamz Mpdreamz added chore Internal change, no user-visible effect (patch) and removed chore Internal change, no user-visible effect (patch) labels Nov 13, 2026
Base automatically changed from tests to main November 14, 2026 07:08
Mpdreamz and others added 2 commits November 14, 2026 08:08
The engine is about to be replaced, and the scenarios cover too little of
C# to prove a replacement matches. A generator now writes old and new
versions that cover generics, nested types, by-ref parameters, indexers,
events, operators, explicit implementations, attributes and every
accessibility; 100 fixed seeds are snapshotted in every format.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…mbly

The comparison ran on eight dlls built in 2020 from an unmerged branch of
an archived fork, for .NET Framework, that nobody could rebuild. Engine/
ports JustAssembly's comparers onto System.Reflection.Metadata and
JustDecompile's naming with them, so every report comes out the same,
quirks included. The corpus snapshots, 3000 further generated versions and
seven real package upgrades show no difference against the old build.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Mpdreamz
Mpdreamz merged commit ca60a71 into main Nov 14, 2026
6 checks passed
@Mpdreamz
Mpdreamz deleted the engine branch November 14, 2026 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Internal change, no user-visible effect (patch)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant