Skip to content

Commit 06995c3

Browse files
committed
fix
1 parent 4d630c3 commit 06995c3

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/coverlet.core/Symbols/CecilSymbolHelper.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -497,8 +497,11 @@ static bool CheckForAsyncEnumerator(List<Instruction> instructions, Instruction
497497
(instructions[currentIndex - 2].OpCode == OpCodes.Ldarg ||
498498
instructions[currentIndex - 2].OpCode == OpCodes.Ldarg_0) &&
499499
instructions[currentIndex - 1].OpCode == OpCodes.Ldfld &&
500-
instructions[currentIndex - 1].Operand is FieldDefinition field &&
501-
IsCompilerGenerated(field) && field.FieldType.FullName.StartsWith("System.Collections.Generic.IAsyncEnumerator"))
500+
(
501+
(instructions[currentIndex - 1].Operand is FieldDefinition field && IsCompilerGenerated(field) && field.FieldType.FullName.StartsWith("System.Collections.Generic.IAsyncEnumerator")) ||
502+
(instructions[currentIndex - 1].Operand is FieldReference fieldRef && IsCompilerGenerated(fieldRef.Resolve()) && fieldRef.FieldType.FullName.StartsWith("System.Collections.Generic.IAsyncEnumerator"))
503+
)
504+
)
502505
{
503506
return true;
504507
}
@@ -540,8 +543,9 @@ static bool CheckIfExceptionThrown(List<Instruction> instructions, Instruction i
540543
for (int i = currentIndex - 1; i >= minFieldIndex; --i)
541544
{
542545
if (instructions[i].OpCode == OpCodes.Ldfld &&
543-
instructions[i].Operand is FieldDefinition field &&
544-
IsCompilerGenerated(field) && field.FieldType.FullName == "System.Object")
546+
((instructions[i].Operand is FieldDefinition field && IsCompilerGenerated(field) && field.FieldType.FullName == "System.Object") ||
547+
(instructions[i].Operand is FieldReference fieldRef && IsCompilerGenerated(fieldRef.Resolve()) && fieldRef.FieldType.FullName == "System.Object"))
548+
)
545549
{
546550
// We expect the call to GetResult() to be no more than four
547551
// instructions before the loading of the field's value.

0 commit comments

Comments
 (0)