Skip to content
This repository was archived by the owner on May 2, 2025. It is now read-only.

tobiaswuerth/Object-Content-Comparator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Object-Content-Comparator

Compare objects of any type based on their property values.

Download

✅ .net core v2.0
✅ .net framework v4.6
Download latest release here (pre-release v0.1)

How does it work?

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.

Dependencies

Newtonsoft Json.NET Nuget package

Usage

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

About

Compare any objects based on their properties and property contents

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages