Diffster 3.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Diffster --version 3.1.0
                    
NuGet\Install-Package Diffster -Version 3.1.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="Diffster" Version="3.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Diffster" Version="3.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Diffster" />
                    
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 Diffster --version 3.1.0
                    
#r "nuget: Diffster, 3.1.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 Diffster@3.1.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=Diffster&version=3.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Diffster&version=3.1.0
                    
Install as a Cake Tool

<p align="center"> <img src="assets/icon.png" width="128" height="128" alt="Diffster Logo" /> </p>

Diffster

High-performance compiled expression tree object diffing and automated Entity Framework Core audit logging engine for .NET.


Highlights

  • Compiled Expression Engine: Emits native IL delegates (Func<object, object?>) cached in thread-safe dictionaries, avoiding slow reflection (PropertyInfo.GetValue) at runtime.
  • O(1) Circular Reference Protection: Graph traversal cycle protection powered by RuntimeHelpers.GetHashCode.
  • Collection Diffing: Supports single [DiffKey], composite [DiffKey(Order = ...)], and fallback index matching ([0]).
  • Flexible Data Governance: Mask sensitive values ([DiffMask]), format dates/currency ([DiffFormat]), or ignore properties ([DiffIgnore]) via attributes or fluent API (Diffster.Configure<T>()).
  • Base Class & Interface Support: Configurations and attributes on base classes and interfaces are automatically inherited by subclasses.
  • Entity Framework Core Integration: DiffsterAuditInterceptor captures changes in SavingChangesAsync and aggregates child rows into the parent's flat audit log.
  • Virtual Tree Hydration: Hydrate stored flat dot-bracket JSON into deep hierarchical trees with ToNestedTree(expandSnapshots: true).

Projects in Solution

Package / Project Target Description
Diffster net7.0 Core compiled diffing engine, attributes, and virtual tree hydration.
Diffster.EntityFrameworkCore net7.0 EF Core SaveChangesInterceptor with change tracker aggregation and AuditLog entity.
Diffster.SampleApi net7.0 ASP.NET Core Minimal API with interactive TreeView UI (/viewer).
Diffster.ConsoleSample net7.0 Standalone console app showcasing 13 non-EF diffing scenarios.
Diffster.Tests net7.0 xUnit test suite (25 tests covering collections, cycles, sanitization, and inheritance).

Quick Start

1. In-Memory Object Diffing

using Diffster;

var oldCustomer = new Customer
{
    Id = 1,
    Name = "Alice",
    CreditCard = "4111-2222-3333-1234"
};

var newCustomer = new Customer
{
    Id = 1,
    Name = "Alice Smith",
    CreditCard = "4111-2222-3333-9876"
};

// Compute structural diff
List<DiffNode> diffs = oldCustomer.Diff(newCustomer);

foreach (var diff in diffs)
{
    Console.WriteLine($"{diff.Path}: {diff.Action} (Old: {diff.OldValue} -> New: {diff.NewValue})");
}

2. Model Configuration (Attributes or Fluent API)

// Declarative attributes
public class Customer
{
    [DiffKey]
    public int Id { get; set; }

    [DiffName("Customer Name")]
    public string Name { get; set; } = string.Empty;

    [DiffMask(maskText: "************", visibleLastChars: 4)]
    public string CreditCard { get; set; } = string.Empty;

    [DiffIgnore]
    public string InternalToken { get; set; } = string.Empty;
}

// Or clean POCO configuration without attributes
Diffster.Configure<Customer>()
    .IdentifyBy(c => c.Id)
    .DisplayName(c => c.Name, "Customer Name")
    .Mask(c => c.CreditCard, maskText: "************", visibleLastChars: 4)
    .Ignore(c => c.InternalToken);

3. Entity Framework Core Auditing

// Register in Program.cs
builder.Services.AddDiffsterAudit(sp => "user@domain.com");

builder.Services.AddDbContext<AppDbContext>((sp, options) =>
{
    var interceptor = sp.GetRequiredService<DiffsterAuditInterceptor>();
    options.UseSqlServer(connectionString)
           .AddInterceptors(interceptor);
});

// Mark entities to audit
public class Order : IAuditableEntity
{
    public int Id { get; set; }
    public string Status { get; set; } = string.Empty;
    public List<OrderItem> Items { get; set; } = new();
}

4. Virtual Tree Hydration

// Read stored flat JSON from database and hydrate into a nested UI tree
var tree = auditLog.GetNestedTree(expandSnapshots: true);

Building and Packaging

Build and create NuGet packages locally:

# Build solution in Release mode
dotnet build -c Release

# Pack packages into artifacts directory
dotnet pack -c Release -o ./artifacts

License

This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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.
  • net7.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Diffster:

Package Downloads
Diffster.EntityFrameworkCore

Entity Framework Core audit interceptor for Diffster with change tracker aggregation and transactional persistence.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.3.1 12 11/28/2026
3.3.0 113 11/23/2026
3.2.0 112 11/23/2026
3.1.0 101 11/23/2026
3.0.0 116 11/23/2026
2.1.0 114 11/23/2026
2.0.0 109 11/22/2026
1.2.3 107 11/22/2026
1.2.2 110 11/22/2026
1.2.0 113 11/21/2026
1.1.0 118 11/21/2026
1.0.0 110 11/21/2026