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

Warn about some COM usage #1382

Merged
merged 3 commits into from
Jul 27, 2020
Merged

Conversation

MichalStrehovsky
Copy link
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.
Copy link
Member

@vitek-karas vitek-karas left a comment

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?

src/linker/Linker.Steps/MarkStep.cs Show resolved Hide resolved
src/linker/Linker.Steps/MarkStep.cs Show resolved Hide resolved
@MichalStrehovsky
Copy link
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
Member Author

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

@vitek-karas
Copy link
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
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