Polish and address review comments

pull/12613/head
Mehrdad Afshari 7 years ago
parent 8f1eab1b29
commit 074b802c9f
  1. 6
      src/csharp/Grpc.Core/Interceptors/CallInvokerExtensions.cs
  2. 4
      src/csharp/Grpc.Core/Interceptors/ChannelExtensions.cs
  3. 12
      src/csharp/Grpc.Core/Interceptors/ClientInterceptorContext.cs
  4. 4
      src/csharp/Grpc.Core/Interceptors/InterceptingCallInvoker.cs
  5. 8
      src/csharp/Grpc.Core/Interceptors/ServerServiceDefinitionExtensions.cs
  6. 10
      src/csharp/Grpc.Core/Internal/ServerCallHandler.cs

@ -64,8 +64,8 @@ namespace Grpc.Core.Interceptors
/// </remarks>
public static CallInvoker Intercept(this CallInvoker invoker, params Interceptor[] interceptors)
{
GrpcPreconditions.CheckNotNull(invoker, "invoker");
GrpcPreconditions.CheckNotNull(interceptors, "interceptors");
GrpcPreconditions.CheckNotNull(invoker, nameof(invoker);
GrpcPreconditions.CheckNotNull(interceptors, nameof(interceptors));
foreach (var interceptor in interceptors.Reverse())
{
@ -104,7 +104,7 @@ namespace Grpc.Core.Interceptors
/// </summary>
public MetadataInterceptor(Func<Metadata, Metadata> interceptor)
{
this.interceptor = GrpcPreconditions.CheckNotNull(interceptor, "interceptor");
this.interceptor = GrpcPreconditions.CheckNotNull(interceptor, nameof(interceptor));
}
protected override ClientCallHooks<TRequest, TResponse> InterceptCall<TRequest, TResponse>(ClientInterceptorContext<TRequest, TResponse> context, bool clientStreaming, bool serverStreaming, TRequest request)

@ -76,9 +76,7 @@ namespace Grpc.Core.Interceptors
/// invocation metadata.
/// </param>
/// <remarks>
/// Multiple interceptors can be added on top of each other by calling
/// "channel.Intercept(a, b, c)". The order of invocation will be "a", "b", and then "c".
/// Interceptors can be later added to an existing intercepted channel, effectively
/// Multiple interceptors can be added on top of each other by
/// building a chain like "channel.Intercept(c).Intercept(b).Intercept(a)". Note that
/// in this case, the last interceptor added will be the first to take control.
/// </remarks>

@ -46,20 +46,20 @@ namespace Grpc.Core.Interceptors
}
/// <summary>
/// Gets or sets the <see cref="Grpc.Core.Method{TRequest, TResponse}"/> instance
/// Gets the <see cref="Grpc.Core.Method{TRequest, TResponse}"/> instance
/// representing the method to be invoked.
/// </summary>
public Method<TRequest, TResponse> Method { get; set; }
public Method<TRequest, TResponse> Method { get; }
/// <summary>
/// Gets or sets the host that the currect invocation will be dispatched to.
/// Gets the host that the currect invocation will be dispatched to.
/// </summary>
public string Host { get; set; }
public string Host { get; }
/// <summary>
/// Gets or sets the <see cref="Grpc.Core.CallOptions"/> structure representing the
/// Gets the <see cref="Grpc.Core.CallOptions"/> structure representing the
/// call options associated with the current invocation.
/// </summary>
public CallOptions Options { get; set; }
public CallOptions Options { get; }
}
}

@ -36,8 +36,8 @@ namespace Grpc.Core.Interceptors
/// </summary>
public InterceptingCallInvoker(CallInvoker invoker, Interceptor interceptor)
{
this.invoker = GrpcPreconditions.CheckNotNull(invoker, "invoker");
this.interceptor = GrpcPreconditions.CheckNotNull(interceptor, "interceptor");
this.invoker = GrpcPreconditions.CheckNotNull(invoker, nameof(invoker));
this.interceptor = GrpcPreconditions.CheckNotNull(interceptor, nameof(interceptor));
}
/// <summary>

@ -44,8 +44,8 @@ namespace Grpc.Core.Interceptors
/// </remarks>
public static ServerServiceDefinition Intercept(this ServerServiceDefinition serverServiceDefinition, Interceptor interceptor)
{
GrpcPreconditions.CheckNotNull(serverServiceDefinition, "serverServiceDefinition");
GrpcPreconditions.CheckNotNull(interceptor, "interceptor");
GrpcPreconditions.CheckNotNull(serverServiceDefinition, nameof(serverServiceDefinition));
GrpcPreconditions.CheckNotNull(interceptor, nameof(interceptor));
return new ServerServiceDefinition(serverServiceDefinition.CallHandlers.ToDictionary(x => x.Key, x => x.Value.Intercept(interceptor)));
}
@ -68,8 +68,8 @@ namespace Grpc.Core.Interceptors
/// </remarks>
public static ServerServiceDefinition Intercept(this ServerServiceDefinition serverServiceDefinition, params Interceptor[] interceptors)
{
GrpcPreconditions.CheckNotNull(serverServiceDefinition, "serverServiceDefinition");
GrpcPreconditions.CheckNotNull(interceptors, "interceptors");
GrpcPreconditions.CheckNotNull(serverServiceDefinition, nameof(serverServiceDefinition));
GrpcPreconditions.CheckNotNull(interceptors, nameof(interceptors));
foreach (var interceptor in interceptors.Reverse())
{

@ -76,7 +76,7 @@ namespace Grpc.Core.Internal
{
if (!(e is RpcException))
{
Logger.Warning(e, "Exception occured in handler or interceptors.");
Logger.Warning(e, "Exception occurred in the handler or an interceptor.");
}
status = HandlerUtils.GetStatusFromExceptionAndMergeTrailers(e, context.ResponseTrailers);
}
@ -138,7 +138,7 @@ namespace Grpc.Core.Internal
{
if (!(e is RpcException))
{
Logger.Warning(e, "Exception occured in handler or interceptors.");
Logger.Warning(e, "Exception occurred in the handler or an interceptor.");
}
status = HandlerUtils.GetStatusFromExceptionAndMergeTrailers(e, context.ResponseTrailers);
}
@ -201,7 +201,7 @@ namespace Grpc.Core.Internal
{
if (!(e is RpcException))
{
Logger.Warning(e, "Exception occured in handler or interceptor.");
Logger.Warning(e, "Exception occurred in the handler or an interceptor.");
}
status = HandlerUtils.GetStatusFromExceptionAndMergeTrailers(e, context.ResponseTrailers);
}
@ -262,7 +262,7 @@ namespace Grpc.Core.Internal
{
if (!(e is RpcException))
{
Logger.Warning(e, "Exception occured in handler or interceptor.");
Logger.Warning(e, "Exception occurred in the handler or an interceptor.");
}
status = HandlerUtils.GetStatusFromExceptionAndMergeTrailers(e, context.ResponseTrailers);
}
@ -313,7 +313,7 @@ namespace Grpc.Core.Internal
public IServerCallHandler Intercept(Interceptor interceptor)
{
return this; // Do not intercept unimplemented services
return this; // Do not intercept unimplemented methods.
}
}

Loading…
Cancel
Save