blob: 5a7f010e804ed39eee594276de12c3c481355822 (
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;
using Mono.Linker.Tests.Cases.Expectations.Assertions;
namespace Mono.Linker.Tests.Cases.Reflection
{
public class MethodUsedViaReflectionAndLocal
{
public static void Main ()
{
new A (); // Needed to avoid lazy body marking stubbing
new B (); // Needed to avoid lazy body marking stubbing
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]
[KeptMember (".ctor()")]
public class A
{
[Kept]
public int Foo ()
{
return 42;
}
}
[Kept]
[KeptMember (".ctor()")]
public class B
{
public int Foo ()
{
return 43;
}
}
}
}
|