From d2fe090cb879f896ba8615381ebe7bd8d53cd064 Mon Sep 17 00:00:00 2001 From: Alex Hildebrand Date: Mon, 30 Nov 2020 22:08:54 +0100 Subject: [PATCH] Separate namespaces for generated projects --- src/CodeGenerator/Program.cs | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/CodeGenerator/Program.cs b/src/CodeGenerator/Program.cs index 3f6dad8..5ed289d 100644 --- a/src/CodeGenerator/Program.cs +++ b/src/CodeGenerator/Program.cs @@ -38,9 +38,18 @@ namespace CodeGenerator string projectNamespace = libraryName switch { "cimgui" => "ImGuiNET", - "cimplot" => "ImGuiNET", - "cimnodes" => "ImGuiNET", - "cimguizmo" => "ImGuiNET", + "cimplot" => "ImPlotNET", + "cimnodes" => "ImNodesNET", + "cimguizmo" => "ImGuizmoNET", + _ => throw new NotImplementedException() + }; + + bool referencesImGui = libraryName switch + { + "cimgui" => false, + "cimplot" => true, + "cimnodes" => true, + "cimguizmo" => true, _ => throw new NotImplementedException() }; @@ -99,6 +108,10 @@ namespace CodeGenerator writer.Using("System.Numerics"); writer.Using("System.Runtime.CompilerServices"); writer.Using("System.Text"); + if (referencesImGui) + { + writer.Using("ImGuiNET"); + } writer.WriteLine(string.Empty); writer.PushBlock($"namespace {projectNamespace}"); @@ -262,6 +275,10 @@ namespace CodeGenerator writer.Using("System"); writer.Using("System.Numerics"); writer.Using("System.Runtime.InteropServices"); + if (referencesImGui) + { + writer.Using("ImGuiNET"); + } writer.WriteLine(string.Empty); writer.PushBlock($"namespace {projectNamespace}"); writer.PushBlock($"public static unsafe partial class {classPrefix}Native"); @@ -331,6 +348,10 @@ namespace CodeGenerator writer.Using("System.Numerics"); writer.Using("System.Runtime.InteropServices"); writer.Using("System.Text"); + if (referencesImGui) + { + writer.Using("ImGuiNET"); + } writer.WriteLine(string.Empty); writer.PushBlock($"namespace {projectNamespace}"); writer.PushBlock($"public static unsafe partial class {classPrefix}");