Separate namespaces for generated projects

internals
Alex Hildebrand 4 years ago
parent a5a66dd8ed
commit d2fe090cb8
  1. 27
      src/CodeGenerator/Program.cs

@ -38,9 +38,18 @@ namespace CodeGenerator
string projectNamespace = libraryName switch string projectNamespace = libraryName switch
{ {
"cimgui" => "ImGuiNET", "cimgui" => "ImGuiNET",
"cimplot" => "ImGuiNET", "cimplot" => "ImPlotNET",
"cimnodes" => "ImGuiNET", "cimnodes" => "ImNodesNET",
"cimguizmo" => "ImGuiNET", "cimguizmo" => "ImGuizmoNET",
_ => throw new NotImplementedException()
};
bool referencesImGui = libraryName switch
{
"cimgui" => false,
"cimplot" => true,
"cimnodes" => true,
"cimguizmo" => true,
_ => throw new NotImplementedException() _ => throw new NotImplementedException()
}; };
@ -99,6 +108,10 @@ namespace CodeGenerator
writer.Using("System.Numerics"); writer.Using("System.Numerics");
writer.Using("System.Runtime.CompilerServices"); writer.Using("System.Runtime.CompilerServices");
writer.Using("System.Text"); writer.Using("System.Text");
if (referencesImGui)
{
writer.Using("ImGuiNET");
}
writer.WriteLine(string.Empty); writer.WriteLine(string.Empty);
writer.PushBlock($"namespace {projectNamespace}"); writer.PushBlock($"namespace {projectNamespace}");
@ -262,6 +275,10 @@ namespace CodeGenerator
writer.Using("System"); writer.Using("System");
writer.Using("System.Numerics"); writer.Using("System.Numerics");
writer.Using("System.Runtime.InteropServices"); writer.Using("System.Runtime.InteropServices");
if (referencesImGui)
{
writer.Using("ImGuiNET");
}
writer.WriteLine(string.Empty); writer.WriteLine(string.Empty);
writer.PushBlock($"namespace {projectNamespace}"); writer.PushBlock($"namespace {projectNamespace}");
writer.PushBlock($"public static unsafe partial class {classPrefix}Native"); writer.PushBlock($"public static unsafe partial class {classPrefix}Native");
@ -331,6 +348,10 @@ namespace CodeGenerator
writer.Using("System.Numerics"); writer.Using("System.Numerics");
writer.Using("System.Runtime.InteropServices"); writer.Using("System.Runtime.InteropServices");
writer.Using("System.Text"); writer.Using("System.Text");
if (referencesImGui)
{
writer.Using("ImGuiNET");
}
writer.WriteLine(string.Empty); writer.WriteLine(string.Empty);
writer.PushBlock($"namespace {projectNamespace}"); writer.PushBlock($"namespace {projectNamespace}");
writer.PushBlock($"public static unsafe partial class {classPrefix}"); writer.PushBlock($"public static unsafe partial class {classPrefix}");

Loading…
Cancel
Save