AnyDiff 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package AnyDiff --version 1.0.0
NuGet\Install-Package AnyDiff -Version 1.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="AnyDiff" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AnyDiff --version 1.0.0
#r "nuget: AnyDiff, 1.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.
// Install AnyDiff as a Cake Addin
#addin nuget:?package=AnyDiff&version=1.0.0

// Install AnyDiff as a Cake Tool
#tool nuget:?package=AnyDiff&version=1.0.0

AnyDiff

A CSharp library that allows you to diff two objects and get a list of the differences back.

Description

AnyDiff works with complex objects of any type, and is great for performing changeset tracking, auditing, or anything else that might require comparing differences between complex objects. Great when combined with AnyClone, as it lets you take a snapshot of the current state of an object and then compare it in the future for changes to it.

It can even do this for objects that are of different types, though the results may vary depending on how different they are.

Usage

Comparing two objects with no differences:

var object1 = new MyComplexObject(1, "A string");
var object2 = new MyComplexObject(1, "A string");
var diff = AnyDiff.Diff(object1, object2);
Assert.AreEqual(diff.Count, 0);

Comparing two objects with a single expected change:

var object1 = new MyComplexObject(1, "A string");
var object2 = new MyComplexObject(1, "A different string");
var diff = AnyDiff.Diff(object1, object2);
Assert.AreEqual(diff.Count, 1);

Viewing the results of a diff:

var diff = AnyDiff.Diff(object1, object2);
var diff = AnyDiff.Diff(object1, object2);

foreach(var difference in diff)
{
  Console.Write($"Index: {difference.ArrayIndex}"); // when array elements differ in value
  Console.Write($"Delta: {difference.Delta}"); // when numbers, strings differ in value
  Console.Write($"Left: {difference.LeftValue}"); // the left value being compared
  Console.Write($"Right: {difference.RightValue}"); // the right value being compared
  Console.Write($"Property name: {difference.Property}"); // the name of the field/property
  Console.Write($"Property type: {difference.PropertyType}"); // the type of the field/property
}

Comparing the difference between the same object at different states, using AnyClone

// using AnyClone;
var object1 = new MyComplexObject(1, "A string");
var object1Snapshot = object1.Clone();

var diff = AnyDiff.Diff(object1, object1Snapshot);
Assert.AreEqual(diff.Count, 0);

// change something anywhere in the object tree
object1.Name = "A different string";

diff = AnyDiff.Diff(object1, object1Snapshot);
Assert.AreEqual(diff.Count, 1);
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on AnyDiff:

Package Downloads
RF.Common

RabbitFoot Common

IdOps.Server

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.91 172 4/3/2024
1.0.88 257,233 7/29/2021
1.0.86 430 7/29/2021
1.0.83 110,733 7/10/2020
1.0.82 586 7/10/2020
1.0.81 607 7/10/2020
1.0.80 611 7/10/2020
1.0.78 495 7/10/2020
1.0.73 4,318 5/23/2020
1.0.71 5,923 4/22/2020
1.0.68 493 4/20/2020
1.0.62 47,992 3/17/2020
1.0.61 3,575 11/22/2019
1.0.59 571 11/22/2019
1.0.56 19,077 5/23/2019
1.0.55 965 5/22/2019
1.0.54 944 5/22/2019
1.0.52 986 5/22/2019
1.0.51 931 5/22/2019
1.0.50 972 5/21/2019
1.0.48 980 5/21/2019
1.0.47 962 5/16/2019
1.0.45 1,394 4/20/2019
1.0.38 2,679 1/11/2019
1.0.37 39,115 1/7/2019
1.0.34 1,107 12/28/2018
1.0.25 1,384 12/4/2018
1.0.23 1,101 12/2/2018
1.0.22 1,157 12/2/2018
1.0.20 1,717 12/2/2018
1.0.8 1,117 12/1/2018
1.0.7 1,120 11/30/2018
1.0.5 1,085 11/29/2018
1.0.4 1,145 11/28/2018
1.0.0 1,226 11/16/2018

A CSharp library that allows you to diff two objects and get a list of the differences back.