You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The source generator currently generates structs instead of interfaces. This makes things a little difficult when an API relies on being able to use inheritance and multiple interfaces, for example DWriteCreateFactory:
using Microsoft.Windows.Sdk;namespaceInterFaceGenerationRepro{internalclassProgram{privatestaticvoidMain(string[]args){IDWriteFactoryfactory;HRESULTresult= PInvoke.DWriteCreateFactory(DWRITE_FACTORY_TYPE.DWRITE_FACTORY_TYPE_SHARED,typeof(IDWriteFactory).GUID,out factory);}}}
The IDWriteFactory interface is based off of IUnknown, and has seven other interfaces that can be swapped in to provide additional methods that can be called, by changing the GUID in the DWriteCreateFactory iid parameter to communicate which interface to use.
Expected:
The source generator should generate interfaces with full inheritance hierarchy for interfaces.
Actual:
The source generator currently generates structs in place of interfaces, causing DWriteCreateFactory's factory out parameter to not be able to cast to any of the IDWriteFactory interfaces to the defined IUnknown type.
The text was updated successfully, but these errors were encountered:
Thanks for the feedback. The current behavior is intentional but we want to offer interface generation as an option.
Once we get into interfaces, marshaling of structs is required, which unravels a bunch of the rest of the generated code. We do want to do this as an option variant of code gen.
The source generator currently generates structs instead of interfaces. This makes things a little difficult when an API relies on being able to use inheritance and multiple interfaces, for example DWriteCreateFactory:
NativeMethods.txt
Program.cs
The IDWriteFactory interface is based off of IUnknown, and has seven other interfaces that can be swapped in to provide additional methods that can be called, by changing the GUID in the DWriteCreateFactory iid parameter to communicate which interface to use.
Expected:
The source generator should generate interfaces with full inheritance hierarchy for interfaces.
Actual:
The source generator currently generates structs in place of interfaces, causing DWriteCreateFactory's factory out parameter to not be able to cast to any of the IDWriteFactory interfaces to the defined IUnknown type.
The text was updated successfully, but these errors were encountered: