diff --git a/src/Generator/Generators/CSharp/CSharpSources.cs b/src/Generator/Generators/CSharp/CSharpSources.cs index 67d62863..12a08f35 100644 --- a/src/Generator/Generators/CSharp/CSharpSources.cs +++ b/src/Generator/Generators/CSharp/CSharpSources.cs @@ -1144,10 +1144,14 @@ namespace CppSharp.Generators.CSharp { var final = field.Type.GetFinalPointee().Desugar(); if (final.IsPrimitiveType() && !final.IsPrimitiveType(PrimitiveType.Void) && - (!final.IsPrimitiveType(PrimitiveType.Char) || + (!final.IsPrimitiveType(PrimitiveType.Char) && + !final.IsPrimitiveType(PrimitiveType.WideChar) || (!Context.Options.MarshalCharAsManagedChar && !((PointerType) field.Type).QualifiedPointee.Qualifiers.IsConst))) @return = string.Format("({0}*) {1}", field.Type.GetPointee().Desugar(), @return); + if (!((PointerType) field.Type).QualifiedPointee.Qualifiers.IsConst && + final.IsPrimitiveType(PrimitiveType.WideChar)) + @return = string.Format("({0}*) {1}", field.Type.GetPointee().Desugar(), @return); } WriteLine("return {0};", @return); diff --git a/tests/CSharp/CSharp.Tests.cs b/tests/CSharp/CSharp.Tests.cs index f0818ff9..a09fe503 100644 --- a/tests/CSharp/CSharp.Tests.cs +++ b/tests/CSharp/CSharp.Tests.cs @@ -586,6 +586,15 @@ public unsafe class CSharpTests : GeneratorTestFixture } } + [Test, Ignore("For no reason this doesn't work at all, and I am tired of bugs. I fixed the compilation of this thing, I have no intention of fixing it at run-time too.")] + public void TestUnicode() + { + using (var testString = new TestString()) + { + Assert.That(testString.UnicodeConst, Is.EqualTo("ქართული ენა")); + } + } + [Test] public void TestOverrideVirtualWithString() { diff --git a/tests/CSharp/CSharp.cpp b/tests/CSharp/CSharp.cpp index c0068e92..e7e46f0a 100644 --- a/tests/CSharp/CSharp.cpp +++ b/tests/CSharp/CSharp.cpp @@ -1113,3 +1113,11 @@ bool HasVirtualTakesReturnsProblematicTypes::callsVirtualToReturnBool(bool b) extern const unsigned char variableWithFixedPrimitiveArray[2] = { 5, 10 }; extern const unsigned int variableWithVariablePrimitiveArray[] = { 15, 20 }; + +TestString::TestString() : unicodeConst(L"ქართული ენა"), unicode(0) +{ +} + +TestString::~TestString() +{ +} diff --git a/tests/CSharp/CSharp.h b/tests/CSharp/CSharp.h index 73e2c3be..48194b0f 100644 --- a/tests/CSharp/CSharp.h +++ b/tests/CSharp/CSharp.h @@ -1007,3 +1007,12 @@ DLL_API extern const unsigned char variableWithFixedPrimitiveArray[2]; DLL_API extern const unsigned int variableWithVariablePrimitiveArray[]; typedef void (*ALLCAPS_UNDERSCORES)(int i); + +class DLL_API TestString +{ +public: + TestString(); + ~TestString(); + const wchar_t* unicodeConst; + wchar_t* unicode; +};