-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Provide a clean migration experience from built-in COM to source-generated COM #87350
Comments
Tagging subscribers to this area: @dotnet/interop-contrib Issue DetailsWe recently tested out the "convert to source-generated COM experience" on System.Transactions.Local and we found that the existing analyzers/fixers have a few holes that can make adoption more difficult and cause runtime errors. In particular, it is really easy to end up in a state where some, but not all, interfaces have been (or can be) converted over from built-in COM to source-generated COM. We feel that this scenario will be decently common due to the following reasons:
We discussed this issue offline and determined that a multi-pronged approach here would be best. Each of these steps can be done gradually or not at all. They're listed in increasing cost/complexity.
|
We recently tested out the "convert to source-generated COM experience" on System.Transactions.Local and we found that the existing analyzers/fixers have a few holes that can make adoption more difficult and cause runtime errors.
In particular, it is really easy to end up in a state where some, but not all, interfaces have been (or can be) converted over from built-in COM to source-generated COM.
We feel that this scenario will be decently common due to the following reasons:
[ComImport]
interface that is part of public surface area to[GeneratedComInterface]
is a runtime breaking change.System.Transactions.IDtcTransaction
is a public interface, but the rest of the COM surface area in System.Transactions.Local is internal only. We can useMarshal.Get/SetComObjectData
to bridge the two systems, but it's ugly and easy to mess up and means that there are two different managed objects to represent the same COM object in the same library.System.Runtime.InteropServices.ComTypes
namespace. This namespace has standard COM types that we cannot move to being source-generated due to the prior mentioned breaking change issues.System.Transactions.Local
usesIConnectionPointContainer
and related connection point sinks, so one of the internal interfaces (and the corresponding implementing C# class) to use built-in COM for that scenario. We can reuse theMarshal.Get/SetComObjectData
trick we used above to work around this.We discussed this issue offline and determined that a multi-pronged approach here would be best. Each of these steps can be done gradually or not at all. They're listed in increasing cost/complexity.
[ComImport]
interface, and reflection-emit a type that will enable us to shim the[ComImport]
interface to the underlying managed object using the built-in marshalling rules (RCW interop).ICustomQueryInterface
to all[GeneratedComClass]
types that do not already implement the interface, as well as new implementations of. At runtime, this interface implementation will check if the feature flag is enabled, and if so, get a pointer to a compatible interface implementation that does source-generated marshalling for parameters and gets thethis
managed object from the runtime-based COM interop system.The text was updated successfully, but these errors were encountered: