pinvoke
pinvoke copied to clipboard
Codegen should produce friendly string overloads
As @vbfox said:
Always generating
StringBuilderfor "out + char_" andstringfor "in + char_" seem like good defaults
Unfortunately generating StringBuilder overloads will be more complicated. It's not possible to get a pointer to its internal buffer (which may not even be contiguous!). The .NET interop marshaler does magic to make it work, which we'll have to re-implement in our 'friendly' methods.
Using string for in parameters is straightforward, but there is exactly one method so far that defines a [Friendly(FriendlyFlags.In | FriendlyFlags.Array)] char* parameter as required to get the new behavior, so we need to audit all the char* parameters that are not decorated to see if they would benefit from the friendly attribute so they get a string overload.
We should also audit all the extern methods that accept string to consider revising them to use [Friendly(FriendlyFlags.In | FriendlyFlags.Array)] char* instead.