@@ -287,13 +287,45 @@ private void FillTypeSpecsFromTypes()
287
287
{
288
288
foreach ( TypeDefinition td in _context . TypeDefinitionTable . Items )
289
289
{
290
+ // Fields of the type
291
+ foreach ( var field in td . Fields . Where ( f => ! f . IsLiteral ) )
292
+ {
293
+ if ( field . FieldType is ArrayType array && array . ElementType is GenericParameter )
294
+ {
295
+ AddIfNew ( field . FieldType , _context . SignaturesTable . GetOrCreateSignatureId ( field . FieldType ) ) ;
296
+ }
297
+ }
298
+
290
299
foreach ( MethodDefinition m in td . Methods . Where ( m => m . HasBody ) )
291
300
{
292
301
foreach ( Instruction instr in m . Body . Instructions )
293
302
{
294
- if ( instr . Operand is GenericParameter gp )
303
+ if ( instr . Operand is GenericInstanceMethod genericInstanceMethod )
295
304
{
296
- AddIfNew ( gp , _context . SignaturesTable . GetOrCreateSignatureId ( gp ) ) ;
305
+ GenericInstanceType genericInstanceType = genericInstanceMethod . DeclaringType as GenericInstanceType ;
306
+ if ( genericInstanceType != null
307
+ && ! _idByTypeSpecifications . ContainsKey ( genericInstanceType )
308
+ && ! genericInstanceType . IsToExclude ( ) )
309
+ {
310
+ ushort sigId = _context . SignaturesTable . GetOrCreateSignatureId ( genericInstanceType ) ;
311
+ _idByTypeSpecifications . Add ( genericInstanceType , sigId ) ;
312
+
313
+ // also pull in its element‐type and args
314
+ ExpandNestedTypeSpecs ( genericInstanceType ) ;
315
+ }
316
+
317
+ // capture the *return‐type* of the instantiation (e.g. T[] for Array.Empty<T>())
318
+ TypeReference returnType = genericInstanceMethod . ReturnType ;
319
+ ExpandNestedTypeSpecs ( returnType ) ;
320
+
321
+ if ( returnType is ArrayType )
322
+ {
323
+ if ( ! _idByTypeSpecifications . ContainsKey ( returnType . GetElementType ( ) )
324
+ && ! returnType . GetElementType ( ) . IsToExclude ( ) )
325
+ {
326
+ AddIfNew ( returnType . GetElementType ( ) , _context . SignaturesTable . GetOrCreateSignatureId ( returnType . GetElementType ( ) ) ) ;
327
+ }
328
+ }
297
329
}
298
330
else if ( instr . Operand is MethodReference mr )
299
331
{
@@ -306,27 +338,16 @@ private void FillTypeSpecsFromTypes()
306
338
ExpandNestedTypeSpecs ( p . ParameterType ) ;
307
339
}
308
340
}
309
-
341
+ else if ( instr . Operand is GenericParameter gp )
342
+ {
343
+ AddIfNew ( gp , _context . SignaturesTable . GetOrCreateSignatureId ( gp ) ) ;
344
+ }
310
345
// catch field‐refs too
311
346
else if ( instr . Operand is FieldReference fieldRef )
312
347
{
313
348
ExpandNestedTypeSpecs ( fieldRef . DeclaringType ) ;
314
349
ExpandNestedTypeSpecs ( fieldRef . FieldType ) ;
315
350
}
316
- else if ( instr . Operand is GenericInstanceMethod genericInstanceMethod )
317
- {
318
- GenericInstanceType genericInstanceType = genericInstanceMethod . DeclaringType as GenericInstanceType ;
319
- if ( genericInstanceType != null
320
- && ! _idByTypeSpecifications . ContainsKey ( genericInstanceType )
321
- && ! genericInstanceType . IsToExclude ( ) )
322
- {
323
- ushort sigId = _context . SignaturesTable . GetOrCreateSignatureId ( genericInstanceType ) ;
324
- _idByTypeSpecifications . Add ( genericInstanceType , sigId ) ;
325
-
326
- // also pull in its element‐type and args
327
- ExpandNestedTypeSpecs ( genericInstanceType ) ;
328
- }
329
- }
330
351
else if ( instr . Operand is TypeReference tr )
331
352
{
332
353
// refuse multi-dimensional arrays (we only support jagged arrays)
0 commit comments