File tree Expand file tree Collapse file tree 2 files changed +17
-9
lines changed Expand file tree Collapse file tree 2 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -449,15 +449,26 @@ private static Func<IInspectable, object> CreateAbiNullableTFactory(
449
449
#endif
450
450
Type implementationType )
451
451
{
452
+ // This method is only called when 'implementationType' has been validated to be some ABI.System.Nullable_Delegate<T>.
453
+ // As such, we know that the type definitely has a method with signature 'static Nullable GetValue(IInspectable)'.
452
454
var getValueMethod = implementationType . GetMethod ( "GetValue" , BindingFlags . Static | BindingFlags . NonPublic ) ;
455
+
456
+ #if NET6_0_OR_GREATER
457
+ return getValueMethod . CreateDelegate < Func < IInspectable , ABI . System . Nullable > > ( ) ;
458
+ #else
453
459
return ( IInspectable obj ) => getValueMethod . Invoke ( null , new [ ] { obj } ) ;
460
+ #endif
454
461
}
455
462
456
463
private static Func < IInspectable , object > CreateArrayFactory ( Type implementationType )
457
464
{
458
- var getValueFunc = ( Func < IInspectable , object > ) implementationType . GetHelperType ( ) . GetMethod ( "GetValue" , BindingFlags . Static | BindingFlags . NonPublic ) .
459
- CreateDelegate ( typeof ( Func < IInspectable , object > ) ) ;
460
- return getValueFunc ;
465
+ var getValueMethod = implementationType . GetHelperType ( ) . GetMethod ( "GetValue" , BindingFlags . Static | BindingFlags . NonPublic ) ;
466
+
467
+ #if NET6_0_OR_GREATER
468
+ return getValueMethod . CreateDelegate < Func < IInspectable , object > > ( ) ;
469
+ #else
470
+ return ( Func < IInspectable , object > ) getValueMethod . CreateDelegate ( typeof ( Func < IInspectable , object > ) ) ;
471
+ #endif
461
472
}
462
473
463
474
// This is used to hold the reference to the native value type object (IReference) until the actual value in it (boxed as an object) gets cleaned up by GC
Original file line number Diff line number Diff line change @@ -244,13 +244,10 @@ internal static Type GetAuthoringMetadataType(this Type type)
244
244
{
245
245
return null ;
246
246
}
247
- else
248
247
#endif
249
- {
250
- // Fallback code path for back compat with previously generated projections
251
- // running without AOT.
252
- return GetAuthoringMetadataTypeFallback ( type ) ;
253
- }
248
+ // Fallback code path for back compat with previously generated projections
249
+ // running without AOT.
250
+ return GetAuthoringMetadataTypeFallback ( type ) ;
254
251
} ) ;
255
252
}
256
253
You can’t perform that action at this time.
0 commit comments