You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
We've no plans to update our built-in marshallers to support this. It is however something we will be taking into account with out DllImport source generator – see #43060.
Issue moved from dotnet/sdk#12809
From @johndaintree on Thursday, August 6, 2020 2:28:49 PM
I have a similar issue to the (now close, but not fixed) one made here:
#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.
The text was updated successfully, but these errors were encountered: