Skip to content
Snippets Groups Projects
Commit e6af5d10 authored by Jan Tattermusch's avatar Jan Tattermusch
Browse files

add service descriptor property to generated code

parent 9ee27e10
No related branches found
No related tags found
No related merge requests found
......@@ -44,6 +44,7 @@
using google::protobuf::compiler::csharp::GetFileNamespace;
using google::protobuf::compiler::csharp::GetClassName;
using google::protobuf::compiler::csharp::GetUmbrellaClassName;
using google::protobuf::SimpleItoa;
using grpc::protobuf::FileDescriptor;
using grpc::protobuf::Descriptor;
using grpc::protobuf::ServiceDescriptor;
......@@ -226,6 +227,16 @@ void GenerateStaticMethodField(Printer* out, const MethodDescriptor *method) {
out->Outdent();
}
void GenerateServiceDescriptorProperty(Printer* out, const ServiceDescriptor *service) {
out->Print("// service descriptor\n");
out->Print("public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor\n");
out->Print("{\n");
out->Print(" get { return $umbrella$.Descriptor.Services[$index$]; }\n",
"umbrella", GetUmbrellaClassName(service->file()), "index", SimpleItoa(service->index()));
out->Print("}\n");
out->Print("\n");
}
void GenerateClientInterface(Printer* out, const ServiceDescriptor *service) {
out->Print("// client interface\n");
out->Print("public interface $name$\n", "name",
......@@ -472,6 +483,7 @@ void GenerateService(Printer* out, const ServiceDescriptor *service) {
for (int i = 0; i < service->method_count(); i++) {
GenerateStaticMethodField(out, service->method(i));
}
GenerateServiceDescriptorProperty(out, service);
GenerateClientInterface(out, service);
GenerateServerInterface(out, service);
GenerateClientStub(out, service);
......
......@@ -39,6 +39,7 @@
using namespace std;
#include <google/protobuf/compiler/csharp/csharp_names.h>
#include <google/protobuf/stubs/strutil.h>
namespace grpc_csharp_generator {
......
......@@ -48,7 +48,7 @@ namespace Math {
// service descriptor
public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor
{
get { return global::Math.Proto.Math.Descriptor.Services[0]; }
get { return global::Math.Proto.Math.Descriptor.Services[0]; }
}
// client interface
......
......@@ -22,6 +22,12 @@ namespace Grpc.Health.V1Alpha {
__Marshaller_HealthCheckRequest,
__Marshaller_HealthCheckResponse);
// service descriptor
public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor
{
get { return global::Grpc.Health.V1Alpha.Proto.Health.Descriptor.Services[0]; }
}
// client interface
public interface IHealthClient
{
......
......@@ -62,6 +62,12 @@ namespace Grpc.Testing {
__Marshaller_StreamingOutputCallRequest,
__Marshaller_StreamingOutputCallResponse);
// service descriptor
public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor
{
get { return global::Grpc.Testing.Test.Descriptor.Services[0]; }
}
// client interface
public interface ITestServiceClient
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment