@@ -22,6 +22,8 @@ static partial class TypeOffset
22
22
internal static int mp_subscript { get ; private set ; }
23
23
internal static int name { get ; private set ; }
24
24
internal static int nb_add { get ; private set ; }
25
+ internal static int nb_inplace_add { get ; private set ; }
26
+ internal static int nb_inplace_subtract { get ; private set ; }
25
27
internal static int ob_size { get ; private set ; }
26
28
internal static int ob_type { get ; private set ; }
27
29
internal static int qualname { get ; private set ; }
@@ -73,6 +75,7 @@ internal static void Use(ITypeOffsets offsets)
73
75
}
74
76
75
77
ValidateUnusedTypeOffsetProperties ( offsetProperties ) ;
78
+ ValidateRequiredOffsetsPresent ( offsetProperties ) ;
76
79
}
77
80
78
81
static readonly BindingFlags FieldFlags = BindingFlags . NonPublic | BindingFlags . Static ;
@@ -102,5 +105,48 @@ static void ValidateUnusedTypeOffsetProperties(PropertyInfo[] offsetProperties)
102
105
extras . Sort ( ) ;
103
106
Debug . Assert ( extras . Count == 0 , message : string . Join ( ", " , extras ) ) ;
104
107
}
108
+
109
+ [ Conditional ( "DEBUG" ) ]
110
+ static void ValidateRequiredOffsetsPresent ( PropertyInfo [ ] offsetProperties )
111
+ {
112
+ var present = new HashSet < string > ( offsetProperties . Select ( p => p . Name ) ) ;
113
+ var missing = new HashSet < string > ( ) ;
114
+
115
+ var thisAssembly = Assembly . GetExecutingAssembly ( ) ;
116
+ var managedTypes = thisAssembly . GetTypes ( )
117
+ . Where ( typeof ( ManagedType ) . IsAssignableFrom )
118
+ . ToList ( ) ;
119
+ foreach ( var managedType in managedTypes )
120
+ {
121
+ var slots = managedType . GetMethods ( BindingFlags . Public | BindingFlags . Static ) ;
122
+ foreach ( var slot in slots )
123
+ if ( ! present . Contains ( slot . Name ) )
124
+ missing . Add ( slot . Name ) ;
125
+ }
126
+ foreach ( string notSlot in new [ ]
127
+ {
128
+ "__instancecheck__" ,
129
+ "__subclasscheck__" ,
130
+ "_AtExit" ,
131
+ "AddReference" ,
132
+ "FinalizeObject" ,
133
+ "FindAssembly" ,
134
+ "get_SuppressDocs" ,
135
+ "get_SuppressOverloads" ,
136
+ "GetClrType" ,
137
+ "getPreload" ,
138
+ "Initialize" ,
139
+ "ListAssemblies" ,
140
+ "Release" ,
141
+ "Reset" ,
142
+ "set_SuppressDocs" ,
143
+ "set_SuppressOverloads" ,
144
+ "setPreload" ,
145
+ } )
146
+ missing . Remove ( notSlot ) ;
147
+
148
+ Debug . Assert ( missing . Count == 0 ,
149
+ "Missing slots: " + string . Join ( ", " , missing ) ) ;
150
+ }
105
151
}
106
152
}
0 commit comments