From 205e6c80c5392cf8c2385e6b3d6e065198a9b6cc Mon Sep 17 00:00:00 2001
From: Jan Tattermusch <jtattermusch@google.com>
Date: Fri, 14 Aug 2015 09:25:06 -0700
Subject: [PATCH] dont generate directories in C# protoc plugin

---
 src/compiler/csharp_generator_helpers.h |  2 +-
 src/compiler/generator_helpers.h        | 13 ++++++++++---
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/compiler/csharp_generator_helpers.h b/src/compiler/csharp_generator_helpers.h
index 1370627633..5639ea058b 100644
--- a/src/compiler/csharp_generator_helpers.h
+++ b/src/compiler/csharp_generator_helpers.h
@@ -41,7 +41,7 @@ namespace grpc_csharp_generator {
 
 inline bool ServicesFilename(const grpc::protobuf::FileDescriptor *file,
                              grpc::string *file_name_or_error) {
-  *file_name_or_error = grpc_generator::FileNameInUpperCamel(file) + "Grpc.cs";
+  *file_name_or_error = grpc_generator::FileNameInUpperCamel(file, false) + "Grpc.cs";
   return true;
 }
 
diff --git a/src/compiler/generator_helpers.h b/src/compiler/generator_helpers.h
index 68b807b057..e1bb66a875 100644
--- a/src/compiler/generator_helpers.h
+++ b/src/compiler/generator_helpers.h
@@ -125,16 +125,23 @@ inline grpc::string LowerUnderscoreToUpperCamel(grpc::string str) {
   return result;
 }
 
-inline grpc::string FileNameInUpperCamel(const grpc::protobuf::FileDescriptor *file) {
+inline grpc::string FileNameInUpperCamel(const grpc::protobuf::FileDescriptor *file,
+                                         bool include_package_path) {
   std::vector<grpc::string> tokens = tokenize(StripProto(file->name()), "/");
   grpc::string result = "";
-  for (unsigned int i = 0; i < tokens.size() - 1; i++) {
-    result += tokens[i] + "/";
+  if (include_package_path) {
+    for (unsigned int i = 0; i < tokens.size() - 1; i++) {
+      result += tokens[i] + "/";
+    }
   }
   result += LowerUnderscoreToUpperCamel(tokens.back());
   return result;
 }
 
+inline grpc::string FileNameInUpperCamel(const grpc::protobuf::FileDescriptor *file) {
+  return FileNameInUpperCamel(file, true);
+}
+
 enum MethodType {
   METHODTYPE_NO_STREAMING,
   METHODTYPE_CLIENT_STREAMING,
-- 
GitLab