From 39d5828b642b846fb582b489de4b2d69143a964d Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Mon, 29 Apr 2019 01:33:40 +0300 Subject: [PATCH] Fix a regression with headers named after keywords Fixes https://github.com/mono/CppSharp/issues/1212. Signed-off-by: Dimitar Dobrev --- src/Generator/Generators/CSharp/CSharpSources.cs | 7 +++---- tests/Common/interface.h | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 tests/Common/interface.h diff --git a/src/Generator/Generators/CSharp/CSharpSources.cs b/src/Generator/Generators/CSharp/CSharpSources.cs index 137a2fb6cd..8d7906857c 100644 --- a/src/Generator/Generators/CSharp/CSharpSources.cs +++ b/src/Generator/Generators/CSharp/CSharpSources.cs @@ -244,7 +244,7 @@ public virtual void GenerateNamespaceFunctionsAndVariables(DeclarationContext co return; PushBlock(BlockKind.Functions); - var parentName = context.TranslationUnit.FileNameWithoutExtension; + var parentName = SafeIdentifier(context.TranslationUnit.FileNameWithoutExtension); var keyword = "class"; var classes = EnumerateClasses().ToList(); @@ -740,10 +740,9 @@ public override void GenerateClassSpecifier(Class @class) } } - if (@class.IsGenerated && isBindingGen) + if (@class.IsGenerated && isBindingGen && @class.IsRefType && !@class.IsOpaque) { - if (@class.IsRefType && !@class.IsOpaque) - bases.Add("IDisposable"); + bases.Add("IDisposable"); } if (bases.Count > 0 && !@class.IsStatic) diff --git a/tests/Common/interface.h b/tests/Common/interface.h new file mode 100644 index 0000000000..523da3d344 --- /dev/null +++ b/tests/Common/interface.h @@ -0,0 +1 @@ +void Func();