@@ -373,32 +373,56 @@ public static void Verify_ManagedUnmanagedFunctionPointersDontMatch()
373
373
extern static string CallManagedMethod ( UserDataClass d , delegate * unmanaged[ Cdecl] < void > fptr ) ;
374
374
}
375
375
376
- class InheritanceBase
376
+ abstract class InheritanceBase
377
377
{
378
378
private static string OnBase ( ) => nameof ( OnBase ) ;
379
379
private static string FieldOnBase = nameof ( FieldOnBase ) ;
380
+ protected abstract string Abstract ( ) ;
381
+ protected virtual string Virtual ( ) => $ "{ nameof ( InheritanceBase ) } .{ nameof ( Virtual ) } ";
382
+ protected virtual string NewVirtual ( ) => $ "{ nameof ( InheritanceBase ) } .{ nameof ( NewVirtual ) } ";
383
+ protected virtual string BaseVirtual ( ) => $ "{ nameof ( InheritanceBase ) } .{ nameof ( BaseVirtual ) } ";
380
384
}
381
385
382
386
class InheritanceDerived : InheritanceBase
383
387
{
384
388
private static string OnDerived ( ) => nameof ( OnDerived ) ;
385
389
private static string FieldOnDerived = nameof ( FieldOnDerived ) ;
390
+ protected override string Abstract ( ) => $ "{ nameof ( InheritanceDerived ) } .{ nameof ( Abstract ) } ";
391
+ protected override string Virtual ( ) => $ "{ nameof ( InheritanceDerived ) } .{ nameof ( Virtual ) } ";
392
+ protected new virtual string NewVirtual ( ) => $ "{ nameof ( InheritanceDerived ) } .{ nameof ( NewVirtual ) } ";
386
393
}
387
394
388
395
[ Fact ]
396
+ [ ActiveIssue ( "https://github.com/dotnet/runtime/issues/89212" , TestRuntimes . Mono ) ]
389
397
public static void Verify_InheritanceMethodResolution ( )
390
398
{
391
399
Console . WriteLine ( $ "Running { nameof ( Verify_InheritanceMethodResolution ) } ") ;
392
400
393
401
var instance = new InheritanceDerived ( ) ;
394
402
Assert . Throws < MissingMethodException > ( ( ) => OnBase ( instance ) ) ;
403
+ Assert . Throws < MissingMethodException > ( ( ) => BaseVirtual ( instance ) ) ;
395
404
Assert . Equal ( nameof ( OnDerived ) , OnDerived ( instance ) ) ;
405
+ Assert . Equal ( $ "{ nameof ( InheritanceDerived ) } .{ nameof ( Abstract ) } ", Abstract ( instance ) ) ;
406
+ Assert . Equal ( $ "{ nameof ( InheritanceDerived ) } .{ nameof ( Virtual ) } ", Virtual ( instance ) ) ;
407
+ Assert . Equal ( $ "{ nameof ( InheritanceBase ) } .{ nameof ( NewVirtual ) } ", NewVirtual ( instance ) ) ;
396
408
397
409
[ UnsafeAccessor ( UnsafeAccessorKind . StaticMethod , Name = nameof ( OnBase ) ) ]
398
410
extern static string OnBase ( InheritanceDerived i ) ;
399
411
412
+ [ UnsafeAccessor ( UnsafeAccessorKind . Method , Name = nameof ( BaseVirtual ) ) ]
413
+ extern static string BaseVirtual ( InheritanceDerived target ) ;
414
+
400
415
[ UnsafeAccessor ( UnsafeAccessorKind . StaticMethod , Name = nameof ( OnDerived ) ) ]
401
416
extern static string OnDerived ( InheritanceDerived i ) ;
417
+
418
+ [ UnsafeAccessor ( UnsafeAccessorKind . Method , Name = nameof ( Abstract ) ) ]
419
+ extern static string Abstract ( InheritanceBase target ) ;
420
+
421
+ [ UnsafeAccessor ( UnsafeAccessorKind . Method , Name = nameof ( Virtual ) ) ]
422
+ extern static string Virtual ( InheritanceBase target ) ;
423
+
424
+ [ UnsafeAccessor ( UnsafeAccessorKind . Method , Name = nameof ( NewVirtual ) ) ]
425
+ extern static string NewVirtual ( InheritanceBase target ) ;
402
426
}
403
427
404
428
[ Fact ]
@@ -436,7 +460,7 @@ public static void Verify_InvalidTargetUnsafeAccessor()
436
460
( ) => FieldNotFound ( null ) ) ;
437
461
AssertExtensions . ThrowsMissingMemberException < MissingFieldException > (
438
462
isNativeAot ? null : UserDataClass . StaticFieldName ,
439
- ( ) =>
463
+ ( ) =>
440
464
{
441
465
UserDataValue value = default ;
442
466
FieldNotFoundStaticMismatch1 ( ref value ) ;
@@ -489,6 +513,8 @@ public static void Verify_InvalidTargetUnsafeAccessor()
489
513
[ ActiveIssue ( "https://github.com/dotnet/runtime/issues/86040" , TestRuntimes . Mono ) ]
490
514
public static void Verify_InvalidTargetUnsafeAccessorAmbiguousMatch ( )
491
515
{
516
+ Console . WriteLine ( $ "Running { nameof ( Verify_InvalidTargetUnsafeAccessorAmbiguousMatch ) } ") ;
517
+
492
518
Assert . Throws < AmbiguousMatchException > (
493
519
( ) => CallAmbiguousMethod ( CallPrivateConstructorClass ( ) , null ) ) ;
494
520
0 commit comments