File tree Expand file tree Collapse file tree 1 file changed +41
-1
lines changed
src/coreclr/tools/aot/ILCompiler/repro Expand file tree Collapse file tree 1 file changed +41
-1
lines changed Original file line number Diff line number Diff line change 2
2
// The .NET Foundation licenses this file to you under the MIT license.
3
3
4
4
using System ;
5
+ using System . Diagnostics . CodeAnalysis ;
5
6
6
7
class Program
7
8
{
9
+ [ method: DynamicDependency ( DynamicallyAccessedMemberTypes . All , typeof ( DerivedAttributeWithGetter ) ) ]
10
+ [ method: DynamicDependency ( DynamicallyAccessedMemberTypes . All , typeof ( ClassWithDerivedAttr ) ) ]
8
11
static void Main ( )
9
12
{
10
- Console . WriteLine ( "Hello world" ) ;
13
+ DerivedAttributeWithGetter derivedAttributeWithGetter = new DerivedAttributeWithGetter ( ) ;
14
+ Console . WriteLine ( "Hello world " + derivedAttributeWithGetter . P ) ;
15
+ object [ ] attributes = typeof ( ClassWithDerivedAttr ) . GetCustomAttributes ( true ) ;
16
+
17
+ if ( attributes . Length > 0 && attributes [ 0 ] is DerivedAttributeWithGetter attr )
18
+ {
19
+ Console . WriteLine ( $ "attribute found with value { attr . P } ") ;
20
+ }
21
+ else
22
+ {
23
+ Console . WriteLine ( "No Attributes I guess" + derivedAttributeWithGetter . P ) ;
24
+ }
25
+ }
26
+ }
27
+
28
+ public class BaseAttributeWithGetterSetter : Attribute
29
+ {
30
+ protected int _p ;
31
+
32
+ public virtual int P
33
+ {
34
+ get => _p ;
35
+ set
36
+ {
37
+ _p = value ;
38
+ }
11
39
}
12
40
}
41
+
42
+ public class DerivedAttributeWithGetter : BaseAttributeWithGetterSetter
43
+ {
44
+ public override int P
45
+ {
46
+ get => _p ;
47
+ }
48
+ }
49
+
50
+ [ DerivedAttributeWithGetter ( P = 2 ) ]
51
+ public class ClassWithDerivedAttr
52
+ { }
You can’t perform that action at this time.
0 commit comments