From 3de9f49e3c73266688adc8f424e3efe309c4cedd Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 12 Mar 2015 12:53:50 -0700 Subject: [PATCH] Setting up stylecop to ignore generated files and fixing style --- src/csharp/Grpc.Examples/MathGrpc.cs | 57 ++++++----- src/csharp/Grpc.Examples/Settings.StyleCop | 10 ++ .../Grpc.IntegrationTesting/Settings.StyleCop | 11 +++ .../TestServiceGrpc.cs | 95 +++++++++---------- src/csharp/Settings.StyleCop | 3 - 5 files changed, 96 insertions(+), 80 deletions(-) create mode 100644 src/csharp/Grpc.Examples/Settings.StyleCop create mode 100644 src/csharp/Grpc.IntegrationTesting/Settings.StyleCop diff --git a/src/csharp/Grpc.Examples/MathGrpc.cs b/src/csharp/Grpc.Examples/MathGrpc.cs index f938a245439b9..33a9ca9287649 100644 --- a/src/csharp/Grpc.Examples/MathGrpc.cs +++ b/src/csharp/Grpc.Examples/MathGrpc.cs @@ -45,35 +45,34 @@ namespace math /// public class MathGrpc { - readonly static Marshaller divArgsMarshaller = Marshallers.Create((arg) => arg.ToByteArray(), DivArgs.ParseFrom); - readonly static Marshaller divReplyMarshaller = Marshallers.Create((arg) => arg.ToByteArray(), DivReply.ParseFrom); - readonly static Marshaller numMarshaller = Marshallers.Create((arg) => arg.ToByteArray(), Num.ParseFrom); - readonly static Marshaller fibArgsMarshaller = Marshallers.Create((arg) => arg.ToByteArray(), FibArgs.ParseFrom); + static readonly Marshaller DivArgsMarshaller = Marshallers.Create((arg) => arg.ToByteArray(), DivArgs.ParseFrom); + static readonly Marshaller DivReplyMarshaller = Marshallers.Create((arg) => arg.ToByteArray(), DivReply.ParseFrom); + static readonly Marshaller NumMarshaller = Marshallers.Create((arg) => arg.ToByteArray(), Num.ParseFrom); + static readonly Marshaller FibArgsMarshaller = Marshallers.Create((arg) => arg.ToByteArray(), FibArgs.ParseFrom); - readonly static Method divMethod = new Method( + static readonly Method DivMethod = new Method( MethodType.Unary, "/math.Math/Div", - divArgsMarshaller, - divReplyMarshaller - ); - readonly static Method fibMethod = new Method( + DivArgsMarshaller, + DivReplyMarshaller); + + static readonly Method FibMethod = new Method( MethodType.ServerStreaming, "/math.Math/Fib", - fibArgsMarshaller, - numMarshaller - ); - readonly static Method sumMethod = new Method( + FibArgsMarshaller, + NumMarshaller); + + static readonly Method SumMethod = new Method( MethodType.ClientStreaming, "/math.Math/Sum", - numMarshaller, - numMarshaller - ); - readonly static Method divManyMethod = new Method( + NumMarshaller, + NumMarshaller); + + static readonly Method DivManyMethod = new Method( MethodType.DuplexStreaming, "/math.Math/DivMany", - divArgsMarshaller, - divReplyMarshaller - ); + DivArgsMarshaller, + DivReplyMarshaller); public interface IMathServiceClient { @@ -99,31 +98,31 @@ public MathServiceClientStub(Channel channel) public DivReply Div(DivArgs request, CancellationToken token = default(CancellationToken)) { - var call = new Grpc.Core.Call(divMethod, channel); + var call = new Grpc.Core.Call(DivMethod, channel); return Calls.BlockingUnaryCall(call, request, token); } public Task DivAsync(DivArgs request, CancellationToken token = default(CancellationToken)) { - var call = new Grpc.Core.Call(divMethod, channel); + var call = new Grpc.Core.Call(DivMethod, channel); return Calls.AsyncUnaryCall(call, request, token); } public void Fib(FibArgs request, IObserver responseObserver, CancellationToken token = default(CancellationToken)) { - var call = new Grpc.Core.Call(fibMethod, channel); + var call = new Grpc.Core.Call(FibMethod, channel); Calls.AsyncServerStreamingCall(call, request, responseObserver, token); } public ClientStreamingAsyncResult Sum(CancellationToken token = default(CancellationToken)) { - var call = new Grpc.Core.Call(sumMethod, channel); + var call = new Grpc.Core.Call(SumMethod, channel); return Calls.AsyncClientStreamingCall(call, token); } public IObserver DivMany(IObserver responseObserver, CancellationToken token = default(CancellationToken)) { - var call = new Grpc.Core.Call(divManyMethod, channel); + var call = new Grpc.Core.Call(DivManyMethod, channel); return Calls.DuplexStreamingCall(call, responseObserver, token); } } @@ -143,10 +142,10 @@ public interface IMathService public static ServerServiceDefinition BindService(IMathService serviceImpl) { return ServerServiceDefinition.CreateBuilder("/math.Math/") - .AddMethod(divMethod, serviceImpl.Div) - .AddMethod(fibMethod, serviceImpl.Fib) - .AddMethod(sumMethod, serviceImpl.Sum) - .AddMethod(divManyMethod, serviceImpl.DivMany).Build(); + .AddMethod(DivMethod, serviceImpl.Div) + .AddMethod(FibMethod, serviceImpl.Fib) + .AddMethod(SumMethod, serviceImpl.Sum) + .AddMethod(DivManyMethod, serviceImpl.DivMany).Build(); } public static IMathServiceClient NewStub(Channel channel) diff --git a/src/csharp/Grpc.Examples/Settings.StyleCop b/src/csharp/Grpc.Examples/Settings.StyleCop new file mode 100644 index 0000000000000..e9b6e7172aa37 --- /dev/null +++ b/src/csharp/Grpc.Examples/Settings.StyleCop @@ -0,0 +1,10 @@ + + + Math.cs + + + False + + + + \ No newline at end of file diff --git a/src/csharp/Grpc.IntegrationTesting/Settings.StyleCop b/src/csharp/Grpc.IntegrationTesting/Settings.StyleCop new file mode 100644 index 0000000000000..fb99cd4af1cd6 --- /dev/null +++ b/src/csharp/Grpc.IntegrationTesting/Settings.StyleCop @@ -0,0 +1,11 @@ + + + Messages.cs + Empty.cs + + + False + + + + \ No newline at end of file diff --git a/src/csharp/Grpc.IntegrationTesting/TestServiceGrpc.cs b/src/csharp/Grpc.IntegrationTesting/TestServiceGrpc.cs index b71704bcc7b05..9b0251c3ca9d6 100644 --- a/src/csharp/Grpc.IntegrationTesting/TestServiceGrpc.cs +++ b/src/csharp/Grpc.IntegrationTesting/TestServiceGrpc.cs @@ -44,50 +44,49 @@ namespace grpc.testing /// public class TestServiceGrpc { - readonly static Marshaller emptyMarshaller = Marshallers.Create((arg) => arg.ToByteArray(), Empty.ParseFrom); - readonly static Marshaller simpleRequestMarshaller = Marshallers.Create((arg) => arg.ToByteArray(), SimpleRequest.ParseFrom); - readonly static Marshaller simpleResponseMarshaller = Marshallers.Create((arg) => arg.ToByteArray(), SimpleResponse.ParseFrom); - readonly static Marshaller streamingOutputCallRequestMarshaller = Marshallers.Create((arg) => arg.ToByteArray(), StreamingOutputCallRequest.ParseFrom); - readonly static Marshaller streamingOutputCallResponseMarshaller = Marshallers.Create((arg) => arg.ToByteArray(), StreamingOutputCallResponse.ParseFrom); - readonly static Marshaller streamingInputCallRequestMarshaller = Marshallers.Create((arg) => arg.ToByteArray(), StreamingInputCallRequest.ParseFrom); - readonly static Marshaller streamingInputCallResponseMarshaller = Marshallers.Create((arg) => arg.ToByteArray(), StreamingInputCallResponse.ParseFrom); - - readonly static Method emptyCallMethod = new Method( + static readonly Marshaller EmptyMarshaller = Marshallers.Create((arg) => arg.ToByteArray(), Empty.ParseFrom); + static readonly Marshaller SimpleRequestMarshaller = Marshallers.Create((arg) => arg.ToByteArray(), SimpleRequest.ParseFrom); + static readonly Marshaller SimpleResponseMarshaller = Marshallers.Create((arg) => arg.ToByteArray(), SimpleResponse.ParseFrom); + static readonly Marshaller StreamingOutputCallRequestMarshaller = Marshallers.Create((arg) => arg.ToByteArray(), StreamingOutputCallRequest.ParseFrom); + static readonly Marshaller StreamingOutputCallResponseMarshaller = Marshallers.Create((arg) => arg.ToByteArray(), StreamingOutputCallResponse.ParseFrom); + static readonly Marshaller StreamingInputCallRequestMarshaller = Marshallers.Create((arg) => arg.ToByteArray(), StreamingInputCallRequest.ParseFrom); + static readonly Marshaller StreamingInputCallResponseMarshaller = Marshallers.Create((arg) => arg.ToByteArray(), StreamingInputCallResponse.ParseFrom); + + static readonly Method EmptyCallMethod = new Method( MethodType.Unary, "/grpc.testing.TestService/EmptyCall", - emptyMarshaller, - emptyMarshaller - ); - readonly static Method unaryCallMethod = new Method( + EmptyMarshaller, + EmptyMarshaller); + + static readonly Method UnaryCallMethod = new Method( MethodType.Unary, "/grpc.testing.TestService/UnaryCall", - simpleRequestMarshaller, - simpleResponseMarshaller - ); - readonly static Method streamingOutputCallMethod = new Method( + SimpleRequestMarshaller, + SimpleResponseMarshaller); + + static readonly Method StreamingOutputCallMethod = new Method( MethodType.ServerStreaming, "/grpc.testing.TestService/StreamingOutputCall", - streamingOutputCallRequestMarshaller, - streamingOutputCallResponseMarshaller - ); - readonly static Method streamingInputCallMethod = new Method( + StreamingOutputCallRequestMarshaller, + StreamingOutputCallResponseMarshaller); + + static readonly Method StreamingInputCallMethod = new Method( MethodType.ClientStreaming, "/grpc.testing.TestService/StreamingInputCall", - streamingInputCallRequestMarshaller, - streamingInputCallResponseMarshaller - ); - readonly static Method fullDuplexCallMethod = new Method( + StreamingInputCallRequestMarshaller, + StreamingInputCallResponseMarshaller); + + static readonly Method FullDuplexCallMethod = new Method( MethodType.DuplexStreaming, "/grpc.testing.TestService/FullDuplexCall", - streamingOutputCallRequestMarshaller, - streamingOutputCallResponseMarshaller - ); - readonly static Method halfDuplexCallMethod = new Method( + StreamingOutputCallRequestMarshaller, + StreamingOutputCallResponseMarshaller); + + static readonly Method HalfDuplexCallMethod = new Method( MethodType.DuplexStreaming, "/grpc.testing.TestService/HalfDuplexCall", - streamingOutputCallRequestMarshaller, - streamingOutputCallResponseMarshaller - ); + StreamingOutputCallRequestMarshaller, + StreamingOutputCallResponseMarshaller); public interface ITestServiceClient { @@ -119,49 +118,49 @@ public TestServiceClientStub(Channel channel) public Empty EmptyCall(Empty request, CancellationToken token = default(CancellationToken)) { - var call = new Grpc.Core.Call(emptyCallMethod, channel); + var call = new Grpc.Core.Call(EmptyCallMethod, channel); return Calls.BlockingUnaryCall(call, request, token); } public Task EmptyCallAsync(Empty request, CancellationToken token = default(CancellationToken)) { - var call = new Grpc.Core.Call(emptyCallMethod, channel); + var call = new Grpc.Core.Call(EmptyCallMethod, channel); return Calls.AsyncUnaryCall(call, request, token); } public SimpleResponse UnaryCall(SimpleRequest request, CancellationToken token = default(CancellationToken)) { - var call = new Grpc.Core.Call(unaryCallMethod, channel); + var call = new Grpc.Core.Call(UnaryCallMethod, channel); return Calls.BlockingUnaryCall(call, request, token); } public Task UnaryCallAsync(SimpleRequest request, CancellationToken token = default(CancellationToken)) { - var call = new Grpc.Core.Call(unaryCallMethod, channel); + var call = new Grpc.Core.Call(UnaryCallMethod, channel); return Calls.AsyncUnaryCall(call, request, token); } - public void StreamingOutputCall(StreamingOutputCallRequest request, IObserver responseObserver, CancellationToken token = default(CancellationToken)) { - var call = new Grpc.Core.Call(streamingOutputCallMethod, channel); + public void StreamingOutputCall(StreamingOutputCallRequest request, IObserver responseObserver, CancellationToken token = default(CancellationToken)) + { + var call = new Grpc.Core.Call(StreamingOutputCallMethod, channel); Calls.AsyncServerStreamingCall(call, request, responseObserver, token); } public ClientStreamingAsyncResult StreamingInputCall(CancellationToken token = default(CancellationToken)) { - var call = new Grpc.Core.Call(streamingInputCallMethod, channel); + var call = new Grpc.Core.Call(StreamingInputCallMethod, channel); return Calls.AsyncClientStreamingCall(call, token); } public IObserver FullDuplexCall(IObserver responseObserver, CancellationToken token = default(CancellationToken)) { - var call = new Grpc.Core.Call(fullDuplexCallMethod, channel); + var call = new Grpc.Core.Call(FullDuplexCallMethod, channel); return Calls.DuplexStreamingCall(call, responseObserver, token); } - public IObserver HalfDuplexCall(IObserver responseObserver, CancellationToken token = default(CancellationToken)) { - var call = new Grpc.Core.Call(halfDuplexCallMethod, channel); + var call = new Grpc.Core.Call(HalfDuplexCallMethod, channel); return Calls.DuplexStreamingCall(call, responseObserver, token); } } @@ -185,12 +184,12 @@ public interface ITestService public static ServerServiceDefinition BindService(ITestService serviceImpl) { return ServerServiceDefinition.CreateBuilder("/grpc.testing.TestService/") - .AddMethod(emptyCallMethod, serviceImpl.EmptyCall) - .AddMethod(unaryCallMethod, serviceImpl.UnaryCall) - .AddMethod(streamingOutputCallMethod, serviceImpl.StreamingOutputCall) - .AddMethod(streamingInputCallMethod, serviceImpl.StreamingInputCall) - .AddMethod(fullDuplexCallMethod, serviceImpl.FullDuplexCall) - .AddMethod(halfDuplexCallMethod, serviceImpl.HalfDuplexCall) + .AddMethod(EmptyCallMethod, serviceImpl.EmptyCall) + .AddMethod(UnaryCallMethod, serviceImpl.UnaryCall) + .AddMethod(StreamingOutputCallMethod, serviceImpl.StreamingOutputCall) + .AddMethod(StreamingInputCallMethod, serviceImpl.StreamingInputCall) + .AddMethod(FullDuplexCallMethod, serviceImpl.FullDuplexCall) + .AddMethod(HalfDuplexCallMethod, serviceImpl.HalfDuplexCall) .Build(); } diff --git a/src/csharp/Settings.StyleCop b/src/csharp/Settings.StyleCop index 094d93f1bb5bc..2ecf22f69e946 100644 --- a/src/csharp/Settings.StyleCop +++ b/src/csharp/Settings.StyleCop @@ -1,7 +1,4 @@ - - NoMerge -