-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Add option to keep/remove COM interfaces #101087
Conversation
Tagging subscribers to this area: @agocke, @sbomer, @vitek-karas |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have another idea to avoid silent bad RCWs/CCWs: Given that this would break when built-in COM is enabled, could we remove the attributes/metadata that make an interface a COM interface if any of its members are trimmed? Then we wouldn't have the bad scenario where someone could say "don't keep COM interfaces, but keep built-in COM enabled", as if a COM interface is trimmed, it's no longer a COM interface.
...ono.Linker.Tests.Cases/Inheritance.Interfaces/OnReferenceType/UnusedComInterfaceIsRemoved.cs
Show resolved
Hide resolved
Thanks for the suggestion, I opened #101128 to track that, but I don't think we need it for this change. The problem you mentioned exists with the current behavior - even when keeping COM interfaces, we may remove interface members. I think we are covered by the fact that built-in COM is not supported when trimming. |
Adds an illink option that can be used to remove COM interfaces (the existing behavior is to preserve COM interfaces on marked types). If a type implements a COM interface that is also marked elsewhere, it will still be kept even with `--keep-com-interfaces false`. This includes windows runtime interfaces under the same option name. This eliminates some trim warnings in winforms due to trim-incompatible code in Control's implementations of COM interfaces like IPersistPropertyBag. Experimentally, this still produces a working app for the scenario we've been testing (https://github.com/dotnet/winforms/tree/main/src/System.Windows.Forms/tests/IntegrationTests/TrimTest). For now, this just introduces the option without setting it by default anywhere (or exposing it in MSBuild) so that we can opt in from the winforms scenario. We might consider setting it wherever `BuiltInComInteropSupport` is false.
Adds an illink option that can be used to remove COM interfaces (the existing behavior is to preserve COM interfaces on marked types). If a type implements a COM interface that is also marked elsewhere, it will still be kept even with
--keep-com-interfaces false
. This includes windows runtime interfaces under the same option name.This eliminates some trim warnings in winforms due to trim-incompatible code in Control's implementations of COM interfaces like IPersistPropertyBag. Experimentally, this still produces a working app for the scenario we've been testing. For now, this just introduces the option without setting it by default anywhere (or exposing it in MSBuild) so that we can opt in from the winforms scenario. We might consider setting it wherever
BuiltInComInteropSupport
is false.