summaryrefslogtreecommitdiff
path: root/tests/src/Interop/MarshalAPI/Miscellaneous/AutoLayoutStructure.cs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/Interop/MarshalAPI/Miscellaneous/AutoLayoutStructure.cs')
-rw-r--r--tests/src/Interop/MarshalAPI/Miscellaneous/AutoLayoutStructure.cs45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/src/Interop/MarshalAPI/Miscellaneous/AutoLayoutStructure.cs b/tests/src/Interop/MarshalAPI/Miscellaneous/AutoLayoutStructure.cs
new file mode 100644
index 0000000000..b701a01314
--- /dev/null
+++ b/tests/src/Interop/MarshalAPI/Miscellaneous/AutoLayoutStructure.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Reflection;
+using System.Threading;
+using System.Runtime.InteropServices;
+using CoreFXTestLibrary;
+
+class MarshalClassTests
+{
+ [StructLayout(LayoutKind.Auto)]
+ public struct SomeTestStruct_Auto
+ {
+ public int i;
+ }
+
+ [STAThread]
+ static int Main()
+ {
+ SomeTestStruct_Auto someTs_Auto = new SomeTestStruct_Auto();
+ try
+ {
+ Marshal.StructureToPtr(someTs_Auto, new IntPtr(123), true);
+ }
+ catch (ArgumentException ex)
+ {
+ if (ex.ParamName != "structure")
+ {
+ Console.WriteLine("Thrown ArgumentException is incorrect.");
+ return 103;
+ }
+ if (!ex.Message.Contains("The specified structure must be blittable or have layout information."))
+ {
+ Console.WriteLine("Thrown ArgumentException is incorrect.");
+ return 104;
+ }
+ return 100;
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Marshal.StructureToPtr threw unexpected exception {0}.", e);
+ return 102;
+ }
+ Console.WriteLine("Marshal.StructureToPtr did not throw an exception.");
+ return 101;
+ }
+}