From c191d0b3377d2fa84a2d4aca45dc2c3e183150f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98ystein=20Krog?= Date: Sun, 16 Feb 2014 21:11:23 +0100 Subject: [PATCH] Add new option (DependentNameSpaces) that allows for specifying custom using statements/namespaces in generated units --- src/Generator/Generators/CLI/CLISourcesTemplate.cs | 4 ++++ src/Generator/Generators/CSharp/CSharpTextTemplate.cs | 4 ++++ src/Generator/Options.cs | 1 + 3 files changed, 9 insertions(+) diff --git a/src/Generator/Generators/CLI/CLISourcesTemplate.cs b/src/Generator/Generators/CLI/CLISourcesTemplate.cs index ac983a80..5453db5c 100644 --- a/src/Generator/Generators/CLI/CLISourcesTemplate.cs +++ b/src/Generator/Generators/CLI/CLISourcesTemplate.cs @@ -42,6 +42,10 @@ namespace CppSharp.Generators.CLI PushBlock(CLIBlockKind.Usings); WriteLine("using namespace System;"); WriteLine("using namespace System::Runtime::InteropServices;"); + foreach (var customUsingStatement in Options.DependentNameSpaces) + { + WriteLine(string.Format("using namespace {0};", customUsingStatement)); ; + } NewLine(); PopBlock(); diff --git a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs index 81c766d9..ed531859 100644 --- a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs +++ b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs @@ -156,6 +156,10 @@ namespace CppSharp.Generators.CSharp WriteLine("using System;"); WriteLine("using System.Runtime.InteropServices;"); WriteLine("using System.Security;"); + foreach (var customUsingStatement in Options.DependentNameSpaces) + { + WriteLine(string.Format("using {0};", customUsingStatement));; + } PopBlock(NewLineKind.BeforeNextBlock); if (Options.GenerateLibraryNamespace) diff --git a/src/Generator/Options.cs b/src/Generator/Options.cs index 6a91d9fb..aa09a1ec 100644 --- a/src/Generator/Options.cs +++ b/src/Generator/Options.cs @@ -131,6 +131,7 @@ namespace CppSharp public bool Is32Bit { get { return true; } } public List CodeFiles { get; private set; } + public readonly List DependentNameSpaces = new List(); } public class InvalidOptionException : Exception