diff --git a/src/Generator/Generators/CLI/CLIMarshal.cs b/src/Generator/Generators/CLI/CLIMarshal.cs index f6f732a8..93de9915 100644 --- a/src/Generator/Generators/CLI/CLIMarshal.cs +++ b/src/Generator/Generators/CLI/CLIMarshal.cs @@ -211,6 +211,7 @@ namespace CppSharp.Generators.CLI return true; case PrimitiveType.Bool: case PrimitiveType.Char: + case PrimitiveType.Char16: case PrimitiveType.WideChar: case PrimitiveType.SChar: case PrimitiveType.UChar: diff --git a/src/Generator/Generators/CSharp/CSharpMarshal.cs b/src/Generator/Generators/CSharp/CSharpMarshal.cs index d6b2a3cd..bcfa0abe 100644 --- a/src/Generator/Generators/CSharp/CSharpMarshal.cs +++ b/src/Generator/Generators/CSharp/CSharpMarshal.cs @@ -244,8 +244,6 @@ namespace CppSharp.Generators.CSharp return true; } goto default; - case PrimitiveType.Char16: - return false; case PrimitiveType.Bool: if (Context.MarshalKind == MarshalKind.NativeField) { @@ -728,8 +726,6 @@ namespace CppSharp.Generators.CSharp return true; } goto default; - case PrimitiveType.Char16: - return false; case PrimitiveType.Bool: if (Context.MarshalKind == MarshalKind.NativeField) { diff --git a/tests/Common/Common.Tests.cs b/tests/Common/Common.Tests.cs index 605afd79..9a756f5b 100644 --- a/tests/Common/Common.Tests.cs +++ b/tests/Common/Common.Tests.cs @@ -826,4 +826,13 @@ This is a very long string. This is a very long string. This is a very long stri Assert.That(testProperties.RefToPrimitiveInSetter, Is.EqualTo(value)); } } + + [Test] + public void TestReturnChar16() + { + using (var foo = new Foo()) + { + Assert.That(foo.ReturnChar16(), Is.EqualTo('a')); + } + } } diff --git a/tests/Common/Common.cpp b/tests/Common/Common.cpp index 433e9e2e..51805a95 100644 --- a/tests/Common/Common.cpp +++ b/tests/Common/Common.cpp @@ -74,6 +74,11 @@ int Foo::fooPtr() return 1; } +char16_t Foo::returnChar16() +{ + return 'a'; +} + Foo2::Foo2() {} Foo2 Foo2::operator<<(signed int i) diff --git a/tests/Common/Common.h b/tests/Common/Common.h index 06d53161..01ba80c8 100644 --- a/tests/Common/Common.h +++ b/tests/Common/Common.h @@ -108,6 +108,7 @@ public: bool operator ==(const Foo& other) const; int fooPtr(); + char16_t returnChar16(); }; // HACK: do not move these to the cpp - C++/CLI is buggy and cannot link static fields initialised in the cpp