linux-packaging-mono/mcs/build/common/basic-profile-check.cs
Xamarin Public Jenkins (auto-signing) 6bdd276d05 Imported Upstream version 5.0.0.42
Former-commit-id: fd56571888259555122d8a0f58c68838229cea2b
2017-04-10 11:41:01 +00:00

49 lines
1.1 KiB
C#

using System;
class X {
// Check installed compiler
static void Generic<T> ()
{
// we use 'var' all around in the compiler sources
var x = new X ();
}
void DefaultParametersAvailable (int i = 3)
{
}
static int Main ()
{
// Check installed mscorlib
// Type is included in Mono 2.4+, and .NET 3.5 SP1
object o = typeof (System.Runtime.InteropServices.AllowReversePInvokeCallsAttribute);
// It should crash but double check it in case of very old old runtime
if (o == null)
return 1;
var consts = o.GetType ().Assembly.GetType ("Consts");
if (consts == null) {
// We could be bootraping on cygwin using .net runtime
var assembly = o.GetType ().Assembly;
if (assembly.GetName ().Version >= new Version (4, 0) && assembly.Location.Contains ("Microsoft.NET"))
return 0;
return 2;
}
var field = consts.GetField ("MonoVersion");
if (field == null)
return 3;
Version version;
if (!Version.TryParse (field.GetValue (null) as string, out version))
return 4;
if (version < new Version (4, 9))
return 5;
return 0;
}
}