Enable delegate marshalling for collectible types (#20158)
authorJan Vorlicek <janvorli@microsoft.com>
Fri, 28 Sep 2018 20:09:24 +0000 (22:09 +0200)
committerGitHub <noreply@github.com>
Fri, 28 Sep 2018 20:09:24 +0000 (22:09 +0200)
* Enable delegate marshalling for collectible types

This change is trivial - it just removes checks preventing the delegate
marshalling for collectible types. The unmanaged to managed thunks are
allocated from a global LoaderAllocator and they are released when the
corresponding managed delegates are collected. So for unloadability, we
don't need to change this behavior in any way.

* Disable CoreFX tests outdated by the change

src/System.Private.CoreLib/Resources/Strings.resx
src/vm/comdelegate.cpp
tests/CoreFX/CoreFX.issues.json

index 5d70c86..30c3831 100644 (file)
   <data name="NotSupported_CollectibleCOM" xml:space="preserve">
     <value>COM Interop is not supported for collectible types.</value>
   </data>
-  <data name="NotSupported_CollectibleDelegateMarshal" xml:space="preserve">
-    <value>Delegate marshaling for types within collectible assemblies is not supported.</value>
-  </data>
   <data name="NotSupported_CreateInstanceWithTypeBuilder" xml:space="preserve">
     <value>CreateInstance cannot be used with an object of type TypeBuilder.</value>
   </data>
index 749310b..cef90b0 100644 (file)
@@ -1145,9 +1145,6 @@ LPVOID COMDelegate::ConvertToCallback(OBJECTREF pDelegateObj)
     if (pMT->HasInstantiation())
         COMPlusThrowArgumentException(W("delegate"), W("Argument_NeedNonGenericType"));
 
-    if (pMT->Collectible())
-        COMPlusThrow(kNotSupportedException, W("NotSupported_CollectibleDelegateMarshal"));
-
     // If we are a delegate originally created from an unmanaged function pointer, we will simply return 
     // that function pointer.
     if (DELEGATE_MARKER_UNMANAGEDFPTR == pDelegate->GetInvocationCount())
@@ -1338,9 +1335,6 @@ OBJECTREF COMDelegate::ConvertToDelegate(LPVOID pCallback, MethodTable* pMT)
     DelegateEEClass*    pClass      = (DelegateEEClass*)pMT->GetClass();
     MethodDesc*         pMD         = FindDelegateInvokeMethod(pMT);
 
-    if (pMT->Collectible())
-        COMPlusThrow(kNotSupportedException, W("NotSupported_CollectibleDelegateMarshal"));
-
     PREFIX_ASSUME(pClass != NULL);
 
     //////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1441,9 +1435,6 @@ OBJECTREF COMDelegate::ConvertWinRTInterfaceToDelegate(IUnknown *pIdentity, Meth
 
     MethodDesc*         pMD         = FindDelegateInvokeMethod(pMT);
 
-    if (pMT->Collectible())
-        COMPlusThrow(kNotSupportedException, W("NotSupported_CollectibleDelegateMarshal"));
-
     if (pMD->IsSharedByGenericInstantiations())
     {
         // we need an exact MD to represent the call
index 9c39707..580a636 100644 (file)
                 {
                     "name" : "System.Runtime.InteropServices.Tests.SafeBufferTests.Initialize_NumBytesTimesSizeOfEachElement_ThrowsOverflowException",
                     "reason" : "https://github.com/dotnet/coreclr/pull/20132"
+                },
+                {
+                    "name" : "System.Runtime.InteropServices.Tests.GetFunctionPointerForDelegateTests.GetFunctionPointerForDelegate_DelegateCollectible_ThrowsNotSupportedException",
+                    "reason" : "outdated"
+                }
+            ]
+        }
+    },
+    {
+        "name": "System.Runtime.Loader.Tests",
+        "enabled": true,
+        "exclusions": {
+            "namespaces": null,
+            "classes": null,
+            "methods": [
+                {
+                    "name" : "System.Runtime.Loader.Tests.AssemblyLoadContextTest.Unsupported_DelegateMarshalling",
+                    "reason" : "outdated"
+                },
+                {
+                    "name" : "System.Runtime.Loader.Tests.AssemblyLoadContextTest.Unsupported_ThreadStaticAndFixedAddressValueType",
+                    "reason" : "outdated"
                 }
             ]
         }