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

Implement basic (recommended against) support for inheriting from COM interfaces defined in different assemblies #105119

Merged
merged 8 commits into from
Aug 6, 2024

Conversation

jkoritzinsky
Copy link
Member

Fixes #102602

This PR provides support for simple scenarios of interface inheritance across different assemblies. Using this feature emits a user-suppressible warning with pointers to our (to be updated) documentation.

This feature may not work in advanced scenarios. We expect that the majority of usage of the COM source generator will not use this feature, so that is okay. The following are some scenarios that may not work today or in the future:

  • The base interface type defines a method that shadows a method in its base interface.
  • The base interface type is part of a project compiled using ComInterfaceGenerator vX, which has one set of rules for how methods are defined on a COM interface. The derived type is compiled using ComInterfaceGenerator vY, which has another set of rules (property support in the future comes to mind).
  • The base interface's project had various source generator errors suppressed, and the base interface is defined incorrectly.

Additionally, having a COM interface inheritance chain defined across assemblies causes problems with assembly versioning and creates a really bad pit of failure if the author violates the rules of COM and changes the vtable of their COM interface type (see #102602 (comment)).

We believe that for the amount of usage we expect for this feature, providing an effectively "opt-in and agree to the pitfalls" experience provides the necessary guardrails to avoid guiding users into a pit of failure.

@jkoritzinsky
Copy link
Member Author

@dotnet/appmodel PTAL

@jkoritzinsky
Copy link
Member Author

/ba-g failure unrelated

@jkoritzinsky jkoritzinsky merged commit 1563fec into dotnet:main Aug 6, 2024
93 of 95 checks passed
@jkoritzinsky jkoritzinsky deleted the no-cross-syntax-tree-warning branch August 6, 2024 21:27
jkoritzinsky added a commit to dotnet/docs that referenced this pull request Aug 6, 2024
…ross assembly boundaries

Add documentation about the feature introduced in dotnet/runtime#105119
@github-actions github-actions bot locked and limited conversation to collaborators Sep 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Runtime.InteropServices source-generator Indicates an issue with a source generator feature
Projects
Status: Done
3 participants