@@ -329,10 +329,14 @@ private bool TryGetByReflection(TSelfType target, out object result) {
329329 return false ;
330330 }
331331
332- private static TryGetProperty TryGetByJit ( MethodInfo method ) {
333- return method . DeclaringType ! . IsAssignableFrom ( typeof ( TSelfType ) )
334- ? TryGetByJitWithoutCast ( method )
335- : TryGetByJitRequiringCast ( method ) ;
332+ private TryGetProperty TryGetByJit ( MethodInfo method ) {
333+ try {
334+ return method . DeclaringType ! . IsAssignableFrom ( typeof ( TSelfType ) )
335+ ? TryGetByJitWithoutCast ( method )
336+ : TryGetByJitRequiringCast ( method ) ;
337+ } catch ( NotImplementedException ) { // Mono can throw this...
338+ return TryGetByReflection ;
339+ }
336340 }
337341
338342 private static TryGetProperty TryGetByJitWithoutCast ( MethodInfo method ) {
@@ -342,8 +346,6 @@ private static TryGetProperty TryGetByJitWithoutCast(MethodInfo method) {
342346 var returnTarget = Expression . Label ( typeof ( bool ) ) ;
343347 return Expression . Lambda < TryGetProperty > (
344348 Expression . Block ( new Expression [ ] {
345-
346-
347349 Expression . IfThen (
348350 // if (input != null)
349351 Expression . NotEqual ( input , Expression . Constant ( null ) ) ,
@@ -482,8 +484,8 @@ private Func<CallSite, TSelfType, CodeContext, object> MakeGetMemberTarget<TSelf
482484 case TrackerTypes . Property :
483485 if ( members . Count == 1 ) {
484486 PropertyTracker pt = ( PropertyTracker ) members [ 0 ] ;
485- if ( ! pt . IsStatic && pt . GetIndexParameters ( ) is { Length : 0 } ) {
486- if ( pt . GetGetMethod ( ) is { } prop && prop . GetParameters ( ) is { Length : 0 } ) {
487+ if ( ! pt . IsStatic && pt . GetIndexParameters ( ) is { Length : 0 } ) {
488+ if ( pt . GetGetMethod ( ) is { } prop && prop . GetParameters ( ) is { Length : 0 } ) {
487489 return new TieredJitPropertyGet < TSelfType > ( type , prop ) . GetProperty ;
488490 }
489491 }
0 commit comments