Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply BuiltInComInterop feature switch to managed code #54056

Merged
merged 3 commits into from
Nov 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<linker>
<assembly fullname="Microsoft.CSharp">
<assembly fullname="Microsoft.CSharp" feature="System.Runtime.InteropServices.BuiltInComInterop.IsSupported" featurevalue="true" featuredefault="true">
<!-- Required for COM event dispatch -->
<type fullname="System.Runtime.InteropServices.ComEventsSink"/>
</assembly>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,34 @@
</type>
</assembly>

<!-- The following attributes are only necessary when COM is supported -->
<assembly fullname="System.Private.CoreLib" feature="System.Runtime.InteropServices.BuiltInComInterop.IsSupported" featurevalue="false">
<type fullname="System.Runtime.InteropServices.ClassInterfaceAttribute">
<attribute internal="RemoveAttributeInstances" />
</type>
<type fullname="System.Runtime.InteropServices.ComDefaultInterfaceAttribute">
<attribute internal="RemoveAttributeInstances" />
</type>
<type fullname="System.Runtime.InteropServices.ComEventInterfaceAttribute">
<attribute internal="RemoveAttributeInstances" />
</type>
<type fullname="System.Runtime.InteropServices.ComSourceInterfacesAttribute">
<attribute internal="RemoveAttributeInstances" />
</type>
<type fullname="System.Runtime.InteropServices.ComVisibleAttribute">
<attribute internal="RemoveAttributeInstances" />
</type>
<type fullname="System.Runtime.InteropServices.DispIdAttribute">
<attribute internal="RemoveAttributeInstances" />
</type>
<type fullname="System.Runtime.InteropServices.InterfaceTypeAttribute">
<attribute internal="RemoveAttributeInstances" />
</type>
<type fullname="System.Runtime.InteropServices.ProgIdAttribute">
<attribute internal="RemoveAttributeInstances" />
</type>
</assembly>

<!--
Attributes listed below here should be behind the 'System.AggressiveAttributeTrimming' feature switch, which
is only enabled by default on app models that need as much size savings as possible.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Reflection;
using System.Diagnostics;
using System.Runtime.InteropServices;
using CultureInfo = System.Globalization.CultureInfo;

namespace System
Expand Down Expand Up @@ -227,7 +228,7 @@ public sealed override MethodBase BindToMethod(

if (!pCls.IsAssignableFrom(argTypes[paramOrder[i][j]]))
{
if (argTypes[paramOrder[i][j]].IsCOMObject)
if (Marshal.IsBuiltInComSupported && argTypes[paramOrder[i][j]].IsCOMObject)
{
if (pCls.IsInstanceOfType(args[paramOrder[i][j]]))
continue;
Expand Down Expand Up @@ -255,7 +256,7 @@ public sealed override MethodBase BindToMethod(

if (!paramArrayType.IsAssignableFrom(argTypes[j]))
{
if (argTypes[j].IsCOMObject)
if (Marshal.IsBuiltInComSupported && argTypes[j].IsCOMObject)
{
if (paramArrayType.IsInstanceOfType(args[j]))
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ namespace System.Runtime.InteropServices
{
public static partial class Marshal
{
internal static bool IsBuiltInComSupported => false;

public static int GetHRForException(Exception? e)
{
return e?.HResult ?? 0;
Expand Down