[2020-02] Avoid following invalid pointers in mono_w32process_get_modules on Darwin...
[mono-project.git] / mono / tests / test-byval-in-struct.cs
blobc247714df6fa579e0ff67529df3ca1b0b156cf18
1 using System;
2 using System.Runtime.InteropServices;
4 [StructLayout (LayoutKind.Explicit)]
5 struct TestStructure {
6 [FieldOffset (0)]
7 internal int number;
8 [FieldOffset (8)]
9 [MarshalAs(UnmanagedType.ByValArray, SizeConst=1024)]
10 internal byte[] stuff;
12 static int Main () {
13 int size = Marshal.SizeOf(typeof(TestStructure));
14 Console.WriteLine("Size of t: {0}", size);
15 if (size != 1032)
16 return 1;
18 size = Marshal.SizeOf(typeof(TestStructure2));
19 Console.WriteLine("Size of t2: {0}", size);
20 if (size != 8)
21 return 2;
23 return 0;
27 [StructLayout (LayoutKind.Explicit)]
28 struct TestStructure2 {
29 [FieldOffset (0)]
30 byte val;
31 [FieldOffset (2)]
32 int val2;