blob: 52322d37a55ae76f32ef29f7a49b340f3074c4df (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
//
// This tests checks that the compiler catches the special attributes
// for in a struct for CharSet, and turns the right bit on the TypeAttribute
//
using System;
using System.Reflection;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Explicit, Size=32,CharSet=CharSet.Unicode)]
struct MyUnicode
{
[FieldOffset(0)] public float fh_float;
[FieldOffset(0)] public int fh_int;
}
[StructLayout(LayoutKind.Explicit, Size=32,CharSet=CharSet.Ansi)]
struct MyAnsi
{
[FieldOffset(0)] public float fh_float;
[FieldOffset(0)] public int fh_int;
}
[StructLayout(LayoutKind.Explicit, Size=32,CharSet=CharSet.Auto)]
struct MyAuto
{
[FieldOffset(0)] public float fh_float;
[FieldOffset(0)] public int fh_int;
}
class test
{
public static int Main ()
{
int errors = 0;
Type t = typeof (MyUnicode);
if ((t.Attributes & TypeAttributes.StringFormatMask) != TypeAttributes.UnicodeClass){
Console.WriteLine ("Class MyUnicode does not have Unicode bit set");
errors += 1;
}
t = typeof (MyAuto);
if ((t.Attributes & TypeAttributes.StringFormatMask) != TypeAttributes.AutoClass){
Console.WriteLine ("Class MyAuto does not have Auto bit set");
errors += 2;
}
t = typeof (MyAnsi);
if ((t.Attributes & TypeAttributes.StringFormatMask) != TypeAttributes.AnsiClass){
Console.WriteLine ("Class MyUnicode does not have Ansi bit set");
errors += 4;
}
return errors;
}
}
|