Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No support to marshal Strings in structures to and from wchar_t. #12809

Closed
johndaintree opened this issue Aug 6, 2020 · 2 comments
Closed

No support to marshal Strings in structures to and from wchar_t. #12809

johndaintree opened this issue Aug 6, 2020 · 2 comments

Comments

@johndaintree
Copy link

I have a similar issue to the (now close, but not fixed) one made here:

dotnet/runtime#8271 (comment)

In that I have a lot of unmanaged code that uses structures that contain pointers to arrays of wchar_t. I'd like to be able to marshal these structures in an out of managed code as Strings.

However, there is no UnmanagedType field that will do this. There is UnmanagedTtype.LPWStr, which will work for Windows (2 byte wchar_t), but no equivalent for the Unixes (which have a 4 byte wchar_t). The only portable option is to use UnmanagedType.LPUTF8Str but then I'll have to change all my unmanaged code (in multiple places) to cope.

Custom marshalling also doesn't work on fields in structures- otherwise I'd use that. I guess I could refactor all the code into functions with a parameter per field in the structure - I believe that custom marshalling will work there. But it seems like a lot hoops to jump though where ( I reckon) the built in marshaller could do it.

@johndaintree
Copy link
Author

It would also be great of System.Runtime.InteropServices.Charset could be similarly extended for use with P/Invoke.

@sfoslund
Copy link
Member

This issue was moved to dotnet/runtime#40718

@sfoslund sfoslund removed the untriaged Request triage from a team member label Aug 12, 2020
@sfoslund sfoslund removed their assignment Aug 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants