Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/linker.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMarek Safar <marek.safar@gmail.com>2020-12-22 21:10:08 +0300
committerGitHub <noreply@github.com>2020-12-22 21:10:08 +0300
commit8ecdb90f69bacd96eb8a171d01a29b83494c0611 (patch)
tree545ac5bbbc2918855bad40a5ecd97609f4d5423c /test
parent9d47fbfb5f2fcd2d209ab4b4847f5dd6f2074067 (diff)
Implement marking of custom marshaler required members (#1712)
Co-authored-by: Michal Strehovský <MichalStrehovsky@users.noreply.github.com>
Diffstat (limited to 'test')
-rw-r--r--test/Mono.Linker.Tests.Cases/Attributes/MarshalAsCustomMarshalerInterface.cs103
1 files changed, 103 insertions, 0 deletions
diff --git a/test/Mono.Linker.Tests.Cases/Attributes/MarshalAsCustomMarshalerInterface.cs b/test/Mono.Linker.Tests.Cases/Attributes/MarshalAsCustomMarshalerInterface.cs
new file mode 100644
index 000000000..ee278e46b
--- /dev/null
+++ b/test/Mono.Linker.Tests.Cases/Attributes/MarshalAsCustomMarshalerInterface.cs
@@ -0,0 +1,103 @@
+using System;
+using System.Runtime.InteropServices;
+using System.Runtime.Serialization;
+using Mono.Linker.Tests.Cases.Expectations.Assertions;
+using Mono.Linker.Tests.Cases.Expectations.Metadata;
+
+namespace Mono.Linker.Tests.Cases.Attributes
+{
+ [SetupLinkerCoreAction ("link")]
+ [SkipPeVerify]
+
+ [KeptInterface (typeof (IUserData))]
+ public class MarshalAsCustomMarshalerInterface : IUserData
+ {
+ [Kept]
+ public MarshalAsCustomMarshalerInterface ()
+ {
+ }
+
+ public static void Main ()
+ {
+ IUserData icm = new MarshalAsCustomMarshalerInterface ();
+ icm.TestM1 (null);
+
+ CustomMarhaler2.StaticMethod ();
+ }
+
+ [Kept]
+ public void TestM1 (object o)
+ {
+ }
+ }
+
+ [Kept]
+ interface IUserData
+ {
+ [Kept]
+ void TestM1 ([MarshalAs (UnmanagedType.CustomMarshaler, MarshalType = "Mono.Linker.Tests.Cases.Attributes.CustomMarhaler1")] object o);
+ }
+
+ [Kept]
+ [KeptInterface (typeof (ICustomMarshaler))]
+ class CustomMarhaler1 : ICustomMarshaler
+ {
+ [Kept]
+ private CustomMarhaler1 ()
+ {
+ }
+
+ [Kept]
+ public static ICustomMarshaler GetInstance (string cookie)
+ {
+ return new CustomMarhaler1 ();
+ }
+
+ [Kept]
+ public Object MarshalNativeToManaged (IntPtr pNativeData) => throw new NotImplementedException ();
+
+ [Kept]
+ public IntPtr MarshalManagedToNative (Object ManagedObj) => throw new NotImplementedException ();
+
+ [Kept]
+ public void CleanUpNativeData (IntPtr pNativeData) => throw new NotImplementedException ();
+
+ [Kept]
+ void ICustomMarshaler.CleanUpManagedData (Object ManagedObj) => throw new NotImplementedException ();
+
+ [Kept]
+ public int GetNativeDataSize () => throw new NotImplementedException ();
+
+ public void ExtraMethod ()
+ {
+ }
+ }
+
+ [Kept]
+ class CustomMarhaler2 : ICustomMarshaler
+ {
+ public CustomMarhaler2 ()
+ {
+ }
+
+ public static ICustomMarshaler GetInstance (string cookie)
+ {
+ return new CustomMarhaler2 ();
+ }
+
+ public Object MarshalNativeToManaged (IntPtr pNativeData) => throw new NotImplementedException ();
+
+ public IntPtr MarshalManagedToNative (Object ManagedObj) => throw new NotImplementedException ();
+
+ public void CleanUpNativeData (IntPtr pNativeData) => throw new NotImplementedException ();
+
+ void ICustomMarshaler.CleanUpManagedData (Object ManagedObj) => throw new NotImplementedException ();
+
+ public int GetNativeDataSize () => throw new NotImplementedException ();
+
+ [Kept]
+ public static void StaticMethod ()
+ {
+ }
+ }
+}