DeepCopy
DeepCopy copied to clipboard
A problem of HashSet<>
private class MyClass
{
}
[Fact]
public void CopyObjectHashSet()
{
HashSet<MyClass> original = new HashSet<MyClass>();
original.Add(new MyClass());
var result = DeepCopier.Copy(original);
Assert.NotSame(original, result);
foreach (MyClass myClass in result) {
Assert.True(result.Contains(myClass));
}
}
After deep copy , then Contains method return false.
We'll have to add custom copiers in order to make this work - the hash code for each object is stored in the HashTable.