-
Notifications
You must be signed in to change notification settings - Fork 94
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
Consider a "non-PreserveSig" codegen setting #120
Comments
There are the occasional COM methods where distinguishing multiple different successful HRESULTs is required (most prominently S_OK vs. S_FALSE which could actually be modeled by a boolean return value if it were annotated in the metadata). Do you expect to annotate the APIs which may return more than S_OK ? Also there are plenty of COM methods where "error" HRESULTs are actually normal non-exceptional code paths, so forcing this to go through the slow .NET Exception handling logic seems counterintuitive when most other design decisions of this library (currently) are for high performance. |
Great points, @weltkante. In fact I was just discussing this with @mikebattista yesterday. What do you think? Does that sound like the right set of options? |
If theres an option to be selective and get the best of both worlds that works for me. Definitely not worse than what you currently have to do when writing ComImport mappings. |
This was done in #194 |
@AArnott Do we have to list each interface where we want [PreserveSig] applied manually in 'NativeMethods.json' or is there a way to enable [PreserveSig] by default for all COM interfaces? |
Yes, you have to list each interface or interface member. If you want it on for all generation, can you open a new issue to track that? It should be cheap enough to support. But also please explain why, since we are considering what we should do for the dotnet/pinvoke precompiled library version of this, where users will have to take what we precompile or be forced to use the source generator. |
When methods return HRESULT, consider making their friendly overload return
void
or theretval
parameter and having the method throw on errors.The text was updated successfully, but these errors were encountered: