2 // Check that the empty field we produce on empty structs with LayoutKind.Explicit
3 // has a FieldOffset of zero, or the .NET runtime complains
6 using System
.Reflection
;
7 using System
.Runtime
.InteropServices
;
9 [StructLayout(LayoutKind
.Explicit
)]
19 // On .NET if we got this far, we run
20 // On Mono, we are going to actually use an internal routine to check if the offset is there
22 Type fit
= typeof (FieldInfo
);
23 MethodInfo gfo
= fit
.GetMethod ("GetFieldOffset", BindingFlags
.Instance
| BindingFlags
.NonPublic
);
25 Console
.WriteLine ("PASS: On MS runtime, Test OK");
29 Type t
= typeof (foo2
);
30 FieldInfo fi
= t
.GetField ("$PRIVATE$", BindingFlags
.Instance
| BindingFlags
.NonPublic
);
32 object res
= gfo
.Invoke (fi
, null);
33 if (res
.GetType () != typeof (Int32
))
37 Console
.WriteLine ("FAIL: Offset is not zero");
40 Console
.WriteLine ("PASS: Test passes on Mono");