Fatorin commented on issue #3966:
URL: https://github.com/apache/opendal/issues/3966#issuecomment-3944544858
Hi, I noticed this issue has been open for some time.
I’m interested in helping with it. Would it be okay if I take a look and
work on a PR?
I checked the latest .NET documentation, and LibraryImport (source-generated
P/Invoke) is now the recommended modern approach. In this case, switching from
DllImport to LibraryImport generally provides better performance in most
scenarios and can also improve string marshalling behavior (e.g., explicit
UTF-8 handling).
For example, the current implementation:
```
[DllImport(
"opendal_dotnet",
EntryPoint = "blocking_operator_construct",
CallingConvention = CallingConvention.Cdecl,
CharSet = CharSet.Auto)]
private static extern IntPtr blocking_operator_construct(string scheme);
```
Could be rewritten as:
```
[LibraryImport("opendal_dotnet", EntryPoint = "blocking_operator_construct",
StringMarshalling = StringMarshalling.Utf8)]
[UnmanagedCallConv(CallConvs =
[typeof(System.Runtime.CompilerServices.CallConvCdecl)])]
private static partial IntPtr blocking_operator_construct(string scheme);
```
I’ve verified this change locally and confirmed that existing tests pass
without behavioral differences.
Additionally, I’m interested in gradually improving and completing the .NET
binding as it continues to evolve.
I’d be happy to start with small, incremental changes like this and continue
filling in missing implementations over time, if that aligns with the project’s
direction.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]