Fixing value type root element comparison
Solving #8.
Added the safe navigation operator to the affected instructions by the bug, so the exception isn't thrown anymore.
Also, added a test to check if the implementation was correct.
@Starkie If you can fix the build and resolve conflicts, I can get this merged.
@pwelter34 Thanks for the headsup. I had notes about it at work, and won't be able to check it out until I get back.
But, if I remember correctly, the bug was related on how the pathStack is handled in EntityComparer.cs. The problem starts with the CompareObject() method, during the member analysis:
- There is a
_pathStack.Push()before theCompareType(), that affects later on. - When, for example, comparing a List by equality, in
CompareByEquality(), the full path is obtained forcurrentPath. - This
currentPathis then added an index and assigned top, which holds the full path for an item of the list. pis then pushed to the_pathStack.- In the case where the item of the list is another list, when using the
CurrentPath()method again, the path will be duplicated. It concatenates all the previous elements with the last one, which was already the full path.
However, this couldn't be solved by simply obtaining the last element of the stack, because this behaviour changes with different combinations objects or nesting.
Before making any kind of drastic change, do you have suggestions on how could this be solved?