Compare objects of any type based on their property values.
✅ .net core v2.0
✅ .net framework v4.6
Download latest release here (pre-release v0.1)
The object is serialized into JSON (properties can be labled using the attributes [JsonProperty]
and [JsonIgnore]
) which then is hashed using the SHA512 Algorithm. The objects are compared by comparing their hashes which does not guarantee that every content generates a unique hash ... but pretty much. Click here to find out more.
Newtonsoft Json.NET Nuget package
var obj1 = new MyStatelessClass();
var obj2 = new MyStatelessClass();
Comparator.AreEqual(obj1, obj2);
>>> true
Comparator.AreEqual(15, "15"); // this is because string "15" and integer 15 are not considered equal
>>> false
Comparator.AreEqual(DateTime.MinValue, DateTime.Parse("01/01/0001 00:00:00"));
>>> true