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

MightKeepExtraThings.cs « Reflection « Mono.Linker.Tests.Cases « test - github.com/mono/linker.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b5b6a1c52b60ab7b11454c0dc802fadba8c20fe0 (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
using System;
using System.Reflection;
using Mono.Linker.Tests.Cases.Expectations.Assertions;

namespace Mono.Linker.Tests.Cases.Reflection {
	public class MightKeepExtraThings {
		public static void Main ()
		{
			var typeA = typeof (A);
			var typeB = typeof (B);
			Console.WriteLine (typeB); // Use typeB so the C# compiler keeps it in the IL code.
			var method = typeA.GetMethod ("Foo", BindingFlags.Public);
			method.Invoke (null, new object[] { });
		}

		[Kept]
		public class A {
			[Kept]
			public int Foo ()
			{
				return 42;
			}
		}

		[Kept]
		public class B {
			[Kept]
			public int Foo ()
			{
				return 43;
			}
		}
	}
}