Browse Source

Fixed the generated C# when a header and a contained name-space bear the same name.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/719/head 0.7.6
Dimitar Dobrev 9 years ago
parent
commit
1b41897172
  1. 6
      src/Generator/Generators/CSharp/CSharpSources.cs
  2. 4
      src/Generator/Generators/Template.cs
  3. 5
      tests/Common/AnotherUnit.h

6
src/Generator/Generators/CSharp/CSharpSources.cs

@ -248,8 +248,10 @@ namespace CppSharp.Generators.CSharp @@ -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);

4
src/Generator/Generators/Template.cs

@ -306,8 +306,8 @@ namespace CppSharp.Generators @@ -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);
}

5
tests/Common/AnotherUnit.h

@ -13,3 +13,8 @@ namespace DelegateNamespace @@ -13,3 +13,8 @@ namespace DelegateNamespace
void DLL_API f4(void (*)());
}
namespace AnotherUnit
{
void DLL_API f();
}

Loading…
Cancel
Save