From db1c413f87da4e16414196218b287cd9fc86594a Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Fri, 16 Aug 2013 15:52:15 +0300 Subject: [PATCH] Ensure safe property and variable names. Signed-off-by: Dimitar Dobrev --- src/Generator/Generators/CSharp/CSharpMarshal.cs | 4 ++-- src/Generator/Generators/CSharp/CSharpTextTemplate.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Generator/Generators/CSharp/CSharpMarshal.cs b/src/Generator/Generators/CSharp/CSharpMarshal.cs index 641622eb..b4a57b8d 100644 --- a/src/Generator/Generators/CSharp/CSharpMarshal.cs +++ b/src/Generator/Generators/CSharp/CSharpMarshal.cs @@ -311,9 +311,9 @@ namespace CppSharp.Generators.CSharp type.IsPrimitiveType(PrimitiveType.WideChar)) { Context.Return.Write("Marshal.StringToHGlobalAnsi({0})", - Context.Parameter.Name); + Helpers.SafeIdentifier(Context.Parameter.Name)); CSharpContext.Cleanup.WriteLine("Marshal.FreeHGlobal({0});", - Context.ArgName); + Helpers.SafeIdentifier(Context.ArgName)); return true; } diff --git a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs index b7e4d70f..298f825e 100644 --- a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs +++ b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs @@ -887,7 +887,7 @@ namespace CppSharp.Generators.CSharp if (prop.Ignore) continue; PushBlock(CSharpBlockKind.Property); - WriteLine("public {0} {1}", prop.Type, prop.Name); + WriteLine("public {0} {1}", prop.Type, SafeIdentifier(prop.Name)); WriteStartBraceIndent(); if (prop.Field != null) @@ -915,7 +915,7 @@ namespace CppSharp.Generators.CSharp private void GenerateVariable(Class @class, Type type, Variable variable) { PushBlock(CSharpBlockKind.Variable); - WriteLine("public static {0} {1}", type, variable.Name); + WriteLine("public static {0} {1}", type, SafeIdentifier(variable.Name)); WriteStartBraceIndent(); GeneratePropertyGetter(variable, @class);