Make sure full method name starts with slash

pull/1562/head
Jan Tattermusch 10 years ago
parent 4491fbd0e9
commit bee9325d56
  1. 2
      src/csharp/Grpc.Core/Call.cs
  2. 9
      src/csharp/Grpc.Core/Method.cs
  3. 13
      src/csharp/Grpc.Core/ServerServiceDefinition.cs

@ -52,7 +52,7 @@ namespace Grpc.Core
public Call(string serviceName, Method<TRequest, TResponse> method, Channel channel, Metadata headers) public Call(string serviceName, Method<TRequest, TResponse> method, Channel channel, Metadata headers)
{ {
this.name = Preconditions.CheckNotNull(serviceName) + "/" + method.Name; this.name = method.GetFullName(serviceName);
this.requestMarshaller = method.RequestMarshaller; this.requestMarshaller = method.RequestMarshaller;
this.responseMarshaller = method.ResponseMarshaller; this.responseMarshaller = method.ResponseMarshaller;
this.channel = Preconditions.CheckNotNull(channel); this.channel = Preconditions.CheckNotNull(channel);

@ -32,6 +32,7 @@
#endregion #endregion
using System; using System;
using Grpc.Core.Utils;
namespace Grpc.Core namespace Grpc.Core
{ {
@ -95,5 +96,13 @@ namespace Grpc.Core
return this.responseMarshaller; return this.responseMarshaller;
} }
} }
/// <summary>
/// Gets full name of the method including the service name.
/// </summary>
internal string GetFullName(string serviceName)
{
return "/" + Preconditions.CheckNotNull(serviceName) + "/" + this.Name;
}
} }
} }

@ -79,7 +79,7 @@ namespace Grpc.Core
where TRequest : class where TRequest : class
where TResponse : class where TResponse : class
{ {
callHandlers.Add(GetFullMethodName(serviceName, method.Name), ServerCalls.UnaryCall(method, handler)); callHandlers.Add(method.GetFullName(serviceName), ServerCalls.UnaryCall(method, handler));
return this; return this;
} }
@ -89,7 +89,7 @@ namespace Grpc.Core
where TRequest : class where TRequest : class
where TResponse : class where TResponse : class
{ {
callHandlers.Add(GetFullMethodName(serviceName, method.Name), ServerCalls.ClientStreamingCall(method, handler)); callHandlers.Add(method.GetFullName(serviceName), ServerCalls.ClientStreamingCall(method, handler));
return this; return this;
} }
@ -99,7 +99,7 @@ namespace Grpc.Core
where TRequest : class where TRequest : class
where TResponse : class where TResponse : class
{ {
callHandlers.Add(GetFullMethodName(serviceName, method.Name), ServerCalls.ServerStreamingCall(method, handler)); callHandlers.Add(method.GetFullName(serviceName), ServerCalls.ServerStreamingCall(method, handler));
return this; return this;
} }
@ -109,7 +109,7 @@ namespace Grpc.Core
where TRequest : class where TRequest : class
where TResponse : class where TResponse : class
{ {
callHandlers.Add(GetFullMethodName(serviceName, method.Name), ServerCalls.DuplexStreamingCall(method, handler)); callHandlers.Add(method.GetFullName(serviceName), ServerCalls.DuplexStreamingCall(method, handler));
return this; return this;
} }
@ -117,11 +117,6 @@ namespace Grpc.Core
{ {
return new ServerServiceDefinition(callHandlers.ToImmutableDictionary()); return new ServerServiceDefinition(callHandlers.ToImmutableDictionary());
} }
private string GetFullMethodName(string serviceName, string methodName)
{
return serviceName + "/" + methodName;
}
} }
} }
} }

Loading…
Cancel
Save