aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsmithx <smithx@pm.me>2019-05-17 18:57:52 +0300
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2019-07-22 19:11:21 +0100
commit8f6d97ab8c97295fc74fac05f45f27c91884690a (patch)
tree38224fb4343939d3d457fb4e754fb202b582b264
parenta9a7b03ba6557a6f9c8c8b284d907d6a7017e989 (diff)
downloadswig-8f6d97ab8c97295fc74fac05f45f27c91884690a.tar.gz
fix undesirable `wstring` encoding at return value marshalling for C#
-rw-r--r--Lib/csharp/std_wstring.i5
-rw-r--r--Lib/csharp/wchar.i1
2 files changed, 5 insertions, 1 deletions
diff --git a/Lib/csharp/std_wstring.i b/Lib/csharp/std_wstring.i
index 09bdaaaa2..b18a2cca4 100644
--- a/Lib/csharp/std_wstring.i
+++ b/Lib/csharp/std_wstring.i
@@ -23,7 +23,10 @@ class wstring;
// wstring
%typemap(ctype, out="void *") wstring "wchar_t *"
-%typemap(imtype, inattributes="[global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]") wstring "string"
+%typemap(imtype,
+ inattributes="[global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]",
+ outattributes="[return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]"
+ ) wstring "string"
%typemap(cstype) wstring "string"
%typemap(csdirectorin) wstring "$iminput"
%typemap(csdirectorout) wstring "$cscall"
diff --git a/Lib/csharp/wchar.i b/Lib/csharp/wchar.i
index 9361edf6f..79fb5a8cf 100644
--- a/Lib/csharp/wchar.i
+++ b/Lib/csharp/wchar.i
@@ -20,6 +20,7 @@ static SWIG_CSharpWStringHelperCallback SWIG_csharp_wstring_callback = NULL;
%pragma(csharp) imclasscode=%{
protected class SWIGWStringHelper {
+ [return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]
public delegate string SWIGWStringDelegate(global::System.IntPtr message);
static SWIGWStringDelegate wstringDelegate = new SWIGWStringDelegate(CreateWString);