Replies: 1 comment
-
Great questions. We hope to get some good guidance and probably some cswin32 changes made in the next month or so to improve the story here. In the meantime, @JeremyKuhne may have some ideas to help as he already does a lot of trim-friendly COM stuff with cswin32 in WinForms. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've been trying to implement COM interface (specifically ITextHost) from my C# code in a way that is AOT friendly.
I was able to manually declare this interface with all methods and implement it using COM Wrappers code generator approach, but I was wondering whether this is possible with cswin32 currently, so that I do not have to code method signatures by hand?
When I import
ITextHost
interfaces without Marshaling (required for AOT), is there some simple way I can implement it on my class that will be passed to code expectingITextHost
? Currently code generated by cswin32 is astruct
, I don't see any mentions how would I implement this interface. I've read mentions that cswin32 does use COM Wrapper compatible code when Marshaling is disabled, but generated code is really different than what is mentioned in COM Wrappers source generator article.Right now I have to use two different approaches for COM interop - cswin32 for importing interfaces and COM Wrappers source generator for exposing interfaces, which I would like to unify.
I've noticed that generated code includes
ITextHost.Interface
interface, but it is not partial so I cannot annotate it with[GeneratedComInterface]
attribute nor can I change calling conventions of methods to ThisCall (ITextHost has weird calling convention). I'm not sure how I would doQueryInterface
on an object implementingITextHost.Interface
(this is needed for CreateTextServices API call).I've tried to copy generated interface and simply annotate it with attributes for COM Wrapper generator, but compilation errors out with marshalling failures such as:
The type 'Windows.Win32.Foundation.HRESULT' is not supported by source-generated COM. The generated source will not handle marshalling of the return value of method 'TxGetBackStyle'.
For types that are not supported by source-generated COM, the resulting function pointer will rely on the underlying runtime to marshal the specified type.
I've also noticed that COM Wrappers api has strategy based methods for managing lifetime of instances of COM objects, how does this relate to cswin32?
Beta Was this translation helpful? Give feedback.
All reactions