DeepEqual
DeepEqual copied to clipboard
Comparing dictionaries containing classes is problematic
When running the provided code the IsDeepEqual call consumes more than 1 GB of memory and had to be stopped after 1 minute.
using System;
using System.Collections.Generic;
using DeepEqual.Syntax;
namespace test1
{
class Test
{
public string A { get; set; }
}
class Program
{
static void Main(string[] args)
{
var object1 = new Dictionary<int, Test>();
var object2 = new Dictionary<int, Test>();
for (int c = 0; c < 100; c++)
{
object1.Add(c, new Test { A = c.ToString() });
object2.Add(c, new Test { A = c.ToString() });
}
object2[10].A = "different";
Console.WriteLine($"Equals: {object1.IsDeepEqual(object2)}");
}
}
}
This happens under .NET Core 3.1 and .NET 5 using version 2.0.0
A usable workaround seems to be object1.ToList().IsDeepEqual(object2.ToList())
I believe this is fixed in the latest version. Please let me know if it's not.