fix generic attribute bug when generic attribute has parameters and the parameters...
authorAvi Avni <avi.avni@gmail.com>
Tue, 11 Jun 2019 00:22:34 +0000 (03:22 +0300)
committerDavid Wrighton <davidwr@microsoft.com>
Tue, 11 Jun 2019 00:22:34 +0000 (17:22 -0700)
* fix generic attribute bug

* add missing test cases

src/vm/customattribute.cpp
tests/src/reflection/GenericAttribute/GenericAttributeTests.cs

index 6edda67..2c99785 100644 (file)
@@ -768,7 +768,7 @@ FCIMPL6(LPVOID, COMCustomAttribute::CreateCaObject, ReflectModuleBaseObject* pAt
         memset((void*)argToProtect, 0, cArgs * sizeof(OBJECTREF));
 
         // load the this pointer
-        argToProtect[0] = pCtorMD->GetMethodTable()->Allocate(); // this is the value to return after the ctor invocation
+        argToProtect[0] = gc.refCaType->GetType().GetMethodTable()->Allocate(); // this is the value to return after the ctor invocation
 
         if (pBlob) 
         {
index 762f011..f930570 100644 (file)
@@ -133,6 +133,22 @@ class Program
         var b8 = ((ICustomAttributeProvider)programTypeInfo).GetCustomAttributes(typeof(MultiAttribute<bool?>), true);
         AssertAny(b8, a => (a as MultiAttribute<bool?>)?.Value == null);
 
+        var a9 = CustomAttributeExtensions.GetCustomAttributes<MultiAttribute<string>>(programTypeInfo, true);
+        AssertAny(a9, a => (a as MultiAttribute<string>)?.Value == "Ctor");
+        AssertAny(a9, a => (a as MultiAttribute<string>)?.Value == "Property");
+
+        var b9 = ((ICustomAttributeProvider)programTypeInfo).GetCustomAttributes(typeof(MultiAttribute<string>), true);
+        AssertAny(b9, a => (a as MultiAttribute<string>)?.Value == "Ctor");
+        AssertAny(b9, a => (a as MultiAttribute<string>)?.Value == "Property");
+
+        var a10 = CustomAttributeExtensions.GetCustomAttributes<MultiAttribute<Type>>(programTypeInfo, true);
+        AssertAny(a10, a => (a as MultiAttribute<Type>)?.Value == typeof(Class));
+        AssertAny(a10, a => (a as MultiAttribute<Type>)?.Value == typeof(Class.Derive));
+
+        var b10 = ((ICustomAttributeProvider)programTypeInfo).GetCustomAttributes(typeof(MultiAttribute<Type>), true);
+        AssertAny(b10, a => (a as MultiAttribute<Type>)?.Value == typeof(Class));
+        AssertAny(b10, a => (a as MultiAttribute<Type>)?.Value == typeof(Class.Derive));
+
         Assert(CustomAttributeExtensions.GetCustomAttributes(programTypeInfo, typeof(MultiAttribute<>), false) == null);
         Assert(CustomAttributeExtensions.GetCustomAttributes(programTypeInfo, typeof(MultiAttribute<>), true) == null);
         Assert(!((ICustomAttributeProvider)programTypeInfo).GetCustomAttributes(typeof(MultiAttribute<>), true).GetEnumerator().MoveNext());