Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when comparing root elements #8

Open
Starkie opened this issue Aug 7, 2018 · 1 comment
Open

Exception when comparing root elements #8

Starkie opened this issue Aug 7, 2018 · 1 comment

Comments

@Starkie
Copy link
Contributor

Starkie commented Aug 7, 2018

This issue was detected when comparing root elements, for example, of a value type. When change is detected in the root element, a null reference exception is launched when creating the ChangeRecord (CreateChange() method):

var displayName = currentMember.DisplayName ?? propertyName.ToSpacedWords();

It seems to be caused by the currentMember variable, which is null when comparing root elements.

Code snippet to reproduce the error:

int original = 1;
int current  = 2;

var comparer = new EntityComparer();
var changes = comparer.Compare(original, current);
@Starkie
Copy link
Contributor Author

Starkie commented Aug 8, 2018

With further testing, now comparing arrays as root nodes, I found another exception in the method CompareByIndexer<T>:

When peeking the pathStack, an InvalidOperationException is thrown because it is empty:
var currentPath = _pathStack.peek().

Changing that line for var currentPath = CurrentPath() seems to solve the issue.

Edit: Apparently, I introduced this bug while fixing #5, and applying the proposed fix causes a regression. I'll try to look up for another solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant