linux-packaging-mono/mcs/tests/gtest-fixedbuffer-09.cs
Jo Shields a575963da9 Imported Upstream version 3.6.0
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
2014-08-13 10:39:27 +01:00

31 lines
585 B
C#

// Compiler options: -unsafe
using System;
using System.Runtime.CompilerServices;
unsafe struct Foo
{
public fixed long FieldName[32];
}
class Test
{
public static int Main ()
{
var t = typeof (Foo);
var f = t.GetField ("FieldName");
var fbas = f.GetCustomAttributes (typeof (FixedBufferAttribute), true)[0] as FixedBufferAttribute;
if (fbas.Length != 32)
return 1;
var fixed_type = typeof (Foo).GetNestedTypes ()[0];
if (fixed_type.StructLayoutAttribute.Pack != 8)
return 2;
if (fixed_type.StructLayoutAttribute.Size != 256)
return 3;
return 0;
}
}