Object comparison flaws

Aug 11, 2010 at 5:06 PM
Edited Aug 11, 2010 at 5:16 PM



First of all thanks for a get job you have done!!! I really appreciate it!

We use your object comparison functionality as base. However we found some issues with the current implementation.

You use GetHashCode to track circular references. I guess it's bad idea because, in the object hierarchy two object with the same hash will be collapsed  to use single node, which obviously wrong.

Code doesn't handle enumerations. IsLeafNode simply doesn't take it in account.

Code handles DateTime as complex type, which is questionable...

To remedy two issues above one can use IsValue in IsLeafNode

ObjectComparer code doesn't handle additions on the right side. There should be another foreach by right side, similar to what you have one the left side, to create MissingLeftsideNode.

Collection comparison by index? It's not going to work if item added/deleted multiple times resulting in let say different order. We used some code to get identity from our objects (which is specific to our implementation).  However I guess, some sort of GetHashCode() and IEnumerble.Index combination, might work for all situations. One comparing lists using QualifiedName at the end ;-)

Would be nice to have generic classes, to get information about changes in context of arbitrary object hierarchy. I know LINQ is there, but any way...








Aug 11, 2010 at 5:54 PM

Thanks for the report, WBR!

We will take a look at this and get back to you.