Carubbi.DiffAnalyzer 3.0.0

dotnet add package Carubbi.DiffAnalyzer --version 3.0.0
                    
NuGet\Install-Package Carubbi.DiffAnalyzer -Version 3.0.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="Carubbi.DiffAnalyzer" Version="3.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Carubbi.DiffAnalyzer" Version="3.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Carubbi.DiffAnalyzer" />
                    
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 Carubbi.DiffAnalyzer --version 3.0.0
                    
#r "nuget: Carubbi.DiffAnalyzer, 3.0.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 Carubbi.DiffAnalyzer@3.0.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=Carubbi.DiffAnalyzer&version=3.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Carubbi.DiffAnalyzer&version=3.0.0
                    
Install as a Cake Tool

Carubbi.DiffAnalyzer

NuGet NuGet downloads CI

Compares two object instances by reflection and reports every added, deleted, modified and unchanged property. Built for .NET 10.

  • Deep comparison: nested objects, collections and dictionaries are walked up to a configurable depth.
  • Attribute-driven: [DiffAnalyzable] marks or excludes properties; [DiffKey] declares the identity of an entity.
  • Two modes: compare everything (All) or only decorated properties (DecoratedOnly).
  • Culture invariant: numbers and dates are rendered with CultureInfo.InvariantCulture.
  • Thread safe: a single analyzer instance can be shared across concurrent comparisons.
  • Blazor viewer: the companion package Carubbi.DiffAnalyzer.UI renders the results as an HTML table.

Installation

dotnet add package Carubbi.DiffAnalyzer
dotnet add package Carubbi.DiffAnalyzer.UI # optional Blazor viewer

Usage

using Carubbi.DiffAnalyzer;

var before = new User
{
    Id = 1,
    Name = "Michael",
    Nicknames = ["Mike", "MK"],
    Addresses =
    [
        new Address
        {
            Street = "1st street",
            State = new State
            {
                Name = "SP",
                Cities = [new City { Name = "Sao Paulo" }, new City { Name = "Santos" }],
            },
        },
    ],
    Phones = [new Phone { AreaCode = "11", Number = "91234-5678", Type = PhoneType.Mobile }],
};

var after = new User
{
    Id = 1,
    Name = "Michael",
    Nicknames = ["None"],
    Phones = [new Phone { AreaCode = "11", Number = "1234-5678", Type = PhoneType.Business }],
};

var analyzer = new DiffAnalyzer();
List<DiffComparison> results = analyzer.Compare(before, after);

foreach (var difference in results)
{
    Console.WriteLine($"{difference.Breadcrumb}: {difference.PreviousValue} -> {difference.CurrentValue} ({difference.State})");
}

Modes and attributes

public class User
{
    [DiffAnalyzable(DiffAnalyzableUsage.Ignore)] // excluded from every mode
    public int Id { get; set; }

    [DiffAnalyzable]                             // compared in every mode
    public string Name { get; set; }

    public List<string> Nicknames { get; set; }  // compared only in DiffModes.All

    [DiffKey]                                    // identity used to track entities across reorders
    public int Code { get; set; }
}

// Only properties marked with [DiffAnalyzable]:
var results = analyzer.Compare(before, after, DiffModes.DecoratedOnly);

Blazor viewer

@using Carubbi.DiffAnalyzer.UI

<DiffComparisonViewer Data="results"
                      Disposition="LabelDisposition.Row"
                      ShowState="true"
                      ModifiedBackColor="#fff3cd"
                      DeletedBackColor="#f8d7da"
                      AddedBackColor="#d4edda" />

Building and testing locally

Requires the .NET 10 SDK.

dotnet build -c Release
dotnet test Carubbi.DiffAnalyzer.slnx -c Release --no-build

No external infrastructure is needed: the whole suite runs as unit tests.

Releasing

Pushing a tag v* (for example v3.0.0) triggers the publish workflow, which packs both projects in Release mode and pushes them to nuget.org through trusted publishing. The workflow can also be run manually from the Actions tab via workflow_dispatch.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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.
  • net10.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Carubbi.DiffAnalyzer:

Package Downloads
Carubbi.DiffAnalyzer.UI

Blazor component that renders the differences reported by Carubbi.DiffAnalyzer as a configurable HTML table with state filtering and customizable labels.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.0 104 8/26/2026
2.0.0 1,964 9/11/2018
1.0.0 1,125 8/21/2018