Skip to content

Warn about some COM usage - #1382

Merged
MichalStrehovsky merged 3 commits into
dotnet:masterfrom
MichalStrehovsky:comWarn
Jul 27, 2020
Merged

Warn about some COM usage#1382
MichalStrehovsky merged 3 commits into
dotnet:masterfrom
MichalStrehovsky:comWarn

Conversation

@MichalStrehovsky

Copy link
Copy Markdown
Member

COM represents a problem for trimming because the usage of the interfaces are not visible to the linker.

The problem is twofold:

  • The IDispatch interface that COM objects can be cast to is basically reflection.
  • IUnknown.QueryInterface lets the native side get to any COM visible interface on the managed side. COM visible is pretty much everything because it's the default. We can't root those because it would make trimming ineffective.

COM represents a problem for trimming because the usage of the interfaces are not visible to the linker.

The problem is twofold:
* The IDispatch interface that COM objects can be cast to is basically reflection.
* IUnknown.QueryInterface lets the native side get to any COM visible interface on the managed side. COM visible is pretty much everything because it's the default. We can't root those because it would make trimming not very effective.

@vitek-karas vitek-karas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the impact on framework? How many such warnings show up when we run this over CoreLib and friends?

Comment thread src/linker/Linker.Steps/MarkStep.cs
Comment thread src/linker/Linker.Steps/MarkStep.cs
@MichalStrehovsky

Copy link
Copy Markdown
Member Author

What's the impact on framework? How many such warnings show up when we run this over CoreLib and friends?

For a trimmed Console app there's no warnings. No warnings for Blazor either. About a dozen warnings for a WinForms app.

There are some warnings within the framework, e.g. System.Drawing (Image.Save uses COM for example since it's just a thin wrapper over GDI+).

@MichalStrehovsky

Copy link
Copy Markdown
Member Author

We should wait merging this until your big warning overhaul goes through.

@vitek-karas

Copy link
Copy Markdown
Member

Actually I would rather do it the other way round - merge this when possible - I have some other reshuffling of warnings to do in the overhaul PR.

@MichalStrehovsky

Copy link
Copy Markdown
Member Author

Actually I would rather do it the other way round - merge this when possible - I have some other reshuffling of warnings to do in the overhaul PR.

Works for me if it's not causing extra trouble for you, thanks! I'll merge once I see the CI green.

@MichalStrehovsky
MichalStrehovsky merged commit 968d356 into dotnet:master Jul 27, 2020
@MichalStrehovsky
MichalStrehovsky deleted the comWarn branch July 27, 2020 12:57
tkapin pushed a commit to tkapin/runtime that referenced this pull request Jan 31, 2023
COM represents a problem for trimming because the usage of the interfaces are not visible to the linker.

The problem is twofold:
* The IDispatch interface that COM objects can be cast to is basically reflection.
* IUnknown.QueryInterface lets the native side get to any COM visible interface on the managed side. COM visible is pretty much everything because it's the default. We can't root those because it would make trimming not very effective.

Commit migrated from dotnet/linker@968d356
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants