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

Consecutive references marked for deletion are skipped #9

Closed
manfred-brands opened this issue May 3, 2018 · 1 comment
Closed

Consecutive references marked for deletion are skipped #9

manfred-brands opened this issue May 3, 2018 · 1 comment

Comments

@manfred-brands
Copy link

manfred-brands commented May 3, 2018

In the method RemoveNodesInProject, the code iterates using an index over an array from which elements are deleted. When element 2 is deleted, the element 3 becomes element 2. As the indexer is always incremented, the next item considered is element 3 meaning the old element 3 (now 2) is skipped.

Fixed code:

-           for (var i = 0; i < item.ChildNodes.Count; i++)
+          for (var i = 0; i < item.ChildNodes.Count; )
            {
                if (_isCancel)
                    break;

                if (_nodesToRemove.Any(x => x.Attributes[0].Value == item.ChildNodes[i].Attributes[0].Value))
                    item.RemoveChild(item.ChildNodes[i]);
+               else
+                   i++;
            }
@manfred-brands
Copy link
Author

Issue merged into master by Suresh.

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