Skip to content

Commit 4824209

Browse files
committed
fix(XMLDiff): improve element comparison logic to right handle last elements
1 parent 4d4ae11 commit 4824209

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

XMLDiff/Program.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -598,9 +598,13 @@ private static bool CompareElements(
598598
matchedEnough = false;
599599
if (
600600
!CompareElements(original, modified, diffRoot, pathOptions, originalChild, modifiedChild, true)
601-
&& originalChildren[i + 1].Name == modifiedChildren[j + 1].Name
602-
&& originalChildren[i + 1].Attributes().Count() == modifiedChildren[j + 1].Attributes().Count()
603-
&& originalChildren[i + 1].Attributes().All(attr => modifiedChildren[j + 1].Attribute(attr.Name)?.Value == attr.Value)
601+
&& (
602+
i + 1 == originalChildren.Count
603+
|| j + 1 == modifiedChildren.Count
604+
|| originalChildren[i + 1].Name == modifiedChildren[j + 1].Name
605+
&& originalChildren[i + 1].Attributes().Count() == modifiedChildren[j + 1].Attributes().Count()
606+
&& originalChildren[i + 1].Attributes().All(attr => modifiedChildren[j + 1].Attribute(attr.Name)?.Value == attr.Value)
607+
)
604608
)
605609
{
606610
if (savedOp != null)

0 commit comments

Comments
 (0)