diff options
author | Sven Boemer <sbomer@gmail.com> | 2022-08-23 21:25:58 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-23 21:25:58 +0300 |
commit | e2dba52f463e35b90b25886e404ae46a0702c71f (patch) | |
tree | 62635b0db5035a328764c3314b4a3d4c75ca4a31 | |
parent | 86951339aa858607be7aa8df2edfbefda862742d (diff) |
Add support for generic attributes (#2980)
* Add generic attribute tests
* Update cecil
m--------- | external/cecil | 0 | ||||
-rw-r--r-- | test/Mono.Linker.Tests.Cases/Attributes/GenericAttributes.cs | 69 |
2 files changed, 69 insertions, 0 deletions
diff --git a/external/cecil b/external/cecil -Subproject 2cd569a98964629b8fa88284a8b5af8077d5f9d +Subproject 1840b7410d37a613e684b6f9650e39e2d4950bb diff --git a/test/Mono.Linker.Tests.Cases/Attributes/GenericAttributes.cs b/test/Mono.Linker.Tests.Cases/Attributes/GenericAttributes.cs new file mode 100644 index 000000000..430fbc714 --- /dev/null +++ b/test/Mono.Linker.Tests.Cases/Attributes/GenericAttributes.cs @@ -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() {} + } + } +}
\ No newline at end of file |