diff --git a/src/Generator/Generators/CSharp/CSharpSources.cs b/src/Generator/Generators/CSharp/CSharpSources.cs index ad1c483a..39cedb32 100644 --- a/src/Generator/Generators/CSharp/CSharpSources.cs +++ b/src/Generator/Generators/CSharp/CSharpSources.cs @@ -149,14 +149,17 @@ namespace CppSharp.Generators.CSharp { GenerateFilePreamble(); + var module = TranslationUnits.Count == 0 ? + Context.Options.SystemModule : TranslationUnit.Module; + PushBlock(CSharpBlockKind.Usings); WriteLine("using System;"); WriteLine("using System.Runtime.InteropServices;"); WriteLine("using System.Security;"); - var internalsVisibleTo = from m in Options.Modules - where m.Dependencies.Contains(Module) - select m.LibraryName; + var internalsVisibleTo = (from m in Options.Modules + where m.Dependencies.Contains(module) + select m.LibraryName).ToList(); if (internalsVisibleTo.Any()) WriteLine("using System.Runtime.CompilerServices;"); @@ -170,17 +173,17 @@ namespace CppSharp.Generators.CSharp if (internalsVisibleTo.Any()) NewLine(); - if (!string.IsNullOrEmpty(Module.OutputNamespace)) + if (!string.IsNullOrEmpty(module.OutputNamespace)) { PushBlock(CSharpBlockKind.Namespace); - WriteLine("namespace {0}", Module.OutputNamespace); + WriteLine("namespace {0}", module.OutputNamespace); WriteStartBraceIndent(); } foreach (var unit in TranslationUnits) unit.Visit(this); - if (!string.IsNullOrEmpty(Module.OutputNamespace)) + if (!string.IsNullOrEmpty(module.OutputNamespace)) { WriteCloseBraceIndent(); PopBlock(NewLineKind.BeforeNextBlock); diff --git a/src/Generator/Generators/CodeGenerator.cs b/src/Generator/Generators/CodeGenerator.cs index abdd9461..7e238175 100644 --- a/src/Generator/Generators/CodeGenerator.cs +++ b/src/Generator/Generators/CodeGenerator.cs @@ -14,9 +14,6 @@ namespace CppSharp.Generators public TranslationUnit TranslationUnit => TranslationUnits[0]; - public Module Module => TranslationUnits.Count == 0 ? - Context.Options.SystemModule : TranslationUnit.Module; - public abstract string FileExtension { get; } protected CodeGenerator(BindingContext context, TranslationUnit unit)