Skip to content

Commit

Permalink
Merge pull request #10 from tonerdo/improve-coverage-accuracy
Browse files Browse the repository at this point in the history
ensure instrumentation code becomes the new target
  • Loading branch information
tonerdo committed Mar 22, 2018
2 parents 87135a5 + d525863 commit 2639aad
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/coverlet.core/Instrumentation/Instrumenter.cs
Expand Up @@ -138,20 +138,21 @@ private Instruction AddInstrumentationCode(MethodDefinition method, ILProcessor

private void ReplaceInstructionTarget(Instruction instruction, Instruction oldTarget, Instruction newTarget)
{
if (!(instruction.Operand is Instruction _instruction)
|| !(instruction.Operand is Instruction[] _instructions))
return;

if (_instruction == oldTarget)
if (instruction.Operand is Instruction _instruction)
{
instruction.Operand = newTarget;
return;
if (_instruction == oldTarget)
{
instruction.Operand = newTarget;
return;
}
}

for (int i = 0; i < _instructions.Length; i++)
else if (instruction.Operand is Instruction[] _instructions)
{
if (_instructions[i] == oldTarget)
_instructions[i] = newTarget;
for (int i = 0; i < _instructions.Length; i++)
{
if (_instructions[i] == oldTarget)
_instructions[i] = newTarget;
}
}
}

Expand Down

0 comments on commit 2639aad

Please sign in to comment.