Skip to content

Commit

Permalink
Add support for generic attributes (#2980) (#2997)
Browse files Browse the repository at this point in the history
* Add generic attribute tests
* Update cecil
  • Loading branch information
sbomer authored Aug 23, 2022
1 parent 6252a21 commit 313671b
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 1 deletion.
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() {}
}
}
}

0 comments on commit 313671b

Please sign in to comment.