diff --git a/src/compiler/csharp_generator.cc b/src/compiler/csharp_generator.cc
index 59ddbd82f61..c1eaf971483 100644
--- a/src/compiler/csharp_generator.cc
+++ b/src/compiler/csharp_generator.cc
@@ -645,6 +645,36 @@ void GenerateBindServiceWithBinderMethod(Printer* out,
out->Print("\n");
}
+void GenerateBindServiceWithBinderMethodWithoutImplementation(
+ Printer* out, const ServiceDescriptor* service) {
+ out->Print(
+ "/// Register service method with a service "
+ "binder without implementation. Useful when customizing the service "
+ "binding logic.\n"
+ "/// Note: this method is part of an experimental API that can change or "
+ "be "
+ "removed without any prior notice.\n");
+ out->Print(
+ "/// Service methods will be bound by "
+ "calling AddMethod on this object."
+ "\n");
+ out->Print(
+ "public static void BindService(grpc::ServiceBinderBase "
+ "serviceBinder)\n");
+ out->Print("{\n");
+ out->Indent();
+
+ for (int i = 0; i < service->method_count(); i++) {
+ const MethodDescriptor* method = service->method(i);
+ out->Print("serviceBinder.AddMethod($methodfield$);\n", "methodfield",
+ GetMethodFieldName(method));
+ }
+
+ out->Outdent();
+ out->Print("}\n");
+ out->Print("\n");
+}
+
void GenerateService(Printer* out, const ServiceDescriptor* service,
bool generate_client, bool generate_server,
bool internal_access) {
@@ -674,6 +704,7 @@ void GenerateService(Printer* out, const ServiceDescriptor* service,
if (generate_server) {
GenerateBindServiceMethod(out, service);
GenerateBindServiceWithBinderMethod(out, service);
+ GenerateBindServiceWithBinderMethodWithoutImplementation(out, service);
}
out->Outdent();
diff --git a/src/csharp/Grpc.Core/ServiceBinderBase.cs b/src/csharp/Grpc.Core/ServiceBinderBase.cs
index d4909f4a269..79267d8f3d1 100644
--- a/src/csharp/Grpc.Core/ServiceBinderBase.cs
+++ b/src/csharp/Grpc.Core/ServiceBinderBase.cs
@@ -97,5 +97,19 @@ namespace Grpc.Core
{
throw new NotImplementedException();
}
+
+ ///
+ /// Adds a method without a handler.
+ ///
+ /// The request message class.
+ /// The response message class.
+ /// The method.
+ public virtual void AddMethod(
+ Method method)
+ where TRequest : class
+ where TResponse : class
+ {
+ throw new NotImplementedException();
+ }
}
}
diff --git a/src/csharp/Grpc.Examples/MathGrpc.cs b/src/csharp/Grpc.Examples/MathGrpc.cs
index e5be387e67e..717f3fab5ea 100644
--- a/src/csharp/Grpc.Examples/MathGrpc.cs
+++ b/src/csharp/Grpc.Examples/MathGrpc.cs
@@ -4,13 +4,13 @@
//
// Original file comments:
// Copyright 2015 gRPC authors.
-//
+//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
-//
+//
// http://www.apache.org/licenses/LICENSE-2.0
-//
+//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -299,6 +299,17 @@ namespace Math {
serviceBinder.AddMethod(__Method_Sum, serviceImpl.Sum);
}
+ /// Register service method with a service binder without implementation. Useful when customizing the service binding logic.
+ /// Note: this method is part of an experimental API that can change or be removed without any prior notice.
+ /// Service methods will be bound by calling AddMethod on this object.
+ public static void BindService(grpc::ServiceBinderBase serviceBinder)
+ {
+ serviceBinder.AddMethod(__Method_Div);
+ serviceBinder.AddMethod(__Method_DivMany);
+ serviceBinder.AddMethod(__Method_Fib);
+ serviceBinder.AddMethod(__Method_Sum);
+ }
+
}
}
#endregion
diff --git a/src/csharp/Grpc.HealthCheck/HealthGrpc.cs b/src/csharp/Grpc.HealthCheck/HealthGrpc.cs
index 51956f2f234..f7002328acd 100644
--- a/src/csharp/Grpc.HealthCheck/HealthGrpc.cs
+++ b/src/csharp/Grpc.HealthCheck/HealthGrpc.cs
@@ -4,13 +4,13 @@
//
// Original file comments:
// Copyright 2015 The gRPC Authors
-//
+//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
-//
+//
// http://www.apache.org/licenses/LICENSE-2.0
-//
+//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -243,6 +243,15 @@ namespace Grpc.Health.V1 {
serviceBinder.AddMethod(__Method_Watch, serviceImpl.Watch);
}
+ /// Register service method with a service binder without implementation. Useful when customizing the service binding logic.
+ /// Note: this method is part of an experimental API that can change or be removed without any prior notice.
+ /// Service methods will be bound by calling AddMethod on this object.
+ public static void BindService(grpc::ServiceBinderBase serviceBinder)
+ {
+ serviceBinder.AddMethod(__Method_Check);
+ serviceBinder.AddMethod(__Method_Watch);
+ }
+
}
}
#endregion
diff --git a/src/csharp/Grpc.IntegrationTesting/BenchmarkServiceGrpc.cs b/src/csharp/Grpc.IntegrationTesting/BenchmarkServiceGrpc.cs
index 3431b5fa181..39a48f2bb38 100644
--- a/src/csharp/Grpc.IntegrationTesting/BenchmarkServiceGrpc.cs
+++ b/src/csharp/Grpc.IntegrationTesting/BenchmarkServiceGrpc.cs
@@ -4,13 +4,13 @@
//
// Original file comments:
// Copyright 2015 gRPC authors.
-//
+//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
-//
+//
// http://www.apache.org/licenses/LICENSE-2.0
-//
+//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -337,6 +337,18 @@ namespace Grpc.Testing {
serviceBinder.AddMethod(__Method_StreamingBothWays, serviceImpl.StreamingBothWays);
}
+ /// Register service method with a service binder without implementation. Useful when customizing the service binding logic.
+ /// Note: this method is part of an experimental API that can change or be removed without any prior notice.
+ /// Service methods will be bound by calling AddMethod on this object.
+ public static void BindService(grpc::ServiceBinderBase serviceBinder)
+ {
+ serviceBinder.AddMethod(__Method_UnaryCall);
+ serviceBinder.AddMethod(__Method_StreamingCall);
+ serviceBinder.AddMethod(__Method_StreamingFromClient);
+ serviceBinder.AddMethod(__Method_StreamingFromServer);
+ serviceBinder.AddMethod(__Method_StreamingBothWays);
+ }
+
}
}
#endregion
diff --git a/src/csharp/Grpc.IntegrationTesting/Control.cs b/src/csharp/Grpc.IntegrationTesting/Control.cs
index 368b86659a5..2e80dac074c 100644
--- a/src/csharp/Grpc.IntegrationTesting/Control.cs
+++ b/src/csharp/Grpc.IntegrationTesting/Control.cs
@@ -96,12 +96,13 @@ namespace Grpc.Testing {
"GAcgAygIEhYKDnNlcnZlcl9zdWNjZXNzGAggAygIEjkKD3JlcXVlc3RfcmVz",
"dWx0cxgJIAMoCzIgLmdycGMudGVzdGluZy5SZXF1ZXN0UmVzdWx0Q291bnQq",
"VgoKQ2xpZW50VHlwZRIPCgtTWU5DX0NMSUVOVBAAEhAKDEFTWU5DX0NMSUVO",
- "VBABEhAKDE9USEVSX0NMSUVOVBACEhMKD0NBTExCQUNLX0NMSUVOVBADKlsK",
+ "VBABEhAKDE9USEVSX0NMSUVOVBACEhMKD0NBTExCQUNLX0NMSUVOVBADKnAK",
"ClNlcnZlclR5cGUSDwoLU1lOQ19TRVJWRVIQABIQCgxBU1lOQ19TRVJWRVIQ",
"ARIYChRBU1lOQ19HRU5FUklDX1NFUlZFUhACEhAKDE9USEVSX1NFUlZFUhAD",
- "KnIKB1JwY1R5cGUSCQoFVU5BUlkQABINCglTVFJFQU1JTkcQARIZChVTVFJF",
- "QU1JTkdfRlJPTV9DTElFTlQQAhIZChVTVFJFQU1JTkdfRlJPTV9TRVJWRVIQ",
- "AxIXChNTVFJFQU1JTkdfQk9USF9XQVlTEARiBnByb3RvMw=="));
+ "EhMKD0NBTExCQUNLX1NFUlZFUhAEKnIKB1JwY1R5cGUSCQoFVU5BUlkQABIN",
+ "CglTVFJFQU1JTkcQARIZChVTVFJFQU1JTkdfRlJPTV9DTElFTlQQAhIZChVT",
+ "VFJFQU1JTkdfRlJPTV9TRVJWRVIQAxIXChNTVFJFQU1JTkdfQk9USF9XQVlT",
+ "EARiBnByb3RvMw=="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { global::Grpc.Testing.PayloadsReflection.Descriptor, global::Grpc.Testing.StatsReflection.Descriptor, },
new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Grpc.Testing.ClientType), typeof(global::Grpc.Testing.ServerType), typeof(global::Grpc.Testing.RpcType), }, new pbr::GeneratedClrTypeInfo[] {
@@ -152,6 +153,7 @@ namespace Grpc.Testing {
/// used for some language-specific variants
///
[pbr::OriginalName("OTHER_SERVER")] OtherServer = 3,
+ [pbr::OriginalName("CALLBACK_SERVER")] CallbackServer = 4,
}
public enum RpcType {
diff --git a/src/csharp/Grpc.IntegrationTesting/Empty.cs b/src/csharp/Grpc.IntegrationTesting/Empty.cs
index 0d4c28bf7fc..389fe433755 100644
--- a/src/csharp/Grpc.IntegrationTesting/Empty.cs
+++ b/src/csharp/Grpc.IntegrationTesting/Empty.cs
@@ -44,6 +44,7 @@ namespace Grpc.Testing {
/// service Foo {
/// rpc Bar (grpc.testing.Empty) returns (grpc.testing.Empty) { };
/// };
+ ///
///
public sealed partial class Empty : pb::IMessage {
private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Empty());
diff --git a/src/csharp/Grpc.IntegrationTesting/EmptyServiceGrpc.cs b/src/csharp/Grpc.IntegrationTesting/EmptyServiceGrpc.cs
index 7e77f8d1141..965d08d8a36 100644
--- a/src/csharp/Grpc.IntegrationTesting/EmptyServiceGrpc.cs
+++ b/src/csharp/Grpc.IntegrationTesting/EmptyServiceGrpc.cs
@@ -4,13 +4,13 @@
//
// Original file comments:
// Copyright 2018 gRPC authors.
-//
+//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
-//
+//
// http://www.apache.org/licenses/LICENSE-2.0
-//
+//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -88,6 +88,13 @@ namespace Grpc.Testing {
{
}
+ /// Register service method with a service binder without implementation. Useful when customizing the service binding logic.
+ /// Note: this method is part of an experimental API that can change or be removed without any prior notice.
+ /// Service methods will be bound by calling AddMethod on this object.
+ public static void BindService(grpc::ServiceBinderBase serviceBinder)
+ {
+ }
+
}
}
#endregion
diff --git a/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs b/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs
index c66a9a9161e..64db5b3ad08 100644
--- a/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs
+++ b/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs
@@ -4,13 +4,13 @@
//
// Original file comments:
// Copyright 2015-2016 gRPC authors.
-//
+//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
-//
+//
// http://www.apache.org/licenses/LICENSE-2.0
-//
+//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,7 +19,7 @@
//
// Contains the definitions for a metrics service and the type of metrics
// exposed by the service.
-//
+//
// Currently, 'Gauge' (i.e a metric that represents the measured value of
// something at an instant of time) is the only metric type supported by the
// service.
@@ -203,6 +203,15 @@ namespace Grpc.Testing {
serviceBinder.AddMethod(__Method_GetGauge, serviceImpl.GetGauge);
}
+ /// Register service method with a service binder without implementation. Useful when customizing the service binding logic.
+ /// Note: this method is part of an experimental API that can change or be removed without any prior notice.
+ /// Service methods will be bound by calling AddMethod on this object.
+ public static void BindService(grpc::ServiceBinderBase serviceBinder)
+ {
+ serviceBinder.AddMethod(__Method_GetAllGauges);
+ serviceBinder.AddMethod(__Method_GetGauge);
+ }
+
}
}
#endregion
diff --git a/src/csharp/Grpc.IntegrationTesting/ReportQpsScenarioServiceGrpc.cs b/src/csharp/Grpc.IntegrationTesting/ReportQpsScenarioServiceGrpc.cs
index 954c1722723..81787892c32 100644
--- a/src/csharp/Grpc.IntegrationTesting/ReportQpsScenarioServiceGrpc.cs
+++ b/src/csharp/Grpc.IntegrationTesting/ReportQpsScenarioServiceGrpc.cs
@@ -4,13 +4,13 @@
//
// Original file comments:
// Copyright 2015 gRPC authors.
-//
+//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
-//
+//
// http://www.apache.org/licenses/LICENSE-2.0
-//
+//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -152,6 +152,14 @@ namespace Grpc.Testing {
serviceBinder.AddMethod(__Method_ReportScenario, serviceImpl.ReportScenario);
}
+ /// Register service method with a service binder without implementation. Useful when customizing the service binding logic.
+ /// Note: this method is part of an experimental API that can change or be removed without any prior notice.
+ /// Service methods will be bound by calling AddMethod on this object.
+ public static void BindService(grpc::ServiceBinderBase serviceBinder)
+ {
+ serviceBinder.AddMethod(__Method_ReportScenario);
+ }
+
}
}
#endregion
diff --git a/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs b/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs
index d125fd5627b..049cb65d7de 100644
--- a/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs
+++ b/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs
@@ -4,13 +4,13 @@
//
// Original file comments:
// Copyright 2015-2016 gRPC authors.
-//
+//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
-//
+//
// http://www.apache.org/licenses/LICENSE-2.0
-//
+//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -555,6 +555,21 @@ namespace Grpc.Testing {
serviceBinder.AddMethod(__Method_UnimplementedCall, serviceImpl.UnimplementedCall);
}
+ /// Register service method with a service binder without implementation. Useful when customizing the service binding logic.
+ /// Note: this method is part of an experimental API that can change or be removed without any prior notice.
+ /// Service methods will be bound by calling AddMethod on this object.
+ public static void BindService(grpc::ServiceBinderBase serviceBinder)
+ {
+ serviceBinder.AddMethod(__Method_EmptyCall);
+ serviceBinder.AddMethod(__Method_UnaryCall);
+ serviceBinder.AddMethod(__Method_CacheableUnaryCall);
+ serviceBinder.AddMethod(__Method_StreamingOutputCall);
+ serviceBinder.AddMethod(__Method_StreamingInputCall);
+ serviceBinder.AddMethod(__Method_FullDuplexCall);
+ serviceBinder.AddMethod(__Method_HalfDuplexCall);
+ serviceBinder.AddMethod(__Method_UnimplementedCall);
+ }
+
}
///
/// A simple service NOT implemented at servers so clients can test for
@@ -686,6 +701,14 @@ namespace Grpc.Testing {
serviceBinder.AddMethod(__Method_UnimplementedCall, serviceImpl.UnimplementedCall);
}
+ /// Register service method with a service binder without implementation. Useful when customizing the service binding logic.
+ /// Note: this method is part of an experimental API that can change or be removed without any prior notice.
+ /// Service methods will be bound by calling AddMethod on this object.
+ public static void BindService(grpc::ServiceBinderBase serviceBinder)
+ {
+ serviceBinder.AddMethod(__Method_UnimplementedCall);
+ }
+
}
///
/// A service used to control reconnect server.
@@ -814,6 +837,15 @@ namespace Grpc.Testing {
serviceBinder.AddMethod(__Method_Stop, serviceImpl.Stop);
}
+ /// Register service method with a service binder without implementation. Useful when customizing the service binding logic.
+ /// Note: this method is part of an experimental API that can change or be removed without any prior notice.
+ /// Service methods will be bound by calling AddMethod on this object.
+ public static void BindService(grpc::ServiceBinderBase serviceBinder)
+ {
+ serviceBinder.AddMethod(__Method_Start);
+ serviceBinder.AddMethod(__Method_Stop);
+ }
+
}
}
#endregion
diff --git a/src/csharp/Grpc.IntegrationTesting/WorkerServiceGrpc.cs b/src/csharp/Grpc.IntegrationTesting/WorkerServiceGrpc.cs
index 5b22337d533..b58d71a784d 100644
--- a/src/csharp/Grpc.IntegrationTesting/WorkerServiceGrpc.cs
+++ b/src/csharp/Grpc.IntegrationTesting/WorkerServiceGrpc.cs
@@ -4,13 +4,13 @@
//
// Original file comments:
// Copyright 2015 gRPC authors.
-//
+//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
-//
+//
// http://www.apache.org/licenses/LICENSE-2.0
-//
+//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -333,6 +333,17 @@ namespace Grpc.Testing {
serviceBinder.AddMethod(__Method_QuitWorker, serviceImpl.QuitWorker);
}
+ /// Register service method with a service binder without implementation. Useful when customizing the service binding logic.
+ /// Note: this method is part of an experimental API that can change or be removed without any prior notice.
+ /// Service methods will be bound by calling AddMethod on this object.
+ public static void BindService(grpc::ServiceBinderBase serviceBinder)
+ {
+ serviceBinder.AddMethod(__Method_RunServer);
+ serviceBinder.AddMethod(__Method_RunClient);
+ serviceBinder.AddMethod(__Method_CoreCount);
+ serviceBinder.AddMethod(__Method_QuitWorker);
+ }
+
}
}
#endregion
diff --git a/src/csharp/Grpc.Reflection/ReflectionGrpc.cs b/src/csharp/Grpc.Reflection/ReflectionGrpc.cs
index ed55c2f584f..51ef8ace5cc 100644
--- a/src/csharp/Grpc.Reflection/ReflectionGrpc.cs
+++ b/src/csharp/Grpc.Reflection/ReflectionGrpc.cs
@@ -4,13 +4,13 @@
//
// Original file comments:
// Copyright 2016 gRPC authors.
-//
+//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
-//
+//
// http://www.apache.org/licenses/LICENSE-2.0
-//
+//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -132,6 +132,14 @@ namespace Grpc.Reflection.V1Alpha {
serviceBinder.AddMethod(__Method_ServerReflectionInfo, serviceImpl.ServerReflectionInfo);
}
+ /// Register service method with a service binder without implementation. Useful when customizing the service binding logic.
+ /// Note: this method is part of an experimental API that can change or be removed without any prior notice.
+ /// Service methods will be bound by calling AddMethod on this object.
+ public static void BindService(grpc::ServiceBinderBase serviceBinder)
+ {
+ serviceBinder.AddMethod(__Method_ServerReflectionInfo);
+ }
+
}
}
#endregion