Skip to content

Commit 51f01ad

Browse files
committed
refacto linker
1 parent 729ef60 commit 51f01ad

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

src/coreclr/tools/aot/ILCompiler/repro/Program.cs

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,51 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System;
5+
using System.Diagnostics.CodeAnalysis;
56

67
class Program
78
{
9+
[method: DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(DerivedAttributeWithGetter))]
10+
[method: DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ClassWithDerivedAttr))]
811
static void Main()
912
{
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+
}
1139
}
1240
}
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+
{ }

0 commit comments

Comments
 (0)