From b5897bf1a63c5801538649ede30d88f779c97008 Mon Sep 17 00:00:00 2001
From: Jan Tattermusch <jtattermusch@google.com>
Date: Thu, 7 May 2015 15:45:37 -0700
Subject: [PATCH] moved GetMethodType function to generator_helpers.h

---
 src/compiler/csharp_generator.cc | 30 +++++++-----------------------
 src/compiler/generator_helpers.h | 23 +++++++++++++++++++++++
 2 files changed, 30 insertions(+), 23 deletions(-)

diff --git a/src/compiler/csharp_generator.cc b/src/compiler/csharp_generator.cc
index b139c06014..82dd06bcec 100644
--- a/src/compiler/csharp_generator.cc
+++ b/src/compiler/csharp_generator.cc
@@ -36,6 +36,7 @@
 #include <vector>
 
 #include "src/compiler/config.h"
+#include "src/compiler/csharp_generator_helpers.h"
 #include "src/compiler/csharp_generator.h"
 
 using grpc::protobuf::FileDescriptor;
@@ -44,35 +45,18 @@ using grpc::protobuf::ServiceDescriptor;
 using grpc::protobuf::MethodDescriptor;
 using grpc::protobuf::io::Printer;
 using grpc::protobuf::io::StringOutputStream;
+using grpc_generator::MethodType;
+using grpc_generator::GetMethodType;
+using grpc_generator::METHODTYPE_NO_STREAMING;
+using grpc_generator::METHODTYPE_CLIENT_STREAMING;
+using grpc_generator::METHODTYPE_SERVER_STREAMING;
+using grpc_generator::METHODTYPE_BIDI_STREAMING;
 using std::map;
 using std::vector;
 
 namespace grpc_csharp_generator {
 namespace {
 
-enum MethodType {
-  METHODTYPE_NO_STREAMING,
-  METHODTYPE_CLIENT_STREAMING,
-  METHODTYPE_SERVER_STREAMING,
-  METHODTYPE_BIDI_STREAMING
-};
-
-MethodType GetMethodType(const MethodDescriptor *method) {
-  if (method->client_streaming()) {
-    if (method->server_streaming()) {
-      return METHODTYPE_BIDI_STREAMING;
-    } else {
-      return METHODTYPE_CLIENT_STREAMING;
-    }
-  } else {
-    if (method->server_streaming()) {
-      return METHODTYPE_SERVER_STREAMING;
-    } else {
-      return METHODTYPE_NO_STREAMING;
-    }
-  }
-}
-
 std::string GetCSharpNamespace(const FileDescriptor* file) {
   // TODO(jtattermusch): this should be based on csharp_namespace option
   return file->package();
diff --git a/src/compiler/generator_helpers.h b/src/compiler/generator_helpers.h
index 374e1374cf..7ce4ec526c 100644
--- a/src/compiler/generator_helpers.h
+++ b/src/compiler/generator_helpers.h
@@ -116,6 +116,29 @@ inline grpc::string FileNameInUpperCamel(const grpc::protobuf::FileDescriptor *f
   return LowerUnderscoreToUpperCamel(StripProto(file->name()));
 }
 
+enum MethodType {
+  METHODTYPE_NO_STREAMING,
+  METHODTYPE_CLIENT_STREAMING,
+  METHODTYPE_SERVER_STREAMING,
+  METHODTYPE_BIDI_STREAMING
+};
+
+inline MethodType GetMethodType(const grpc::protobuf::MethodDescriptor *method) {
+  if (method->client_streaming()) {
+    if (method->server_streaming()) {
+      return METHODTYPE_BIDI_STREAMING;
+    } else {
+      return METHODTYPE_CLIENT_STREAMING;
+    }
+  } else {
+    if (method->server_streaming()) {
+      return METHODTYPE_SERVER_STREAMING;
+    } else {
+      return METHODTYPE_NO_STREAMING;
+    }
+  }
+}
+
 }  // namespace grpc_generator
 
 #endif  // GRPC_INTERNAL_COMPILER_GENERATOR_HELPERS_H
-- 
GitLab