Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gtest-412.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8b3045220f8c719f45c9b091f2952ddc3f68e1e5 (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
using System;
using System.Reflection;

class Program
{
	public static int Main ()
	{
		Type type = typeof (Foo<>);
		Type [] gargs = type.GetGenericArguments ();
		if (gargs == null || gargs.Length != 1) {
			Console.WriteLine ("#1");
			return 1;
		}

		Type garg = gargs [0];
		Type [] csts = garg.GetGenericParameterConstraints ();

		if (garg.Name != "T") {
			Console.WriteLine ("#2: " + garg.Name);
			return 2;
		}
		if (garg.GenericParameterAttributes !=
			(GenericParameterAttributes.DefaultConstructorConstraint | GenericParameterAttributes.NotNullableValueTypeConstraint)) {
			Console.WriteLine ("#3: " + garg.GenericParameterAttributes);
			return 3;
		}
		if (csts == null || csts.Length != 1) {
			Console.WriteLine ("#4");
			return 4;
		}
		if (csts [0] != typeof (ValueType)) {
			Console.WriteLine ("#5: " + csts [0].FullName);
			return 5;
		}

		return 0;
	}
}

struct Foo<T> where T : struct
{
}