diff options
author | Mike Voorhees <michaelv@unity3d.com> | 2017-05-31 17:00:43 +0300 |
---|---|---|
committer | Marek Safar <marek.safar@gmail.com> | 2017-05-31 19:28:47 +0300 |
commit | 392310da518785c1ed177bbd118780ef89aaa946 (patch) | |
tree | eb9c70474f0dc53c9ad48e6341f82f338a8194bd | |
parent | 65fd2098ffb981b3162da4399ae07b90306c5270 (diff) |
Add some tests for situation where interface method is removed
4 files changed, 82 insertions, 0 deletions
diff --git a/linker/Tests/Mono.Linker.Tests.Cases/Mono.Linker.Tests.Cases.csproj b/linker/Tests/Mono.Linker.Tests.Cases/Mono.Linker.Tests.Cases.csproj index ba81df75d..0055c2991 100644 --- a/linker/Tests/Mono.Linker.Tests.Cases/Mono.Linker.Tests.Cases.csproj +++ b/linker/Tests/Mono.Linker.Tests.Cases/Mono.Linker.Tests.Cases.csproj @@ -57,6 +57,9 @@ <Compile Include="Basic\UnusedPropertySetterRemoved.cs" /> <Compile Include="Basic\UsedPropertyIsKept.cs" /> <Compile Include="Basic\UsedStructIsKept.cs" /> + <Compile Include="VirtualMethods\ClassUsedFromConcreteTypeHasInterfaceMethodRemoved.cs" /> + <Compile Include="VirtualMethods\ClassUsedFromInterfaceHasInterfaceMethodKept.cs" /> + <Compile Include="VirtualMethods\StructUsedFromConcreteTypeHasInterfaceMethodRemoved.cs" /> <Compile Include="VirtualMethods\StructUsedFromInterfaceHasInterfaceMethodKept.cs" /> <Compile Include="CoreLink\CopyOfCoreLibrariesKeepsUnusedTypes.cs" /> <Compile Include="CoreLink\LinkingOfCoreLibrariesRemovesUnusedMethods.cs" /> diff --git a/linker/Tests/Mono.Linker.Tests.Cases/VirtualMethods/ClassUsedFromConcreteTypeHasInterfaceMethodRemoved.cs b/linker/Tests/Mono.Linker.Tests.Cases/VirtualMethods/ClassUsedFromConcreteTypeHasInterfaceMethodRemoved.cs new file mode 100644 index 000000000..51ea017d7 --- /dev/null +++ b/linker/Tests/Mono.Linker.Tests.Cases/VirtualMethods/ClassUsedFromConcreteTypeHasInterfaceMethodRemoved.cs @@ -0,0 +1,26 @@ +using Mono.Linker.Tests.Cases.Expectations.Assertions; + +namespace Mono.Linker.Tests.Cases.VirtualMethods +{ + class ClassUsedFromConcreteTypeHasInterfaceMethodRemoved { + public static void Main () + { + A a = new A (); + a.Foo (); + } + + [Kept] + [KeptInterface (typeof (IFoo))] + struct A : IFoo { + [Kept] + public void Foo () + { + } + } + + [Kept] + public interface IFoo { + void Foo (); + } + } +} diff --git a/linker/Tests/Mono.Linker.Tests.Cases/VirtualMethods/ClassUsedFromInterfaceHasInterfaceMethodKept.cs b/linker/Tests/Mono.Linker.Tests.Cases/VirtualMethods/ClassUsedFromInterfaceHasInterfaceMethodKept.cs new file mode 100644 index 000000000..0f32024a3 --- /dev/null +++ b/linker/Tests/Mono.Linker.Tests.Cases/VirtualMethods/ClassUsedFromInterfaceHasInterfaceMethodKept.cs @@ -0,0 +1,27 @@ +using Mono.Linker.Tests.Cases.Expectations.Assertions; + +namespace Mono.Linker.Tests.Cases.VirtualMethods +{ + class ClassUsedFromInterfaceHasInterfaceMethodKept { + public static void Main () + { + IFoo a = new A (); + a.Foo (); + } + + [Kept] + [KeptInterface (typeof (IFoo))] + struct A : IFoo { + [Kept] + public void Foo () + { + } + } + + [Kept] + public interface IFoo { + [Kept] + void Foo (); + } + } +} diff --git a/linker/Tests/Mono.Linker.Tests.Cases/VirtualMethods/StructUsedFromConcreteTypeHasInterfaceMethodRemoved.cs b/linker/Tests/Mono.Linker.Tests.Cases/VirtualMethods/StructUsedFromConcreteTypeHasInterfaceMethodRemoved.cs new file mode 100644 index 000000000..bb795599d --- /dev/null +++ b/linker/Tests/Mono.Linker.Tests.Cases/VirtualMethods/StructUsedFromConcreteTypeHasInterfaceMethodRemoved.cs @@ -0,0 +1,26 @@ +using Mono.Linker.Tests.Cases.Expectations.Assertions; + +namespace Mono.Linker.Tests.Cases.VirtualMethods +{ + class StructUsedFromConcreteTypeHasInterfaceMethodRemoved { + public static void Main () + { + A a = new A (); + a.Foo (); + } + + [Kept] + [KeptInterface (typeof (IFoo))] + struct A : IFoo { + [Kept] + public void Foo () + { + } + } + + [Kept] + public interface IFoo { + void Foo (); + } + } +} |