@@ -44,12 +44,12 @@ internal enum AssignmentVariation
44
44
[ RuntimeExport ( "RhTypeCast_IsInstanceOfClass" ) ]
45
45
public static unsafe object IsInstanceOfClass ( MethodTable * pTargetType , object obj )
46
46
{
47
- if ( obj == null || obj . MethodTable == pTargetType )
47
+ if ( obj == null || obj . GetMethodTable ( ) == pTargetType )
48
48
{
49
49
return obj ;
50
50
}
51
51
52
- MethodTable * pObjType = obj . MethodTable ;
52
+ MethodTable * pObjType = obj . GetMethodTable ( ) ;
53
53
54
54
Debug . Assert ( ! pTargetType ->IsParameterizedType , "IsInstanceOfClass called with parameterized MethodTable" ) ;
55
55
Debug . Assert ( ! pTargetType ->IsInterface , "IsInstanceOfClass called with interface MethodTable" ) ;
@@ -177,7 +177,7 @@ public static unsafe object IsInstanceOfArray(MethodTable* pTargetType, object o
177
177
return null ;
178
178
}
179
179
180
- MethodTable * pObjType = obj . MethodTable ;
180
+ MethodTable * pObjType = obj . GetMethodTable ( ) ;
181
181
182
182
Debug . Assert ( pTargetType ->IsArray , "IsInstanceOfArray called with non-array MethodTable" ) ;
183
183
Debug . Assert ( ! pTargetType ->IsCloned , "cloned array types are disallowed" ) ;
@@ -244,7 +244,7 @@ public static unsafe object IsInstanceOfInterface(MethodTable* pTargetType, obje
244
244
return null ;
245
245
}
246
246
247
- MethodTable * pObjType = obj . MethodTable ;
247
+ MethodTable * pObjType = obj . GetMethodTable ( ) ;
248
248
249
249
if ( CastCache . AreTypesAssignableInternal_SourceNotTarget_BoxedSource ( pObjType , pTargetType , null ) )
250
250
return obj ;
@@ -661,7 +661,7 @@ public static unsafe object CheckCastInterface(MethodTable* pTargetType, object
661
661
return null ;
662
662
}
663
663
664
- MethodTable * pObjType = obj . MethodTable ;
664
+ MethodTable * pObjType = obj . GetMethodTable ( ) ;
665
665
666
666
if ( CastCache . AreTypesAssignableInternal_SourceNotTarget_BoxedSource ( pObjType , pTargetType , null ) )
667
667
return obj ;
@@ -687,21 +687,21 @@ public static unsafe void CheckArrayStore(object array, object obj)
687
687
return ;
688
688
}
689
689
690
- Debug . Assert ( array . MethodTable ->IsArray , "first argument must be an array" ) ;
690
+ Debug . Assert ( array . GetMethodTable ( ) ->IsArray , "first argument must be an array" ) ;
691
691
692
- MethodTable * arrayElemType = array . MethodTable ->RelatedParameterType ;
693
- if ( CastCache . AreTypesAssignableInternal ( obj . MethodTable , arrayElemType , AssignmentVariation . BoxedSource , null ) )
692
+ MethodTable * arrayElemType = array . GetMethodTable ( ) ->RelatedParameterType ;
693
+ if ( CastCache . AreTypesAssignableInternal ( obj . GetMethodTable ( ) , arrayElemType , AssignmentVariation . BoxedSource , null ) )
694
694
return ;
695
695
696
696
// If object type implements IDynamicInterfaceCastable then there's one more way to check whether it implements
697
697
// the interface.
698
- if ( obj . MethodTable ->IsIDynamicInterfaceCastable && IsInstanceOfInterfaceViaIDynamicInterfaceCastable ( arrayElemType , obj , throwing : false ) )
698
+ if ( obj . GetMethodTable ( ) ->IsIDynamicInterfaceCastable && IsInstanceOfInterfaceViaIDynamicInterfaceCastable ( arrayElemType , obj , throwing : false ) )
699
699
return ;
700
700
701
701
// Throw the array type mismatch exception defined by the classlib, using the input array's MethodTable*
702
702
// to find the correct classlib.
703
703
704
- throw array . MethodTable ->GetClasslibException ( ExceptionIDs . ArrayTypeMismatch ) ;
704
+ throw array . GetMethodTable ( ) ->GetClasslibException ( ExceptionIDs . ArrayTypeMismatch ) ;
705
705
}
706
706
707
707
[ RuntimeExport ( "RhTypeCast_CheckVectorElemAddr" ) ]
@@ -712,9 +712,9 @@ public static unsafe void CheckVectorElemAddr(MethodTable* elemType, object arra
712
712
return ;
713
713
}
714
714
715
- Debug . Assert ( array . MethodTable ->IsArray , "second argument must be an array" ) ;
715
+ Debug . Assert ( array . GetMethodTable ( ) ->IsArray , "second argument must be an array" ) ;
716
716
717
- MethodTable * arrayElemType = array . MethodTable ->RelatedParameterType ;
717
+ MethodTable * arrayElemType = array . GetMethodTable ( ) ->RelatedParameterType ;
718
718
719
719
if ( ! AreTypesEquivalent ( elemType , arrayElemType )
720
720
// In addition to the exactness check, add another check to allow non-exact matches through
@@ -730,7 +730,7 @@ public static unsafe void CheckVectorElemAddr(MethodTable* elemType, object arra
730
730
// Throw the array type mismatch exception defined by the classlib, using the input array's MethodTable*
731
731
// to find the correct classlib.
732
732
733
- throw array . MethodTable ->GetClasslibException ( ExceptionIDs . ArrayTypeMismatch ) ;
733
+ throw array . GetMethodTable ( ) ->GetClasslibException ( ExceptionIDs . ArrayTypeMismatch ) ;
734
734
}
735
735
}
736
736
@@ -746,7 +746,7 @@ internal struct ArrayElement
746
746
public static unsafe void StelemRef ( Array array , int index , object obj )
747
747
{
748
748
// This is supported only on arrays
749
- Debug . Assert ( array . MethodTable ->IsArray , "first argument must be an array" ) ;
749
+ Debug . Assert ( array . GetMethodTable ( ) ->IsArray , "first argument must be an array" ) ;
750
750
751
751
#if INPLACE_RUNTIME
752
752
// this will throw appropriate exceptions if array is null or access is out of range.
@@ -766,12 +766,12 @@ public static unsafe void StelemRef(Array array, int index, object obj)
766
766
ref object element = ref Unsafe . Add ( ref rawData , index ) ;
767
767
#endif
768
768
769
- MethodTable * elementType = array . MethodTable ->RelatedParameterType ;
769
+ MethodTable * elementType = array . GetMethodTable ( ) ->RelatedParameterType ;
770
770
771
771
if ( obj == null )
772
772
goto assigningNull ;
773
773
774
- if ( elementType != obj . MethodTable )
774
+ if ( elementType != obj . GetMethodTable ( ) )
775
775
goto notExactMatch ;
776
776
777
777
doWrite :
@@ -785,7 +785,7 @@ public static unsafe void StelemRef(Array array, int index, object obj)
785
785
notExactMatch :
786
786
#if INPLACE_RUNTIME
787
787
// This optimization only makes sense for inplace runtime where there's only one System.Object.
788
- if ( array . MethodTable == MethodTableOf < object [ ] > ( ) )
788
+ if ( array . GetMethodTable ( ) == MethodTable . Of < object [ ] > ( ) )
789
789
goto doWrite ;
790
790
#endif
791
791
@@ -795,15 +795,15 @@ public static unsafe void StelemRef(Array array, int index, object obj)
795
795
[ MethodImpl ( MethodImplOptions . NoInlining ) ]
796
796
private static unsafe void StelemRef_Helper ( ref object element , MethodTable * elementType , object obj )
797
797
{
798
- if ( CastCache . AreTypesAssignableInternal ( obj . MethodTable , elementType , AssignmentVariation . BoxedSource , null ) )
798
+ if ( CastCache . AreTypesAssignableInternal ( obj . GetMethodTable ( ) , elementType , AssignmentVariation . BoxedSource , null ) )
799
799
{
800
800
InternalCalls . RhpAssignRef ( ref element , obj ) ;
801
801
}
802
802
else
803
803
{
804
804
// If object type implements IDynamicInterfaceCastable then there's one more way to check whether it implements
805
805
// the interface.
806
- if ( ! obj . MethodTable ->IsIDynamicInterfaceCastable || ! IsInstanceOfInterfaceViaIDynamicInterfaceCastable ( elementType , obj , throwing : false ) )
806
+ if ( ! obj . GetMethodTable ( ) ->IsIDynamicInterfaceCastable || ! IsInstanceOfInterfaceViaIDynamicInterfaceCastable ( elementType , obj , throwing : false ) )
807
807
{
808
808
// Throw the array type mismatch exception defined by the classlib, using the input array's
809
809
// MethodTable* to find the correct classlib.
@@ -816,17 +816,17 @@ private static unsafe void StelemRef_Helper(ref object element, MethodTable* ele
816
816
[ RuntimeExport ( "RhpLdelemaRef" ) ]
817
817
public static unsafe ref object LdelemaRef ( Array array , int index , IntPtr elementType )
818
818
{
819
- Debug . Assert ( array . MethodTable ->IsArray , "first argument must be an array" ) ;
819
+ Debug . Assert ( array . GetMethodTable ( ) ->IsArray , "first argument must be an array" ) ;
820
820
821
821
MethodTable * elemType = ( MethodTable * ) elementType ;
822
- MethodTable * arrayElemType = array . MethodTable ->RelatedParameterType ;
822
+ MethodTable * arrayElemType = array . GetMethodTable ( ) ->RelatedParameterType ;
823
823
824
824
if ( ! AreTypesEquivalent ( elemType , arrayElemType ) )
825
825
{
826
826
// Throw the array type mismatch exception defined by the classlib, using the input array's MethodTable*
827
827
// to find the correct classlib.
828
828
829
- throw array . MethodTable ->GetClasslibException ( ExceptionIDs . ArrayTypeMismatch ) ;
829
+ throw array . GetMethodTable ( ) ->GetClasslibException ( ExceptionIDs . ArrayTypeMismatch ) ;
830
830
}
831
831
832
832
ref object rawData = ref Unsafe . As < byte , object > ( ref Unsafe . As < RawArrayData > ( array ) . Data ) ;
0 commit comments