diff --git a/src/Generator/Generators/CSharp/CSharpSources.cs b/src/Generator/Generators/CSharp/CSharpSources.cs index 40303e10..7a4cf7fb 100644 --- a/src/Generator/Generators/CSharp/CSharpSources.cs +++ b/src/Generator/Generators/CSharp/CSharpSources.cs @@ -248,8 +248,10 @@ namespace CppSharp.Generators.CSharp GenerateClassTemplateSpecializationInternal(@class); } - if (context.HasFunctions || (!(context is Class) && context.Variables.Any( - v => v.IsGenerated && v.Access == AccessSpecifier.Public))) + if (context.Functions.Any(f => f.IsGenerated) || + (!(context is Class) && + context.Variables.Any( + v => v.IsGenerated && v.Access == AccessSpecifier.Public))) { PushBlock(CSharpBlockKind.Functions); var parentName = Helpers.SafeIdentifier(context.TranslationUnit.FileNameWithoutExtension); diff --git a/src/Generator/Generators/Template.cs b/src/Generator/Generators/Template.cs index 90c097bb..d771855e 100644 --- a/src/Generator/Generators/Template.cs +++ b/src/Generator/Generators/Template.cs @@ -306,8 +306,8 @@ namespace CppSharp.Generators public string Generate() { - //if (Options.IsCSharpGenerator && Options.CompileCode) - // return RootBlock.GenerateUnformatted(Options).ToString(); + if (Options.IsCSharpGenerator && Options.CompileCode) + return RootBlock.GenerateUnformatted(Options).ToString(); return RootBlock.Generate(Options); } diff --git a/tests/Common/AnotherUnit.h b/tests/Common/AnotherUnit.h index 5b5da5ad..1914985f 100644 --- a/tests/Common/AnotherUnit.h +++ b/tests/Common/AnotherUnit.h @@ -13,3 +13,8 @@ namespace DelegateNamespace void DLL_API f4(void (*)()); } + +namespace AnotherUnit +{ + void DLL_API f(); +}