Closed qmfrederik closed 1 year ago
Helper methods are documented in our contributing guidelines as enabling such things as IEnumerable<T>
, so returning Task
may fit. But I would hesitate to recreate an full async I/O stack, particularly if it's redundant with what .NET has. Would it be?
Methods for which I have a personal interest in adding them:
DeviceIoControl
WinUsb_ReadPipe
WinUsb_WritePipe
I took a look at your PR and it looks like something that may belong in the repo. But I'm still curious whether async IO is something you could just do with the .NET base class libraries as opposed to requiring a p/invoke level API.
Never mind. I guess DeviceIoControl
is a very low-level API that likely isn't exposed by the .NET BCL.
Correct; I looked for DeviceIoControl
in .NET Core. It was there, but it was dead code: dotnet/runtime#38861 .
WinUSB is not in .NET at all.
On the other hand, there's a bunch of P/Invoke code at https://github.com/dotnet/runtime/tree/master/src/libraries/Common/src/Interop/Windows which may serve as a reference for dotnet/pinvoke.
Oh wow. What a great resource, @qmfrederik. Thanks for sharing. I've added the link to our contributing doc.
Overlapped I/O in Win32 maps to async I/O in .NET.
There's some boilerplate code that needs to be written to make overlapped I/O functions behave as async methods in .NET. For example, here's how .NET Core does it for the FileStream.
Are these async wrappers for I/O operations in scope for dotnet/pinvoke?