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

TypeDelegator.cs « Reflection « Mono.Linker.Tests.Cases « test - github.com/mono/linker.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fb7f61b0448048e5872fbebe4ac148a36c100612 (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
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Text;
using Mono.Linker.Tests.Cases.Expectations.Assertions;

namespace Mono.Linker.Tests.Cases.Reflection
{
	public class TypeDelegator
	{
		public static void Main ()
		{
			TestTypeUsedWithDelegator ();
			TestNullValue ();
			TestNoValue ();
		}

		[Kept]
		static class TypeUsedWithDelegator
		{
			[Kept]
			public static void Method () { }

			public static void UnrelatedMethod () { }
		}

		[Kept]
		static void TestTypeUsedWithDelegator ()
		{
			_ = new System.Reflection.TypeDelegator (typeof (TypeUsedWithDelegator)).GetMethod ("Method");
		}

		[Kept]
		static void TestNullValue ()
		{
			var typeDelegator = new System.Reflection.TypeDelegator (null);
			RequireAll (typeDelegator);
		}

		[Kept]
		static void TestNoValue ()
		{
			Type t = null;
			Type noValue = Type.GetTypeFromHandle (t.TypeHandle);
			var typeDelegator = new System.Reflection.TypeDelegator (noValue);
			RequireAll (typeDelegator);
		}

		[Kept]
		public static void RequireAll (
			[KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))]
			[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.All)]
			System.Reflection.TypeDelegator t
		)
		{ }
	}
}