-
Notifications
You must be signed in to change notification settings - Fork 984
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 LibraryImport for PInvoke generation #6217
Comments
I think it should wait until it actually gets shipped and if it can add support for com marshalling then use it to avoid possibly breaking changes. |
I create issue for exploration. but I want to note, that Com Marshalling does not applicable. .NET 7 should work with NativeAOT/disabled built-in COM without bandaid required for previous versions. Given that Preview 5 would have LibraryImportGenerator I think I can start playing with it here. |
First work is started in #7172 |
I think Winforms will still need a way to use COM then when this happens. Perhaps one should ask the maintainers of the generator to add COM marshaling support so that way there won't be any possible regressions in winforms. |
/cc: @AaronRobinsonMSFT for visibility |
WinForms can start to consume LibraryImport now and that would be much appreciated. We started doing this in dotnet/aspnetcore#41573 and found some deficiencies so it is possible WinForms will also find issues we should address.
This is on deck - see dotnet/runtime#66674. /cc @dotnet/interop-contrib |
For the record LibraryImport work started #7172 based on my previous attempts we need a lot of structure marshalers. What’s recommendations for dealing with structures? There a lot of them in WinForms and writing all of marshalers would be boring. Can simple marshalers be generated for us for this case? |
That is something we have discussed. We are still looking for the justification of cost though. Knowing how many marshallers would need to be written manually in WinForms coupled with a few examples would be helpful in understanding the benefit. |
Okay. I wrote a small tool which analyze Methods analysis:
And types analysis
I would not claim that I copy all rules for LibraryImportGenerator, but seems to be I'm pretty close. Not sure about which scenario runtime team think to implement, but I think it was what I call Also not sure should Applying DisableRuntimeMarshallingAttribute should be last step, as it is require ComWrappers to be fully implemented across codebase. It is not clear from documentation, would it be possible to introduce changes piece meal or not. It is not clear from documentation what is considered not Strictly blittable types seems to be a way how to postpone applying /cc @gpetrou because you are driving changes in that direction now. |
Right.
The idea is basically the old definition but limited to value types, classes marked sequential are not blittable, and must be made up of types that are either all defined in the same assembly or of always blittable primitives.
Sort of. There are a number of cases where
Right. This was our assumption. Generating marshallers for these types is expected to be rather simple and helps owners to be more active in the interop space rather than keeping it a mystery. If someone wants to perform some non-trivial interop they should be expected to participate at least a little. |
@merriemcgaw is this still valid with the move to using |
/cc @JeremyKuhne |
Yes, this is no longer relevant. Thanks for pointing it out, @elachlan. |
The LibraryImportGenerator experiment lands .NET 7 and provide slightly better performance with high compatibility bar. Also LibraryImportGenerator probably would be productized for .NET 7 dotnet/runtime#60595
.NET Team itself embrace it in core .NET - See https://github.com/dotnet/runtime/issues?q=is%3Aissue+is%3Aopen+LibraryImport
Unfortunately COM marshalling does not supported, but given that ComWrappers should be done here, it's probably would not be a problem.
Open issues:
The text was updated successfully, but these errors were encountered: