| TBD | System.Threading.ThreadPool.EnableDispatchAutoreleasePool | When set to true, creates an NSAutoreleasePool around each thread pool work item on applicable platforms. |
| CustomResourceTypesSupport | System.Resources.ResourceManager.AllowCustomResourceTypes | Use of custom resource types is disabled when set to false. ResourceManager code paths that use reflection for custom types can be trimmed. |
| EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization | System.ComponentModel.TypeConverter.EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization | BinaryFormatter serialization support is trimmed when set to false. |
+| BuiltInComInteropSupport | System.Runtime.InteropServices.BuiltInComInterop.IsSupported | Built-in COM support is trimmed when set to false. |
Any feature-switch which defines property can be set in csproj file or
on the command line as any other MSBuild property. Those without predefined property name
<type fullname="System.StartupHookProvider" feature="System.StartupHookProvider.IsSupported" featurevalue="false">
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" />
</type>
+ <type fullname="System.Runtime.InteropServices.Marshal" feature="System.Runtime.InteropServices.BuiltInComInterop.IsSupported" featurevalue="false">
+ <method signature="System.Boolean get_IsBuiltInComSupported()" body="stub" value="false" />
+ </type>
</assembly>
-</linker>
\ No newline at end of file
+</linker>
// The .NET Foundation licenses this file to you under the MIT license.
using System;
+using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
namespace Internal.Runtime.InteropServices
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IClassFactory
{
+ [RequiresUnreferencedCode("Built-in COM support is not trim compatible", Url = "https://aka.ms/dotnet-illink/com")]
void CreateInstance(
[MarshalAs(UnmanagedType.Interface)] object? pUnkOuter,
ref Guid riid,
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IClassFactory2 : IClassFactory
{
+ [RequiresUnreferencedCode("Built-in COM support is not trim compatible", Url = "https://aka.ms/dotnet-illink/com")]
new void CreateInstance(
[MarshalAs(UnmanagedType.Interface)] object? pUnkOuter,
ref Guid riid,
[CLSCompliant(false)]
public static unsafe ComActivationContext Create(ref ComActivationContextInternal cxtInt)
{
- if (!Marshal.IsComSupported)
+ if (!Marshal.IsBuiltInComSupported)
{
throw new NotSupportedException(SR.NotSupported_COM);
}
[RequiresUnreferencedCode("Built-in COM support is not trim compatible", Url = "https://aka.ms/dotnet-illink/com")]
public static object GetClassFactoryForType(ComActivationContext cxt)
{
- if (!Marshal.IsComSupported)
+ if (!Marshal.IsBuiltInComSupported)
{
throw new NotSupportedException(SR.NotSupported_COM);
}
[RequiresUnreferencedCode("Built-in COM support is not trim compatible", Url = "https://aka.ms/dotnet-illink/com")]
public static void ClassRegistrationScenarioForType(ComActivationContext cxt, bool register)
{
- if (!Marshal.IsComSupported)
+ if (!Marshal.IsBuiltInComSupported)
{
throw new NotSupportedException(SR.NotSupported_COM);
}
[UnmanagedCallersOnly]
public static unsafe int GetClassFactoryForTypeInternal(ComActivationContextInternal* pCxtInt)
{
- if (!Marshal.IsComSupported)
+ if (!Marshal.IsBuiltInComSupported)
{
throw new NotSupportedException(SR.NotSupported_COM);
}
[UnmanagedCallersOnly]
public static unsafe int RegisterClassForTypeInternal(ComActivationContextInternal* pCxtInt)
{
- if (!Marshal.IsComSupported)
+ if (!Marshal.IsBuiltInComSupported)
{
throw new NotSupportedException(SR.NotSupported_COM);
}
[UnmanagedCallersOnly]
public static unsafe int UnregisterClassForTypeInternal(ComActivationContextInternal* pCxtInt)
{
- if (!Marshal.IsComSupported)
+ if (!Marshal.IsBuiltInComSupported)
{
throw new NotSupportedException(SR.NotSupported_COM);
}
Debug.WriteLine(fmt, args);
}
+ [RequiresUnreferencedCode("Built-in COM support is not trim compatible", Url = "https://aka.ms/dotnet-illink/com")]
private static Type FindClassType(Guid clsid, string assemblyPath, string assemblyName, string typeName)
{
try
}
}
+ [RequiresUnreferencedCode("Built-in COM support is not trim compatible", Url = "https://aka.ms/dotnet-illink/com")]
public void CreateInstance(
[MarshalAs(UnmanagedType.Interface)] object? pUnkOuter,
ref Guid riid,
_classType = classType;
}
+ [RequiresUnreferencedCode("Built-in COM support is not trim compatible", Url = "https://aka.ms/dotnet-illink/com")]
public void CreateInstance(
[MarshalAs(UnmanagedType.Interface)] object? pUnkOuter,
ref Guid riid,
private static extern void InternalPrelink(RuntimeMethodHandleInternal m);
[DllImport(RuntimeHelpers.QCall)]
- private static extern bool IsComSupportedInternal();
+ private static extern bool IsBuiltInComSupportedInternal();
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern /* struct _EXCEPTION_POINTERS* */ IntPtr GetExceptionPointers();
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern bool IsPinnable(object? obj);
- internal static bool IsComSupported { get; } = InitializeIsComSupported();
-
- private static bool InitializeIsComSupported() => IsComSupportedInternal();
+ internal static bool IsBuiltInComSupported { get; } = IsBuiltInComSupportedInternal();
#if TARGET_WINDOWS
/// <summary>
// on Marshal for more consistent API surface.
internal static Type? GetTypeFromCLSID(Guid clsid, string? server, bool throwOnError)
{
- if (!IsComSupported)
+ if (!IsBuiltInComSupported)
{
throw new NotSupportedException(SR.NotSupported_COM);
}
[SupportedOSPlatform("windows")]
public static IntPtr CreateAggregatedObject(IntPtr pOuter, object o)
{
- if (!IsComSupported)
+ if (!IsBuiltInComSupported)
{
throw new NotSupportedException(SR.NotSupported_COM);
}
[SupportedOSPlatform("windows")]
public static IntPtr CreateAggregatedObject<T>(IntPtr pOuter, T o) where T : notnull
{
- if (!IsComSupported)
+ if (!IsBuiltInComSupported)
{
throw new NotSupportedException(SR.NotSupported_COM);
}
[SupportedOSPlatform("windows")]
public static int ReleaseComObject(object o)
{
- if (!IsComSupported)
+ if (!IsBuiltInComSupported)
{
throw new NotSupportedException(SR.NotSupported_COM);
}
[SupportedOSPlatform("windows")]
public static int FinalReleaseComObject(object o)
{
- if (!IsComSupported)
+ if (!IsBuiltInComSupported)
{
throw new NotSupportedException(SR.NotSupported_COM);
}
[SupportedOSPlatform("windows")]
public static object? GetComObjectData(object obj, object key)
{
- if (!IsComSupported)
+ if (!IsBuiltInComSupported)
{
throw new NotSupportedException(SR.NotSupported_COM);
}
[SupportedOSPlatform("windows")]
public static bool SetComObjectData(object obj, object key, object? data)
{
- if (!IsComSupported)
+ if (!IsBuiltInComSupported)
{
throw new NotSupportedException(SR.NotSupported_COM);
}
[return: NotNullIfNotNull("o")]
public static object? CreateWrapperOfType(object? o, Type t)
{
- if (!IsComSupported)
+ if (!IsBuiltInComSupported)
{
throw new NotSupportedException(SR.NotSupported_COM);
}
[SupportedOSPlatform("windows")]
public static TWrapper CreateWrapperOfType<T, TWrapper>(T? o)
{
- if (!IsComSupported)
+ if (!IsBuiltInComSupported)
{
throw new NotSupportedException(SR.NotSupported_COM);
}
[SupportedOSPlatform("windows")]
public static void GetNativeVariantForObject(object? obj, /* VARIANT * */ IntPtr pDstNativeVariant)
{
- if (!IsComSupported)
+ if (!IsBuiltInComSupported)
{
throw new NotSupportedException(SR.NotSupported_COM);
}
[SupportedOSPlatform("windows")]
public static void GetNativeVariantForObject<T>(T? obj, IntPtr pDstNativeVariant)
{
- if (!IsComSupported)
+ if (!IsBuiltInComSupported)
{
throw new NotSupportedException(SR.NotSupported_COM);
}
[SupportedOSPlatform("windows")]
public static object? GetObjectForNativeVariant(/* VARIANT * */ IntPtr pSrcNativeVariant)
{
- if (!IsComSupported)
+ if (!IsBuiltInComSupported)
{
throw new NotSupportedException(SR.NotSupported_COM);
}
[SupportedOSPlatform("windows")]
public static T? GetObjectForNativeVariant<T>(IntPtr pSrcNativeVariant)
{
- if (!IsComSupported)
+ if (!IsBuiltInComSupported)
{
throw new NotSupportedException(SR.NotSupported_COM);
}
[SupportedOSPlatform("windows")]
public static object?[] GetObjectsForNativeVariants(/* VARIANT * */ IntPtr aSrcNativeVariant, int cVars)
{
- if (!IsComSupported)
+ if (!IsBuiltInComSupported)
{
throw new NotSupportedException(SR.NotSupported_COM);
}
[SupportedOSPlatform("windows")]
public static T[] GetObjectsForNativeVariants<T>(IntPtr aSrcNativeVariant, int cVars)
{
- if (!IsComSupported)
+ if (!IsBuiltInComSupported)
{
throw new NotSupportedException(SR.NotSupported_COM);
}
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern int GetEndComSlot(Type t);
+ [RequiresUnreferencedCode("Built-in COM support is not trim compatible", Url = "https://aka.ms/dotnet-illink/com")]
[SupportedOSPlatform("windows")]
public static object BindToMoniker(string monikerName)
{
- if (!IsComSupported)
+ if (!IsBuiltInComSupported)
{
throw new NotSupportedException(SR.NotSupported_COM);
}
return obj;
}
+ // Revist after https://github.com/mono/linker/issues/1989 is fixed
+ [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2050:UnrecognizedReflectionPattern",
+ Justification = "The calling method is annotated with RequiresUnreferencedCode")]
[DllImport(Interop.Libraries.Ole32, PreserveSig = false)]
private static extern void CreateBindCtx(uint reserved, out IBindCtx ppbc);
+ [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2050:UnrecognizedReflectionPattern",
+ Justification = "The calling method is annotated with RequiresUnreferencedCode")]
[DllImport(Interop.Libraries.Ole32, PreserveSig = false)]
private static extern void MkParseDisplayName(IBindCtx pbc, [MarshalAs(UnmanagedType.LPWStr)] string szUserName, out uint pchEaten, out IMoniker ppmk);
+ [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2050:UnrecognizedReflectionPattern",
+ Justification = "The calling method is annotated with RequiresUnreferencedCode")]
[DllImport(Interop.Libraries.Ole32, PreserveSig = false)]
private static extern void BindMoniker(IMoniker pmk, uint grfOpt, ref Guid iidResult, [MarshalAs(UnmanagedType.Interface)] out object ppvResult);
Type[] aArgsTypes,
Type retType)
{
- if (!Marshal.IsComSupported)
+ if (!Marshal.IsBuiltInComSupported)
{
throw new NotSupportedException(SR.NotSupported_COM);
}
FCFuncElement("OffsetOfHelper", MarshalNative::OffsetOfHelper)
QCFuncElement("InternalPrelink", MarshalNative::Prelink)
- QCFuncElement("IsComSupportedInternal", MarshalNative::IsComSupported)
+ QCFuncElement("IsBuiltInComSupportedInternal", MarshalNative::IsBuiltInComSupported)
FCFuncElement("GetExceptionForHRInternal", MarshalNative::GetExceptionForHR)
FCFuncElement("GetDelegateForFunctionPointerInternal", MarshalNative::GetDelegateForFunctionPointerInternal)
FCFuncElement("GetFunctionPointerForDelegateInternal", MarshalNative::GetFunctionPointerForDelegateInternal)
bLogCCWRefCountChange = true;
fEnableRCWCleanupOnSTAShutdown = (CLRConfig::GetConfigValue(CLRConfig::INTERNAL_EnableRCWCleanupOnSTAShutdown) != 0);
- m_fBuiltInCOMInteropSupported = Configuration::GetKnobBooleanValue(W("System.Runtime.InteropServices.Marshal.IsComSupported"), true);
+ m_fBuiltInCOMInteropSupported = Configuration::GetKnobBooleanValue(W("System.Runtime.InteropServices.BuiltInComInterop.IsSupported"), true);
#endif // FEATURE_COMINTEROP
#ifdef _DEBUG
END_QCALL;
}
-// IsComSupported
+// IsBuiltInComSupported
// Built-in COM support is only checked from the native side to ensure the runtime
// is in a consistent state
-BOOL QCALLTYPE MarshalNative::IsComSupported()
+BOOL QCALLTYPE MarshalNative::IsBuiltInComSupported()
{
QCALL_CONTRACT;
{
public:
static VOID QCALLTYPE Prelink(MethodDesc * pMD);
- static BOOL QCALLTYPE IsComSupported();
+ static BOOL QCALLTYPE IsBuiltInComSupported();
//====================================================================
// These methods convert between an HR and and a managed exception.
<?xml version="1.0" encoding="utf-8"?>
<linker>
<assembly fullname="System.Private.CoreLib, PublicKeyToken=7cec85d7bea7798e">
- <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
- <argument>ILLink</argument>
- <argument>IL2026</argument>
- <property name="Scope">member</property>
- <property name="Target">M:Internal.Runtime.InteropServices.ComActivator.FindClassType(System.Guid,System.String,System.String,System.String)</property>
- </attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2072</argument>
<property name="Scope">member</property>
<property name="Target">M:Internal.Runtime.InteropServices.IsolatedComponentLoadContext.Load(System.Reflection.AssemblyName)</property>
</attribute>
- <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
- <argument>ILLink</argument>
- <argument>IL2050</argument>
- <property name="Scope">member</property>
- <property name="Target">M:System.Runtime.InteropServices.Marshal.BindMoniker(System.Runtime.InteropServices.ComTypes.IMoniker,System.UInt32,System.Guid@,System.Object@)</property>
- </attribute>
- <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
- <argument>ILLink</argument>
- <argument>IL2050</argument>
- <property name="Scope">member</property>
- <property name="Target">M:System.Runtime.InteropServices.Marshal.CreateBindCtx(System.UInt32,System.Runtime.InteropServices.ComTypes.IBindCtx@)</property>
- </attribute>
- <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
- <argument>ILLink</argument>
- <argument>IL2050</argument>
- <property name="Scope">member</property>
- <property name="Target">M:System.Runtime.InteropServices.Marshal.MkParseDisplayName(System.Runtime.InteropServices.ComTypes.IBindCtx,System.String,System.UInt32@,System.Runtime.InteropServices.ComTypes.IMoniker@)</property>
- </attribute>
- <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
- <argument>ILLink</argument>
- <argument>IL2057</argument>
- <property name="Scope">member</property>
- <property name="Target">M:Internal.Runtime.InteropServices.ComActivator.ClassRegistrationScenarioForType(Internal.Runtime.InteropServices.ComActivationContext,System.Boolean)</property>
- </attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2057</argument>
<property name="Scope">member</property>
<property name="Target">M:Internal.Runtime.InteropServices.ComponentActivator.InternalGetFunctionPointer(System.Runtime.Loader.AssemblyLoadContext,System.String,System.String,System.IntPtr)</property>
</attribute>
- <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
- <argument>ILLink</argument>
- <argument>IL2075</argument>
- <property name="Scope">member</property>
- <property name="Target">M:Internal.Runtime.InteropServices.ComActivator.ClassRegistrationScenarioForType(Internal.Runtime.InteropServices.ComActivationContext,System.Boolean)</property>
- </attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2075</argument>
<property name="Scope">member</property>
<property name="Target">M:Internal.Runtime.InteropServices.ComponentActivator.InternalGetFunctionPointer(System.Runtime.Loader.AssemblyLoadContext,System.String,System.String,System.IntPtr)</property>
</attribute>
- <attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
- <argument>ILLink</argument>
- <argument>IL2077</argument>
- <property name="Scope">member</property>
- <property name="Target">M:Internal.Runtime.InteropServices.ComActivator.BasicClassFactory.CreateInstance(System.Object,System.Guid@,System.IntPtr@)</property>
- </attribute>
</assembly>
</linker>
<Compile Include="System\Runtime\InteropServices\Marshal\MarshalComDisabledTests.cs" />
</ItemGroup>
<ItemGroup>
- <RuntimeHostConfigurationOption Include="System.Runtime.InteropServices.Marshal.IsComSupported" Value="false" />
+ <RuntimeHostConfigurationOption Include="System.Runtime.InteropServices.BuiltInComInterop.IsSupported" Value="false" />
</ItemGroup>
</Project>
-//using System.Runtime.InteropServices.Tests.Common;
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
using Xunit;
namespace System.Runtime.InteropServices.Tests