Skip to content

Commit e44460c

Browse files
committed
Update EntityComparer.cs
1 parent 6732bd4 commit e44460c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/EntityChange/EntityComparer.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace EntityChange;
88

99
/// <summary>
10-
/// A class to compare two entities generating a change list.
10+
/// A class to compare two entities generating a change list.
1111
/// </summary>
1212
public class EntityComparer : IEntityComparer
1313
{
@@ -54,6 +54,9 @@ public EntityComparer(IEntityConfiguration configuration)
5454
public IReadOnlyList<ChangeRecord> Compare<TEntity>(TEntity original, TEntity current)
5555
{
5656
_changes.Clear();
57+
_pathStack.Clear();
58+
_memberStack.Clear();
59+
5760
var type = typeof(TEntity);
5861

5962
CompareType(type, original, current);
@@ -427,10 +430,10 @@ private void CreateChange(
427430
{
428431
var currentMember = CurrentMember();
429432
var propertyName = name ?? CurrentName();
430-
var displayName = currentMember.DisplayName ?? propertyName.ToSpacedWords();
433+
var displayName = currentMember?.DisplayName ?? propertyName.ToSpacedWords();
431434
var currentPath = path ?? CurrentPath();
432-
var originalFormatted = FormatValue(original, currentMember.Formatter);
433-
var currentFormatted = FormatValue(current, currentMember.Formatter);
435+
var originalFormatted = FormatValue(original, currentMember?.Formatter);
436+
var currentFormatted = FormatValue(current, currentMember?.Formatter);
434437

435438
var changeRecord = new ChangeRecord
436439
{

0 commit comments

Comments
 (0)