diff --git a/src/Generator/Generators/CSharp/CSharpMarshal.cs b/src/Generator/Generators/CSharp/CSharpMarshal.cs index 0389076b..9618b012 100644 --- a/src/Generator/Generators/CSharp/CSharpMarshal.cs +++ b/src/Generator/Generators/CSharp/CSharpMarshal.cs @@ -148,7 +148,7 @@ namespace CppSharp.Generators.CSharp if (CSharpTypePrinter.IsConstCharString(pointer) || marshalPointeeAsString) { Context.Return.Write(MarshalStringToManaged(Context.ReturnVarName, - pointer.GetFinalPointee() as BuiltinType)); + pointer.GetFinalPointee().Desugar() as BuiltinType)); return true; } diff --git a/tests/Common/Common.Tests.cs b/tests/Common/Common.Tests.cs index 12fe26fd..4ab717be 100644 --- a/tests/Common/Common.Tests.cs +++ b/tests/Common/Common.Tests.cs @@ -94,6 +94,7 @@ public class CommonTests : GeneratorTestFixture str = "Hello"; hello.StringInOutRef(ref str); Assert.That(str, Is.EqualTo("StringInOutRef")); + hello.StringTypedef(str); } [Test] diff --git a/tests/Common/Common.cpp b/tests/Common/Common.cpp index d68e59a5..40f3c626 100644 --- a/tests/Common/Common.cpp +++ b/tests/Common/Common.cpp @@ -270,6 +270,10 @@ void Hello::StringInOutRef(CS_IN_OUT const char*& str) str = "Failed"; } +void Hello::StringTypedef(const TypedefChar* str) +{ +} + int unsafeFunction(const Bar& ret, char* testForString, void (*foo)(int)) { return ret.A; diff --git a/tests/Common/Common.h b/tests/Common/Common.h index e5943604..9452a922 100644 --- a/tests/Common/Common.h +++ b/tests/Common/Common.h @@ -142,6 +142,8 @@ enum Enum F = -9 }; +typedef char TypedefChar; + class DLL_API Hello { union NestedPrivate { @@ -193,6 +195,8 @@ public: void StringOutRef(CS_OUT const char*& str); void StringInOut(CS_IN_OUT const char** str); void StringInOutRef(CS_IN_OUT const char*& str); + + void StringTypedef(const TypedefChar* str); }; class DLL_API AbstractFoo @@ -1048,3 +1052,4 @@ class DLL_API DerivedFromTemplateInstantiationWithVirtual : public TemplateWithV public: DerivedFromTemplateInstantiationWithVirtual(); }; +