pinvoke icon indicating copy to clipboard operation
pinvoke copied to clipboard

Codegen should produce friendly string overloads

Open AArnott opened this issue 9 years ago • 2 comments

As @vbfox said:

Always generating StringBuilder for "out + char_" and string for "in + char_" seem like good defaults

AArnott avatar Sep 12 '16 05:09 AArnott

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.

AArnott avatar Dec 24 '19 16:12 AArnott

We should also audit all the extern methods that accept string to consider revising them to use [Friendly(FriendlyFlags.In | FriendlyFlags.Array)] char* instead.

AArnott avatar Oct 27 '20 14:10 AArnott