Browse Source

Fix test compiler error

Don't skip function bodies to force template instantiations
pull/1919/head
duckdoom5 8 months ago
parent
commit
16fa166716
  1. 15
      tests/dotnet/CSharp/CSharp.Gen.cs

15
tests/dotnet/CSharp/CSharp.Gen.cs

@ -25,6 +25,7 @@ namespace CppSharp.Tests
base.Setup(driver); base.Setup(driver);
driver.ParserOptions.UnityBuild = true; driver.ParserOptions.UnityBuild = true;
driver.ParserOptions.SkipFunctionBodies = false;
driver.ParserOptions.AddSupportedFunctionTemplates("FunctionTemplate"); driver.ParserOptions.AddSupportedFunctionTemplates("FunctionTemplate");
driver.Options.GenerateFreeStandingFunctionsClassName = t => t.FileNameWithoutExtension + "Cool"; driver.Options.GenerateFreeStandingFunctionsClassName = t => t.FileNameWithoutExtension + "Cool";
@ -42,7 +43,7 @@ namespace CppSharp.Tests
driver.Options.GenerateClassTemplates = true; driver.Options.GenerateClassTemplates = true;
var disableNativeToManaged = new ClassGenerationOptions { GenerateNativeToManaged = false }; var disableNativeToManaged = new ClassGenerationOptions { GenerateNativeToManaged = false };
driver.Options.GetClassGenerationOptions = e => driver.Options.GetClassGenerationOptions = e =>
{ {
return e.Name == "ClassWithoutNativeToManaged" ? disableNativeToManaged : null; return e.Name == "ClassWithoutNativeToManaged" ? disableNativeToManaged : null;
}; };
@ -237,16 +238,12 @@ namespace CppSharp.Tests
var specialization = type.GetClassTemplateSpecialization(); var specialization = type.GetClassTemplateSpecialization();
var typePrinter = new CSharpTypePrinter(null); var typePrinter = new CSharpTypePrinter(null);
typePrinter.PushContext(TypePrinterContextKind.Native); typePrinter.PushContext(TypePrinterContextKind.Native);
return new CustomType(string.Format($@"{ return new CustomType(string.Format($@"{specialization.Visit(typePrinter)}{(Type.IsAddress() ? "*" : string.Empty)}", specialization.Visit(typePrinter),
specialization.Visit(typePrinter)}{
(Type.IsAddress() ? "*" : string.Empty)}", specialization.Visit(typePrinter),
Type.IsAddress() ? "*" : string.Empty)); Type.IsAddress() ? "*" : string.Empty));
} }
return new CustomType( return new CustomType(
$@"global::System.Collections.Generic.{ $@"global::System.Collections.Generic.{(ctx.MarshalKind == MarshalKind.DefaultExpression ? "List" : "IList")}<{ctx.GetTemplateParameterList()}>");
(ctx.MarshalKind == MarshalKind.DefaultExpression ? "List" : "IList")}<{
ctx.GetTemplateParameterList()}>");
} }
public override void MarshalToNative(MarshalContext ctx) public override void MarshalToNative(MarshalContext ctx)
@ -292,9 +289,7 @@ namespace CppSharp.Tests
{ {
if (ctx.Kind == TypePrinterContextKind.Native) if (ctx.Kind == TypePrinterContextKind.Native)
{ {
return new CustomType($@"global::CSharp.QString.{ return new CustomType($@"global::CSharp.QString.{Helpers.InternalStruct}{(ctx.Type.IsAddress() ? "*" : string.Empty)}");
Helpers.InternalStruct}{
(ctx.Type.IsAddress() ? "*" : string.Empty)}");
} }
return new CILType(typeof(string)); return new CILType(typeof(string));
} }

Loading…
Cancel
Save