dotnet / pinvoke

A library containing all P/Invoke code so you don't have to import it every time. Maintained and updated to support the latest Windows OS.
MIT License
2.12k stars 222 forks source link

Change CreatePipe to use SafeFileHandle instead of SafeObjectHandle #429

Closed ZoeyR closed 1 year ago

ZoeyR commented 5 years ago

The CreatePipe method should output SafeFileHandles intead of SafeObjectHandles. By outputting SafeFileHandle directly it makes it easier to wrap these up in FileReader and FileWriter classes.

qmfrederik commented 4 years ago

There's a lot of Kernel32 which interop with files. Basically every first argument to a Kernel32 method which is named hFile or hDevice should be a SafeFileHandle instead.

It makes a lot of sense to change them all. @AArnott thoughts?

blakegordon commented 3 years ago

I had similar thoughts to the OP's, only CreateFile was the API I cared about. Help me understand the thinking in returning SafeObjectHandle? None of the .NET FileStream constructors know what to do with that, but maybe you had a different .NET API in mind to interact with SafeObjectHandles?

AArnott commented 3 years ago

Probably not enough care in choosing it. I could see us unifying this.