+ return 0;
+ }
+
+ [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
+ public struct Struct1
+ {
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 8)]
+ public string Field1;
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 10)]
+ public string Field2;
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 14)]
+ public string Field3;
+ }
+
+ public static int test_0_byvaltstr () {
+ ByValTStrStruct s = new ByValTStrStruct ();
+
+ IntPtr p2 = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (ByValTStrStruct)));
+ Marshal.StructureToPtr(s, p2, false);
+
+ /* Check that the ByValTStr is initialized correctly */
+ for (int i = 0; i < 4; ++i)
+ if (Marshal.ReadByte (p2, i) != 0)
+ return 31;
+
+ s.s1 = "ABCD";
+ s.i = 55;
+
+ Marshal.StructureToPtr(s, p2, false);