Merge pull request #3647 from BrzVlad/fix-sgen-internal-alloc
[mono.git] / mcs / build / common / basic-profile-check.cs
1 using System;
2
3 class X {
4         // Check installed compiler
5         static void Generic<T> ()
6         {
7                 // we use 'var' all around in the compiler sources
8                 var x = new X ();
9         }
10         
11         void DefaultParametersAvailable (int i = 3)
12         {
13         }
14
15         static int Main ()
16         {
17                 // Check installed mscorlib
18                 // Type is included in Mono 2.4+, and .NET 3.5 SP1
19                 object o = typeof (System.Runtime.InteropServices.AllowReversePInvokeCallsAttribute);
20                 
21                 // It should crash but double check it in case of very old old runtime
22                 if (o == null)
23                         return 1;
24
25                 var consts = o.GetType ().Assembly.GetType ("Consts");
26                 if (consts == null) {
27                         // We could be bootraping on cygwin using .net runtime
28                         var assembly = o.GetType ().Assembly;
29                         if (assembly.GetName ().Version >= new Version (4, 0) && assembly.Location.Contains ("Microsoft.NET"))
30                                 return 0;
31
32                         return 2;
33                 }
34
35                 var field = consts.GetField ("MonoVersion");
36                 if (field == null)
37                         return 3;
38
39                 Version version;
40                 if (!Version.TryParse (field.GetValue (null) as string, out version))
41                         return 4;
42
43                 if (version < new Version (4, 0))
44                         return 5;
45
46                 return 0;
47         }
48 }