EntityChange icon indicating copy to clipboard operation
EntityChange copied to clipboard

Fixing value type root element comparison

Open Starkie opened this issue 7 years ago • 2 comments

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 avatar Aug 07 '18 09:08 Starkie

@Starkie If you can fix the build and resolve conflicts, I can get this merged.

pwelter34 avatar Aug 20 '18 18:08 pwelter34

@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:

  1. There is a _pathStack.Push() before the CompareType(), that affects later on.
  2. When, for example, comparing a List by equality, in CompareByEquality(), the full path is obtained for currentPath.
  3. This currentPath is then added an index and assigned to p, which holds the full path for an item of the list.
  4. p is then pushed to the _pathStack.
  5. 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?

Starkie avatar Aug 21 '18 11:08 Starkie