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
|
using System;
using Mono.Linker.Tests.Cases.Expectations.Assertions;
using Mono.Linker.Tests.Cases.Expectations.Metadata;
using Mono.Linker.Tests.Cases.Reflection.Dependencies;
namespace Mono.Linker.Tests.Cases.Reflection
{
[SetupCompileBefore ("base.dll", new[] { "Dependencies/AssemblyImportedViaReflectionWithDerivedType_Base.cs" })]
[SetupCompileBefore ("reflection.dll", new[] { "Dependencies/AssemblyImportedViaReflectionWithDerivedType_Reflect.cs" }, references: new[] { "base.dll" }, addAsReference: false)]
[KeptAssembly ("base.dll")]
[KeptAssembly ("reflection.dll")]
[KeptMemberInAssembly ("base.dll", typeof (AssemblyImportedViaReflectionWithDerivedType_Base), "Method()")]
[KeptMemberInAssembly ("reflection.dll", "Mono.Linker.Tests.Cases.Reflection.Dependencies.AssemblyImportedViaReflectionWithDerivedType_Reflect", "Method()")]
public class AssemblyImportedViaReflectionWithDerivedType
{
public static void Main ()
{
// Cause a the new assembly to be included via reflection usage
const string newAssemblyType = "Mono.Linker.Tests.Cases.Reflection.Dependencies.AssemblyImportedViaReflectionWithDerivedType_Reflect, reflection, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null";
var res = Type.GetType (newAssemblyType, true);
// Foo and the reflection assembly both have a class the inherits from the base type.
// by using `Method` here and marking the reflection type above, we've introduced a requirement that `Method` be marked on the type in the reflection assembly as well
var obj = new Foo ();
var val = obj.Method ();
}
[Kept]
[KeptMember (".ctor()")]
[KeptBaseType (typeof (AssemblyImportedViaReflectionWithDerivedType_Base))]
class Foo : AssemblyImportedViaReflectionWithDerivedType_Base
{
[Kept]
public override string Method ()
{
return "Foo";
}
}
}
}
|