diff --git a/tests/dotnet/CLI/CLI.Gen.cs b/tests/dotnet/CLI/CLI.Gen.cs index de4b7ee33..5a5d25c7a 100644 --- a/tests/dotnet/CLI/CLI.Gen.cs +++ b/tests/dotnet/CLI/CLI.Gen.cs @@ -1,7 +1,6 @@ using CppSharp.AST; using CppSharp.Generators; using CppSharp.Generators.C; -using CppSharp.Passes; using CppSharp.Types; using CppSharp.Utils; @@ -21,32 +20,49 @@ public override void MarshalToManaged(MarshalContext ctx, GeneratorKind kind) } } - [TypeMap("TestMappedTypeNonConstRefParam", GeneratorKindID = GeneratorKind.CLI_ID)] - public class TestMappedTypeNonConstRefParamTypeMap : TypeMap + namespace CLI { - public override Type SignatureType(TypePrinterContext ctx, GeneratorKind kind) - { - return new CILType(typeof(string)); - } - - public override void MarshalToManaged(MarshalContext ctx, GeneratorKind kind) + [TypeMap("TestMappedTypeNonConstRefParam", GeneratorKindID = GeneratorKind.CLI_ID)] + public class TestMappedTypeNonConstRefParamTypeMap : TypeMap { - ctx.Return.Write("clix::marshalString({0}.m_str)", ctx.ReturnVarName); - } + public override Type SignatureType(TypePrinterContext ctx, GeneratorKind kind) + { + return new CILType(typeof(string)); + } - public override void MarshalToNative(MarshalContext ctx, GeneratorKind kind) - { - if (ctx.Parameter.Usage == ParameterUsage.InOut) + public override void MarshalToManaged(MarshalContext ctx, GeneratorKind kind) { - ctx.Before.WriteLine($"System::String^ _{ctx.Parameter.Name} = {ctx.Parameter.Name};"); + ctx.Return.Write("clix::marshalString({0}.m_str)", ctx.ReturnVarName); } - string paramName = ctx.Parameter.Usage == ParameterUsage.InOut ? $"_{ctx.Parameter.Name}" : ctx.Parameter.Name; + public override void MarshalToNative(MarshalContext ctx, GeneratorKind kind) + { + if (ctx.Parameter.Usage == ParameterUsage.InOut) + { + ctx.Before.WriteLine($"System::String^ _{ctx.Parameter.Name} = {ctx.Parameter.Name};"); + } - ctx.Before.WriteLine( - $"::TestMappedTypeNonConstRefParam _{ctx.ArgName} = clix::marshalString({paramName});"); + string paramName = ctx.Parameter.Usage == ParameterUsage.InOut ? $"_{ctx.Parameter.Name}" : ctx.Parameter.Name; - ctx.Return.Write("_{0}", ctx.ArgName); + ctx.Before.WriteLine( + $"::TestMappedTypeNonConstRefParam _{ctx.ArgName} = clix::marshalString({paramName});"); + + ctx.Return.Write("_{0}", ctx.ArgName); + } + } + } + + namespace Cpp + { + [TypeMap("TestMappedTypeNonConstRefParam", GeneratorKindID = GeneratorKind.CPlusPlus_ID)] + public class TestMappedTypeNonConstRefParamTypeMap : TypeMap + { + public override Type SignatureType(TypePrinterContext ctx, GeneratorKind kind) + { + var tagType = ctx.Type as TagType; + var typePrinter = new CppTypePrinter(Context); + return new CustomType(tagType.Declaration.Visit(typePrinter)); + } } }