-
Notifications
You must be signed in to change notification settings - Fork 114
Description
Actual behavior
The signature generated for the ReadFile and WriteFile structures is:
internal static unsafe winmdroot.Foundation.BOOL WriteFile(SafeHandle hFile, void* lpBuffer,
uint nNumberOfBytesToWrite, uint* lpNumberOfBytesWritten,
winmdroot.System.IO.OVERLAPPED* lpOverlapped) {}On the other hand, .NET already defines System.Threading.NativeOverlapped which must be used with ThreadPoolBoundHandle.GetNativeOverlappedState and other APIs.
As a consequence, when using the asynchronous behaviour on Windows, I can't rely on the generated code, but I have to define separately the PInvokes.
Please note that this is also true for other APIs like:
- GetOverlappedResult
- ClearCommError
- WaitCommEvent
- WIN32_ERROR (must be casted to match
Marshal.GetLastWin32Error()
Expected behavior
Whenever .NET defines some interop code, I expect the generated code matches them. Or at least provides a different overload with a native pointer so that it can be used with code different than the one created by the genrator.
In general, when there is a pointer, it would be useful to get overloads with a "void*" to avoid being blocked.
Repro steps
NativeMethods.txtcontent:
CreateFile
ReadFile
WriteFile
GetOverlappedResult
CloseHandle
NativeMethods.jsoncontent (if present):
N/A
- Any of your own code that should be shared?
Not needed
Context
- CsWin32 version:
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.1.647-beta"> - Win32Metadata version: N/A
- Target Framework: net6.0
LangVersion: N/A