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

Add CreateFile overload that doesn't require a string object #535

Closed AArnott closed 3 years ago

qmfrederik commented 3 years ago

nit: would it be possible to have System.ReadOnlySpan<byte>, too?

AArnott commented 3 years ago

@qmfrederik said:

would it be possible to have System.ReadOnlySpan, too?

We could, but it wouldn't convey that it should be UTF-16 encoded. But given a ReadOnlySpan<byte>, you can readily cast to ReadOnlySpan<char> (i.e. without copying data) using this:

ReadOnlySpan<byte> bytes; // initialized elsewhere, assumed to be UTF-16 encoded chars
ReadOnlySpan<char> chars = MemoryMarshal.Cast<byte, char>(bytes);
qmfrederik commented 3 years ago

Fair enough, thanks!

qmfrederik commented 3 years ago

@AArnott Thanks. Is CI still configured for this repo? Looks like the last CI run dates from early October?

AArnott commented 3 years ago

@qmfrederik Oh, snap. Ya Azure Pipelines triggers broke for GitHub triggers all over the place. I finally found a workaround but hadn't applied it to this one. I've fixed it and queued another CI build.