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
This is the first I've heard about the attribute. I've heard about the source generator that avoids relying on the .NET runtime for interop code. CsWin32 is actually pretty close to this already for extern methods because if you turn off marshaling (a CsWin32 setting) we emit blittable, non-marshaled extern methods, and replace COM interfaces with blittable structs. It's not the most friendly API, but it's a start toward this if folks really want this.
Given Roslyn doesn't support chaining source generators. CsWin32 already does a significant amount of work to avoid relying on .NET marshaling already, and has just a bit more to do (#600).
If we need more from LibraryImport, we'll just have to borrow code (or even the dll) from that source generator.
Activity
AArnott commentedon Jun 24, 2022
This is the first I've heard about the attribute. I've heard about the source generator that avoids relying on the .NET runtime for interop code. CsWin32 is actually pretty close to this already for
externmethods because if you turn off marshaling (a CsWin32 setting) we emit blittable, non-marshaled extern methods, and replace COM interfaces with blittable structs. It's not the most friendly API, but it's a start toward this if folks really want this.elachlan commentedon Jun 24, 2022
Thanks for the reply!
What about function pointers? Would they work/make sense in CSWin32 or are they already implemented?
dotnet/winforms#4135
eg:
dotnet/winforms#4003
AArnott commentedon Jun 25, 2022
Yes, CsWin32 already generates function pointers where needed.
alexrp commentedon Jul 8, 2022
It's worth noting that CsWin32's support for disabling marshalling won't actually be usable with
DisableRuntimeMarshallingAttributeyet because ofSetLastError: https://docs.microsoft.com/en-us/dotnet/standard/native-interop/disabled-marshalling#disabled-featuresLibraryImportAttributesupports generating appropriate code forSetLastError, so that's a point in favor of using it.AArnott commentedon Aug 10, 2022
Given Roslyn doesn't support chaining source generators. CsWin32 already does a significant amount of work to avoid relying on .NET marshaling already, and has just a bit more to do (#600).
If we need more from LibraryImport, we'll just have to borrow code (or even the dll) from that source generator.