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

ParametersUsedViaReflection.cs « Reflection « Mono.Linker.Tests.Cases « test - github.com/mono/linker.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 57b16569acb488ea4bbaade230f9b05e553ab3e8 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using System;
using System.Reflection;
using Mono.Linker.Tests.Cases.Expectations.Assertions;
using Mono.Linker.Tests.Cases.Expectations.Metadata;

namespace Mono.Linker.Tests.Cases.Reflection
{
	public class ParametersUsedViaReflection
	{
		public static void Main ()
		{
			TestMethodParameters ();
			TestClassParameters ();
		}

		[Kept]
		static void TestMethodParameters ()
		{
			var method = typeof (GetMethod_Name).GetMethod ("OnlyCalledViaReflection");
			var name = method.GetParameters ()[0].Name;

			GetMethod_Name.CalledDirectly (11);
			GetMethod_Name.CalledDirectly2<string> (1);
		}

		[Kept]
		static void TestClassParameters ()
		{
			var type = Type.GetType ("Mono.Linker.Tests.Cases.Reflection.ParametersUsedViaReflection/GenericClass1`1");

			var type2 = new GenericClass2<int> ();
		}

		[Kept]
		class GetMethod_Name
		{
			[Kept]
			public static int OnlyCalledViaReflection (int firstName)
			{
				return 2;
			}

			[Kept]
			public static int OnlyCalledViaReflection (int arg1, int arg2)
			{
				return 3;
			}

			[Kept]
			public static void CalledDirectly ([RemovedNameValue] int firstArg)
			{
			}

			[Kept]
			public static void CalledDirectly2</*[RemovedNameValue]*/LongGenericName> ([RemovedNameValue] int firstArg)
			{
			}
		}

		[Kept]
		public class GenericClass1<TKey>
		{
		}

		[Kept]
		public class GenericClass2</*[RemovedNameValue]*/TRKey>
		{
			[Kept]
			public GenericClass2 ()
			{
			}
		}
	}

}