1
- // Licensed to the .NET Foundation under one or more agreements.
1
+ // Licensed to the .NET Foundation under one or more agreements.
2
2
// The .NET Foundation licenses this file to you under the MIT license.
3
3
4
4
using System ;
@@ -15,7 +15,8 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
15
15
[ ExpectedNoWarnings ]
16
16
public class RequiresOnAttributeCtor
17
17
{
18
- [ ExpectedWarning ( "IL2026" , "Message from attribute's ctor." ) ]
18
+ [ ExpectedWarning ( "IL2026" , "RUC on MethodAnnotatedWithRequires" ) ]
19
+ [ ExpectedWarning ( "IL2026" , "RUC on TestTypeWithRequires" ) ]
19
20
public static void Main ( )
20
21
{
21
22
var type = new Type ( ) ;
@@ -27,6 +28,17 @@ public static void Main ()
27
28
type . EventAdd -= ( sender , e ) => { } ;
28
29
type . EventRemove += ( sender , e ) => { } ;
29
30
Type . Interface annotatedInterface = new Type . NestedType ( ) ;
31
+
32
+ TestTypeWithRequires ( ) ;
33
+ }
34
+
35
+ [ RequiresUnreferencedCode ( "RUC on TestTypeWithRequires" ) ]
36
+ public static void TestTypeWithRequires ( )
37
+ {
38
+ var typeWithRequires = new TypeWithRequires ( ) ;
39
+ typeWithRequires . Method ( ) ;
40
+ TypeWithRequires . StaticMethod ( ) ;
41
+ TypeWithRequires . Interface annotatedInterface = new TypeWithRequires . NestedType ( ) ;
30
42
}
31
43
32
44
[ ExpectedWarning ( "IL2026" , "Message from attribute's ctor." ) ]
@@ -40,7 +52,7 @@ public void Method ()
40
52
{
41
53
}
42
54
43
- [ RequiresUnreferencedCode ( "Message from attribute's ctor. " ) ]
55
+ [ RequiresUnreferencedCode ( "RUC on MethodAnnotatedWithRequires " ) ]
44
56
[ RequiresOnAttributeCtor ]
45
57
public void MethodAnnotatedWithRequires ( )
46
58
{
@@ -82,6 +94,41 @@ public interface Interface
82
94
{
83
95
}
84
96
97
+ [ ExpectedWarning ( "IL2026" , "Message from attribute's ctor." ) ]
98
+ [ RequiresOnAttributeCtor ]
99
+ public class NestedType : Interface
100
+ {
101
+ }
102
+ }
103
+
104
+ // https://github.com/dotnet/linker/issues/2529
105
+ [ ExpectedWarning ( "IL2026" , "Message from attribute's ctor." , ProducedBy = ProducedBy . Trimmer ) ]
106
+ [ RequiresUnreferencedCode ( "RUC on TypeWithRequires" ) ]
107
+ [ RequiresOnAttributeCtor ]
108
+ public class TypeWithRequires
109
+ {
110
+ // https://github.com/dotnet/linker/issues/2529
111
+ [ ExpectedWarning ( "IL2026" , "Message from attribute's ctor." , ProducedBy = ProducedBy . Analyzer ) ]
112
+ [ RequiresOnAttributeCtor ]
113
+ public void Method ( )
114
+ {
115
+ }
116
+
117
+ // https://github.com/dotnet/linker/issues/2529
118
+ [ ExpectedWarning ( "IL2026" , "Message from attribute's ctor." , ProducedBy = ProducedBy . Analyzer ) ]
119
+ [ RequiresOnAttributeCtor ]
120
+ public static void StaticMethod ( )
121
+ {
122
+ }
123
+
124
+ [ ExpectedWarning ( "IL2026" , "Message from attribute's ctor." ) ]
125
+ [ RequiresOnAttributeCtor ]
126
+ public interface Interface
127
+ {
128
+ }
129
+
130
+ [ ExpectedWarning ( "IL2026" , "Message from attribute's ctor." ) ]
131
+ [ RequiresOnAttributeCtor ]
85
132
public class NestedType : Interface
86
133
{
87
134
}
0 commit comments