pinvoke
pinvoke copied to clipboard
Ensure `ReadOnlySpan<char>` where null-terminated element is required is done right
#535 introduces a ReadOnlySpan<char> overload for CreateFile. The use of span suggests to the caller that length is taken into account, but it is not. Instead, CreateFile is only going to get the pointer and will read till it encounters a UTF-16 null character.
To help avoid calls that are missing a null character from badly misbehaving, should we:
- rely on documentation on the parameter?
- enhance the code generated overload with
ReadOnlySpan<char>to check and throw if the last element in the span is not a null character?