Expose Marshal.CleanupUnusedObjectsInCurrentContext
authorFaizur Rahman <shrah@microsoft.com>
Fri, 4 Nov 2016 21:50:02 +0000 (14:50 -0700)
committerFaizur Rahman <shrah@microsoft.com>
Tue, 8 Nov 2016 18:11:58 +0000 (10:11 -0800)
This change exposes Marshal.CleanupUnusedObjectsInCurrentContext. Also it a GetHINSTANCE implementation for non-windows platform by throwing
ArgumentNullException as per https://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshal.gethinstance(v=vs.110).aspx.

src/mscorlib/model.xml
src/mscorlib/ref/mscorlib.cs
src/mscorlib/src/System/Runtime/InteropServices/NonPortable.cs
src/vm/ecalllist.h

index ee4d3b9..167be24 100644 (file)
       <Member Name="AllocCoTaskMem(System.Int32)" />
       <Member Name="BindToMoniker(System.String)" />
       <Member Name="ChangeWrapperHandleStrength(System.Object,System.Boolean)" />
+      <Member Name="CleanupUnusedObjectsInCurrentContext" />
       <Member Name="Copy(System.Byte[],System.Int32,System.IntPtr,System.Int32)" />
       <Member Name="Copy(System.Char[],System.Int32,System.IntPtr,System.Int32)" />
       <Member Name="Copy(System.Double[],System.Int32,System.IntPtr,System.Int32)" />
index b7dcc5a..09e2905 100644 (file)
@@ -10811,7 +10811,9 @@ namespace System.Runtime.InteropServices
         [System.Security.SecurityCriticalAttribute]
         public static object BindToMoniker(string monikerName) { throw null; }
         [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.InternalCall)][System.Security.SecurityCritical]
-        public static void ChangeWrapperHandleStrength(object otp, bool fIsWeak) { throw null; }        
+        public static void ChangeWrapperHandleStrength(object otp, bool fIsWeak) { throw null; }
+        [System.Security.SecurityCriticalAttribute]
+        public static void CleanupUnusedObjectsInCurrentContext() { throw null; }        
         [System.Security.SecurityCriticalAttribute]
         public static void Copy(byte[] source, int startIndex, System.IntPtr destination, int length) { }
         [System.Security.SecurityCriticalAttribute]
index a3948bb..0c8ae76 100644 (file)
@@ -39,6 +39,12 @@ namespace System.Runtime.InteropServices
         }
         
         [System.Security.SecurityCriticalAttribute]
+        public static void CleanupUnusedObjectsInCurrentContext()
+        {
+           return;
+        }
+
+        [System.Security.SecurityCriticalAttribute]
         public static System.IntPtr CreateAggregatedObject<T>(System.IntPtr pOuter, T o)
         {
             throw new PlatformNotSupportedException();
@@ -89,6 +95,10 @@ namespace System.Runtime.InteropServices
         [System.Security.SecurityCriticalAttribute]
         public static System.IntPtr GetHINSTANCE(System.Reflection.Module m)
         {
+            if (m == null)
+            {
+                throw new ArgumentNullException(nameof(m));
+            }
             return (System.IntPtr) (-1);
         }           
 
index e8a0c96..7242314 100644 (file)
@@ -1655,10 +1655,10 @@ FCFuncStart(gInteropMarshalFuncs)
     FCFuncElement("InitializeWrapperForWinRT", MarshalNative::InitializeWrapperForWinRT)
     FCFuncElement("GetTypedObjectForIUnknown", MarshalNative::GetTypedObjectForIUnknown)
     FCFuncElement("ChangeWrapperHandleStrength", MarshalNative::ChangeWrapperHandleStrength)
+    FCFuncElement("CleanupUnusedObjectsInCurrentContext", MarshalNative::CleanupUnusedObjectsInCurrentContext)
 #ifndef FEATURE_CORECLR
     FCFuncElement("GetLoadedTypeForGUID", MarshalNative::GetLoadedTypeForGUID)
     FCFuncElement("GetITypeInfoForType", MarshalNative::GetITypeInfoForType)
-    FCFuncElement("CleanupUnusedObjectsInCurrentContext", MarshalNative::CleanupUnusedObjectsInCurrentContext)
     FCFuncElement("IsTypeVisibleFromCom", MarshalNative::IsTypeVisibleFromCom)
     FCFuncElement("FCallGenerateGuidForType", MarshalNative::DoGenerateGuidForType)
     FCFuncElement("FCallGetTypeLibGuid", MarshalNative::DoGetTypeLibGuid)