From 14e53b523f6a27486dc23316982a94935e0e01cd Mon Sep 17 00:00:00 2001 From: triton Date: Thu, 18 Jun 2015 12:26:03 +0100 Subject: [PATCH] Cast when creating new object instances since CreateInstance returns the base type. --- src/Generator/Generators/CSharp/CSharpMarshal.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Generator/Generators/CSharp/CSharpMarshal.cs b/src/Generator/Generators/CSharp/CSharpMarshal.cs index a29ae23a..707f2477 100644 --- a/src/Generator/Generators/CSharp/CSharpMarshal.cs +++ b/src/Generator/Generators/CSharp/CSharpMarshal.cs @@ -325,8 +325,8 @@ namespace CppSharp.Generators.CSharp var dtor = originalClass.Destructors.FirstOrDefault(); if (dtor != null && dtor.IsVirtual) { - Context.SupportBefore.WriteLine("else {0}.NativeToManagedMap[{1}] = {2} = {3}.{4}({1});", - qualifiedClass, Context.ReturnVarName, ret, type, + Context.SupportBefore.WriteLine("else {0}.NativeToManagedMap[{1}] = {2} = ({3}) {4}.{5}({1});", + qualifiedClass, Context.ReturnVarName, ret, QualifiedIdentifier(@class), type, Helpers.CreateInstanceIdentifier, Context.ReturnVarName); } else