diff options
Diffstat (limited to 'test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/InterfaceVariants.cs')
-rw-r--r-- | test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/InterfaceVariants.cs | 94 |
1 files changed, 73 insertions, 21 deletions
diff --git a/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/InterfaceVariants.cs b/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/InterfaceVariants.cs index f9d54d009..9b766b42a 100644 --- a/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/InterfaceVariants.cs +++ b/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/InterfaceVariants.cs @@ -17,24 +17,77 @@ namespace Mono.Linker.Tests.Cases.Inheritance.Interfaces public static void Main () { Type t = typeof (UninstantiatedPublicClassWithInterface); - t = typeof (UninstantiatedPublicClassWithImplicitlyImplementedInterface); + t = typeof (UninstantiatedClassWithImplicitlyImplementedInterface); t = typeof (UninstantiatedPublicClassWithPrivateInterface); + t = typeof (ImplementsUsedStaticInterface.InterfaceMethodUnused); + t = typeof (ImplementsUnusedStaticInterface.InterfaceMethodUnused); - UninstantiatedPublicClassWithInterface.InternalStaticInterfaceMethodUsed (); - InstantiatedClassWithInterfaces.InternalStaticInterfaceMethodUsed (); - + ImplementsUnusedStaticInterface.InterfaceMethodUsedThroughImplementation.InternalStaticInterfaceMethodUsedThroughImplementation (); + GenericMethodThatCallsInternalStaticInterfaceMethod + <ImplementsUsedStaticInterface.InterfaceMethodUsedThroughInterface> (); // Use all public interfaces - they're marked as public only to denote them as "used" typeof (IPublicInterface).RequiresPublicMethods (); typeof (IPublicStaticInterface).RequiresPublicMethods (); + var ___ = new InstantiatedClassWithInterfaces (); + } + + [Kept] + internal static void GenericMethodThatCallsInternalStaticInterfaceMethod<T> () where T : IStaticInterfaceUsed + { + T.StaticMethodUsedThroughInterface (); + } + + [Kept] + class ImplementsUsedStaticInterface + { + + [Kept] + [KeptInterface (typeof (IStaticInterfaceUsed))] + internal class InterfaceMethodUsedThroughInterface : IStaticInterfaceUsed + { + [Kept] + [KeptOverride (typeof (IStaticInterfaceUsed))] + public static void StaticMethodUsedThroughInterface () + { + } + public static void UnusedMethod () { } + } + + [Kept] + [KeptInterface (typeof (IStaticInterfaceUsed))] + internal class InterfaceMethodUnused : IStaticInterfaceUsed + { + [Kept] + [KeptOverride (typeof (IStaticInterfaceUsed))] + public static void StaticMethodUsedThroughInterface () + { + } + public static void UnusedMethod () { } + } + } + + [Kept] + internal class ImplementsUnusedStaticInterface + { + [Kept] + internal class InterfaceMethodUsedThroughImplementation : IStaticInterfaceUnused + { + [Kept] + [RemovedOverride (typeof (IStaticInterfaceUnused))] + public static void InternalStaticInterfaceMethodUsedThroughImplementation () { } + } - var a = new InstantiatedClassWithInterfaces (); + [Kept] + internal class InterfaceMethodUnused : IStaticInterfaceUnused + { + public static void InternalStaticInterfaceMethodUsedThroughImplementation () { } + } } [Kept] [KeptInterface (typeof (IEnumerator))] [KeptInterface (typeof (IPublicInterface))] [KeptInterface (typeof (IPublicStaticInterface))] - [KeptInterface (typeof (IInternalStaticInterfaceWithUsedMethod))] // https://github.com/dotnet/linker/issues/2733 [KeptInterface (typeof (ICopyLibraryInterface))] [KeptInterface (typeof (ICopyLibraryStaticInterface))] public class UninstantiatedPublicClassWithInterface : @@ -42,7 +95,6 @@ namespace Mono.Linker.Tests.Cases.Inheritance.Interfaces IPublicStaticInterface, IInternalInterface, IInternalStaticInterface, - IInternalStaticInterfaceWithUsedMethod, IEnumerator, ICopyLibraryInterface, ICopyLibraryStaticInterface @@ -69,8 +121,6 @@ namespace Mono.Linker.Tests.Cases.Inheritance.Interfaces static void IInternalStaticInterface.ExplicitImplementationInternalStaticInterfaceMethod () { } - [Kept] - public static void InternalStaticInterfaceMethodUsed () { } [Kept] [ExpectBodyModified] @@ -101,9 +151,9 @@ namespace Mono.Linker.Tests.Cases.Inheritance.Interfaces [Kept] [KeptInterface (typeof (IFormattable))] - public class UninstantiatedPublicClassWithImplicitlyImplementedInterface : IInternalInterface, IFormattable + public class UninstantiatedClassWithImplicitlyImplementedInterface : IInternalInterface, IFormattable { - internal UninstantiatedPublicClassWithImplicitlyImplementedInterface () { } + internal UninstantiatedClassWithImplicitlyImplementedInterface () { } public void InternalInterfaceMethod () { } @@ -122,7 +172,6 @@ namespace Mono.Linker.Tests.Cases.Inheritance.Interfaces [KeptInterface (typeof (IEnumerator))] [KeptInterface (typeof (IPublicInterface))] [KeptInterface (typeof (IPublicStaticInterface))] - [KeptInterface (typeof (IInternalStaticInterfaceWithUsedMethod))] // https://github.com/dotnet/linker/issues/2733 [KeptInterface (typeof (ICopyLibraryInterface))] [KeptInterface (typeof (ICopyLibraryStaticInterface))] public class InstantiatedClassWithInterfaces : @@ -130,7 +179,6 @@ namespace Mono.Linker.Tests.Cases.Inheritance.Interfaces IPublicStaticInterface, IInternalInterface, IInternalStaticInterface, - IInternalStaticInterfaceWithUsedMethod, IEnumerator, ICopyLibraryInterface, ICopyLibraryStaticInterface @@ -159,9 +207,6 @@ namespace Mono.Linker.Tests.Cases.Inheritance.Interfaces static void IInternalStaticInterface.ExplicitImplementationInternalStaticInterfaceMethod () { } [Kept] - public static void InternalStaticInterfaceMethodUsed () { } - - [Kept] bool IEnumerator.MoveNext () { throw new PlatformNotSupportedException (); } [Kept] @@ -225,13 +270,20 @@ namespace Mono.Linker.Tests.Cases.Inheritance.Interfaces static abstract void ExplicitImplementationInternalStaticInterfaceMethod (); } - // The interface methods themselves are not used, but the implentation of these methods is - // https://github.com/dotnet/linker/issues/2733 + // The interface methods themselves are not used, but the implementation of these methods is + internal interface IStaticInterfaceUnused + { + static abstract void InternalStaticInterfaceMethodUsedThroughImplementation (); + } + + // The interface methods themselves are used through the interface [Kept] - internal interface IInternalStaticInterfaceWithUsedMethod + internal interface IStaticInterfaceUsed { - [Kept] // https://github.com/dotnet/linker/issues/2733 - static abstract void InternalStaticInterfaceMethodUsed (); + [Kept] + static abstract void StaticMethodUsedThroughInterface (); + + static abstract void UnusedMethod (); } private interface IPrivateInterface |