blob: b2e1e0f39ec51be782c8424b86ee47663b01e62f (
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
62
63
64
65
66
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Mono.Linker.Tests.Cases.Expectations.Assertions;
using Mono.Linker.Tests.Cases.Expectations.Metadata;
using Mono.Linker.Tests.Cases.RequiresCapability.Dependencies;
namespace Mono.Linker.Tests.Cases.RequiresCapability
{
[SetupLinkerAction ("copy", "lib")]
[SetupCompileBefore ("lib.dll", new[] { "Dependencies/RequiresInCopyAssembly.cs" })]
[KeptAllTypesAndMembersInAssembly ("lib.dll")]
[SkipKeptItemsValidation]
// Annotated members on a copied assembly should not produce any warnings
// unless directly called or referenced through reflection.
[LogDoesNotContain ("--UncalledMethod--")]
[LogDoesNotContain ("--getter UnusedProperty--")]
[LogDoesNotContain ("--setter UnusedProperty--")]
[LogDoesNotContain ("--UnusedBaseTypeCctor--")]
[LogDoesNotContain ("--UnusedVirtualMethod1--")]
[LogDoesNotContain ("--UnusedVirtualMethod2--")]
[LogDoesNotContain ("--IUnusedInterface.UnusedMethod--")]
[LogDoesNotContain ("--UnusedImplementationClass.UnusedMethod--")]
// [LogDoesNotContain ("UnusedVirtualMethod2")] // https://github.com/dotnet/linker/issues/2106
[ExpectedNoWarnings]
class RequiresWithCopyAssembly
{
[ExpectedWarning ("IL2026", "--IDerivedInterface.MethodInDerivedInterface--")]
[ExpectedWarning ("IL2026", "--IBaseInterface.MethodInBaseInterface--")]
public static void Main ()
{
TestRequiresInMethodFromCopiedAssembly ();
TestRequiresThroughReflectionInMethodFromCopiedAssembly ();
TestRequiresInDynamicallyAccessedMethodFromCopiedAssembly (typeof (RequiresInCopyAssembly.IDerivedInterface));
}
[ExpectedWarning ("IL2026", "--Method--")]
[ExpectedWarning ("IL3002", "--Method--", ProducedBy = ProducedBy.Analyzer)]
[ExpectedWarning ("IL3050", "--Method--", ProducedBy = ProducedBy.Analyzer)]
static void TestRequiresInMethodFromCopiedAssembly ()
{
var tmp = new RequiresInCopyAssembly ();
tmp.Method ();
}
[ExpectedWarning ("IL2026", "--MethodCalledThroughReflection--")]
static void TestRequiresThroughReflectionInMethodFromCopiedAssembly ()
{
typeof (RequiresInCopyAssembly)
.GetMethod ("MethodCalledThroughReflection", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic)
.Invoke (null, new object[0]);
}
static void TestRequiresInDynamicallyAccessedMethodFromCopiedAssembly (
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.All)] Type type)
{
}
}
}
|