blob: 5cecf5e5dc86efd962e50b77b43aefb3e47a0e7c (
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
|
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
{
[SetupCSharpCompilerToUse ("csc")]
[SetupCompileBefore ("unusedreference.dll", new[] { "Dependencies/UnusedAssemblyDependency.cs" })]
[SetupCompileBefore ("reference.dll", new[] { "Dependencies/AssemblyDependency.cs" }, addAsReference: false)]
[SetupCompileBefore ("library.dll", new[] { "Dependencies/AssemblyDependencyWithMultipleReferences.cs" }, new[] { "reference.dll", "unusedreference.dll" }, addAsReference: false)]
// TODO: keep library even if type is not found in it (https://github.com/dotnet/linker/issues/1795)
// [KeptAssembly ("library")]
public class AssemblyImportedViaReflectionWithSweptReferences
{
public static void Main ()
{
AccessNonExistingTypeInAssembly ();
}
[Kept]
[RecognizedReflectionAccessPattern]
static void AccessNonExistingTypeInAssembly ()
{
// Import the library without marking it.
var typeName = "DoesntExist, library";
var typeKept = Type.GetType (typeName, false);
}
static void ReferenceUnusedAssemblyDependency ()
{
UnusedAssemblyDependency.UsedToKeepReferenceAtCompileTime ();
}
}
}
|