-
Notifications
You must be signed in to change notification settings - Fork 127
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 members accessible due ComVisibleAttribute handling #378
Comments
Members in all [ComImport] types shouldn't be trimmed. |
I see, thanks for that clarification. |
This is the same issue we encountered in dotnet/corefx#30092 where System.Drawing.Common.Interop/Ole32/IStream (https://github.com/dotnet/corefx/blob/dee434428ee392302ff2050bbee304c9fce68b2f/src/Common/src/Interop/Windows/Ole32/Interop.IStream.cs#L22), which is also [ComImport] had its members trimmed. I opened #338 to track fixing that in the linker but it looks like my fix suggestion there wasn't correct. I'll close that issue and keep this one open. |
ILLink doesn't trim public type members when running with -r option. That's how it's running in corefx. However, it does trim public type members in other configurations. The fix for this issue should include not trimming members in [ComVisible] public types. |
Yes, Please. CCW scenario need these type members. |
In .NET 7 the built-in COM is not trim compatible (and probably never will be, it's almost impossible to guarantee correctness statically). So it's disable by default. The recommended solution for making COM usage trimmable is to use ComWrappers. COM through ComWrappers is completely trimmable and supported. |
See dotnet/corefx#32491
The linker was trimming an internal interface because it didn't see any uses, but it would be used by COM. The managed code passes the object implementing that interface to native code and the native code would QI for the interface. Runtime would return the CCW for the interface but that would be missing the necessary methods and native code AV'ed when calling it.
We should look at a heuristic for identifying these interfaces.
@jkotas suggests looking at the ComImportAttribute: I'm not sure that's sufficient. I think technically any COMVisible interface would fall in this bucket. I believe most interfaces are COMVisible by default, but @luqunl would know better here.
/cc @sbomer @erozenfeld
The text was updated successfully, but these errors were encountered: