-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
CoreCLR ComClassFactory::CreateInstanceFromClassFactory calls into managed Internal.Runtime.InteropServices.LicenseInteropProxy.Create (and some other methods as well). This dependency is hardcoded in the System.Private.CoreLib descriptor and so linker can't ever remove the LicenseInteropProxy.
This type brings in a lot of dependencies (ultimately even BinaryFormatter) which also have some trim analysis warnings.
This functionality should not be needed when COM support is turned off - see COM Feature switch.
Also - this functionality is probably only needed when managed COM activation is used by the project - that is, it can only ever be called if ComActivator was used.
Vast majority of .NET Core projects don't use ComActivator and thus including this code is unnecessary.
What to do about this:
- Verify that the code in
ComClassFactory::CreateInstanceFromClassFactorywhich calls intoLicenseInteropProxycan only be used whenComActivatoris also used. If this is not true, then more work is needed to determine what to do. - Instead of rooting the
LicenseInteropProxyalways, make it a dynamic dependency (viaDynamicDependencyAttribute) of theComActivator(the right method on it) and remove it from the CoreLib's ILLink descriptor. - Add a trimming test which validates that the
LicenseInteropProxyis not present in a normal console hello world (even without any feature switches) - Make sure that the code is also hidden behind the COM feature switch (this might be a NOP since
ComActivatorshould be hidden behind the feature switch, but maybe some small pieces will be left-over).