Skip to content

Commit 702c6b0

Browse files
committed
clone navigator before move it
1 parent 3d8ced8 commit 702c6b0

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

SharedProject/Core/MsTestPlatform/CodeCoverage/UserRunSettingsService.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,9 @@ private void EnsureCorrectMsDataCollectorAndReplace(XPathNavigator xpathNavigato
193193
if (msDataCollectorNavigator != null)
194194
{
195195
addedMsDataCollector = false;
196+
var msDataCollectorNavigatorClone = msDataCollectorNavigator.Clone();
196197
EnsureCorrectCoberturaFormat(msDataCollectorNavigator);
197-
ReplaceExcludesIncludes(msDataCollectorNavigator.Clone(), replacements);
198+
ReplaceExcludesIncludes(msDataCollectorNavigatorClone, replacements);
198199
}
199200
else
200201
{
@@ -236,27 +237,27 @@ private void ReplaceExcludesIncludes(XPathNavigator msDataCollectorNavigator, IR
236237
msDataCollectorNavigator.OuterXml = replaced;
237238
}
238239

239-
private void EnsureCorrectCoberturaFormat(XPathNavigator navigator)
240+
private void EnsureCorrectCoberturaFormat(XPathNavigator msDataCollectorNavigator)
240241
{
241-
var movedToConfiguration = navigator.MoveToChild("Configuration", "");
242+
var movedToConfiguration = msDataCollectorNavigator.MoveToChild("Configuration", "");
242243
if (movedToConfiguration)
243244
{
244-
var movedToFormat = navigator.MoveToChild("Format", "");
245+
var movedToFormat = msDataCollectorNavigator.MoveToChild("Format", "");
245246
if (movedToFormat)
246247
{
247-
if (navigator.InnerXml != "Cobertura")
248+
if (msDataCollectorNavigator.InnerXml != "Cobertura")
248249
{
249-
navigator.InnerXml = "Cobertura";
250+
msDataCollectorNavigator.InnerXml = "Cobertura";
250251
}
251252
}
252253
else
253254
{
254-
navigator.AppendChild("<Format>Cobertura</Format>");
255+
msDataCollectorNavigator.AppendChild("<Format>Cobertura</Format>");
255256
}
256257
}
257258
else
258259
{
259-
navigator.AppendChild("<Configuration><Format>Cobertura</Format></Configuration>");
260+
msDataCollectorNavigator.AppendChild("<Configuration><Format>Cobertura</Format></Configuration>");
260261
}
261262
}
262263

0 commit comments

Comments
 (0)