@@ -553,11 +553,9 @@ static bool CheckForAsyncEnumerator(List<Instruction> instructions, Instruction
553553 ( instructions [ currentIndex - 2 ] . OpCode == OpCodes . Ldarg ||
554554 instructions [ currentIndex - 2 ] . OpCode == OpCodes . Ldarg_0 ) &&
555555 instructions [ currentIndex - 1 ] . OpCode == OpCodes . Ldfld &&
556- (
557- ( instructions [ currentIndex - 1 ] . Operand is FieldDefinition field && IsCompilerGenerated ( field ) && field . FieldType . FullName . StartsWith ( "System.Collections.Generic.IAsyncEnumerator" ) ) ||
558- ( instructions [ currentIndex - 1 ] . Operand is FieldReference fieldRef && IsCompilerGenerated ( fieldRef . Resolve ( ) ) && fieldRef . FieldType . FullName . StartsWith ( "System.Collections.Generic.IAsyncEnumerator" ) )
559- )
560- )
556+ IsCompilerGeneratedField ( instructions [ currentIndex - 1 ] , out FieldDefinition field ) &&
557+ field . FieldType . FullName . StartsWith ( "System.Collections.Generic.IAsyncEnumerator" )
558+ )
561559 {
562560 return true ;
563561 }
@@ -598,10 +596,8 @@ static bool CheckIfExceptionThrown(List<Instruction> instructions, Instruction i
598596 for ( int i = currentIndex - 1 ; i >= minFieldIndex ; -- i )
599597 {
600598 if ( instructions [ i ] . OpCode == OpCodes . Ldfld &&
601- (
602- ( instructions [ i ] . Operand is FieldDefinition field && IsCompilerGenerated ( field ) && field . FieldType . FullName == "System.Object" ) ||
603- ( instructions [ i ] . Operand is FieldReference fieldRef && IsCompilerGenerated ( fieldRef . Resolve ( ) ) && fieldRef . FieldType . FullName == "System.Object" )
604- ) )
599+ IsCompilerGeneratedField ( instructions [ i ] , out FieldDefinition field ) &&
600+ field . FieldType . FullName == "System.Object" )
605601 {
606602 // We expect the call to GetResult() to be no more than four
607603 // instructions before the loading of the field's value.
@@ -932,10 +928,8 @@ static bool DisposeCheck(List<Instruction> instructions, Instruction instruction
932928
933929 if ( currentIndex >= 2 &&
934930 instructions [ currentIndex - 1 ] . OpCode == OpCodes . Ldfld &&
935- (
936- ( instructions [ currentIndex - 1 ] . Operand is FieldDefinition field && IsCompilerGenerated ( field ) && field . FullName . EndsWith ( "__disposeMode" ) ) ||
937- ( instructions [ currentIndex - 1 ] . Operand is FieldReference fieldRef && IsCompilerGenerated ( fieldRef . Resolve ( ) ) && fieldRef . FullName . EndsWith ( "__disposeMode" ) )
938- ) &&
931+ IsCompilerGeneratedField ( instructions [ currentIndex - 1 ] , out FieldDefinition field ) &&
932+ field . FullName . EndsWith ( "__disposeMode" ) &&
939933 ( instructions [ currentIndex - 2 ] . OpCode == OpCodes . Ldarg ||
940934 instructions [ currentIndex - 2 ] . OpCode == OpCodes . Ldarg_0 ) )
941935 {
0 commit comments