From 311bd6656853c7998b006f5207d0c1e4fbc57840 Mon Sep 17 00:00:00 2001 From: Dan Shechter Date: Tue, 30 Jul 2019 13:05:21 +0300 Subject: [PATCH] Add csharp code-gen time property that allows squashing of namespace folder generation --- csharp/sbe-dll/sbe-dll.csproj | 2 +- sbe-tool/src/main/java/uk/co/real_logic/sbe/SbeTool.java | 8 ++++++++ .../generation/csharp/CSharpNamespaceOutputManager.java | 9 ++++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/csharp/sbe-dll/sbe-dll.csproj b/csharp/sbe-dll/sbe-dll.csproj index 0adb2d09d6..c695a2b072 100644 --- a/csharp/sbe-dll/sbe-dll.csproj +++ b/csharp/sbe-dll/sbe-dll.csproj @@ -13,7 +13,7 @@ https://github.com/real-logic/simple-binary-encoding SBE;Marshaling;Low;Latency;Simple;Binary;Encoding sbe-dll - 0.1.12.1-beta-2 + 0.1.12.1-beta-3 Simple Binary Encoding for .NET This package contains all you need to define SBE messages and generate C# encoders and decoders. See https://github.com/real-logic/simple-binary-encoding for more detailed instructions git diff --git a/sbe-tool/src/main/java/uk/co/real_logic/sbe/SbeTool.java b/sbe-tool/src/main/java/uk/co/real_logic/sbe/SbeTool.java index 6a24abadc3..d2c9ef79f6 100644 --- a/sbe-tool/src/main/java/uk/co/real_logic/sbe/SbeTool.java +++ b/sbe-tool/src/main/java/uk/co/real_logic/sbe/SbeTool.java @@ -66,6 +66,8 @@ *
  • * sbe.java.generate.group-order.annotation: Should the GroupOrder annotation be added to generated stubs. *
  • + *
  • sbe.csharp.generate.namespace.dir: Should a directory be created for the namespace under + * the output directory? Defaults to true
  • *
  • sbe.keyword.append.token: Token to be appended to keywords.
  • *
  • sbe.decode.unknown.enum.values: Support unknown decoded enum values.
  • *
  • sbe.xinclude.aware: Is XInclude supported for the schema. Defaults to false.
  • @@ -163,6 +165,12 @@ public class SbeTool */ public static final String JAVA_GROUP_ORDER_ANNOTATION = "sbe.java.generate.group-order.annotation"; + /** + * Boolean system property to turn on or off generation of namespace directories during csharp code generation. + * Defaults to true + */ + public static final String CSHARP_GENERATE_NAMESPACE_DIR = "sbe.csharp.generate.namespace.dir"; + /** * Specifies token that should be appended to keywords to avoid compilation errors. *

    diff --git a/sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/csharp/CSharpNamespaceOutputManager.java b/sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/csharp/CSharpNamespaceOutputManager.java index 32514eebde..8892f669fa 100644 --- a/sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/csharp/CSharpNamespaceOutputManager.java +++ b/sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/csharp/CSharpNamespaceOutputManager.java @@ -24,6 +24,7 @@ import java.nio.file.Files; import static java.io.File.separatorChar; +import static uk.co.real_logic.sbe.SbeTool.CSHARP_GENERATE_NAMESPACE_DIR; /** * {@link OutputManager} for managing the creation of C# source files @@ -48,7 +49,13 @@ public CSharpNamespaceOutputManager(final String baseDirName, final String packa Verify.notNull(packageName, "packageName"); final String dirName = baseDirName.endsWith("" + separatorChar) ? baseDirName : baseDirName + separatorChar; - final String packageDirName = dirName + packageName.replace('.', '_'); + + final String packageComponment = + Boolean.parseBoolean(System.getProperty(CSHARP_GENERATE_NAMESPACE_DIR, "true")) ? + packageName.replace('.', '_') : + ""; + + final String packageDirName = dirName + packageComponment; outputDir = new File(packageDirName); if (!outputDir.exists() && !outputDir.mkdirs())