Browse Source

Fixed a crash when generating any C# bindings on Windows.

It was a regression from the dropping of the C# option for a single generated source file.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/661/head
Dimitar Dobrev 9 years ago
parent
commit
010e35abc0
  1. 3
      src/Generator/Generator.cs
  2. 7
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs

3
src/Generator/Generator.cs

@ -118,7 +118,8 @@ namespace CppSharp.Generators @@ -118,7 +118,8 @@ namespace CppSharp.Generators
FilePath = string.Format("{0}.cs", module.LibraryName),
Module = module
},
Templates = Generate(module.Units)
Templates = Generate(module.Units.Where(
u => u.IsGenerated && u.HasDeclarations && !u.IsSystemHeader && u.IsValid))
};
output.Templates[0].Process();
outputs.Add(output);

7
src/Generator/Generators/CSharp/CSharpTextTemplate.cs

@ -198,10 +198,11 @@ namespace CppSharp.Generators.CSharp @@ -198,10 +198,11 @@ namespace CppSharp.Generators.CSharp
}
PopBlock(NewLineKind.BeforeNextBlock);
if (!string.IsNullOrEmpty(TranslationUnit.Module.OutputNamespace))
var module = TranslationUnits.Count == 0 ? Module.SystemModule : TranslationUnit.Module;
if (!string.IsNullOrEmpty(module.OutputNamespace))
{
PushBlock(CSharpBlockKind.Namespace);
WriteLine("namespace {0}", TranslationUnit.Module.OutputNamespace);
WriteLine("namespace {0}", module.OutputNamespace);
WriteStartBraceIndent();
}
@ -210,7 +211,7 @@ namespace CppSharp.Generators.CSharp @@ -210,7 +211,7 @@ namespace CppSharp.Generators.CSharp
GenerateDeclContext(unit);
}
if (!string.IsNullOrEmpty(TranslationUnit.Module.OutputNamespace))
if (!string.IsNullOrEmpty(module.OutputNamespace))
{
WriteCloseBraceIndent();
PopBlock(NewLineKind.BeforeNextBlock);

Loading…
Cancel
Save