replaysMike / AnyDiff

A CSharp (C#) diff library that allows you to diff two objects and get a list of the differences back.
Other
160 stars 17 forks source link

Possiblity to avoid diff of Enumerable null vs empty #5

Closed corbel88 closed 4 years ago

corbel88 commented 4 years ago

Hi, Would it be possible to avoid the comparison from an Enumerable null vs empty? Thanks

replaysMike commented 4 years ago

This is now included as of release version 1.0.61

replaysMike commented 4 years ago

For details on how to use, there is a new comparison option called TreatEmptyListAndNullTheSame. Usage is as follows:

var provider = new DiffProvider();
var obj1 = new TestObject { IntCollection = new List<int> { } };
var obj2 = new TestObject { IntCollection = null };
var diff = provider.ComputeDiff<TestObject>(obj1, obj2, ComparisonOptions.All | ComparisonOptions.TreatEmptyListAndNullTheSame);
Assert.AreEqual(0, diff.Count);