2009-12-12 Rodrigo Kumpera <rkumpera@novell.com>
[mcs.git] / tests / test-695.cs
blobd572543a9a1f4334bc37a8308c27c85917e2c4af
1 // Compiler options: -r:../class/lib/net_2_0/Mono.Cecil.dll
3 using System;
4 using System.IO;
5 using System.Reflection;
6 using System.Reflection.Emit;
8 using Mono.Cecil;
10 class Program
12 static int Main ()
14 string basedir = BaseDirectory;
16 AssemblyDefinition assembly;
17 Assembly a;
18 AssemblyName an;
19 AssemblyBuilder ab;
21 assembly = AssemblyFactory.GetAssembly (Path.Combine (basedir, "test-695-2-lib.dll"));
22 if (assembly.Name.Flags != AssemblyFlags.PublicKey)
23 return 1;
24 a = Assembly.LoadFrom (Path.Combine (basedir, "test-695-2-lib.dll"));
25 if (a.GetName ().Flags != AssemblyNameFlags.PublicKey)
26 return 2;
28 assembly = AssemblyFactory.GetAssembly (Path.Combine (basedir, "test-695-3-lib.dll"));
29 if (Environment.Version.Major >= 2) {
30 if (assembly.Name.Flags != AssemblyFlags.SideBySideCompatible)
31 return 3;
33 } else {
34 if (assembly.Name.Flags != AssemblyFlags.PublicKey)
35 return 3;
37 a = Assembly.LoadFrom (Path.Combine (basedir, "test-695-3-lib.dll"));
38 if (a.GetName ().Flags != AssemblyNameFlags.PublicKey)
39 return 4;
41 assembly = AssemblyFactory.GetAssembly (Path.Combine (basedir, "test-695.exe"));
42 if (assembly.Name.Flags != AssemblyFlags.SideBySideCompatible)
43 return 5;
44 a = Assembly.LoadFrom (Path.Combine (basedir, "test-695.exe"));
45 if (a.GetName ().Flags != AssemblyNameFlags.PublicKey)
46 return 6;
48 an = new AssemblyName ();
49 an.Name = "test-695-4-lib";
50 an.SetPublicKey (publicKey);
51 an.Flags = AssemblyNameFlags.Retargetable;
53 ab = AppDomain.CurrentDomain.DefineDynamicAssembly (an,
54 AssemblyBuilderAccess.Save, basedir);
55 ab.Save ("test-695-4-lib.dll");
57 assembly = AssemblyFactory.GetAssembly (Path.Combine (basedir, "test-695-4-lib.dll"));
58 if (assembly.Name.Flags != (AssemblyFlags.PublicKey | AssemblyFlags.Retargetable))
59 return 7;
61 an = new AssemblyName ();
62 an.Name = "test-695-5-lib";
63 an.KeyPair = new StrongNameKeyPair (keyPair);
64 an.Flags = AssemblyNameFlags.Retargetable;
66 ab = AppDomain.CurrentDomain.DefineDynamicAssembly (an,
67 AssemblyBuilderAccess.Save, basedir);
68 ab.Save ("test-695-5-lib.dll");
70 assembly = AssemblyFactory.GetAssembly (Path.Combine (basedir, "test-695-5-lib.dll"));
71 if (assembly.Name.Flags != (AssemblyFlags.PublicKey | AssemblyFlags.Retargetable))
72 return 8;
73 a = Assembly.LoadFrom (Path.Combine (basedir, "test-695-5-lib.dll"));
74 if (a.GetName ().Flags != (AssemblyNameFlags.PublicKey | AssemblyNameFlags.Retargetable))
75 return 9;
77 an = new AssemblyName ();
78 an.Name = "test-695-6-lib";
79 an.KeyPair = new StrongNameKeyPair (keyPair);
80 an.Flags = AssemblyNameFlags.Retargetable;
82 ab = AppDomain.CurrentDomain.DefineDynamicAssembly (an,
83 AssemblyBuilderAccess.Save, basedir);
84 an.Flags = AssemblyNameFlags.None;
85 ab.Save ("test-695-6-lib.dll");
87 assembly = AssemblyFactory.GetAssembly (Path.Combine (basedir, "test-695-6-lib.dll"));
88 if (assembly.Name.Flags != (AssemblyFlags.PublicKey | AssemblyFlags.Retargetable))
89 return 10;
90 a = Assembly.LoadFrom (Path.Combine (basedir, "test-695-6-lib.dll"));
91 if (a.GetName ().Flags != (AssemblyNameFlags.PublicKey | AssemblyNameFlags.Retargetable))
92 return 11;
94 return 0;
97 static string BaseDirectory {
98 get {
99 string loc = typeof (Program).Assembly.Location;
100 return Path.GetDirectoryName (loc);
104 static byte [] publicKey = {
105 0x00, 0x24, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x94, 0x00,
106 0x00, 0x00, 0x06, 0x02, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00,
107 0x52, 0x53, 0x41, 0x31, 0x00, 0x04, 0x00, 0x00, 0x01, 0x00,
108 0x01, 0x00, 0x3d, 0xbd, 0x72, 0x08, 0xc6, 0x2b, 0x0e, 0xa8,
109 0xc1, 0xc0, 0x58, 0x07, 0x2b, 0x63, 0x5f, 0x7c, 0x9a, 0xbd,
110 0xcb, 0x22, 0xdb, 0x20, 0xb2, 0xa9, 0xda, 0xda, 0xef, 0xe8,
111 0x00, 0x64, 0x2f, 0x5d, 0x8d, 0xeb, 0x78, 0x02, 0xf7, 0xa5,
112 0x36, 0x77, 0x28, 0xd7, 0x55, 0x8d, 0x14, 0x68, 0xdb, 0xeb,
113 0x24, 0x09, 0xd0, 0x2b, 0x13, 0x1b, 0x92, 0x6e, 0x2e, 0x59,
114 0x54, 0x4a, 0xac, 0x18, 0xcf, 0xc9, 0x09, 0x02, 0x3f, 0x4f,
115 0xa8, 0x3e, 0x94, 0x00, 0x1f, 0xc2, 0xf1, 0x1a, 0x27, 0x47,
116 0x7d, 0x10, 0x84, 0xf5, 0x14, 0xb8, 0x61, 0x62, 0x1a, 0x0c,
117 0x66, 0xab, 0xd2, 0x4c, 0x4b, 0x9f, 0xc9, 0x0f, 0x3c, 0xd8,
118 0x92, 0x0f, 0xf5, 0xff, 0xce, 0xd7, 0x6e, 0x5c, 0x6f, 0xb1,
119 0xf5, 0x7d, 0xd3, 0x56, 0xf9, 0x67, 0x27, 0xa4, 0xa5, 0x48,
120 0x5b, 0x07, 0x93, 0x44, 0x00, 0x4a, 0xf8, 0xff, 0xa4, 0xcb };
122 static byte [] keyPair = {
123 0x07, 0x02, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x52, 0x53,
124 0x41, 0x32, 0x00, 0x04, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00,
125 0x3D, 0xBD, 0x72, 0x08, 0xC6, 0x2B, 0x0E, 0xA8, 0xC1, 0xC0,
126 0x58, 0x07, 0x2B, 0x63, 0x5F, 0x7C, 0x9A, 0xBD, 0xCB, 0x22,
127 0xDB, 0x20, 0xB2, 0xA9, 0xDA, 0xDA, 0xEF, 0xE8, 0x00, 0x64,
128 0x2F, 0x5D, 0x8D, 0xEB, 0x78, 0x02, 0xF7, 0xA5, 0x36, 0x77,
129 0x28, 0xD7, 0x55, 0x8D, 0x14, 0x68, 0xDB, 0xEB, 0x24, 0x09,
130 0xD0, 0x2B, 0x13, 0x1B, 0x92, 0x6E, 0x2E, 0x59, 0x54, 0x4A,
131 0xAC, 0x18, 0xCF, 0xC9, 0x09, 0x02, 0x3F, 0x4F, 0xA8, 0x3E,
132 0x94, 0x00, 0x1F, 0xC2, 0xF1, 0x1A, 0x27, 0x47, 0x7D, 0x10,
133 0x84, 0xF5, 0x14, 0xB8, 0x61, 0x62, 0x1A, 0x0C, 0x66, 0xAB,
134 0xD2, 0x4C, 0x4B, 0x9F, 0xC9, 0x0F, 0x3C, 0xD8, 0x92, 0x0F,
135 0xF5, 0xFF, 0xCE, 0xD7, 0x6E, 0x5C, 0x6F, 0xB1, 0xF5, 0x7D,
136 0xD3, 0x56, 0xF9, 0x67, 0x27, 0xA4, 0xA5, 0x48, 0x5B, 0x07,
137 0x93, 0x44, 0x00, 0x4A, 0xF8, 0xFF, 0xA4, 0xCB, 0x73, 0xC0,
138 0x6A, 0x62, 0xB4, 0xB7, 0xC8, 0x92, 0x58, 0x87, 0xCD, 0x07,
139 0x0C, 0x7D, 0x6C, 0xC1, 0x4A, 0xFC, 0x82, 0x57, 0x0E, 0x43,
140 0x85, 0x09, 0x75, 0x98, 0x51, 0xBB, 0x35, 0xF5, 0x64, 0x83,
141 0xC7, 0x79, 0x89, 0x5C, 0x55, 0x36, 0x66, 0xAB, 0x27, 0xA4,
142 0xD9, 0xD4, 0x7E, 0x6B, 0x67, 0x64, 0xC1, 0x54, 0x4E, 0x37,
143 0xF1, 0x4E, 0xCA, 0xB3, 0xE5, 0x63, 0x91, 0x57, 0x12, 0x14,
144 0xA6, 0xEA, 0x8F, 0x8F, 0x2B, 0xFE, 0xF3, 0xE9, 0x16, 0x08,
145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