[interp] Remove unreachable code (#12411)
[mono-project.git] / mono / tests / assembly-load-remap.cs
blob566e98ce085ba7e56e40ed70c569c73233977126
1 using System;
2 using System.IO;
3 using System.Reflection;
4 using System.Runtime.InteropServices;
6 public class Tests
8 [DllImport("__Internal")]
9 extern static void mono_set_assemblies_path (string path);
11 public static void Main (string[] args)
13 var ver40 = new Version (4, 0, 0, 0);
14 var ver140 = new Version (14, 0, 0, 0);
15 var util20 = Assembly.ReflectionOnlyLoad ("Microsoft.Build.Utilities, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
16 var util35 = Assembly.ReflectionOnlyLoad ("Microsoft.Build.Utilities.v3.5, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
17 var task20 = Assembly.ReflectionOnlyLoad ("Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
18 var task35 = Assembly.ReflectionOnlyLoad ("Microsoft.Build.Tasks.v3.5, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
19 var engn20 = Assembly.ReflectionOnlyLoad ("Microsoft.Build.Engine, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
20 var engn35 = Assembly.ReflectionOnlyLoad ("Microsoft.Build.Engine, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
21 var frwk20 = Assembly.ReflectionOnlyLoad ("Microsoft.Build.Framework, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
22 var frwk35 = Assembly.ReflectionOnlyLoad ("Microsoft.Build.Framework, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
24 // when run as part of the test suite, we need to register the xbuild 14.0 path or v14 assembly lookup will fail
25 var mono_path = Environment.GetEnvironmentVariable ("MONO_PATH");
26 if (!String.IsNullOrEmpty (mono_path)) {
27 var xbuild = Path.Combine (new DirectoryInfo (mono_path).Parent.FullName, "xbuild_14");
28 mono_path = xbuild + Path.PathSeparator + mono_path;
29 Console.WriteLine ("Setting Mono assemblies path to " + mono_path);
30 mono_set_assemblies_path (mono_path);
33 var engn140 = Assembly.ReflectionOnlyLoad ("Microsoft.Build.Engine, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
34 var frwk140 = Assembly.ReflectionOnlyLoad ("Microsoft.Build.Framework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
36 if (util20 == null)
37 throw new Exception ("#1 assembly couldn't be loaded.");
39 if (util35 == null)
40 throw new Exception ("#2 assembly couldn't be loaded.");
42 if (util20.GetName ().Version != ver40)
43 throw new Exception ("#3 expected remap to v4.0.0.0, but got " + util20);
45 if (util35.GetName ().Version != ver40)
46 throw new Exception ("#4 expected remap to v4.0.0.0, but got " + util35);
48 if (task20 == null)
49 throw new Exception ("#5 assembly couldn't be loaded.");
51 if (task35 == null)
52 throw new Exception ("#6 assembly couldn't be loaded.");
54 if (task20.GetName ().Version != ver40)
55 throw new Exception ("#7 expected remap to v4.0.0.0, but got " + task20);
57 if (task35.GetName ().Version != ver40)
58 throw new Exception ("#8 expected remap to v4.0.0.0, but got " + task35);
60 if (engn20 == null)
61 throw new Exception ("#9 assembly couldn't be loaded.");
63 if (engn35 == null)
64 throw new Exception ("#10 assembly couldn't be loaded.");
66 if (engn140 == null)
67 throw new Exception ("#11 assembly couldn't be loaded.");
69 if (engn20.GetName ().Version != ver40)
70 throw new Exception ("#12 expected remap to v4.0.0.0, but got " + engn20);
72 if (engn35.GetName ().Version != ver40)
73 throw new Exception ("#13 expected remap to v4.0.0.0, but got " + engn35);
75 if (engn140.GetName ().Version != ver140)
76 throw new Exception ("#14 expected v14.0.0.0, but got " + engn140);
78 if (frwk20 == null)
79 throw new Exception ("#15 assembly couldn't be loaded.");
81 if (frwk35 == null)
82 throw new Exception ("#16 assembly couldn't be loaded.");
84 if (frwk140 == null)
85 throw new Exception ("#17 assembly couldn't be loaded.");
87 if (frwk20.GetName ().Version != ver40)
88 throw new Exception ("#18 expected remap to v4.0.0.0, but got " + frwk20);
90 if (frwk35.GetName ().Version != ver40)
91 throw new Exception ("#19 expected remap to v4.0.0.0, but got " + frwk35);
93 if (frwk140.GetName ().Version != ver140)
94 throw new Exception ("#20 expected v14.0.0.0, but got " + frwk140);