Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/7.0] Add support for generic attributes (#2980) #2997

Merged
merged 1 commit into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion external/cecil
Submodule cecil updated from 2cd569 to 1840b7
69 changes: 69 additions & 0 deletions test/Mono.Linker.Tests.Cases/Attributes/GenericAttributes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using System;
using Mono.Linker.Tests.Cases.Expectations.Assertions;
using Mono.Linker.Tests.Cases.Expectations.Metadata;

namespace Mono.Linker.Tests.Cases.Attributes
{
class GenericAttributes
{
static void Main ()
{
new WithGenericAttribute_OfString ();
new WithGenericAttribute_OfInt ();
new WithConstrainedGenericAttribute ();
}

[Kept]
[KeptAttributeAttribute (typeof (GenericAttribute<string>))]
[KeptMember (".ctor()")]
[GenericAttribute<string>("t", F = "f", P = "p")]
class WithGenericAttribute_OfString {
}

[Kept]
[KeptAttributeAttribute (typeof (GenericAttribute<int>))]
[KeptMember (".ctor()")]
[GenericAttribute<int>(1, F = 2, P = 3)]
class WithGenericAttribute_OfInt {
}

[Kept]
[KeptAttributeAttribute (typeof (ConstrainedGenericAttribute<DerivedFromConstraintType>))]
[KeptMember (".ctor()")]
[ConstrainedGenericAttribute<DerivedFromConstraintType>()]
class WithConstrainedGenericAttribute {
}

[KeptBaseType (typeof (Attribute))]
class GenericAttribute<T> : Attribute {
[Kept]
public GenericAttribute(T t) {}

[Kept]
public T F;

[Kept]
[KeptBackingField]
public T P {
get;
[Kept]
set;
}
}

[Kept]
class ConstraintType {
}

[KeptBaseType (typeof (ConstraintType))]
class DerivedFromConstraintType : ConstraintType {
}

[KeptBaseType (typeof (Attribute))]
class ConstrainedGenericAttribute<T> : Attribute
where T : ConstraintType {
[Kept]
public ConstrainedGenericAttribute() {}
}
}
}