From 40bfd6513540aa1e7b1986652d922c9a506ae6e5 Mon Sep 17 00:00:00 2001 From: Joao Matos Date: Wed, 15 Feb 2017 00:59:38 +0000 Subject: [PATCH] Revert "Extract current module as read-only property to CodeGenerator.Module." This reverts commit d340de3afae5d91c546f4994ceab40c5c7fe3d98. --- src/Generator/Generators/CSharp/CSharpSources.cs | 15 +++++++++------ src/Generator/Generators/CodeGenerator.cs | 3 --- 2 files changed, 9 insertions(+), 9 deletions(-) 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)