From fbe5851237c8040c89f5e94b917ad63d4331263f Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Wed, 21 Aug 2013 17:07:27 +0300 Subject: [PATCH] Added UnmanagedFunctionPointerAttribute to generated delegates to avoid run-time crashes. Signed-off-by: Dimitar Dobrev --- src/Generator/Generators/CSharp/CSharpTextTemplate.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs index 78e927fd..11b53cf1 100644 --- a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs +++ b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs @@ -1849,15 +1849,16 @@ namespace CppSharp.Generators.CSharp TagType tag; if (typedef.Type.IsPointerToPrimitiveType(PrimitiveType.Void) - || typedef.Type.IsPointerTo(out tag)) + || typedef.Type.IsPointerTo(out tag)) { PushBlock(CSharpBlockKind.Typedef); WriteLine("public class " + SafeIdentifier(typedef.Name) + @" { }"); PopBlock(NewLineKind.BeforeNextBlock); } - else if (typedef.Type.IsPointerTo(out function)) + else if (typedef.Type.IsPointerTo(out function)) { PushBlock(CSharpBlockKind.Typedef); + WriteLine("[UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]"); WriteLine("public {0};", string.Format(TypePrinter.VisitDelegate(function).Type, SafeIdentifier(typedef.Name)));