diff --git a/examples/csharp/helloworld/GreeterClient/Program.cs b/examples/csharp/helloworld/GreeterClient/Program.cs
index 4393f2f3c29..444d4735095 100644
--- a/examples/csharp/helloworld/GreeterClient/Program.cs
+++ b/examples/csharp/helloworld/GreeterClient/Program.cs
@@ -39,7 +39,7 @@ namespace GreeterClient
{
Channel channel = new Channel("127.0.0.1:50051", ChannelCredentials.Insecure);
- var client = Greeter.NewClient(channel);
+ var client = new Greeter.GreeterClient(channel);
String user = "you";
var reply = client.SayHello(new HelloRequest { Name = user });
diff --git a/examples/csharp/route_guide/RouteGuideClient/Program.cs b/examples/csharp/route_guide/RouteGuideClient/Program.cs
index ee51fbe8e04..8a173dcc3b3 100644
--- a/examples/csharp/route_guide/RouteGuideClient/Program.cs
+++ b/examples/csharp/route_guide/RouteGuideClient/Program.cs
@@ -231,7 +231,7 @@ namespace Routeguide
static void Main(string[] args)
{
var channel = new Channel("127.0.0.1:50052", ChannelCredentials.Insecure);
- var client = new RouteGuideClient(RouteGuide.NewClient(channel));
+ var client = new RouteGuideClient(new RouteGuide.RouteGuideClient(channel));
// Looking for a valid feature
client.GetFeature(409146138, -746188906);
diff --git a/src/compiler/csharp_generator.cc b/src/compiler/csharp_generator.cc
index fc8feaf0fcc..f5a0876cf98 100644
--- a/src/compiler/csharp_generator.cc
+++ b/src/compiler/csharp_generator.cc
@@ -333,22 +333,28 @@ void GenerateClientStub(Printer* out, const ServiceDescriptor *service) {
out->Indent();
// constructors
+ out->Print("/// Creates a new client for $servicename$\n"
+ "/// The channel to use to make remote calls.\n",
+ "servicename", GetServiceClassName(service));
out->Print("public $name$(Channel channel) : base(channel)\n",
"name", GetClientClassName(service));
out->Print("{\n");
out->Print("}\n");
+ out->Print("/// Creates a new client for $servicename$ that uses a custom CallInvoker.\n"
+ "/// The callInvoker to use to make remote calls.\n",
+ "servicename", GetServiceClassName(service));
out->Print("public $name$(CallInvoker callInvoker) : base(callInvoker)\n",
"name", GetClientClassName(service));
out->Print("{\n");
out->Print("}\n");
- out->Print("///Protected parameterless constructor to allow creation"
+ out->Print("/// Protected parameterless constructor to allow creation"
" of test doubles.\n");
out->Print("protected $name$() : base()\n",
"name", GetClientClassName(service));
out->Print("{\n");
out->Print("}\n");
- out->Print("///Protected constructor to allow creation of configured"
- " clients.\n");
+ out->Print("/// Protected constructor to allow creation of configured clients.\n"
+ "/// The client configuration.\n");
out->Print("protected $name$(ClientBaseConfiguration configuration)"
" : base(configuration)\n",
"name", GetClientClassName(service));
@@ -485,20 +491,6 @@ void GenerateBindServiceMethod(Printer* out, const ServiceDescriptor *service) {
out->Print("\n");
}
-void GenerateNewStubMethods(Printer* out, const ServiceDescriptor *service) {
- out->Print("/// Creates a new client for $servicename$\n",
- "servicename", GetServiceClassName(service));
- out->Print("public static $classname$ NewClient(Channel channel)\n",
- "classname", GetClientClassName(service));
- out->Print("{\n");
- out->Indent();
- out->Print("return new $classname$(channel);\n", "classname",
- GetClientClassName(service));
- out->Outdent();
- out->Print("}\n");
- out->Print("\n");
-}
-
void GenerateService(Printer* out, const ServiceDescriptor *service,
bool generate_client, bool generate_server,
bool internal_access) {
@@ -524,7 +516,6 @@ void GenerateService(Printer* out, const ServiceDescriptor *service,
}
if (generate_client) {
GenerateClientStub(out, service);
- GenerateNewStubMethods(out, service);
}
if (generate_server) {
GenerateBindServiceMethod(out, service);
diff --git a/src/csharp/Grpc.Examples.Tests/MathClientServerTests.cs b/src/csharp/Grpc.Examples.Tests/MathClientServerTests.cs
index 324c209ca1d..50dacc2eaaf 100644
--- a/src/csharp/Grpc.Examples.Tests/MathClientServerTests.cs
+++ b/src/csharp/Grpc.Examples.Tests/MathClientServerTests.cs
@@ -62,7 +62,7 @@ namespace Math.Tests
};
server.Start();
channel = new Channel(Host, server.Ports.Single().BoundPort, ChannelCredentials.Insecure);
- client = Math.NewClient(channel);
+ client = new Math.MathClient(channel);
}
[TestFixtureTearDown]
diff --git a/src/csharp/Grpc.Examples/MathGrpc.cs b/src/csharp/Grpc.Examples/MathGrpc.cs
index 4bbefcbe01a..25abc514195 100644
--- a/src/csharp/Grpc.Examples/MathGrpc.cs
+++ b/src/csharp/Grpc.Examples/MathGrpc.cs
@@ -128,17 +128,22 @@ namespace Math {
/// Client for Math
public class MathClient : ClientBase
{
+ /// Creates a new client for Math
+ /// The channel to use to make remote calls.
public MathClient(Channel channel) : base(channel)
{
}
+ /// Creates a new client for Math that uses a custom CallInvoker.
+ /// The callInvoker to use to make remote calls.
public MathClient(CallInvoker callInvoker) : base(callInvoker)
{
}
- ///Protected parameterless constructor to allow creation of test doubles.
+ /// Protected parameterless constructor to allow creation of test doubles.
protected MathClient() : base()
{
}
- ///Protected constructor to allow creation of configured clients.
+ /// Protected constructor to allow creation of configured clients.
+ /// The client configuration.
protected MathClient(ClientBaseConfiguration configuration) : base(configuration)
{
}
@@ -235,12 +240,6 @@ namespace Math {
}
}
- /// Creates a new client for Math
- public static MathClient NewClient(Channel channel)
- {
- return new MathClient(channel);
- }
-
/// Creates service definition that can be registered with a server
public static ServerServiceDefinition BindService(MathBase serviceImpl)
{
diff --git a/src/csharp/Grpc.HealthCheck.Tests/HealthClientServerTest.cs b/src/csharp/Grpc.HealthCheck.Tests/HealthClientServerTest.cs
index 070674bae9d..25a58fb3864 100644
--- a/src/csharp/Grpc.HealthCheck.Tests/HealthClientServerTest.cs
+++ b/src/csharp/Grpc.HealthCheck.Tests/HealthClientServerTest.cs
@@ -65,7 +65,7 @@ namespace Grpc.HealthCheck.Tests
server.Start();
channel = new Channel(Host, server.Ports.Single().BoundPort, ChannelCredentials.Insecure);
- client = Grpc.Health.V1.Health.NewClient(channel);
+ client = new Grpc.Health.V1.Health.HealthClient(channel);
}
[TestFixtureTearDown]
diff --git a/src/csharp/Grpc.HealthCheck/HealthGrpc.cs b/src/csharp/Grpc.HealthCheck/HealthGrpc.cs
index d0ade7d02be..43eea0f22f5 100644
--- a/src/csharp/Grpc.HealthCheck/HealthGrpc.cs
+++ b/src/csharp/Grpc.HealthCheck/HealthGrpc.cs
@@ -71,17 +71,22 @@ namespace Grpc.Health.V1 {
/// Client for Health
public class HealthClient : ClientBase
{
+ /// Creates a new client for Health
+ /// The channel to use to make remote calls.
public HealthClient(Channel channel) : base(channel)
{
}
+ /// Creates a new client for Health that uses a custom CallInvoker.
+ /// The callInvoker to use to make remote calls.
public HealthClient(CallInvoker callInvoker) : base(callInvoker)
{
}
- ///Protected parameterless constructor to allow creation of test doubles.
+ /// Protected parameterless constructor to allow creation of test doubles.
protected HealthClient() : base()
{
}
- ///Protected constructor to allow creation of configured clients.
+ /// Protected constructor to allow creation of configured clients.
+ /// The client configuration.
protected HealthClient(ClientBaseConfiguration configuration) : base(configuration)
{
}
@@ -108,12 +113,6 @@ namespace Grpc.Health.V1 {
}
}
- /// Creates a new client for Health
- public static HealthClient NewClient(Channel channel)
- {
- return new HealthClient(channel);
- }
-
/// Creates service definition that can be registered with a server
public static ServerServiceDefinition BindService(HealthBase serviceImpl)
{
diff --git a/src/csharp/Grpc.IntegrationTesting/ClientRunners.cs b/src/csharp/Grpc.IntegrationTesting/ClientRunners.cs
index 39b9ae08e64..b9c0fe6d0d8 100644
--- a/src/csharp/Grpc.IntegrationTesting/ClientRunners.cs
+++ b/src/csharp/Grpc.IntegrationTesting/ClientRunners.cs
@@ -211,7 +211,7 @@ namespace Grpc.IntegrationTesting
bool profilerReset = false;
- var client = BenchmarkService.NewClient(channel);
+ var client = new BenchmarkService.BenchmarkServiceClient(channel);
var request = CreateSimpleRequest();
var stopwatch = new Stopwatch();
@@ -237,7 +237,7 @@ namespace Grpc.IntegrationTesting
private async Task RunUnaryAsync(Channel channel, IInterarrivalTimer timer)
{
- var client = BenchmarkService.NewClient(channel);
+ var client = new BenchmarkService.BenchmarkServiceClient(channel);
var request = CreateSimpleRequest();
var stopwatch = new Stopwatch();
@@ -256,7 +256,7 @@ namespace Grpc.IntegrationTesting
private async Task RunStreamingPingPongAsync(Channel channel, IInterarrivalTimer timer)
{
- var client = BenchmarkService.NewClient(channel);
+ var client = new BenchmarkService.BenchmarkServiceClient(channel);
var request = CreateSimpleRequest();
var stopwatch = new Stopwatch();
diff --git a/src/csharp/Grpc.IntegrationTesting/GeneratedServiceBaseTest.cs b/src/csharp/Grpc.IntegrationTesting/GeneratedServiceBaseTest.cs
index 001533ce315..4216dc1d6be 100644
--- a/src/csharp/Grpc.IntegrationTesting/GeneratedServiceBaseTest.cs
+++ b/src/csharp/Grpc.IntegrationTesting/GeneratedServiceBaseTest.cs
@@ -61,7 +61,7 @@ namespace Grpc.IntegrationTesting
};
server.Start();
channel = new Channel(Host, server.Ports.Single().BoundPort, ChannelCredentials.Insecure);
- client = TestService.NewClient(channel);
+ client = new TestService.TestServiceClient(channel);
}
[TearDown]
diff --git a/src/csharp/Grpc.IntegrationTesting/InteropClientServerTest.cs b/src/csharp/Grpc.IntegrationTesting/InteropClientServerTest.cs
index 4ee1ff5ec8a..f907f630dab 100644
--- a/src/csharp/Grpc.IntegrationTesting/InteropClientServerTest.cs
+++ b/src/csharp/Grpc.IntegrationTesting/InteropClientServerTest.cs
@@ -69,7 +69,7 @@ namespace Grpc.IntegrationTesting
};
int port = server.Ports.Single().BoundPort;
channel = new Channel(Host, port, TestCredentials.CreateSslCredentials(), options);
- client = TestService.NewClient(channel);
+ client = new TestService.TestServiceClient(channel);
}
[TestFixtureTearDown]
@@ -148,7 +148,7 @@ namespace Grpc.IntegrationTesting
[Test]
public void UnimplementedMethod()
{
- InteropClient.RunUnimplementedMethod(UnimplementedService.NewClient(channel));
+ InteropClient.RunUnimplementedMethod(new UnimplementedService.UnimplementedServiceClient(channel));
}
}
}
diff --git a/src/csharp/Grpc.IntegrationTesting/MetadataCredentialsTest.cs b/src/csharp/Grpc.IntegrationTesting/MetadataCredentialsTest.cs
index 9fd575f1900..eb3bb8a28bb 100644
--- a/src/csharp/Grpc.IntegrationTesting/MetadataCredentialsTest.cs
+++ b/src/csharp/Grpc.IntegrationTesting/MetadataCredentialsTest.cs
@@ -88,7 +88,7 @@ namespace Grpc.IntegrationTesting
var channelCredentials = ChannelCredentials.Create(TestCredentials.CreateSslCredentials(),
CallCredentials.FromInterceptor(asyncAuthInterceptor));
channel = new Channel(Host, server.Ports.Single().BoundPort, channelCredentials, options);
- client = TestService.NewClient(channel);
+ client = new TestService.TestServiceClient(channel);
client.UnaryCall(new SimpleRequest { });
}
@@ -97,7 +97,7 @@ namespace Grpc.IntegrationTesting
public void MetadataCredentials_PerCall()
{
channel = new Channel(Host, server.Ports.Single().BoundPort, TestCredentials.CreateSslCredentials(), options);
- client = TestService.NewClient(channel);
+ client = new TestService.TestServiceClient(channel);
var callCredentials = CallCredentials.FromInterceptor(asyncAuthInterceptor);
client.UnaryCall(new SimpleRequest { }, new CallOptions(credentials: callCredentials));
diff --git a/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs b/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs
index 22bd27ec0aa..040798e3c21 100644
--- a/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs
+++ b/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs
@@ -97,17 +97,22 @@ namespace Grpc.Testing {
/// Client for MetricsService
public class MetricsServiceClient : ClientBase
{
+ /// Creates a new client for MetricsService
+ /// The channel to use to make remote calls.
public MetricsServiceClient(Channel channel) : base(channel)
{
}
+ /// Creates a new client for MetricsService that uses a custom CallInvoker.
+ /// The callInvoker to use to make remote calls.
public MetricsServiceClient(CallInvoker callInvoker) : base(callInvoker)
{
}
- ///Protected parameterless constructor to allow creation of test doubles.
+ /// Protected parameterless constructor to allow creation of test doubles.
protected MetricsServiceClient() : base()
{
}
- ///Protected constructor to allow creation of configured clients.
+ /// Protected constructor to allow creation of configured clients.
+ /// The client configuration.
protected MetricsServiceClient(ClientBaseConfiguration configuration) : base(configuration)
{
}
@@ -162,12 +167,6 @@ namespace Grpc.Testing {
}
}
- /// Creates a new client for MetricsService
- public static MetricsServiceClient NewClient(Channel channel)
- {
- return new MetricsServiceClient(channel);
- }
-
/// Creates service definition that can be registered with a server
public static ServerServiceDefinition BindService(MetricsServiceBase serviceImpl)
{
diff --git a/src/csharp/Grpc.IntegrationTesting/ServicesGrpc.cs b/src/csharp/Grpc.IntegrationTesting/ServicesGrpc.cs
index 9c99296115c..e205dea93ea 100644
--- a/src/csharp/Grpc.IntegrationTesting/ServicesGrpc.cs
+++ b/src/csharp/Grpc.IntegrationTesting/ServicesGrpc.cs
@@ -93,17 +93,22 @@ namespace Grpc.Testing {
/// Client for BenchmarkService
public class BenchmarkServiceClient : ClientBase
{
+ /// Creates a new client for BenchmarkService
+ /// The channel to use to make remote calls.
public BenchmarkServiceClient(Channel channel) : base(channel)
{
}
+ /// Creates a new client for BenchmarkService that uses a custom CallInvoker.
+ /// The callInvoker to use to make remote calls.
public BenchmarkServiceClient(CallInvoker callInvoker) : base(callInvoker)
{
}
- ///Protected parameterless constructor to allow creation of test doubles.
+ /// Protected parameterless constructor to allow creation of test doubles.
protected BenchmarkServiceClient() : base()
{
}
- ///Protected constructor to allow creation of configured clients.
+ /// Protected constructor to allow creation of configured clients.
+ /// The client configuration.
protected BenchmarkServiceClient(ClientBaseConfiguration configuration) : base(configuration)
{
}
@@ -162,12 +167,6 @@ namespace Grpc.Testing {
}
}
- /// Creates a new client for BenchmarkService
- public static BenchmarkServiceClient NewClient(Channel channel)
- {
- return new BenchmarkServiceClient(channel);
- }
-
/// Creates service definition that can be registered with a server
public static ServerServiceDefinition BindService(BenchmarkServiceBase serviceImpl)
{
@@ -273,17 +272,22 @@ namespace Grpc.Testing {
/// Client for WorkerService
public class WorkerServiceClient : ClientBase
{
+ /// Creates a new client for WorkerService
+ /// The channel to use to make remote calls.
public WorkerServiceClient(Channel channel) : base(channel)
{
}
+ /// Creates a new client for WorkerService that uses a custom CallInvoker.
+ /// The callInvoker to use to make remote calls.
public WorkerServiceClient(CallInvoker callInvoker) : base(callInvoker)
{
}
- ///Protected parameterless constructor to allow creation of test doubles.
+ /// Protected parameterless constructor to allow creation of test doubles.
protected WorkerServiceClient() : base()
{
}
- ///Protected constructor to allow creation of configured clients.
+ /// Protected constructor to allow creation of configured clients.
+ /// The client configuration.
protected WorkerServiceClient(ClientBaseConfiguration configuration) : base(configuration)
{
}
@@ -398,12 +402,6 @@ namespace Grpc.Testing {
}
}
- /// Creates a new client for WorkerService
- public static WorkerServiceClient NewClient(Channel channel)
- {
- return new WorkerServiceClient(channel);
- }
-
/// Creates service definition that can be registered with a server
public static ServerServiceDefinition BindService(WorkerServiceBase serviceImpl)
{
diff --git a/src/csharp/Grpc.IntegrationTesting/SslCredentialsTest.cs b/src/csharp/Grpc.IntegrationTesting/SslCredentialsTest.cs
index 3df45b5f708..f85e272711f 100644
--- a/src/csharp/Grpc.IntegrationTesting/SslCredentialsTest.cs
+++ b/src/csharp/Grpc.IntegrationTesting/SslCredentialsTest.cs
@@ -79,7 +79,7 @@ namespace Grpc.IntegrationTesting
};
channel = new Channel(Host, server.Ports.Single().BoundPort, clientCredentials, options);
- client = TestService.NewClient(channel);
+ client = new TestService.TestServiceClient(channel);
}
[TestFixtureTearDown]
diff --git a/src/csharp/Grpc.IntegrationTesting/StressTestClient.cs b/src/csharp/Grpc.IntegrationTesting/StressTestClient.cs
index 4d6ca7ece57..74ee040ae49 100644
--- a/src/csharp/Grpc.IntegrationTesting/StressTestClient.cs
+++ b/src/csharp/Grpc.IntegrationTesting/StressTestClient.cs
@@ -148,7 +148,7 @@ namespace Grpc.IntegrationTesting
channels.Add(channel);
for (int j = 0; j < options.NumStubsPerChannel; j++)
{
- var client = TestService.NewClient(channel);
+ var client = new TestService.TestServiceClient(channel);
var task = Task.Factory.StartNew(() => RunBodyAsync(client).GetAwaiter().GetResult(),
TaskCreationOptions.LongRunning);
tasks.Add(task);
diff --git a/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs b/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs
index 6c252013f84..3e149da3e01 100644
--- a/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs
+++ b/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs
@@ -168,17 +168,22 @@ namespace Grpc.Testing {
/// Client for TestService
public class TestServiceClient : ClientBase
{
+ /// Creates a new client for TestService
+ /// The channel to use to make remote calls.
public TestServiceClient(Channel channel) : base(channel)
{
}
+ /// Creates a new client for TestService that uses a custom CallInvoker.
+ /// The callInvoker to use to make remote calls.
public TestServiceClient(CallInvoker callInvoker) : base(callInvoker)
{
}
- ///Protected parameterless constructor to allow creation of test doubles.
+ /// Protected parameterless constructor to allow creation of test doubles.
protected TestServiceClient() : base()
{
}
- ///Protected constructor to allow creation of configured clients.
+ /// Protected constructor to allow creation of configured clients.
+ /// The client configuration.
protected TestServiceClient(ClientBaseConfiguration configuration) : base(configuration)
{
}
@@ -315,12 +320,6 @@ namespace Grpc.Testing {
}
}
- /// Creates a new client for TestService
- public static TestServiceClient NewClient(Channel channel)
- {
- return new TestServiceClient(channel);
- }
-
/// Creates service definition that can be registered with a server
public static ServerServiceDefinition BindService(TestServiceBase serviceImpl)
{
@@ -373,17 +372,22 @@ namespace Grpc.Testing {
/// Client for UnimplementedService
public class UnimplementedServiceClient : ClientBase
{
+ /// Creates a new client for UnimplementedService
+ /// The channel to use to make remote calls.
public UnimplementedServiceClient(Channel channel) : base(channel)
{
}
+ /// Creates a new client for UnimplementedService that uses a custom CallInvoker.
+ /// The callInvoker to use to make remote calls.
public UnimplementedServiceClient(CallInvoker callInvoker) : base(callInvoker)
{
}
- ///Protected parameterless constructor to allow creation of test doubles.
+ /// Protected parameterless constructor to allow creation of test doubles.
protected UnimplementedServiceClient() : base()
{
}
- ///Protected constructor to allow creation of configured clients.
+ /// Protected constructor to allow creation of configured clients.
+ /// The client configuration.
protected UnimplementedServiceClient(ClientBaseConfiguration configuration) : base(configuration)
{
}
@@ -422,12 +426,6 @@ namespace Grpc.Testing {
}
}
- /// Creates a new client for UnimplementedService
- public static UnimplementedServiceClient NewClient(Channel channel)
- {
- return new UnimplementedServiceClient(channel);
- }
-
/// Creates service definition that can be registered with a server
public static ServerServiceDefinition BindService(UnimplementedServiceBase serviceImpl)
{
@@ -485,17 +483,22 @@ namespace Grpc.Testing {
/// Client for ReconnectService
public class ReconnectServiceClient : ClientBase
{
+ /// Creates a new client for ReconnectService
+ /// The channel to use to make remote calls.
public ReconnectServiceClient(Channel channel) : base(channel)
{
}
+ /// Creates a new client for ReconnectService that uses a custom CallInvoker.
+ /// The callInvoker to use to make remote calls.
public ReconnectServiceClient(CallInvoker callInvoker) : base(callInvoker)
{
}
- ///Protected parameterless constructor to allow creation of test doubles.
+ /// Protected parameterless constructor to allow creation of test doubles.
protected ReconnectServiceClient() : base()
{
}
- ///Protected constructor to allow creation of configured clients.
+ /// Protected constructor to allow creation of configured clients.
+ /// The client configuration.
protected ReconnectServiceClient(ClientBaseConfiguration configuration) : base(configuration)
{
}
@@ -538,12 +541,6 @@ namespace Grpc.Testing {
}
}
- /// Creates a new client for ReconnectService
- public static ReconnectServiceClient NewClient(Channel channel)
- {
- return new ReconnectServiceClient(channel);
- }
-
/// Creates service definition that can be registered with a server
public static ServerServiceDefinition BindService(ReconnectServiceBase serviceImpl)
{