Skip to content

Add the ability to remove COM support using ILLinker #36659

Closed
@eerhardt

Description

@eerhardt

As discussed in:

We are currently "rooting" types in the libraries specifically for COM:

<!-- Required for COM event dispatch -->
<type fullname="System.Runtime.InteropServices.ComEventsSink"/>

<!-- IMarshal is internal and never directly called, but needed by COM -->
<type fullname="System.Runtime.InteropServices.IMarshal" />

A lot of scenarios in .NET don't have COM support, as such we should be able to trim out any COM specific code when we are linking for a scenario that won't ever need COM (Blazor, Xamarin, Linux, etc).

One way of doing this would be to add a new feature switch to the product that would enable/disable COM. We can then add the switch in code to remove any COM specific code. In order to remove the COM types from being rooted by the ILLinkTrim.xml "descriptor XML files" above, we would need the ILLinker to allow "feature switches" to be present in the descriptor XML files, and to include/exclude that root based on the feature switch.

Note that Blazor today is already using something similar when it uses monolinker.exe - --exclude-feature com. See the Blazor build code. However, --exclude-feature is not supported by the ILLinker, only by monolinker.exe.

cc @vitek-karas @MichalStrehovsky @sbomer @marek-safar

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions