From cbb4fe809fab5684ecb5302ae1f01a28db418f42 Mon Sep 17 00:00:00 2001 From: Mike Voorhees Date: Wed, 10 May 2017 19:39:12 -0400 Subject: Add tests for ComImport cases --- .../Com/DefaultConstructorOfParameterIsRemoved.cs | 22 ++++++++++++++++++++ .../Com/DefaultConstructorOfReturnTypeIsRemoved.cs | 22 ++++++++++++++++++++ .../Com/FieldsOfParameterAreRemoved.cs | 23 +++++++++++++++++++++ .../Com/FieldsOfReturnTypeAreRemoved.cs | 23 +++++++++++++++++++++ .../InternalCalls/Com/FieldsOfThisAreRemoved.cs | 24 ++++++++++++++++++++++ .../Com/DefaultConstructorOfParameterIsRemoved.cs | 22 ++++++++++++++++++++ .../Com/DefaultConstructorOfReturnTypeIsRemoved.cs | 22 ++++++++++++++++++++ .../PInvoke/Com/FieldsOfParameterAreRemoved.cs | 23 +++++++++++++++++++++ .../PInvoke/Com/FieldsOfReturnTypeAreRemoved.cs | 23 +++++++++++++++++++++ .../Interop/PInvoke/Com/FieldsOfThisAreRemoved.cs | 24 ++++++++++++++++++++++ .../Mono.Linker.Tests.Cases.csproj | 10 +++++++++ 11 files changed, 238 insertions(+) create mode 100644 linker/Tests/Mono.Linker.Tests.Cases/Interop/InternalCalls/Com/DefaultConstructorOfParameterIsRemoved.cs create mode 100644 linker/Tests/Mono.Linker.Tests.Cases/Interop/InternalCalls/Com/DefaultConstructorOfReturnTypeIsRemoved.cs create mode 100644 linker/Tests/Mono.Linker.Tests.Cases/Interop/InternalCalls/Com/FieldsOfParameterAreRemoved.cs create mode 100644 linker/Tests/Mono.Linker.Tests.Cases/Interop/InternalCalls/Com/FieldsOfReturnTypeAreRemoved.cs create mode 100644 linker/Tests/Mono.Linker.Tests.Cases/Interop/InternalCalls/Com/FieldsOfThisAreRemoved.cs create mode 100644 linker/Tests/Mono.Linker.Tests.Cases/Interop/PInvoke/Com/DefaultConstructorOfParameterIsRemoved.cs create mode 100644 linker/Tests/Mono.Linker.Tests.Cases/Interop/PInvoke/Com/DefaultConstructorOfReturnTypeIsRemoved.cs create mode 100644 linker/Tests/Mono.Linker.Tests.Cases/Interop/PInvoke/Com/FieldsOfParameterAreRemoved.cs create mode 100644 linker/Tests/Mono.Linker.Tests.Cases/Interop/PInvoke/Com/FieldsOfReturnTypeAreRemoved.cs create mode 100644 linker/Tests/Mono.Linker.Tests.Cases/Interop/PInvoke/Com/FieldsOfThisAreRemoved.cs (limited to 'linker') diff --git a/linker/Tests/Mono.Linker.Tests.Cases/Interop/InternalCalls/Com/DefaultConstructorOfParameterIsRemoved.cs b/linker/Tests/Mono.Linker.Tests.Cases/Interop/InternalCalls/Com/DefaultConstructorOfParameterIsRemoved.cs new file mode 100644 index 000000000..a75bed14a --- /dev/null +++ b/linker/Tests/Mono.Linker.Tests.Cases/Interop/InternalCalls/Com/DefaultConstructorOfParameterIsRemoved.cs @@ -0,0 +1,22 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using Mono.Linker.Tests.Cases.Expectations.Assertions; + +namespace Mono.Linker.Tests.Cases.Interop.InternalCalls.Com { + class DefaultConstructorOfParameterIsRemoved { + public static void Main () + { + SomeMethod (null); + } + + [Kept] + [ComImport] + [Guid ("D7BB1889-3AB7-4681-A115-60CA9158FECA")] + class A { + } + + [Kept] + [MethodImpl (MethodImplOptions.InternalCall)] + static extern void SomeMethod (A val); + } +} diff --git a/linker/Tests/Mono.Linker.Tests.Cases/Interop/InternalCalls/Com/DefaultConstructorOfReturnTypeIsRemoved.cs b/linker/Tests/Mono.Linker.Tests.Cases/Interop/InternalCalls/Com/DefaultConstructorOfReturnTypeIsRemoved.cs new file mode 100644 index 000000000..a0bee8d72 --- /dev/null +++ b/linker/Tests/Mono.Linker.Tests.Cases/Interop/InternalCalls/Com/DefaultConstructorOfReturnTypeIsRemoved.cs @@ -0,0 +1,22 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using Mono.Linker.Tests.Cases.Expectations.Assertions; + +namespace Mono.Linker.Tests.Cases.Interop.InternalCalls.Com { + class DefaultConstructorOfReturnTypeIsRemoved { + public static void Main () + { + var a = SomeMethod (); + } + + [Kept] + [ComImport] + [Guid ("D7BB1889-3AB7-4681-A115-60CA9158FECA")] + class A { + } + + [Kept] + [MethodImpl (MethodImplOptions.InternalCall)] + static extern A SomeMethod (); + } +} diff --git a/linker/Tests/Mono.Linker.Tests.Cases/Interop/InternalCalls/Com/FieldsOfParameterAreRemoved.cs b/linker/Tests/Mono.Linker.Tests.Cases/Interop/InternalCalls/Com/FieldsOfParameterAreRemoved.cs new file mode 100644 index 000000000..afe98aaca --- /dev/null +++ b/linker/Tests/Mono.Linker.Tests.Cases/Interop/InternalCalls/Com/FieldsOfParameterAreRemoved.cs @@ -0,0 +1,23 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using Mono.Linker.Tests.Cases.Expectations.Assertions; + +namespace Mono.Linker.Tests.Cases.Interop.InternalCalls.Com { + class FieldsOfParameterAreRemoved { + public static void Main () + { + SomeMethod (null); + } + + [Kept] + [ComImport] + [Guid ("D7BB1889-3AB7-4681-A115-60CA9158FECA")] + class A { + private int field; + } + + [Kept] + [MethodImpl (MethodImplOptions.InternalCall)] + static extern void SomeMethod (A val); + } +} diff --git a/linker/Tests/Mono.Linker.Tests.Cases/Interop/InternalCalls/Com/FieldsOfReturnTypeAreRemoved.cs b/linker/Tests/Mono.Linker.Tests.Cases/Interop/InternalCalls/Com/FieldsOfReturnTypeAreRemoved.cs new file mode 100644 index 000000000..1447fc6aa --- /dev/null +++ b/linker/Tests/Mono.Linker.Tests.Cases/Interop/InternalCalls/Com/FieldsOfReturnTypeAreRemoved.cs @@ -0,0 +1,23 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using Mono.Linker.Tests.Cases.Expectations.Assertions; + +namespace Mono.Linker.Tests.Cases.Interop.InternalCalls.Com { + class FieldsOfReturnTypeAreRemoved { + public static void Main () + { + var a = SomeMethod (); + } + + [Kept] + [ComImport] + [Guid ("D7BB1889-3AB7-4681-A115-60CA9158FECA")] + class A { + private int field; + } + + [Kept] + [MethodImpl (MethodImplOptions.InternalCall)] + static extern A SomeMethod (); + } +} diff --git a/linker/Tests/Mono.Linker.Tests.Cases/Interop/InternalCalls/Com/FieldsOfThisAreRemoved.cs b/linker/Tests/Mono.Linker.Tests.Cases/Interop/InternalCalls/Com/FieldsOfThisAreRemoved.cs new file mode 100644 index 000000000..272c5d879 --- /dev/null +++ b/linker/Tests/Mono.Linker.Tests.Cases/Interop/InternalCalls/Com/FieldsOfThisAreRemoved.cs @@ -0,0 +1,24 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using Mono.Linker.Tests.Cases.Expectations.Assertions; + +namespace Mono.Linker.Tests.Cases.Interop.InternalCalls.Com { + class FieldsOfThisAreRemoved { + public static void Main () + { + new A ().SomeMethod (); + } + + [Kept] + [KeptMember (".ctor()")] + [ComImport] + [Guid ("D7BB1889-3AB7-4681-A115-60CA9158FECA")] + class A { + private int field; + + [Kept] + [MethodImpl (MethodImplOptions.InternalCall)] + public extern void SomeMethod (); + } + } +} diff --git a/linker/Tests/Mono.Linker.Tests.Cases/Interop/PInvoke/Com/DefaultConstructorOfParameterIsRemoved.cs b/linker/Tests/Mono.Linker.Tests.Cases/Interop/PInvoke/Com/DefaultConstructorOfParameterIsRemoved.cs new file mode 100644 index 000000000..a22fb03e1 --- /dev/null +++ b/linker/Tests/Mono.Linker.Tests.Cases/Interop/PInvoke/Com/DefaultConstructorOfParameterIsRemoved.cs @@ -0,0 +1,22 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using Mono.Linker.Tests.Cases.Expectations.Assertions; + +namespace Mono.Linker.Tests.Cases.Interop.PInvoke.Com { + class DefaultConstructorOfParameterIsRemoved { + public static void Main () + { + SomeMethod (null); + } + + [Kept] + [ComImport] + [Guid ("D7BB1889-3AB7-4681-A115-60CA9158FECA")] + class A { + } + + [Kept] + [MethodImpl (MethodImplOptions.InternalCall)] + static extern void SomeMethod (A val); + } +} diff --git a/linker/Tests/Mono.Linker.Tests.Cases/Interop/PInvoke/Com/DefaultConstructorOfReturnTypeIsRemoved.cs b/linker/Tests/Mono.Linker.Tests.Cases/Interop/PInvoke/Com/DefaultConstructorOfReturnTypeIsRemoved.cs new file mode 100644 index 000000000..7e4356285 --- /dev/null +++ b/linker/Tests/Mono.Linker.Tests.Cases/Interop/PInvoke/Com/DefaultConstructorOfReturnTypeIsRemoved.cs @@ -0,0 +1,22 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using Mono.Linker.Tests.Cases.Expectations.Assertions; + +namespace Mono.Linker.Tests.Cases.Interop.PInvoke.Com { + class DefaultConstructorOfReturnTypeIsRemoved { + public static void Main () + { + var a = SomeMethod (); + } + + [Kept] + [ComImport] + [Guid ("D7BB1889-3AB7-4681-A115-60CA9158FECA")] + class A { + } + + [Kept] + [MethodImpl (MethodImplOptions.InternalCall)] + static extern A SomeMethod (); + } +} diff --git a/linker/Tests/Mono.Linker.Tests.Cases/Interop/PInvoke/Com/FieldsOfParameterAreRemoved.cs b/linker/Tests/Mono.Linker.Tests.Cases/Interop/PInvoke/Com/FieldsOfParameterAreRemoved.cs new file mode 100644 index 000000000..e0a1839e2 --- /dev/null +++ b/linker/Tests/Mono.Linker.Tests.Cases/Interop/PInvoke/Com/FieldsOfParameterAreRemoved.cs @@ -0,0 +1,23 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using Mono.Linker.Tests.Cases.Expectations.Assertions; + +namespace Mono.Linker.Tests.Cases.Interop.PInvoke.Com { + class FieldsOfParameterAreRemoved { + public static void Main () + { + SomeMethod (null); + } + + [Kept] + [ComImport] + [Guid ("D7BB1889-3AB7-4681-A115-60CA9158FECA")] + class A { + private int field; + } + + [Kept] + [MethodImpl (MethodImplOptions.InternalCall)] + static extern void SomeMethod (A val); + } +} diff --git a/linker/Tests/Mono.Linker.Tests.Cases/Interop/PInvoke/Com/FieldsOfReturnTypeAreRemoved.cs b/linker/Tests/Mono.Linker.Tests.Cases/Interop/PInvoke/Com/FieldsOfReturnTypeAreRemoved.cs new file mode 100644 index 000000000..7b6741bd2 --- /dev/null +++ b/linker/Tests/Mono.Linker.Tests.Cases/Interop/PInvoke/Com/FieldsOfReturnTypeAreRemoved.cs @@ -0,0 +1,23 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using Mono.Linker.Tests.Cases.Expectations.Assertions; + +namespace Mono.Linker.Tests.Cases.Interop.PInvoke.Com { + class FieldsOfReturnTypeAreRemoved { + public static void Main () + { + var a = SomeMethod (); + } + + [Kept] + [ComImport] + [Guid ("D7BB1889-3AB7-4681-A115-60CA9158FECA")] + class A { + private int field; + } + + [Kept] + [MethodImpl (MethodImplOptions.InternalCall)] + static extern A SomeMethod (); + } +} diff --git a/linker/Tests/Mono.Linker.Tests.Cases/Interop/PInvoke/Com/FieldsOfThisAreRemoved.cs b/linker/Tests/Mono.Linker.Tests.Cases/Interop/PInvoke/Com/FieldsOfThisAreRemoved.cs new file mode 100644 index 000000000..a4453338a --- /dev/null +++ b/linker/Tests/Mono.Linker.Tests.Cases/Interop/PInvoke/Com/FieldsOfThisAreRemoved.cs @@ -0,0 +1,24 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using Mono.Linker.Tests.Cases.Expectations.Assertions; + +namespace Mono.Linker.Tests.Cases.Interop.PInvoke.Com { + class FieldsOfThisAreRemoved { + public static void Main () + { + new A ().SomeMethod (); + } + + [Kept] + [KeptMember (".ctor()")] + [ComImport] + [Guid ("D7BB1889-3AB7-4681-A115-60CA9158FECA")] + class A { + private int field; + + [Kept] + [MethodImpl (MethodImplOptions.InternalCall)] + public extern void SomeMethod (); + } + } +} 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 245bc0936..49463ed70 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 @@ -66,7 +66,17 @@ + + + + + + + + + + -- cgit v1.2.3