DeepEqual.Generator 2.3.0

dotnet add package DeepEqual.Generator --version 2.3.0
                    
NuGet\Install-Package DeepEqual.Generator -Version 2.3.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DeepEqual.Generator" Version="2.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DeepEqual.Generator" Version="2.3.0" />
                    
Directory.Packages.props
<PackageReference Include="DeepEqual.Generator" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DeepEqual.Generator --version 2.3.0
                    
#r "nuget: DeepEqual.Generator, 2.3.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DeepEqual.Generator@2.3.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DeepEqual.Generator&version=2.3.0
                    
Install as a Cake Addin
#tool nuget:?package=DeepEqual.Generator&version=2.3.0
                    
Install as a Cake Tool

DeepEqualGenerator

Compare .NET model snapshots with generated code. See what changed by property, index, or business key. Create a patch and apply it with the same comparison rules.

Quick start

DeepEqualGenerator targets .NET 8 or later and requires a C# 12 compiler with Roslyn 4.11 or later. One NuGet package contains the generator, attributes, runtime, and IDE fixes.

dotnet add package DeepEqual.Generator --version 2.3.0
using DeepEqual;
using DeepEqual.Generator.Shared;

var before = new Inventory { Lines = [new("SKU-9", 2), new("SKU-11", 1)] };
var after = new Inventory { Lines = [new("SKU-9", 3), new("SKU-12", 1)] };

Console.WriteLine(before.DescribeDeepChanges(after).ToText());
var patched = before.ApplyDeepDelta(before.ComputeDeepDelta(after));
after.AssertDeepEqual(patched);

[DeepComparable(GenerateDelta = true)]
public sealed class Inventory
{
    [DeepCompare(KeyMembers = [nameof(Line.Sku)])]
    public List<Line> Lines { get; set; } = [];
}

public sealed record Line(string Sku, int Quantity);
$.Lines["SKU-9"].Quantity 2 → 3
$.Lines["SKU-11"] removed <Line>
$.Lines["SKU-12"] added <Line>
When you need Use
A fast yes or no AreDeepEqual
The first reason two objects differ GetDeepMismatch
A bounded change report with named paths DescribeDeepChanges
A test assertion with that same report AssertDeepEqual
A side-by-side HTML report or CI artifact ToHtml
The generated rules for a model ExplainDeepModel
A structural diff for code that consumes operation IDs GetDeepDiff with GenerateDiff = true
An in-memory patch ComputeDeepDelta and ApplyDeepDelta with GenerateDelta = true
A checked, revisioned patch between processes CreateDeepSync with GenerateDelta = true and JSON serializer metadata

Run the inventory walkthrough · Read the comparison recipes · Troubleshoot a compiler diagnostic

Save a failed assertion as a filterable HTML report with the same redaction as its test output. The GitHub Actions example shows how to upload the report on failure.

Comparison rules

  • Public readable instance properties and fields are included by default. Use IncludeBaseMembers = false to exclude inherited members or IncludeInternals = true for eligible internal members. Getters run during comparison. Use stable snapshots when values can mutate concurrently.
  • Cycles are tracked by active reference pairs. Shared reference topology is ignored. Set CycleTracking = false for acyclic models.
  • Ordered collections are compared by position. OrderInsensitive = true matches duplicates one-to-one. KeyMembers matches by key and ignores order by default. Set OrderInsensitive = false alongside keys to compare order and report position changes. Reports compare an unordered bucket as a group when items cannot be paired unambiguously.
  • Dictionary and matching keys use default .NET key equality. String options apply to compared values. A dictionary patch can use a replacement when the receiver’s comparer cannot represent the desired keys. Date values compare DateTime.Kind or DateTimeOffset.Offset as well as the time value.
  • ComparisonOptions controls numeric tolerances, NaN, and string comparison. Named ComparisonProfile instances share options between assertions, validation, and sync. A numeric tolerance may be non-transitive.
  • [DeepCompare(Kind = CompareKind.Skip)] excludes a member. Shallow uses ordinary equality and Reference uses reference identity. ComparerType accepts an IEqualityComparer<T> with an accessible parameterless constructor. Apply Members or IgnoreMembers to the declaring type.
  • Generated helpers handle known runtime model types in interface and object members. Known runtime containers compare by content. Reports list where ordinary equality was used for an unregistered type.
  • Use [assembly: ExternalDeepComparable(typeof(ExternalModel))] for types you cannot annotate. ExternalDeepCompare applies rules to direct members. Roots with external overrides use replacement diffs and deltas.

Patching and deployment

Feature Supported workflow
Comparison, reports, assertions Generated class and struct roots, including generic roots, on the regular runtime and Native AOT
In-memory diffs and deltas Granular operations for supported writable members and mutable collections. Immutable and open generic roots use replacement when needed.
BDC1 binary codec Primitive values, strings, known time and ID types, enums, byte arrays, and supported containers. Explicit JsonTypeInfo registrations extend value support.
Checked sync Generated schemas, revision checks, isolated preview and apply, packet inspection, and full-snapshot recovery. Source-generated serializer metadata supports Native AOT. Register typed container and enum values for AOT.

Raw ApplyDeepDelta can mutate the target. Capture its return value for classes because a patch can replace the entire object. Apply raw deltas to the same model and baseline used to compute them. Use checked sync to validate a packet and stage the result independently.

To record dirty members, add [DeltaTrack] to a partial model with delta generation enabled and call the generated __MarkDirty(__Bit_PropertyName) from the setter. ValidateDirtyOnEmit checks flagged members before emitting an operation. Checked sync compares whole snapshots and leaves dirty markers alone. AccessTrack = AccessMode.Write records write diagnostics and __DumpAccessJson() exposes them.

Build and verify

dotnet build DeepEqual.Generator.sln -c Release
dotnet test DeepEqual.Generator.Tests -c Release --no-build
dotnet pack DeepEqual.Generator.Shared -c Release --no-build -o artifacts/packages
dotnet restore samples/DeltaRoundTrip --source artifacts/packages --packages artifacts/smoke-cache
dotnet run --project samples/DeltaRoundTrip -c Release --no-restore

The benchmark guide covers comparisons, reports, patches, and full snapshots. For a local package, add --source <feed-path> to the installation command. For a 1.x project, remove the separate DeepEqual.Generator.Shared package reference and call expected.AreDeepEqual(actual) with using DeepEqual;.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.3.0 125 11/20/2026

Save side-by-side HTML comparison reports with path and change filters. Assertion failures carry the same redaction into their HTML reports. See the GitHub Actions example for uploading reports from failing tests.