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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
// 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.Reflection;
using Mono.Linker.Tests.Cases.Expectations.Assertions;
using Mono.Linker.Tests.Cases.Expectations.Metadata;
namespace Mono.Linker.Tests.Cases.LinkAttributes
{
[SetupLinkAttributesFile ("LinkerAttributeRemovalConditional.xml")]
[IgnoreLinkAttributes (false)]
class LinkerAttributeRemovalConditional
{
public static void Main ()
{
Kept_1 ();
Kept_2 ();
Kept_3 ();
Removed_1 ();
Removed_2 ();
Removed_3 ();
Removed_4 ();
Kept_4 ();
Kept_5 ();
Removed_5 ();
Removed_6 ();
Kept_6 ();
}
[Kept]
[KeptAttributeAttribute (typeof (TestConditionalRemoveAttribute))]
[TestConditionalRemove ()]
static void Kept_1 ()
{
}
[Kept]
[KeptAttributeAttribute (typeof (TestConditionalRemoveAttribute))]
[TestConditionalRemove ("my-value", "string value")]
static void Kept_2 ()
{
}
[Kept]
[KeptAttributeAttribute (typeof (TestConditionalRemoveAttribute))]
[TestConditionalRemove (1, true)]
static void Kept_3 ()
{
}
[Kept]
[TestConditionalRemove ("remove0", "string value")]
static void Removed_1 ()
{
}
[Kept]
[TestConditionalRemove (100, '1')]
[TestConditionalRemove ("remove1", '1', 3)]
static void Removed_2 ()
{
}
[Kept]
[TestConditionalRemove ("remove0", 'k', 0)] // It's removed because the converted string value matches
static void Removed_3 ()
{
}
[Kept]
[TestConditionalRemove ("remove2", "remove3")]
static void Removed_4 ()
{
}
[Kept]
[KeptAttributeAttribute (typeof (TestConditionalRemoveAttribute))]
[TestConditionalRemove ("remove2", "unmatched second arg")]
static void Kept_4 ()
{
}
[Kept]
[KeptAttributeAttribute (typeof (TestConditionalRemoveAttribute))]
[TestConditionalRemove ((int) 99, "remove3")]
static void Kept_5 () // Kept because int arg in constructor doesn't match long arg in xml
{
}
[Kept]
[TestConditionalRemove (72, "a", "b", "c", "d", "e")]
static void Removed_5 ()
{
}
[Kept]
[TestConditionalRemove (new int[] { 1, 2, 3 }, "remove4")]
static void Removed_6 ()
{
}
[Kept]
[KeptAttributeAttribute (typeof (TestConditionalRemoveAttribute))]
[TestConditionalRemove (new int[] { 1, 2, 3, 4 }, "remove4")]
static void Kept_6 ()
{
}
}
[Kept]
[KeptBaseType (typeof (System.Attribute))]
[KeptAttributeAttribute (typeof (AttributeUsageAttribute))]
[AttributeUsage (AttributeTargets.All, AllowMultiple = true)]
class TestConditionalRemoveAttribute : Attribute
{
[Kept]
public TestConditionalRemoveAttribute ()
{
}
[Kept]
// Any usage with "remove0" key is removed
public TestConditionalRemoveAttribute (string key, string value)
{
}
// Any usage with 100 key is removed
// Any usage with "remove1" key is removed
public TestConditionalRemoveAttribute (object key, char value, int ivalue)
{
}
[Kept]
public TestConditionalRemoveAttribute (int key, object value)
{
}
public TestConditionalRemoveAttribute (int key, [KeptAttributeAttribute (typeof (ParamArrayAttribute))] params object[] values)
{
}
[Kept]
public TestConditionalRemoveAttribute (int[] intArray, string str)
{
}
}
}
|