-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Suggestion ComWrappers.TryGetComInstance()
to improve UX
#106979
Comments
Tagging subscribers to this area: @dotnet/interop-contrib |
We could do this as a method on StrategyBasedComWrappers without too much trouble as we have a mechanism to look up interface details. On ComWrappers, we'd have to require the user to pass in the IID as there's no Type->IID mechanism at that level. |
I like that. We could follow what @smourier is alluding to and simply apply the |
Yep! I think that's a great way to do it. |
I've updated the top of the issue to be in the API Proposal format and added one more convenience overload that I think would be quite useful. |
Background and motivation
It would be nice to have some wrappers that would return other interfaces pointers, something like:
that would do the QI so I could call it like this:
As a "frequent COM flyer", It's quite perturbing to have to juggle between
ComWrappers
andMarshal
classes, actually it would be nice with all that new code to be able to avoid usingMarshal
completely :-)Originally posted by @smourier in #106978 (comment)
public abstract partial class ComWrappers { + public bool TryGetComInstance<TInterface>(object instance, CreateComInterfaceFlags flags, out IntPtr result); }
This could also be an auto-generated method that would be provided on a derived
ComWrappers
instance. Looking up the IID onTInterface
would need to be AOT friendly, which meanstypeof(TInterface).GUID
is out.API Proposal
API Usage
Alternative Designs
No response
Risks
No response
The text was updated successfully, but these errors were encountered: