Author: zoltan
Date: 2006-05-17 12:57:17 -0400 (Wed, 17 May 2006)
New Revision: 60790
Modified:
trunk/mono/mono/tests/ChangeLog
trunk/mono/mono/tests/marshal8.cs
Log:
2006-05-17 Zoltan Varga <[EMAIL PROTECTED]>
* marshal8.cs: Applied a patch from Jonathan Chambers to add a test
case to
#77523.
Modified: trunk/mono/mono/tests/ChangeLog
===================================================================
--- trunk/mono/mono/tests/ChangeLog 2006-05-17 16:56:24 UTC (rev 60789)
+++ trunk/mono/mono/tests/ChangeLog 2006-05-17 16:57:17 UTC (rev 60790)
@@ -1,3 +1,8 @@
+2006-05-17 Zoltan Varga <[EMAIL PROTECTED]>
+
+ * marshal8.cs: Applied a patch from Jonathan Chambers to add a test
case to
+ #77523.
+
2006-05-10 Atsushi Enomoto <[EMAIL PROTECTED]>
* test-enum-indstoreil.il : removed duplicate label.
Modified: trunk/mono/mono/tests/marshal8.cs
===================================================================
--- trunk/mono/mono/tests/marshal8.cs 2006-05-17 16:56:24 UTC (rev 60789)
+++ trunk/mono/mono/tests/marshal8.cs 2006-05-17 16:57:17 UTC (rev 60790)
@@ -14,6 +14,28 @@
public long[] c;
}
+[StructLayout(LayoutKind.Sequential)]
+class FormattedClass
+{
+ public int i;
+
+ public FormattedClass(int i)
+ {
+ this.i = i;
+ }
+}
+
+[StructLayout(LayoutKind.Sequential)]
+struct Struct
+{
+ public int i;
+
+ public Struct(int i)
+ {
+ this.i = i;
+ }
+}
+
public class X {
public static unsafe int Main () {
@@ -70,6 +92,34 @@
Marshal.FreeHGlobal(p);
+
+ ///
+ /// Only allow
+ ///
+ FormattedClass fc = new FormattedClass(20);
+ IntPtr fc_ptr =
Marshal.AllocHGlobal(Marshal.SizeOf(typeof(FormattedClass)));
+ Marshal.StructureToPtr(fc, fc_ptr, false);
+ Marshal.PtrToStructure(fc_ptr, fc);
+ if (fc.i != 20)
+ return 10;
+ Marshal.FreeHGlobal(fc_ptr);
+
+ bool exception = false;
+ try
+ {
+ object str = new Struct(20);
+ IntPtr str_ptr =
Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Struct)));
+ Marshal.StructureToPtr(str, str_ptr, false);
+ Marshal.PtrToStructure(str_ptr, str);
+ Marshal.FreeHGlobal(str_ptr);
+ }
+ catch (Exception ex)
+ {
+ exception = true;
+ }
+ if (!exception)
+ return 11;
+
return 0;
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches