@@ -120,6 +120,27 @@ public void DAMMethod (
120
120
Type t
121
121
)
122
122
{ }
123
+
124
+ [ Kept ]
125
+ // No warning for non-virtual method which only has DAM on return parameter
126
+ [ return : KeptAttributeAttribute ( typeof ( DynamicallyAccessedMembersAttribute ) ) ]
127
+ [ return : DynamicallyAccessedMembersAttribute ( DynamicallyAccessedMemberTypes . PublicMethods ) ]
128
+ public Type DAMReturnMethod ( ) => null ;
129
+
130
+ [ Kept ]
131
+ [ ExpectedWarning ( "IL2114" , nameof ( AnnotatedPublicMethods ) , nameof ( DAMVirtualMethod ) ) ]
132
+ public virtual void DAMVirtualMethod (
133
+ [ KeptAttributeAttribute ( typeof ( DynamicallyAccessedMembersAttribute ) ) ]
134
+ [ DynamicallyAccessedMembers ( DynamicallyAccessedMemberTypes . PublicMethods ) ]
135
+ Type type
136
+ )
137
+ { }
138
+
139
+ [ Kept ]
140
+ [ ExpectedWarning ( "IL2114" , nameof ( AnnotatedPublicMethods ) , nameof ( DAMReturnVirtualMethod ) ) ]
141
+ [ return : KeptAttributeAttribute ( typeof ( DynamicallyAccessedMembersAttribute ) ) ]
142
+ [ return : DynamicallyAccessedMembersAttribute ( DynamicallyAccessedMemberTypes . PublicMethods ) ]
143
+ public virtual Type DAMReturnVirtualMethod ( ) => null ;
123
144
}
124
145
125
146
[ Kept ]
@@ -136,7 +157,6 @@ class AnnotatedPublicFields
136
157
}
137
158
138
159
[ Kept ]
139
- [ KeptMember ( "get_DAMProperty()" ) ]
140
160
[ KeptAttributeAttribute ( typeof ( DynamicallyAccessedMembersAttribute ) ) ]
141
161
[ DynamicallyAccessedMembers ( DynamicallyAccessedMemberTypes . PublicProperties ) ]
142
162
class AnnotatedPublicProperties
@@ -146,9 +166,13 @@ class AnnotatedPublicProperties
146
166
[ KeptAttributeAttribute ( typeof ( DynamicallyAccessedMembersAttribute ) ) ]
147
167
[ DynamicallyAccessedMembers ( DynamicallyAccessedMemberTypes . PublicMethods ) ]
148
168
public static string DAMProperty {
149
- // Property access reports warnings on getter/setter
150
- [ ExpectedWarning ( "IL2114" , nameof ( AnnotatedPublicProperties ) , nameof ( DAMProperty ) + ".get" ) ]
169
+ [ Kept ]
170
+ // No warning for getter since return value is not annotated
151
171
get ;
172
+ [ Kept ]
173
+ // Property access reports warnings on getter/setter
174
+ [ ExpectedWarning ( "IL2114" , nameof ( AnnotatedPublicProperties ) , nameof ( DAMProperty ) + ".set" ) ]
175
+ set ;
152
176
}
153
177
}
154
178
@@ -253,7 +277,6 @@ public virtual void RUCVirtualMethod () { }
253
277
254
278
[ KeptBaseType ( typeof ( Base ) ) ]
255
279
[ KeptMember ( ".ctor()" ) ]
256
- [ KeptMember ( "get_DAMVirtualProperty()" ) ]
257
280
[ ExpectedWarning ( "IL2113" , "--RUCBaseMethod--" ) ]
258
281
[ ExpectedWarning ( "IL2113" , "--Base.RUCVirtualMethod--" ) ]
259
282
[ ExpectedWarning ( "IL2115" , nameof ( Base ) , nameof ( Base . DAMVirtualProperty ) + ".get" ) ]
@@ -283,13 +306,12 @@ public override void RUCVirtualMethod () { }
283
306
[ KeptAttributeAttribute ( typeof ( DynamicallyAccessedMembersAttribute ) ) ]
284
307
// shouldn't warn because we warn on the base getter instead
285
308
[ DynamicallyAccessedMembers ( DynamicallyAccessedMemberTypes . NonPublicMethods ) ]
286
- public override string DAMVirtualProperty { get ; }
309
+ public override string DAMVirtualProperty { [ Kept ] get ; }
287
310
288
311
}
289
312
290
313
[ KeptBaseType ( typeof ( AnnotatedDerivedFromBase ) ) ]
291
314
[ KeptMember ( ".ctor()" ) ]
292
- [ KeptMember ( "get_DAMVirtualProperty()" ) ]
293
315
[ KeptAttributeAttribute ( typeof ( DynamicallyAccessedMembersAttribute ) ) ]
294
316
[ DynamicallyAccessedMembers ( DynamicallyAccessedMemberTypes . PublicFields ) ]
295
317
// Warnings about base members could go away with https://github.com/mono/linker/issues/2175
@@ -324,7 +346,7 @@ public override void RUCVirtualMethod () { }
324
346
[ KeptAttributeAttribute ( typeof ( DynamicallyAccessedMembersAttribute ) ) ]
325
347
// shouldn't warn because we warn on the base getter instead
326
348
[ DynamicallyAccessedMembers ( DynamicallyAccessedMemberTypes . NonPublicMethods ) ]
327
- public override string DAMVirtualProperty { get ; }
349
+ public override string DAMVirtualProperty { [ Kept ] get ; }
328
350
}
329
351
330
352
[ KeptAttributeAttribute ( typeof ( DynamicallyAccessedMembersAttribute ) ) ]
0 commit comments