Add Public API Marshal.IsTypeVisibleFromCom and Marshal.GetEndComSlot (dotnet/coreclr...
authorLuqun Lou <luqunl@users.noreply.github.com>
Wed, 15 Aug 2018 22:52:28 +0000 (15:52 -0700)
committerJan Kotas <jkotas@microsoft.com>
Wed, 15 Aug 2018 22:52:28 +0000 (15:52 -0700)
Commit migrated from https://github.com/dotnet/coreclr/commit/81455f6fe9e078902f1fb331ae81d85c4d001c5f

src/coreclr/src/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs
src/coreclr/src/System.Private.CoreLib/src/System/Runtime/InteropServices/NonPortable.cs
src/coreclr/src/vm/ecalllist.h

index 74d1e6e..e214f1e 100644 (file)
@@ -1459,6 +1459,12 @@ namespace System.Runtime.InteropServices
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern object InternalCreateWrapperOfType(object o, Type t);
 
+        /// <summary>
+        /// check if the type is visible from COM.
+        /// </summary>
+        [MethodImplAttribute(MethodImplOptions.InternalCall)]
+        public static extern bool IsTypeVisibleFromCom(Type t);
+
         [MethodImpl(MethodImplOptions.InternalCall)]
         public static extern int /* HRESULT */ QueryInterface(IntPtr /* IUnknown */ pUnk, ref Guid iid, out IntPtr ppv);
 
@@ -1507,6 +1513,12 @@ namespace System.Runtime.InteropServices
         /// </summary>
         [MethodImpl(MethodImplOptions.InternalCall)]
         public static extern int GetStartComSlot(Type t);
+
+        /// <summary>
+        /// <para>Returns the last valid COM slot that GetMethodInfoForSlot will work on. </para>
+        /// </summary>
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        public static extern int GetEndComSlot(Type t);
 #endif // FEATURE_COMINTEROP
 
         /// <summary>
index c340376..49047a8 100644 (file)
@@ -143,6 +143,11 @@ namespace System.Runtime.InteropServices
             throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
         }
 
+        public static int GetEndComSlot(Type t)
+        {
+            throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
+        }
+
         public static Type GetTypeFromCLSID(Guid clsid) 
         {
             throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
@@ -168,6 +173,15 @@ namespace System.Runtime.InteropServices
             return false;
         }
 
+        public static bool IsTypeVisibleFromCom(Type t)
+        {
+            if (t == null)
+            {
+                throw new ArgumentNullException(nameof(t));
+            }
+            return false;
+        }
+
         public static int QueryInterface(IntPtr pUnk, ref Guid iid, out IntPtr ppv)
         {
             throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
index 46ee7f8..c147ae7 100644 (file)
@@ -872,13 +872,15 @@ FCFuncStart(gInteropMarshalFuncs)
     FCFuncElement("GetNativeVariantForObject", MarshalNative::GetNativeVariantForObject)
     FCFuncElement("GetObjectForNativeVariant", MarshalNative::GetObjectForNativeVariant)
     FCFuncElement("InternalFinalReleaseComObject", MarshalNative::FinalReleaseComObject)
+    FCFuncElement("IsTypeVisibleFromCom", MarshalNative::IsTypeVisibleFromCom)
     FCFuncElement("QueryInterface", MarshalNative::QueryInterface)
     FCFuncElement("CreateAggregatedObject", MarshalNative::CreateAggregatedObject)
     FCFuncElement("AreComObjectsAvailableForCleanup", MarshalNative::AreComObjectsAvailableForCleanup)
     FCFuncElement("InternalCreateWrapperOfType", MarshalNative::InternalCreateWrapperOfType)
     FCFuncElement("GetObjectsForNativeVariants", MarshalNative::GetObjectsForNativeVariants)
     FCFuncElement("GetStartComSlot", MarshalNative::GetStartComSlot)
-
+    FCFuncElement("GetEndComSlot", MarshalNative::GetEndComSlot)
+    
     FCFuncElement("InitializeManagedWinRTFactoryObject", MarshalNative::InitializeManagedWinRTFactoryObject)
 
     FCFuncElement("GetNativeActivationFactory", MarshalNative::GetNativeActivationFactory)