From 13d864e28203d1377f5f63dd7f6c1eff1c7060bb Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 21 Mar 2019 16:26:58 -0400 Subject: [PATCH] Add a couple new test Add a few complicated tests with interface sweeping and abstract classes involved. These tests are green on master. These tests are setup to come close to triggering a new feature I'm working on `lazy body marking`. I'm also tired of seeing the `Inheritance.Complex` tests showing up in the Solution Explorer as missing. Adding these tests provides something to run for that set of tests. --- ...tAndInterfaceMethodWhenInterfaceRemoved.cs | 54 +++++++++++++++++++ ...AndInterfaceMethodWhenInterfaceRemoved2.cs | 54 +++++++++++++++++++ .../Mono.Linker.Tests.Cases.csproj | 3 +- 3 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 test/Mono.Linker.Tests.Cases/Inheritance.Complex/NoKeptCtor/OverrideOfAbstractAndInterfaceMethodWhenInterfaceRemoved.cs create mode 100644 test/Mono.Linker.Tests.Cases/Inheritance.Complex/NoKeptCtor/OverrideOfAbstractAndInterfaceMethodWhenInterfaceRemoved2.cs diff --git a/test/Mono.Linker.Tests.Cases/Inheritance.Complex/NoKeptCtor/OverrideOfAbstractAndInterfaceMethodWhenInterfaceRemoved.cs b/test/Mono.Linker.Tests.Cases/Inheritance.Complex/NoKeptCtor/OverrideOfAbstractAndInterfaceMethodWhenInterfaceRemoved.cs new file mode 100644 index 000000000000..2461fa5badcd --- /dev/null +++ b/test/Mono.Linker.Tests.Cases/Inheritance.Complex/NoKeptCtor/OverrideOfAbstractAndInterfaceMethodWhenInterfaceRemoved.cs @@ -0,0 +1,54 @@ +using Mono.Linker.Tests.Cases.Expectations.Assertions; + +namespace Mono.Linker.Tests.Cases.Inheritance.Complex.NoKeptCtor { + public class OverrideOfAbstractAndInterfaceMethodWhenInterfaceRemoved { + public static void Main () + { + Foo b = HelperToMarkFooAndRequireBase (); + // Use IBar in another method so that IBar can be removed from Foo + HelperToMarkIBar (); + } + + [Kept] + static Foo HelperToMarkFooAndRequireBase () + { + return null; + } + + [Kept] + static void HelperToMarkIBar() + { + GetAnIBar().Method(); + } + + [Kept] + static IBar GetAnIBar() + { + return null; + } + + [Kept] + abstract class Base { + public abstract void Method (); + } + + [Kept] + [KeptBaseType (typeof (Base))] + class Foo : Base, IBar { + public override void Method () + { + UsedByOverride (); + } + + void UsedByOverride () + { + } + } + + [Kept] + interface IBar { + [Kept] + void Method (); + } + } +} \ No newline at end of file diff --git a/test/Mono.Linker.Tests.Cases/Inheritance.Complex/NoKeptCtor/OverrideOfAbstractAndInterfaceMethodWhenInterfaceRemoved2.cs b/test/Mono.Linker.Tests.Cases/Inheritance.Complex/NoKeptCtor/OverrideOfAbstractAndInterfaceMethodWhenInterfaceRemoved2.cs new file mode 100644 index 000000000000..bddcd0459050 --- /dev/null +++ b/test/Mono.Linker.Tests.Cases/Inheritance.Complex/NoKeptCtor/OverrideOfAbstractAndInterfaceMethodWhenInterfaceRemoved2.cs @@ -0,0 +1,54 @@ +using Mono.Linker.Tests.Cases.Expectations.Assertions; + +namespace Mono.Linker.Tests.Cases.Inheritance.Complex.NoKeptCtor { + public class OverrideOfAbstractAndInterfaceMethodWhenInterfaceRemoved2 { + public static void Main () + { + Foo b = null; + HelperToKeepLocalAtCompileTime (b); + // Use IBar in another method so that IBar can be removed from Foo + HelperToMarkIBar (); + } + + [Kept] + static void HelperToKeepLocalAtCompileTime (Foo f) + { + } + + [Kept] + static void HelperToMarkIBar() + { + GetAnIBar().Method(); + } + + [Kept] + static IBar GetAnIBar() + { + return null; + } + + [Kept] + abstract class Base { + public abstract void Method (); + } + + [Kept] + [KeptBaseType (typeof (Base))] + class Foo : Base, IBar { + public override void Method () + { + UsedByOverride (); + } + + void UsedByOverride () + { + } + } + + [Kept] + interface IBar { + [Kept] + void Method (); + } + } +} \ No newline at end of file diff --git a/test/Mono.Linker.Tests.Cases/Mono.Linker.Tests.Cases.csproj b/test/Mono.Linker.Tests.Cases/Mono.Linker.Tests.Cases.csproj index d35562e958d1..ff8a7337f6f0 100644 --- a/test/Mono.Linker.Tests.Cases/Mono.Linker.Tests.Cases.csproj +++ b/test/Mono.Linker.Tests.Cases/Mono.Linker.Tests.Cases.csproj @@ -191,6 +191,8 @@ + + @@ -611,7 +613,6 @@ -