-
Notifications
You must be signed in to change notification settings - Fork 104
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 support for CloakedIid<T> for WinRT/COM interfaces #1308
Comments
@Sergio0694 To make I understand the proposal, basically we want to be able to author types in C# (either using authoring support or even just a C# implemented class that is passed for an interface) and have it implement interfaces some of which you would be able to QI for if you know the IID but it will not get reported in GetIIDs calls. In the Win2D scenario, I assume these interfaces are not represented in metadata either, or are they? |
Yup, that's exactly right! For Win2D, this is used for several interop interfaces, which are only declared either in the published header for Win2D or in some headers from the Windows SDK, but which are not part of metadata, yes. That is, in Win2D, those interfaces are only implemented by the type implementing the public WinRT interfaces, but they are not declared in IDL (so they also don't result in any projections being generated). For instance, the public |
Proposal: support CloakedIid for WinRT/COM interfaces
Summary
When defining a WinRT/COM class, WRL exposes the
CloakedIid<T>
helper, which allows interfaces to be hidden and only show up when explicitly queried for. That is, they wouldn't contribute to the list of implemented interfaces fromIInspectable::GetIids
. This is particularly common and useful for interop interfaces. Right now there's no way to express this with CsWinRT, as even using interface interfaces only makes it so the interface isn't explicitly visible in metadata, but if you retrieve a CCW for the object and callGetIids
, those GUIDs would still show up. For instance, Win2D uses this pattern extensively (all the interop interfaces are implemented by the public WinRT objects as having a cloaked iid), but there's no way to replicate it with types authored in C#.The proposal is to have a new attribute that would be recognized by the CsWinRT architecture, and would cause the corresponding interface to be skipped when computing the list of IIDs to return from the generated
GetIids
method fromIInspectable
:Rationale
CloakedIid<T>
from WRLUse example
Consider the following declarations:
You would then get:
Open Questions
Not 100% clear to me whether this would be entirely on CsWinRT, or whether this should require any support from the
ComWrappers
side? If so, let me know whether I should move this to the runtime repo, or whether this is the right place for it 🙂Also, the proposed API would make the cloaked iid feature opt-in per interface type. Should we consider a way to make this opt-in per concrete type on a given target interface, mirroring what WRL does? That seems more complex and potentially less trimmer friendly?
cc. @AaronRobinsonMSFT @jkoritzinsky @manodasanW
The text was updated successfully, but these errors were encountered: