diff options
author | Jackson Schuster <36744439+jtschuster@users.noreply.github.com> | 2022-10-28 01:19:52 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-28 01:19:52 +0300 |
commit | 83068876a4d126026dde79158360364321ebd7c9 (patch) | |
tree | 9193dc7b873d5e4d4e19f0d830a0430d06ed7893 /test | |
parent | ef10f6dbaa8aae99804e3deaaba6a276a5668285 (diff) |
Check for marking virtual method due to base only when state changes (#3073)
Instead of checking every virtual method to see if it should be kept due
to a base method every iteration of the MarkStep pipeline, check each
method only when its relevant state has changed.
Co-authored-by: Sven Boemer <sbomer@gmail.com>
Diffstat (limited to 'test')
3 files changed, 19 insertions, 15 deletions
diff --git a/test/Mono.Linker.Tests.Cases/Attributes/TypeWithDynamicInterfaceCastableImplementationAttributeIsKept.cs b/test/Mono.Linker.Tests.Cases/Attributes/TypeWithDynamicInterfaceCastableImplementationAttributeIsKept.cs index 7065930ac..c6dd27cb5 100644 --- a/test/Mono.Linker.Tests.Cases/Attributes/TypeWithDynamicInterfaceCastableImplementationAttributeIsKept.cs +++ b/test/Mono.Linker.Tests.Cases/Attributes/TypeWithDynamicInterfaceCastableImplementationAttributeIsKept.cs @@ -16,6 +16,8 @@ namespace Mono.Linker.Tests.Cases.Attributes [KeptMemberInAssembly ("impl", "Mono.Linker.Tests.Cases.Attributes.Dependencies.IReferencedAssemblyImpl", "Foo()")] [KeptInterfaceOnTypeInAssembly ("impl", "Mono.Linker.Tests.Cases.Attributes.Dependencies.IReferencedAssemblyImpl", "interface", "Mono.Linker.Tests.Cases.Attributes.Dependencies.IReferencedAssembly")] + [SetupLinkerTrimMode ("link")] + [IgnoreDescriptors (false)] public class TypeWithDynamicInterfaceCastableImplementationAttributeIsKept { public static void Main () @@ -54,6 +56,7 @@ namespace Mono.Linker.Tests.Cases.Attributes #if NETCOREAPP [Kept] [KeptMember (".ctor()")] + [KeptInterface (typeof (IDynamicInterfaceCastable))] class Foo : IDynamicInterfaceCastable { [Kept] @@ -74,6 +77,7 @@ namespace Mono.Linker.Tests.Cases.Attributes [Kept] [KeptMember (".ctor()")] + [KeptInterface (typeof (IDynamicInterfaceCastable))] class DynamicCastableImplementedInOtherAssembly : IDynamicInterfaceCastable { [Kept] diff --git a/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/InterfaceVariants.cs b/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/InterfaceVariants.cs index 347c3a6a0..b19208bd5 100644 --- a/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/InterfaceVariants.cs +++ b/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/InterfaceVariants.cs @@ -21,16 +21,21 @@ namespace Mono.Linker.Tests.Cases.Inheritance.Interfaces t = typeof (UninstantiatedPublicClassWithPrivateInterface); t = typeof (ImplementsUsedStaticInterface.InterfaceMethodUnused); - ImplementsUnusedStaticInterface.Test (); ; + ImplementsUnusedStaticInterface.Test (); 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 (); + _ = new InstantiatedClassWithInterfaces (); + MarkIFormattable (null); } [Kept] + static void MarkIFormattable (IFormattable x) + { } + + [Kept] internal static void GenericMethodThatCallsInternalStaticInterfaceMethod<T> () where T : IStaticInterfaceUsed { T.StaticMethodUsedThroughInterface (); @@ -113,8 +118,8 @@ namespace Mono.Linker.Tests.Cases.Inheritance.Interfaces } } + // Interfaces are kept despite being uninstantiated because it is relevant to variant casting [Kept] - [KeptInterface (typeof (IEnumerator))] [KeptInterface (typeof (IPublicInterface))] [KeptInterface (typeof (IPublicStaticInterface))] [KeptInterface (typeof (ICopyLibraryInterface))] @@ -151,18 +156,12 @@ namespace Mono.Linker.Tests.Cases.Inheritance.Interfaces static void IInternalStaticInterface.ExplicitImplementationInternalStaticInterfaceMethod () { } - [Kept] - [ExpectBodyModified] bool IEnumerator.MoveNext () { throw new PlatformNotSupportedException (); } - [Kept] object IEnumerator.Current { - [Kept] - [ExpectBodyModified] get { throw new PlatformNotSupportedException (); } } - [Kept] void IEnumerator.Reset () { } [Kept] @@ -198,7 +197,6 @@ namespace Mono.Linker.Tests.Cases.Inheritance.Interfaces } [Kept] - [KeptInterface (typeof (IEnumerator))] [KeptInterface (typeof (IPublicInterface))] [KeptInterface (typeof (IPublicStaticInterface))] [KeptInterface (typeof (ICopyLibraryInterface))] @@ -235,13 +233,10 @@ namespace Mono.Linker.Tests.Cases.Inheritance.Interfaces static void IInternalStaticInterface.ExplicitImplementationInternalStaticInterfaceMethod () { } - [Kept] bool IEnumerator.MoveNext () { throw new PlatformNotSupportedException (); } - [Kept] - object IEnumerator.Current { [Kept] get { throw new PlatformNotSupportedException (); } } + object IEnumerator.Current { get { throw new PlatformNotSupportedException (); } } - [Kept] void IEnumerator.Reset () { } [Kept] diff --git a/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/StaticInterfaceMethods/UnusedInterfacesInPreservedScope.cs b/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/StaticInterfaceMethods/UnusedInterfacesInPreservedScope.cs index a03a28bd2..35ae2dda0 100644 --- a/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/StaticInterfaceMethods/UnusedInterfacesInPreservedScope.cs +++ b/test/Mono.Linker.Tests.Cases/Inheritance.Interfaces/StaticInterfaceMethods/UnusedInterfacesInPreservedScope.cs @@ -37,10 +37,15 @@ namespace Mono.Linker.Tests.Cases.Inheritance.Interfaces.StaticInterfaceMethods public int InstanceMethod () => 0; } + // Keep MyType without marking it relevant to variant casting + [Kept] + static void KeepMyType (MyType x) + { } + [Kept] static void Test () { - var x = typeof (MyType); // The only use of MyType + KeepMyType (null); } } } |