diff --git a/src/csharp/Grpc.Core.Tests/ClientServerTest.cs b/src/csharp/Grpc.Core.Tests/ClientServerTest.cs index 39be35c21906ec582e10f533101fc36a89515a94..e73159b35073ca4eaefc519c613a8bf92adb525a 100644 --- a/src/csharp/Grpc.Core.Tests/ClientServerTest.cs +++ b/src/csharp/Grpc.Core.Tests/ClientServerTest.cs @@ -122,10 +122,13 @@ namespace Grpc.Core.Tests { var call = new Call<string, string>(unaryEchoStringMethod, channel); - try { + try + { Calls.BlockingUnaryCall(call, "ABC", default(CancellationToken)); Assert.Fail(); - } catch(RpcException e) { + } + catch (RpcException e) + { Assert.AreEqual(StatusCode.Unimplemented, e.Status.StatusCode); } } @@ -140,4 +143,3 @@ namespace Grpc.Core.Tests } } } - diff --git a/src/csharp/Grpc.Core.Tests/GrpcEnvironmentTest.cs b/src/csharp/Grpc.Core.Tests/GrpcEnvironmentTest.cs index 596918c231c0115164a0e95ae25fb4bfa706aabd..6a132a5b224c1b9948eb4e42a8f95742e5da6a92 100644 --- a/src/csharp/Grpc.Core.Tests/GrpcEnvironmentTest.cs +++ b/src/csharp/Grpc.Core.Tests/GrpcEnvironmentTest.cs @@ -68,7 +68,7 @@ namespace Grpc.Core.Tests var tp2 = GrpcEnvironment.ThreadPool; GrpcEnvironment.Shutdown(); - Assert.IsFalse(Object.ReferenceEquals(tp1, tp2)); + Assert.IsFalse(object.ReferenceEquals(tp1, tp2)); } } } diff --git a/src/csharp/Grpc.Core.Tests/PInvokeTest.cs b/src/csharp/Grpc.Core.Tests/PInvokeTest.cs index 9db08d2f02f7ba5042a694cdd30ef065eedf1c9a..3beffc39559a86021e2d211da54c987c8a1d1ae2 100644 --- a/src/csharp/Grpc.Core.Tests/PInvokeTest.cs +++ b/src/csharp/Grpc.Core.Tests/PInvokeTest.cs @@ -33,13 +33,13 @@ using System; using System.Diagnostics; +using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; using Grpc.Core; using Grpc.Core.Internal; using Grpc.Core.Utils; using NUnit.Framework; -using System.Runtime.InteropServices; namespace Grpc.Core.Tests { @@ -73,14 +73,13 @@ namespace Grpc.Core.Tests { BenchmarkUtil.RunBenchmark( 100000, 1000000, - () => { + () => + { CompletionQueueSafeHandle cq = CompletionQueueSafeHandle.Create(); cq.Dispose(); - } - ); + }); } - /// <summary> /// Approximate results: /// (~80ns Mono Linux) @@ -94,10 +93,10 @@ namespace Grpc.Core.Tests counter = 0; BenchmarkUtil.RunBenchmark( 1000000, 10000000, - () => { + () => + { grpcsharp_test_callback(handler); - } - ); + }); Assert.AreNotEqual(0, counter); } @@ -113,10 +112,10 @@ namespace Grpc.Core.Tests counter = 0; BenchmarkUtil.RunBenchmark( 10000, 10000, - () => { - grpcsharp_test_callback(new CompletionCallbackDelegate(Handler)); - } - ); + () => + { + grpcsharp_test_callback(new CompletionCallbackDelegate(Handler)); + }); Assert.AreNotEqual(0, counter); } @@ -129,15 +128,15 @@ namespace Grpc.Core.Tests { BenchmarkUtil.RunBenchmark( 1000000, 100000000, - () => { + () => + { grpcsharp_test_nop(IntPtr.Zero); - } - ); + }); } - private void Handler(GRPCOpError op, IntPtr ptr) { - counter ++; + private void Handler(GRPCOpError op, IntPtr ptr) + { + counter++; } } } - diff --git a/src/csharp/Grpc.Core.Tests/Properties/AssemblyInfo.cs b/src/csharp/Grpc.Core.Tests/Properties/AssemblyInfo.cs index 499d931d2acf15cc93ef0d4c6534ad0982fa80c3..e4328806ad4c67c0f2c868afa0969c09b0608d4d 100644 --- a/src/csharp/Grpc.Core.Tests/Properties/AssemblyInfo.cs +++ b/src/csharp/Grpc.Core.Tests/Properties/AssemblyInfo.cs @@ -1,8 +1,6 @@ using System.Reflection; using System.Runtime.CompilerServices; -// Information about this assembly is defined by the following attributes. -// Change them to the values specific to your project. [assembly: AssemblyTitle("Grpc.Core.Tests")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] @@ -11,12 +9,4 @@ using System.Runtime.CompilerServices; [assembly: AssemblyCopyright("Google Inc. All rights reserved.")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". -// The form "{Major}.{Minor}.*" will automatically update the build and revision, -// and "{Major}.{Minor}.{Build}.*" will update just the revision. [assembly: AssemblyVersion("0.1.*")] -// The following attributes are used to specify the signing key for the assembly, -// if desired. See the Mono documentation for more information about signing. -//[assembly: AssemblyDelaySign(false)] -//[assembly: AssemblyKeyFile("")] - diff --git a/src/csharp/Grpc.Core.Tests/ServerTest.cs b/src/csharp/Grpc.Core.Tests/ServerTest.cs index dd30366f6a1286684783b72848121238739f8d45..12f914bfad1bfcb77e5bfb3332eaba773a0f0fcb 100644 --- a/src/csharp/Grpc.Core.Tests/ServerTest.cs +++ b/src/csharp/Grpc.Core.Tests/ServerTest.cs @@ -53,6 +53,5 @@ namespace Grpc.Core.Tests GrpcEnvironment.Shutdown(); } - } } diff --git a/src/csharp/Grpc.Core.Tests/TimespecTest.cs b/src/csharp/Grpc.Core.Tests/TimespecTest.cs index 0ca84ec44bfcdf38dec68e4c5dc360997fc96c06..f5bae6d93552c670bf4f919dd654d2c2eecd480d 100644 --- a/src/csharp/Grpc.Core.Tests/TimespecTest.cs +++ b/src/csharp/Grpc.Core.Tests/TimespecTest.cs @@ -86,4 +86,3 @@ namespace Grpc.Core.Internal.Tests } } } - diff --git a/src/csharp/Grpc.Core/Call.cs b/src/csharp/Grpc.Core/Call.cs index 72dca688952ccd78fd87ae329c3c5dbc43808bda..d84d5940c288c552b1201361084c71f846bead79 100644 --- a/src/csharp/Grpc.Core/Call.cs +++ b/src/csharp/Grpc.Core/Call.cs @@ -47,7 +47,8 @@ namespace Grpc.Core Func<TRequest, byte[]> requestSerializer, Func<byte[], TResponse> responseDeserializer, TimeSpan timeout, - Channel channel) { + Channel channel) + { this.methodName = methodName; this.requestSerializer = requestSerializer; this.responseDeserializer = responseDeserializer; @@ -95,4 +96,3 @@ namespace Grpc.Core } } } - diff --git a/src/csharp/Grpc.Core/Calls.cs b/src/csharp/Grpc.Core/Calls.cs index ee2208e5c255768715cca2f2045f17d37a060bcc..5409ce32bcf4abacbe062bdb336b6f56595cc6bb 100644 --- a/src/csharp/Grpc.Core/Calls.cs +++ b/src/csharp/Grpc.Core/Calls.cs @@ -89,9 +89,9 @@ namespace Grpc.Core return new ClientStreamingInputObserver<TRequest, TResponse>(asyncCall); } - private static CompletionQueueSafeHandle GetCompletionQueue() { + private static CompletionQueueSafeHandle GetCompletionQueue() + { return GrpcEnvironment.ThreadPool.CompletionQueue; } } } - diff --git a/src/csharp/Grpc.Core/Channel.cs b/src/csharp/Grpc.Core/Channel.cs index 83d965debf12a097874e97f026195f91e5605a01..5a47961997191cb734546a0182f46da103ec7330 100644 --- a/src/csharp/Grpc.Core/Channel.cs +++ b/src/csharp/Grpc.Core/Channel.cs @@ -39,7 +39,7 @@ namespace Grpc.Core public class Channel : IDisposable { readonly ChannelSafeHandle handle; - readonly String target; + readonly string target; /// <summary> /// Creates a channel. diff --git a/src/csharp/Grpc.Core/ChannelArgs.cs b/src/csharp/Grpc.Core/ChannelArgs.cs index 298b6edf2066f78e031ea6ca990a10bd47961364..2d560c07b8266fa1fc53f1c539289ae10564231b 100644 --- a/src/csharp/Grpc.Core/ChannelArgs.cs +++ b/src/csharp/Grpc.Core/ChannelArgs.cs @@ -44,7 +44,7 @@ namespace Grpc.Core public class Builder { - Dictionary<string,string> stringArgs = new Dictionary<string,string>(); + Dictionary<string, string> stringArgs = new Dictionary<string, string>(); // TODO: AddInteger not supported yet. public Builder AddString(string key, string value) { @@ -58,7 +58,7 @@ namespace Grpc.Core } } - Dictionary<string,string> stringArgs; + Dictionary<string, string> stringArgs; private ChannelArgs(Dictionary<string, string> stringArgs) { diff --git a/src/csharp/Grpc.Core/ClientStreamingAsyncResult.cs b/src/csharp/Grpc.Core/ClientStreamingAsyncResult.cs index 44580a115424110c78adc13ca11618b54320727c..65bedb0a33f6a96234acf8d0aa6600caae5cd1bd 100644 --- a/src/csharp/Grpc.Core/ClientStreamingAsyncResult.cs +++ b/src/csharp/Grpc.Core/ClientStreamingAsyncResult.cs @@ -67,4 +67,3 @@ namespace Grpc.Core } } } - diff --git a/src/csharp/Grpc.Core/Credentials.cs b/src/csharp/Grpc.Core/Credentials.cs index 5116c277f72a6880abb56a142b5876c1e16c9914..ddf9d6dcd33797b42d36369cd35a86d0bc9f3fe4 100644 --- a/src/csharp/Grpc.Core/Credentials.cs +++ b/src/csharp/Grpc.Core/Credentials.cs @@ -74,4 +74,3 @@ namespace Grpc.Core } } } - diff --git a/src/csharp/Grpc.Core/GrpcEnvironment.cs b/src/csharp/Grpc.Core/GrpcEnvironment.cs index d3a8da4729e3ff3f69c29d03b9d068828d4cf466..9c10a42e23509012574f9fa9815b1b68a1d22bb6 100644 --- a/src/csharp/Grpc.Core/GrpcEnvironment.cs +++ b/src/csharp/Grpc.Core/GrpcEnvironment.cs @@ -63,8 +63,9 @@ namespace Grpc.Core /// lifetime (and call Shutdown once you're done), for the sake of easier testing it's /// allowed to initialize the environment again after it has been successfully shutdown. /// </summary> - public static void Initialize() { - lock(staticLock) + public static void Initialize() + { + lock (staticLock) { if (instance == null) { @@ -79,7 +80,7 @@ namespace Grpc.Core /// </summary> public static void Shutdown() { - lock(staticLock) + lock (staticLock) { if (instance != null) { @@ -133,4 +134,3 @@ namespace Grpc.Core } } } - diff --git a/src/csharp/Grpc.Core/Internal/AsyncCall.cs b/src/csharp/Grpc.Core/Internal/AsyncCall.cs index 5ae036298b00c16f032dc6832f1ba7bf91b76d7f..04fc28d988a669d4f847c0ae08b1adb564df92a2 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCall.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCall.cs @@ -54,7 +54,7 @@ namespace Grpc.Core.Internal TaskCompletionSource<TResponse> unaryResponseTcs; // Set after status is received. Only used for streaming response calls. - Nullable<Status> finishedStatus; + Status? finishedStatus; bool readObserverCompleted; // True if readObserver has already been completed. @@ -64,7 +64,7 @@ namespace Grpc.Core.Internal this.finishedHandler = CreateBatchCompletionCallback(HandleFinished); } - public void Initialize(Channel channel, CompletionQueueSafeHandle cq, String methodName) + public void Initialize(Channel channel, CompletionQueueSafeHandle cq, string methodName) { var call = CallSafeHandle.Create(channel.Handle, cq, methodName, channel.Target, Timespec.InfFuture); InitializeInternal(call); @@ -77,9 +77,9 @@ namespace Grpc.Core.Internal /// <summary> /// Blocking unary request - unary response call. /// </summary> - public TResponse UnaryCall(Channel channel, String methodName, TRequest msg) + public TResponse UnaryCall(Channel channel, string methodName, TRequest msg) { - using(CompletionQueueSafeHandle cq = CompletionQueueSafeHandle.Create()) + using (CompletionQueueSafeHandle cq = CompletionQueueSafeHandle.Create()) { byte[] payload = UnsafeSerialize(msg); @@ -254,7 +254,7 @@ namespace Grpc.Core.Internal /// </summary> private void HandleUnaryResponse(bool wasError, BatchContextSafeHandleNotOwned ctx) { - lock(myLock) + lock (myLock) { finished = true; halfclosed = true; @@ -264,9 +264,7 @@ namespace Grpc.Core.Internal if (wasError) { - unaryResponseTcs.SetException(new RpcException( - new Status(StatusCode.Internal, "Internal error occured.") - )); + unaryResponseTcs.SetException(new RpcException(new Status(StatusCode.Internal, "Internal error occured."))); return; } diff --git a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs index 44d66b394ca6929bc1fea07c0bf85e0de5e0fcf7..15b0cfe2495705346a8ec4cfacc651ae3d5aab7b 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs @@ -225,7 +225,7 @@ namespace Grpc.Core.Internal payload = serializer(msg); return true; } - catch(Exception) + catch (Exception) { Console.WriteLine("Exception occured while trying to serialize message"); payload = null; @@ -240,7 +240,7 @@ namespace Grpc.Core.Internal msg = deserializer(payload); return true; } - catch(Exception) + catch (Exception) { Console.WriteLine("Exception occured while trying to deserialize message"); msg = default(TRead); @@ -254,7 +254,7 @@ namespace Grpc.Core.Internal { readObserver.OnNext(value); } - catch(Exception e) + catch (Exception e) { Console.WriteLine("Exception occured while invoking readObserver.OnNext: " + e); } @@ -266,7 +266,7 @@ namespace Grpc.Core.Internal { readObserver.OnCompleted(); } - catch(Exception e) + catch (Exception e) { Console.WriteLine("Exception occured while invoking readObserver.OnCompleted: " + e); } @@ -278,7 +278,7 @@ namespace Grpc.Core.Internal { readObserver.OnError(error); } - catch(Exception e) + catch (Exception e) { Console.WriteLine("Exception occured while invoking readObserver.OnError: " + e); } @@ -290,7 +290,7 @@ namespace Grpc.Core.Internal { completionDelegate(error); } - catch(Exception e) + catch (Exception e) { Console.WriteLine("Exception occured while invoking completion delegate: " + e); } @@ -302,14 +302,15 @@ namespace Grpc.Core.Internal /// </summary> protected CompletionCallbackDelegate CreateBatchCompletionCallback(Action<bool, BatchContextSafeHandleNotOwned> handler) { - return new CompletionCallbackDelegate( (error, batchContextPtr) => { + return new CompletionCallbackDelegate((error, batchContextPtr) => + { try { var ctx = new BatchContextSafeHandleNotOwned(batchContextPtr); bool wasError = (error != GRPCOpError.GRPC_OP_OK); handler(wasError, ctx); } - catch(Exception e) + catch (Exception e) { Console.WriteLine("Caught exception in a native handler: " + e); } @@ -363,7 +364,6 @@ namespace Grpc.Core.Internal { FireCompletion(origCompletionDelegate, null); } - } /// <summary> diff --git a/src/csharp/Grpc.Core/Internal/AsyncCompletion.cs b/src/csharp/Grpc.Core/Internal/AsyncCompletion.cs index b78bb497fa71efdc0a01340f50bc990a8c454ecd..673b527fb20267fb910b322615fabfb368c977e6 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCompletion.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCompletion.cs @@ -91,5 +91,4 @@ namespace Grpc.Core.Internal tcs.SetException(error); } } - } \ No newline at end of file diff --git a/src/csharp/Grpc.Core/Internal/BatchContextSafeHandleNotOwned.cs b/src/csharp/Grpc.Core/Internal/BatchContextSafeHandleNotOwned.cs index 75cd30e1a2d5f463c1d0e3f4d47091815e142db5..3c54753756edbfae2b8a27319ea93b65d4dc2b0c 100644 --- a/src/csharp/Grpc.Core/Internal/BatchContextSafeHandleNotOwned.cs +++ b/src/csharp/Grpc.Core/Internal/BatchContextSafeHandleNotOwned.cs @@ -80,16 +80,18 @@ namespace Grpc.Core.Internal { return null; } - byte[] data = new byte[(int) len]; + byte[] data = new byte[(int)len]; grpcsharp_batch_context_recv_message_to_buffer(this, data, new UIntPtr((ulong)data.Length)); return data; } - public CallSafeHandle GetServerRpcNewCall() { + public CallSafeHandle GetServerRpcNewCall() + { return grpcsharp_batch_context_server_rpc_new_call(this); } - public string GetServerRpcNewMethod() { + public string GetServerRpcNewMethod() + { return Marshal.PtrToStringAnsi(grpcsharp_batch_context_server_rpc_new_method(this)); } } diff --git a/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs b/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs index 61566b54072bbb8ab11f9bde2240d4b3760bd0a9..a8cef4a68b1f154a8ff050ea9cbdc4c05d631109 100644 --- a/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs @@ -36,13 +36,14 @@ using Grpc.Core; namespace Grpc.Core.Internal { - internal delegate void CompletionCallbackDelegate(GRPCOpError error,IntPtr batchContextPtr); + internal delegate void CompletionCallbackDelegate(GRPCOpError error, IntPtr batchContextPtr); + /// <summary> /// grpc_call from <grpc/grpc.h> /// </summary> internal class CallSafeHandle : SafeHandleZeroIsInvalid { - const UInt32 GRPC_WRITE_BUFFER_HINT = 1; + const uint GRPC_WRITE_BUFFER_HINT = 1; [DllImport("grpc_csharp_ext.dll")] static extern CallSafeHandle grpcsharp_channel_create_call(ChannelSafeHandle channel, CompletionQueueSafeHandle cq, string method, string host, Timespec deadline); @@ -179,7 +180,7 @@ namespace Grpc.Core.Internal Trace.Assert(callError == GRPCCallError.GRPC_CALL_OK, "Status not GRPC_CALL_OK"); } - private static UInt32 GetFlags(bool buffered) + private static uint GetFlags(bool buffered) { return buffered ? 0 : GRPC_WRITE_BUFFER_HINT; } diff --git a/src/csharp/Grpc.Core/Internal/ChannelArgsSafeHandle.cs b/src/csharp/Grpc.Core/Internal/ChannelArgsSafeHandle.cs index ca3c21d84ce83261ca76f8cc941d5d5c05730e71..c69f1a0d0255b5a449ab9f8e2edff29f9c2206c4 100644 --- a/src/csharp/Grpc.Core/Internal/ChannelArgsSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/ChannelArgsSafeHandle.cs @@ -74,4 +74,3 @@ namespace Grpc.Core.Internal } } } - diff --git a/src/csharp/Grpc.Core/Internal/CompletionQueueSafeHandle.cs b/src/csharp/Grpc.Core/Internal/CompletionQueueSafeHandle.cs index 6bff923c55229166189b497d666b797436dc5d3b..600d1fc87c00bb455b1020d52794d3d26fc93bdf 100644 --- a/src/csharp/Grpc.Core/Internal/CompletionQueueSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/CompletionQueueSafeHandle.cs @@ -77,4 +77,3 @@ namespace Grpc.Core.Internal } } } - diff --git a/src/csharp/Grpc.Core/Internal/Enums.cs b/src/csharp/Grpc.Core/Internal/Enums.cs index f363050b07e592583d0e34e681e367c54c4feb25..94a2fd1784f97b30345a4f3f780428e6de2a178a 100644 --- a/src/csharp/Grpc.Core/Internal/Enums.cs +++ b/src/csharp/Grpc.Core/Internal/Enums.cs @@ -112,4 +112,3 @@ namespace Grpc.Core.Internal GRPC_OP_ERROR } } - diff --git a/src/csharp/Grpc.Core/Internal/GrpcLog.cs b/src/csharp/Grpc.Core/Internal/GrpcLog.cs index 98768d05c6db83f9fda9f23d61624adc35bfaa00..2f3c8ad71c1f850c24f1b2b9ec416dda408378d7 100644 --- a/src/csharp/Grpc.Core/Internal/GrpcLog.cs +++ b/src/csharp/Grpc.Core/Internal/GrpcLog.cs @@ -40,7 +40,7 @@ using System.Threading; namespace Grpc.Core.Internal { - internal delegate void GprLogDelegate(IntPtr fileStringPtr, Int32 line, UInt64 threadId, IntPtr severityStringPtr, IntPtr msgPtr); + internal delegate void GprLogDelegate(IntPtr fileStringPtr, int line, ulong threadId, IntPtr severityStringPtr, IntPtr msgPtr); /// <summary> /// Logs from gRPC C core library can get lost if your application is not a console app. @@ -73,7 +73,7 @@ namespace Grpc.Core.Internal } } - private static void HandleWrite(IntPtr fileStringPtr, Int32 line, UInt64 threadId, IntPtr severityStringPtr, IntPtr msgPtr) + private static void HandleWrite(IntPtr fileStringPtr, int line, ulong threadId, IntPtr severityStringPtr, IntPtr msgPtr) { try { diff --git a/src/csharp/Grpc.Core/Internal/GrpcThreadPool.cs b/src/csharp/Grpc.Core/Internal/GrpcThreadPool.cs index 9e69fe2f43090a51c4ef1f1b430f2c56050cd27e..f4224668f1eaa3550b7799a04b1cc47f1f668dc2 100644 --- a/src/csharp/Grpc.Core/Internal/GrpcThreadPool.cs +++ b/src/csharp/Grpc.Core/Internal/GrpcThreadPool.cs @@ -51,12 +51,13 @@ namespace Grpc.Core.Internal CompletionQueueSafeHandle cq; - public GrpcThreadPool(int poolSize) { + public GrpcThreadPool(int poolSize) + { this.poolSize = poolSize; } - public void Start() { - + public void Start() + { lock (myLock) { if (cq != null) @@ -73,8 +74,8 @@ namespace Grpc.Core.Internal } } - public void Stop() { - + public void Stop() + { lock (myLock) { cq.Shutdown(); @@ -86,7 +87,6 @@ namespace Grpc.Core.Internal } cq.Dispose(); - } } @@ -116,10 +116,9 @@ namespace Grpc.Core.Internal do { completionType = cq.NextWithCallback(); - } while(completionType != GRPCCompletionType.GRPC_QUEUE_SHUTDOWN); + } + while (completionType != GRPCCompletionType.GRPC_QUEUE_SHUTDOWN); Console.WriteLine("Completion queue has shutdown successfully, thread " + Thread.CurrentThread.Name + " exiting."); } } - } - diff --git a/src/csharp/Grpc.Core/Internal/SafeHandleZeroIsInvalid.cs b/src/csharp/Grpc.Core/Internal/SafeHandleZeroIsInvalid.cs index aa6fce2e969ec4dc097fc07d0e6dc5c5491a9e4d..702aea2883ad828c6f0b8e6675bb2b0c56522f92 100644 --- a/src/csharp/Grpc.Core/Internal/SafeHandleZeroIsInvalid.cs +++ b/src/csharp/Grpc.Core/Internal/SafeHandleZeroIsInvalid.cs @@ -64,4 +64,3 @@ namespace Grpc.Core.Internal } } } - diff --git a/src/csharp/Grpc.Core/Internal/ServerSafeHandle.cs b/src/csharp/Grpc.Core/Internal/ServerSafeHandle.cs index b5a5ae4976275f427599b64af39a5229deae381a..dc4781e7966b86ecf6e1d7fa29dc72c7b156a27b 100644 --- a/src/csharp/Grpc.Core/Internal/ServerSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/ServerSafeHandle.cs @@ -53,10 +53,10 @@ namespace Grpc.Core.Internal static extern ServerSafeHandle grpcsharp_server_create(CompletionQueueSafeHandle cq, IntPtr args); [DllImport("grpc_csharp_ext.dll")] - static extern Int32 grpcsharp_server_add_http2_port(ServerSafeHandle server, string addr); + static extern int grpcsharp_server_add_http2_port(ServerSafeHandle server, string addr); [DllImport("grpc_csharp_ext.dll")] - static extern Int32 grpcsharp_server_add_secure_http2_port(ServerSafeHandle server, string addr, ServerCredentialsSafeHandle creds); + static extern int grpcsharp_server_add_secure_http2_port(ServerSafeHandle server, string addr, ServerCredentialsSafeHandle creds); [DllImport("grpc_csharp_ext.dll")] static extern void grpcsharp_server_start(ServerSafeHandle server); diff --git a/src/csharp/Grpc.Core/Internal/ServerStreamingOutputObserver.cs b/src/csharp/Grpc.Core/Internal/ServerStreamingOutputObserver.cs index 9873dc9c71077b0d8650199e288e743f8f348896..97b62d05692046bc826cfbda7a21a8c9bb436e52 100644 --- a/src/csharp/Grpc.Core/Internal/ServerStreamingOutputObserver.cs +++ b/src/csharp/Grpc.Core/Internal/ServerStreamingOutputObserver.cs @@ -69,4 +69,3 @@ namespace Grpc.Core.Internal } } } - diff --git a/src/csharp/Grpc.Core/Internal/Timespec.cs b/src/csharp/Grpc.Core/Internal/Timespec.cs index e6efd66f13b9eb717d573f4469927d56c749d9f7..94d48c2c49ca6d55186fd7a405c8ca65fc95718f 100644 --- a/src/csharp/Grpc.Core/Internal/Timespec.cs +++ b/src/csharp/Grpc.Core/Internal/Timespec.cs @@ -40,8 +40,8 @@ namespace Grpc.Core.Internal [StructLayout(LayoutKind.Sequential)] internal struct Timespec { - const int nanosPerSecond = 1000 * 1000 * 1000; - const int nanosPerTick = 100; + const int NanosPerSecond = 1000 * 1000 * 1000; + const int NanosPerTick = 100; [DllImport("grpc_csharp_ext.dll")] static extern Timespec gprsharp_now(); @@ -99,14 +99,13 @@ namespace Grpc.Core.Internal public Timespec Add(TimeSpan timeSpan) { - long nanos = tv_nsec.ToInt64() + (timeSpan.Ticks % TimeSpan.TicksPerSecond) * nanosPerTick; - long overflow_sec = (nanos > nanosPerSecond) ? 1 : 0; + long nanos = tv_nsec.ToInt64() + (timeSpan.Ticks % TimeSpan.TicksPerSecond) * NanosPerTick; + long overflow_sec = (nanos > NanosPerSecond) ? 1 : 0; Timespec result; - result.tv_nsec = new IntPtr(nanos % nanosPerSecond); + result.tv_nsec = new IntPtr(nanos % NanosPerSecond); result.tv_sec = new IntPtr(tv_sec.ToInt64() + (timeSpan.Ticks / TimeSpan.TicksPerSecond) + overflow_sec); return result; } } } - diff --git a/src/csharp/Grpc.Core/Marshaller.cs b/src/csharp/Grpc.Core/Marshaller.cs index 602e0eb8240f4e3e7b258d3f1e370fe35ee437bc..9c9dfa4bc9b64a4df8133b63d51be858c19ac478 100644 --- a/src/csharp/Grpc.Core/Marshaller.cs +++ b/src/csharp/Grpc.Core/Marshaller.cs @@ -40,8 +40,8 @@ namespace Grpc.Core /// </summary> public struct Marshaller<T> { - readonly Func<T,byte[]> serializer; - readonly Func<byte[],T> deserializer; + readonly Func<T, byte[]> serializer; + readonly Func<byte[], T> deserializer; public Marshaller(Func<T, byte[]> serializer, Func<byte[], T> deserializer) { @@ -66,9 +66,9 @@ namespace Grpc.Core } } - public static class Marshallers { - - public static Marshaller<T> Create<T>(Func<T,byte[]> serializer, Func<byte[],T> deserializer) + public static class Marshallers + { + public static Marshaller<T> Create<T>(Func<T, byte[]> serializer, Func<byte[], T> deserializer) { return new Marshaller<T>(serializer, deserializer); } @@ -81,7 +81,5 @@ namespace Grpc.Core System.Text.Encoding.UTF8.GetString); } } - } } - diff --git a/src/csharp/Grpc.Core/Method.cs b/src/csharp/Grpc.Core/Method.cs index c94aa8161fe7fb7aa2deb488ce003c88ce937d1c..4f97eeef37f1fb77b7fcb5bff71bebdce779faf0 100644 --- a/src/csharp/Grpc.Core/Method.cs +++ b/src/csharp/Grpc.Core/Method.cs @@ -94,4 +94,3 @@ namespace Grpc.Core } } } - diff --git a/src/csharp/Grpc.Core/OperationFailedException.cs b/src/csharp/Grpc.Core/OperationFailedException.cs index 34a8c95a85c3790f49582bdcd0e1d627e837a4c7..9b1c24d0c1646caa9e8a01b83d10daadeff5813b 100644 --- a/src/csharp/Grpc.Core/OperationFailedException.cs +++ b/src/csharp/Grpc.Core/OperationFailedException.cs @@ -45,4 +45,3 @@ namespace Grpc.Core } } } - diff --git a/src/csharp/Grpc.Core/Properties/AssemblyInfo.cs b/src/csharp/Grpc.Core/Properties/AssemblyInfo.cs index 37ba1e2263c3f09c378262ab4b6a45c3f36baad3..168939cf8c5c54ea07e6a7e702ed8ac9684210d1 100644 --- a/src/csharp/Grpc.Core/Properties/AssemblyInfo.cs +++ b/src/csharp/Grpc.Core/Properties/AssemblyInfo.cs @@ -1,24 +1,14 @@ using System.Reflection; using System.Runtime.CompilerServices; -// Information about this assembly is defined by the following attributes. -// Change them to the values specific to your project. -[assembly: AssemblyTitle ("Grpc.Core")] -[assembly: AssemblyDescription ("")] -[assembly: AssemblyConfiguration ("")] -[assembly: AssemblyCompany ("")] -[assembly: AssemblyProduct ("")] -[assembly: AssemblyCopyright ("Google Inc. All rights reserved.")] -[assembly: AssemblyTrademark ("")] -[assembly: AssemblyCulture ("")] -// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". -// The form "{Major}.{Minor}.*" will automatically update the build and revision, -// and "{Major}.{Minor}.{Build}.*" will update just the revision. -[assembly: AssemblyVersion ("0.1.*")] -// The following attributes are used to specify the signing key for the assembly, -// if desired. See the Mono documentation for more information about signing. -//[assembly: AssemblyDelaySign(false)] -//[assembly: AssemblyKeyFile("")] +[assembly: AssemblyTitle("Grpc.Core")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("Google Inc. All rights reserved.")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: AssemblyVersion("0.1.*")] [assembly: InternalsVisibleTo("Grpc.Core.Tests")] - diff --git a/src/csharp/Grpc.Core/RpcException.cs b/src/csharp/Grpc.Core/RpcException.cs index e1cf64ca56af8a50a2bf6fbe0d2825bc654f9a4e..0356bf7b4a99c26c58a502b600beed66d3e70d30 100644 --- a/src/csharp/Grpc.Core/RpcException.cs +++ b/src/csharp/Grpc.Core/RpcException.cs @@ -58,4 +58,3 @@ namespace Grpc.Core } } } - diff --git a/src/csharp/Grpc.Core/Server.cs b/src/csharp/Grpc.Core/Server.cs index cafdb3b6637bb2614c5a401ad8731e6bd1d830fa..2439cdb6dc3c9d4752530fbfa66dda779ad6a080 100644 --- a/src/csharp/Grpc.Core/Server.cs +++ b/src/csharp/Grpc.Core/Server.cs @@ -67,8 +67,9 @@ namespace Grpc.Core } // only call this before Start() - public void AddServiceDefinition(ServerServiceDefinition serviceDefinition) { - foreach(var entry in serviceDefinition.CallHandlers) + public void AddServiceDefinition(ServerServiceDefinition serviceDefinition) + { + foreach (var entry in serviceDefinition.CallHandlers) { callHandlers.Add(entry.Key, entry.Value); } @@ -108,7 +109,7 @@ namespace Grpc.Core { var rpcInfo = newRpcQueue.Take(); - //Console.WriteLine("Server received RPC " + rpcInfo.Method); + // Console.WriteLine("Server received RPC " + rpcInfo.Method); IServerCallHandler callHandler; if (!callHandlers.TryGetValue(rpcInfo.Method, out callHandler)) @@ -117,7 +118,7 @@ namespace Grpc.Core } callHandler.StartCall(rpcInfo.Method, rpcInfo.Call, GetCompletionQueue()); } - catch(Exception e) + catch (Exception e) { Console.WriteLine("Exception while handling RPC: " + e); } @@ -128,7 +129,8 @@ namespace Grpc.Core /// cleans up used resources. /// </summary> /// <returns>The async.</returns> - public async Task ShutdownAsync() { + public async Task ShutdownAsync() + { handle.ShutdownAndNotify(serverShutdownHandler); await shutdownTcs.Task; handle.Dispose(); @@ -145,11 +147,13 @@ namespace Grpc.Core } } - public void Kill() { + public void Kill() + { handle.Dispose(); } - private async Task StartHandlingRpcs() { + private async Task StartHandlingRpcs() + { while (true) { await Task.Factory.StartNew(RunRpc); @@ -161,22 +165,27 @@ namespace Grpc.Core AssertCallOk(handle.RequestCall(GetCompletionQueue(), newServerRpcHandler)); } - private void HandleNewServerRpc(GRPCOpError error, IntPtr batchContextPtr) { - try { + private void HandleNewServerRpc(GRPCOpError error, IntPtr batchContextPtr) + { + try + { var ctx = new BatchContextSafeHandleNotOwned(batchContextPtr); - if (error != GRPCOpError.GRPC_OP_OK) { + if (error != GRPCOpError.GRPC_OP_OK) + { // TODO: handle error } var rpcInfo = new NewRpcInfo(ctx.GetServerRpcNewCall(), ctx.GetServerRpcNewMethod()); // after server shutdown, the callback returns with null call - if (!rpcInfo.Call.IsInvalid) { + if (!rpcInfo.Call.IsInvalid) + { newRpcQueue.Add(rpcInfo); } - - } catch(Exception e) { + } + catch (Exception e) + { Console.WriteLine("Caught exception in a native handler: " + e); } } diff --git a/src/csharp/Grpc.Core/ServerCallHandler.cs b/src/csharp/Grpc.Core/ServerCallHandler.cs index 3eb8422f575e3b4f745e03f13856c254d76de10b..c5598e5e99420312a7f24e42002473c692d96a46 100644 --- a/src/csharp/Grpc.Core/ServerCallHandler.cs +++ b/src/csharp/Grpc.Core/ServerCallHandler.cs @@ -70,7 +70,6 @@ namespace Grpc.Core handler(request, responseObserver); finishedTask.Wait(); - } } @@ -93,7 +92,7 @@ namespace Grpc.Core asyncCall.Initialize(call); - var responseObserver = new ServerStreamingOutputObserver<TRequest,TResponse>(asyncCall); + var responseObserver = new ServerStreamingOutputObserver<TRequest, TResponse>(asyncCall); var requestObserver = handler(responseObserver); var finishedTask = asyncCall.ServerSideCallAsync(requestObserver); finishedTask.Wait(); @@ -113,7 +112,7 @@ namespace Grpc.Core var finishedTask = asyncCall.ServerSideCallAsync(new NullObserver<byte[]>()); // TODO: check result of the completion status. - asyncCall.StartSendStatusFromServer(new Status(StatusCode.Unimplemented, "No such method."), new AsyncCompletionDelegate((error) => {})); + asyncCall.StartSendStatusFromServer(new Status(StatusCode.Unimplemented, "No such method."), new AsyncCompletionDelegate((error) => { })); finishedTask.Wait(); } @@ -132,7 +131,5 @@ namespace Grpc.Core public void OnNext(T value) { } - } } - diff --git a/src/csharp/Grpc.Core/ServerCalls.cs b/src/csharp/Grpc.Core/ServerCalls.cs index bed77796de10e7bedc3962326660d0eabd45afcf..b2dcdf24f6b989de96f44ee37331bd719aec5128 100644 --- a/src/csharp/Grpc.Core/ServerCalls.cs +++ b/src/csharp/Grpc.Core/ServerCalls.cs @@ -37,12 +37,12 @@ namespace Grpc.Core { // TODO: perhaps add also serverSideStreaming and clientSideStreaming - public delegate void UnaryRequestServerMethod<TRequest, TResponse> (TRequest request, IObserver<TResponse> responseObserver); + public delegate void UnaryRequestServerMethod<TRequest, TResponse>(TRequest request, IObserver<TResponse> responseObserver); - public delegate IObserver<TRequest> StreamingRequestServerMethod<TRequest, TResponse> (IObserver<TResponse> responseObserver); - - internal static class ServerCalls { + public delegate IObserver<TRequest> StreamingRequestServerMethod<TRequest, TResponse>(IObserver<TResponse> responseObserver); + internal static class ServerCalls + { public static IServerCallHandler UnaryRequestCall<TRequest, TResponse>(Method<TRequest, TResponse> method, UnaryRequestServerMethod<TRequest, TResponse> handler) { return new UnaryRequestServerCallHandler<TRequest, TResponse>(method, handler); @@ -52,7 +52,5 @@ namespace Grpc.Core { return new StreamingRequestServerCallHandler<TRequest, TResponse>(method, handler); } - } } - diff --git a/src/csharp/Grpc.Core/ServerCredentials.cs b/src/csharp/Grpc.Core/ServerCredentials.cs index 1372e61fa71990bb7f1160831877001ec621743c..59c341ef51f8ab0f1f4b9e6ceff5dfde6b077c52 100644 --- a/src/csharp/Grpc.Core/ServerCredentials.cs +++ b/src/csharp/Grpc.Core/ServerCredentials.cs @@ -104,4 +104,3 @@ namespace Grpc.Core } } } - diff --git a/src/csharp/Grpc.Core/ServerServiceDefinition.cs b/src/csharp/Grpc.Core/ServerServiceDefinition.cs index 231c37606205fca9aa2fa700c40422bb90bd0dc4..d7f69f3c9f3a9f7c908bd21a70df513d242a0ccd 100644 --- a/src/csharp/Grpc.Core/ServerServiceDefinition.cs +++ b/src/csharp/Grpc.Core/ServerServiceDefinition.cs @@ -56,8 +56,7 @@ namespace Grpc.Core } } - - public static Builder CreateBuilder(String serviceName) + public static Builder CreateBuilder(string serviceName) { return new Builder(serviceName); } @@ -65,7 +64,7 @@ namespace Grpc.Core public class Builder { readonly string serviceName; - readonly Dictionary<string, IServerCallHandler> callHandlers = new Dictionary<String, IServerCallHandler>(); + readonly Dictionary<string, IServerCallHandler> callHandlers = new Dictionary<string, IServerCallHandler>(); public Builder(string serviceName) { @@ -95,4 +94,3 @@ namespace Grpc.Core } } } - diff --git a/src/csharp/Grpc.Core/StatusCode.cs b/src/csharp/Grpc.Core/StatusCode.cs index 1987e52789a01e181bcb434c9373ba9b5c98ec11..111863a2a9c590fd5253a3315364ebb318773733 100644 --- a/src/csharp/Grpc.Core/StatusCode.cs +++ b/src/csharp/Grpc.Core/StatusCode.cs @@ -139,4 +139,3 @@ namespace Grpc.Core DataLoss = 15 } } - diff --git a/src/csharp/Grpc.Core/Utils/BenchmarkUtil.cs b/src/csharp/Grpc.Core/Utils/BenchmarkUtil.cs index 3f0dae84cf87eb26b6608b558c5c3b3d3af589e1..4180d989385ca2069d4cb72ed0d7acadcb54de01 100644 --- a/src/csharp/Grpc.Core/Utils/BenchmarkUtil.cs +++ b/src/csharp/Grpc.Core/Utils/BenchmarkUtil.cs @@ -32,10 +32,10 @@ #endregion using System; -using System.Threading.Tasks; -using System.Collections.Generic; using System.Collections.Concurrent; +using System.Collections.Generic; using System.Diagnostics; +using System.Threading.Tasks; namespace Grpc.Core.Utils { @@ -61,8 +61,7 @@ namespace Grpc.Core.Utils } stopwatch.Stop(); Console.WriteLine("Elapsed time: " + stopwatch.ElapsedMilliseconds + "ms"); - Console.WriteLine("Ops per second: " + (int) ((double) benchmarkIterations * 1000 / stopwatch.ElapsedMilliseconds)); + Console.WriteLine("Ops per second: " + (int)((double)benchmarkIterations * 1000 / stopwatch.ElapsedMilliseconds)); } } } - diff --git a/src/csharp/Grpc.Core/Utils/ExceptionHelper.cs b/src/csharp/Grpc.Core/Utils/ExceptionHelper.cs index 18702e1cc4257c75703de7b85b9cd3aa8b5f6025..c4d6bee05807437d2905804fbc793121119028c4 100644 --- a/src/csharp/Grpc.Core/Utils/ExceptionHelper.cs +++ b/src/csharp/Grpc.Core/Utils/ExceptionHelper.cs @@ -42,7 +42,8 @@ namespace Grpc.Core.Utils /// Otherwise, rethrows the original aggregate exception. /// Always throws, the exception return type is here only to make the. /// </summary> - public static Exception UnwrapRpcException(AggregateException ae) { + public static Exception UnwrapRpcException(AggregateException ae) + { foreach (var e in ae.InnerExceptions) { if (e is RpcException) @@ -54,4 +55,3 @@ namespace Grpc.Core.Utils } } } - diff --git a/src/csharp/Grpc.Core/Utils/Preconditions.cs b/src/csharp/Grpc.Core/Utils/Preconditions.cs index b17ce4211783701b6b4ab8d6e9fb84057fe0fc75..aeb5d210a79f286fa754b4e898df4e9a96cc62bf 100644 --- a/src/csharp/Grpc.Core/Utils/Preconditions.cs +++ b/src/csharp/Grpc.Core/Utils/Preconditions.cs @@ -32,10 +32,10 @@ #endregion using System; -using System.Threading.Tasks; -using System.Collections.Generic; using System.Collections.Concurrent; +using System.Collections.Generic; using System.Diagnostics; +using System.Threading.Tasks; namespace Grpc.Core.Utils { @@ -66,7 +66,7 @@ namespace Grpc.Core.Utils /// <summary> /// Throws NullReferenceException if reference is null. /// </summary> - public static T CheckNotNull<T> (T reference) + public static T CheckNotNull<T>(T reference) { if (reference == null) { @@ -78,7 +78,7 @@ namespace Grpc.Core.Utils /// <summary> /// Throws NullReferenceException with given message if reference is null. /// </summary> - public static T CheckNotNull<T> (T reference, string errorMessage) + public static T CheckNotNull<T>(T reference, string errorMessage) { if (reference == null) { @@ -110,4 +110,3 @@ namespace Grpc.Core.Utils } } } - diff --git a/src/csharp/Grpc.Core/Utils/RecordingObserver.cs b/src/csharp/Grpc.Core/Utils/RecordingObserver.cs index 99d2725b70eda679b4c0679eb5d40365c67279a2..7b43ab8ad5f20b9fedbd926187e49bfc9ecc1f52 100644 --- a/src/csharp/Grpc.Core/Utils/RecordingObserver.cs +++ b/src/csharp/Grpc.Core/Utils/RecordingObserver.cs @@ -57,9 +57,9 @@ namespace Grpc.Core.Utils data.Add(value); } - public Task<List<T>> ToList() { + public Task<List<T>> ToList() + { return tcs.Task; } } } - diff --git a/src/csharp/Grpc.Core/Utils/RecordingQueue.cs b/src/csharp/Grpc.Core/Utils/RecordingQueue.cs index 63992da6a95d8aa24ca72f5cf951ef7a87fe90ee..9749168af02731f0e02f1a497ece3371080eb4a6 100644 --- a/src/csharp/Grpc.Core/Utils/RecordingQueue.cs +++ b/src/csharp/Grpc.Core/Utils/RecordingQueue.cs @@ -32,9 +32,9 @@ #endregion using System; -using System.Threading.Tasks; -using System.Collections.Generic; using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Threading.Tasks; namespace Grpc.Core.Utils { @@ -81,4 +81,3 @@ namespace Grpc.Core.Utils } } } - diff --git a/src/csharp/Grpc.Examples.MathClient/Properties/AssemblyInfo.cs b/src/csharp/Grpc.Examples.MathClient/Properties/AssemblyInfo.cs index bdd7189db2f43ee1d04fbf153460ecc31b9d568f..11fc099a954c4b3054a327a9f2d78d85de381340 100644 --- a/src/csharp/Grpc.Examples.MathClient/Properties/AssemblyInfo.cs +++ b/src/csharp/Grpc.Examples.MathClient/Properties/AssemblyInfo.cs @@ -1,22 +1,12 @@ using System.Reflection; using System.Runtime.CompilerServices; -// Information about this assembly is defined by the following attributes. -// Change them to the values specific to your project. -[assembly: AssemblyTitle ("Grpc.Examples.MathClient")] -[assembly: AssemblyDescription ("")] -[assembly: AssemblyConfiguration ("")] -[assembly: AssemblyCompany ("")] -[assembly: AssemblyProduct ("")] -[assembly: AssemblyCopyright ("Google Inc. All rights reserved.")] -[assembly: AssemblyTrademark ("")] -[assembly: AssemblyCulture ("")] -// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". -// The form "{Major}.{Minor}.*" will automatically update the build and revision, -// and "{Major}.{Minor}.{Build}.*" will update just the revision. -[assembly: AssemblyVersion ("0.1.*")] -// The following attributes are used to specify the signing key for the assembly, -// if desired. See the Mono documentation for more information about signing. -//[assembly: AssemblyDelaySign(false)] -//[assembly: AssemblyKeyFile("")] - +[assembly: AssemblyTitle("Grpc.Examples.MathClient")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("Google Inc. All rights reserved.")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: AssemblyVersion("0.1.*")] diff --git a/src/csharp/Grpc.Examples.Tests/MathClientServerTests.cs b/src/csharp/Grpc.Examples.Tests/MathClientServerTests.cs index 767340d6f2b287a8af169eb07e6c7ce0c7c0aa50..c86da65af47bd23d2048d9e2ad82d32b63d90465 100644 --- a/src/csharp/Grpc.Examples.Tests/MathClientServerTests.cs +++ b/src/csharp/Grpc.Examples.Tests/MathClientServerTests.cs @@ -105,7 +105,7 @@ namespace math.Tests var recorder = new RecordingObserver<Num>(); client.Fib(new FibArgs.Builder { Limit = 6 }.Build(), recorder); - CollectionAssert.AreEqual(new List<long>{1, 1, 2, 3, 5, 8}, + CollectionAssert.AreEqual(new List<long> { 1, 1, 2, 3, 5, 8 }, recorder.ToList().Result.ConvertAll((n) => n.Num_)); } @@ -114,7 +114,8 @@ namespace math.Tests public void Sum() { var res = client.Sum(); - foreach (var num in new long[] { 10, 20, 30 }) { + foreach (var num in new long[] { 10, 20, 30 }) + { res.Inputs.OnNext(Num.CreateBuilder().SetNum_(num).Build()); } res.Inputs.OnCompleted(); @@ -125,7 +126,8 @@ namespace math.Tests [Test] public void DivMany() { - List<DivArgs> divArgsList = new List<DivArgs>{ + List<DivArgs> divArgsList = new List<DivArgs> + { new DivArgs.Builder { Dividend = 10, Divisor = 3 }.Build(), new DivArgs.Builder { Dividend = 100, Divisor = 21 }.Build(), new DivArgs.Builder { Dividend = 7, Divisor = 2 }.Build() @@ -142,9 +144,8 @@ namespace math.Tests var result = recorder.ToList().Result; - CollectionAssert.AreEqual(new long[] {3, 4, 3}, result.ConvertAll((divReply) => divReply.Quotient)); - CollectionAssert.AreEqual(new long[] {1, 16, 1}, result.ConvertAll((divReply) => divReply.Remainder)); + CollectionAssert.AreEqual(new long[] { 3, 4, 3 }, result.ConvertAll((divReply) => divReply.Quotient)); + CollectionAssert.AreEqual(new long[] { 1, 16, 1 }, result.ConvertAll((divReply) => divReply.Remainder)); } } } - diff --git a/src/csharp/Grpc.Examples.Tests/Properties/AssemblyInfo.cs b/src/csharp/Grpc.Examples.Tests/Properties/AssemblyInfo.cs index 44b075ac0a805161e1bd7c8138a7ae218dcfbbc7..43c7616ac3afc047aa92279b228e64487254cca9 100644 --- a/src/csharp/Grpc.Examples.Tests/Properties/AssemblyInfo.cs +++ b/src/csharp/Grpc.Examples.Tests/Properties/AssemblyInfo.cs @@ -1,8 +1,6 @@ using System.Reflection; using System.Runtime.CompilerServices; -// Information about this assembly is defined by the following attributes. -// Change them to the values specific to your project. [assembly: AssemblyTitle("Grpc.Examples.Tests")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] @@ -11,12 +9,4 @@ using System.Runtime.CompilerServices; [assembly: AssemblyCopyright("Google Inc. All rights reserved.")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". -// The form "{Major}.{Minor}.*" will automatically update the build and revision, -// and "{Major}.{Minor}.{Build}.*" will update just the revision. [assembly: AssemblyVersion("0.1.*")] -// The following attributes are used to specify the signing key for the assembly, -// if desired. See the Mono documentation for more information about signing. -//[assembly: AssemblyDelaySign(false)] -//[assembly: AssemblyKeyFile("")] - diff --git a/src/csharp/Grpc.Examples/MathExamples.cs b/src/csharp/Grpc.Examples/MathExamples.cs index 134270f6f76c8e20c367d132c9e5bffe009df3db..b8bb7eacbd0f3572ab9ec3aa5660dd0af6e9a613 100644 --- a/src/csharp/Grpc.Examples/MathExamples.cs +++ b/src/csharp/Grpc.Examples/MathExamples.cs @@ -71,7 +71,8 @@ namespace math public static void SumExample(MathGrpc.IMathServiceClient stub) { List<Num> numbers = new List<Num> - {new Num.Builder { Num_ = 1 }.Build(), + { + new Num.Builder { Num_ = 1 }.Build(), new Num.Builder { Num_ = 2 }.Build(), new Num.Builder { Num_ = 3 }.Build() }; @@ -110,24 +111,12 @@ namespace math public static void DependendRequestsExample(MathGrpc.IMathServiceClient stub) { var numberList = new List<Num> - { new Num.Builder{ Num_ = 1 }.Build(), - new Num.Builder{ Num_ = 2 }.Build(), new Num.Builder{ Num_ = 3 }.Build() + { + new Num.Builder { Num_ = 1 }.Build(), + new Num.Builder { Num_ = 2 }.Build(), new Num.Builder { Num_ = 3 }.Build() }; numberList.ToObservable(); - - //IObserver<Num> numbers; - //Task<Num> call = stub.Sum(out numbers); - //foreach (var num in numberList) - //{ - // numbers.OnNext(num); - //} - //numbers.OnCompleted(); - - //Num sum = call.Result; - - //DivReply result = stub.Div(new DivArgs.Builder { Dividend = sum.Num_, Divisor = numberList.Count }.Build()); } } } - diff --git a/src/csharp/Grpc.Examples/MathServiceImpl.cs b/src/csharp/Grpc.Examples/MathServiceImpl.cs index 76a08ce51865aba626f85f66a6f91dfc70afdb66..0b2357e0fade71eab84e6e23dede9b24b6e73ef7 100644 --- a/src/csharp/Grpc.Examples/MathServiceImpl.cs +++ b/src/csharp/Grpc.Examples/MathServiceImpl.cs @@ -73,8 +73,8 @@ namespace math public IObserver<Num> Sum(IObserver<Num> responseObserver) { var recorder = new RecordingObserver<Num>(); - Task.Factory.StartNew(() => { - + Task.Factory.StartNew(() => + { List<Num> inputs = recorder.ToList().Result; long sum = 0; @@ -104,7 +104,7 @@ namespace math static IEnumerable<Num> FibInternal(long n) { long a = 1; - yield return new Num.Builder { Num_=a }.Build(); + yield return new Num.Builder { Num_ = a }.Build(); long b = 1; for (long i = 0; i < n - 1; i++) @@ -112,12 +112,12 @@ namespace math long temp = a; a = b; b = temp + b; - yield return new Num.Builder { Num_=a }.Build(); + yield return new Num.Builder { Num_ = a }.Build(); } } - private class DivObserver : IObserver<DivArgs> { - + private class DivObserver : IObserver<DivArgs> + { readonly IObserver<DivReply> responseObserver; public DivObserver(IObserver<DivReply> responseObserver) @@ -142,4 +142,3 @@ namespace math } } } - diff --git a/src/csharp/Grpc.Examples/Properties/AssemblyInfo.cs b/src/csharp/Grpc.Examples/Properties/AssemblyInfo.cs index 7603db7ffd135be4ee2b10adcbf928bc30b8e3b3..b55d24166cc586b02d302e659044f9ef4ee0a2f1 100644 --- a/src/csharp/Grpc.Examples/Properties/AssemblyInfo.cs +++ b/src/csharp/Grpc.Examples/Properties/AssemblyInfo.cs @@ -1,22 +1,12 @@ using System.Reflection; using System.Runtime.CompilerServices; -// Information about this assembly is defined by the following attributes. -// Change them to the values specific to your project. -[assembly: AssemblyTitle ("Grpc.Examples")] -[assembly: AssemblyDescription ("")] -[assembly: AssemblyConfiguration ("")] -[assembly: AssemblyCompany ("")] -[assembly: AssemblyProduct ("")] -[assembly: AssemblyCopyright ("Google Inc. All rights reserved.")] -[assembly: AssemblyTrademark ("")] -[assembly: AssemblyCulture ("")] -// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". -// The form "{Major}.{Minor}.*" will automatically update the build and revision, -// and "{Major}.{Minor}.{Build}.*" will update just the revision. -[assembly: AssemblyVersion ("0.1.*")] -// The following attributes are used to specify the signing key for the assembly, -// if desired. See the Mono documentation for more information about signing. -//[assembly: AssemblyDelaySign(false)] -//[assembly: AssemblyKeyFile("")] - +[assembly: AssemblyTitle("Grpc.Examples")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("Google Inc. All rights reserved.")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: AssemblyVersion("0.1.*")] diff --git a/src/csharp/Grpc.IntegrationTesting.Client/Properties/AssemblyInfo.cs b/src/csharp/Grpc.IntegrationTesting.Client/Properties/AssemblyInfo.cs index d1f9e8560dc8b99946848be51f7be213c4ce9f7a..c93dd1eb2f318dc8f03b34602c2bbb58a4ac1065 100644 --- a/src/csharp/Grpc.IntegrationTesting.Client/Properties/AssemblyInfo.cs +++ b/src/csharp/Grpc.IntegrationTesting.Client/Properties/AssemblyInfo.cs @@ -1,8 +1,6 @@ using System.Reflection; using System.Runtime.CompilerServices; -// Information about this assembly is defined by the following attributes. -// Change them to the values specific to your project. [assembly: AssemblyTitle("Grpc.IntegrationTesting.Client")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] @@ -11,12 +9,4 @@ using System.Runtime.CompilerServices; [assembly: AssemblyCopyright("Google Inc. All rights reserved.")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". -// The form "{Major}.{Minor}.*" will automatically update the build and revision, -// and "{Major}.{Minor}.{Build}.*" will update just the revision. [assembly: AssemblyVersion("0.1.*")] -// The following attributes are used to specify the signing key for the assembly, -// if desired. See the Mono documentation for more information about signing. -//[assembly: AssemblyDelaySign(false)] -//[assembly: AssemblyKeyFile("")] - diff --git a/src/csharp/Grpc.IntegrationTesting.Server/Properties/AssemblyInfo.cs b/src/csharp/Grpc.IntegrationTesting.Server/Properties/AssemblyInfo.cs index 4ef93f328d299796967b51fc0a279eb7e4d28809..f3def1aea4469c4ce6c38d50f3ae7b7de2030ed8 100644 --- a/src/csharp/Grpc.IntegrationTesting.Server/Properties/AssemblyInfo.cs +++ b/src/csharp/Grpc.IntegrationTesting.Server/Properties/AssemblyInfo.cs @@ -1,8 +1,6 @@ using System.Reflection; using System.Runtime.CompilerServices; -// Information about this assembly is defined by the following attributes. -// Change them to the values specific to your project. [assembly: AssemblyTitle("Grpc.IntegrationTesting.Server")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] @@ -11,12 +9,4 @@ using System.Runtime.CompilerServices; [assembly: AssemblyCopyright("Google Inc. All rights reserved.")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". -// The form "{Major}.{Minor}.*" will automatically update the build and revision, -// and "{Major}.{Minor}.{Build}.*" will update just the revision. [assembly: AssemblyVersion("0.1.*")] -// The following attributes are used to specify the signing key for the assembly, -// if desired. See the Mono documentation for more information about signing. -//[assembly: AssemblyDelaySign(false)] -//[assembly: AssemblyKeyFile("")] - diff --git a/src/csharp/Grpc.IntegrationTesting/InteropClient.cs b/src/csharp/Grpc.IntegrationTesting/InteropClient.cs index 2992c42ae95db1710ebc9c5d8b26ca7ec1550213..56760ecdabc0033c1915a7295391fc3a03f1e7b7 100644 --- a/src/csharp/Grpc.IntegrationTesting/InteropClient.cs +++ b/src/csharp/Grpc.IntegrationTesting/InteropClient.cs @@ -38,10 +38,10 @@ using System.IO; using System.Text.RegularExpressions; using System.Threading.Tasks; using Google.ProtocolBuffers; +using grpc.testing; using Grpc.Core; using Grpc.Core.Utils; using NUnit.Framework; -using grpc.testing; namespace Grpc.IntegrationTesting { @@ -50,7 +50,7 @@ namespace Grpc.IntegrationTesting private class ClientOptions { public bool help; - public string serverHost= "127.0.0.1"; + public string serverHost = "127.0.0.1"; public string serverHostOverride = TestCredentials.DefaultHostOverride; public int? serverPort; public string testCase = "large_unary"; @@ -180,7 +180,7 @@ namespace Grpc.IntegrationTesting { Console.WriteLine("running client_streaming"); - var bodySizes = new List<int>{27182, 8, 1828, 45904}; + var bodySizes = new List<int> { 27182, 8, 1828, 45904 }; var context = client.StreamingInputCall(); foreach (var size in bodySizes) @@ -199,7 +199,7 @@ namespace Grpc.IntegrationTesting { Console.WriteLine("running server_streaming"); - var bodySizes = new List<int>{31415, 9, 2653, 58979}; + var bodySizes = new List<int> { 31415, 9, 2653, 58979 }; var request = StreamingOutputCallRequest.CreateBuilder() .SetResponseType(PayloadType.COMPRESSABLE) @@ -256,7 +256,6 @@ namespace Grpc.IntegrationTesting Assert.AreEqual(PayloadType.COMPRESSABLE, response.Payload.Type); Assert.AreEqual(2653, response.Payload.Body.Length); - inputs.OnNext(StreamingOutputCallRequest.CreateBuilder() .SetResponseType(PayloadType.COMPRESSABLE) .AddResponseParameters(ResponseParameters.CreateBuilder().SetSize(58979)) @@ -292,17 +291,18 @@ namespace Grpc.IntegrationTesting public static void RunBenchmarkEmptyUnary(TestServiceGrpc.ITestServiceClient client) { BenchmarkUtil.RunBenchmark(10000, 10000, - () => { client.EmptyCall(Empty.DefaultInstance);}); + () => { client.EmptyCall(Empty.DefaultInstance); }); } - private static Payload CreateZerosPayload(int size) { + private static Payload CreateZerosPayload(int size) + { return Payload.CreateBuilder().SetBody(ByteString.CopyFrom(new byte[size])).Build(); } private static ClientOptions ParseArguments(string[] args) { var options = new ClientOptions(); - foreach(string arg in args) + foreach (string arg in args) { ParseArgument(arg, options); if (options.help) diff --git a/src/csharp/Grpc.IntegrationTesting/InteropClientServerTest.cs b/src/csharp/Grpc.IntegrationTesting/InteropClientServerTest.cs index ab2d6f4a6ac1ed31c3e8d2422d8d39ed9d161ba0..36c784e28f1d27a959c80e76cfc33ef2ea6483ff 100644 --- a/src/csharp/Grpc.IntegrationTesting/InteropClientServerTest.cs +++ b/src/csharp/Grpc.IntegrationTesting/InteropClientServerTest.cs @@ -35,10 +35,10 @@ using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; +using grpc.testing; using Grpc.Core; using Grpc.Core.Utils; using NUnit.Framework; -using grpc.testing; namespace Grpc.IntegrationTesting { @@ -117,7 +117,5 @@ namespace Grpc.IntegrationTesting // TODO: add cancel_after_begin // TODO: add cancel_after_first_response - } } - diff --git a/src/csharp/Grpc.IntegrationTesting/InteropServer.cs b/src/csharp/Grpc.IntegrationTesting/InteropServer.cs index 24d72da0c3f2b87d3a01d81d974c572314e7e573..5e580280b6119411d015d6dd21007e5905d08607 100644 --- a/src/csharp/Grpc.IntegrationTesting/InteropServer.cs +++ b/src/csharp/Grpc.IntegrationTesting/InteropServer.cs @@ -38,10 +38,10 @@ using System.IO; using System.Text.RegularExpressions; using System.Threading.Tasks; using Google.ProtocolBuffers; +using grpc.testing; using Grpc.Core; using Grpc.Core.Utils; using NUnit.Framework; -using grpc.testing; namespace Grpc.IntegrationTesting { @@ -113,7 +113,7 @@ namespace Grpc.IntegrationTesting private static ServerOptions ParseArguments(string[] args) { var options = new ServerOptions(); - foreach(string arg in args) + foreach (string arg in args) { ParseArgument(arg, options); if (options.help) diff --git a/src/csharp/Grpc.IntegrationTesting/Properties/AssemblyInfo.cs b/src/csharp/Grpc.IntegrationTesting/Properties/AssemblyInfo.cs index f633c19132e2eab39fb8b9cadfc68a41c1477b68..f09a448e9e28bc48f073dfbe18cbbcf336882800 100644 --- a/src/csharp/Grpc.IntegrationTesting/Properties/AssemblyInfo.cs +++ b/src/csharp/Grpc.IntegrationTesting/Properties/AssemblyInfo.cs @@ -1,8 +1,6 @@ using System.Reflection; using System.Runtime.CompilerServices; -// Information about this assembly is defined by the following attributes. -// Change them to the values specific to your project. [assembly: AssemblyTitle("Grpc.IntegrationTesting")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] @@ -11,12 +9,4 @@ using System.Runtime.CompilerServices; [assembly: AssemblyCopyright("Google Inc. All rights reserved.")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". -// The form "{Major}.{Minor}.*" will automatically update the build and revision, -// and "{Major}.{Minor}.{Build}.*" will update just the revision. [assembly: AssemblyVersion("0.1.*")] -// The following attributes are used to specify the signing key for the assembly, -// if desired. See the Mono documentation for more information about signing. -//[assembly: AssemblyDelaySign(false)] -//[assembly: AssemblyKeyFile("")] - diff --git a/src/csharp/Grpc.IntegrationTesting/TestCredentials.cs b/src/csharp/Grpc.IntegrationTesting/TestCredentials.cs index b31abf118118fc2e992c32c237e7844da7b5462f..10df704f1dddf2c984a4b4014c060f235e3c420f 100644 --- a/src/csharp/Grpc.IntegrationTesting/TestCredentials.cs +++ b/src/csharp/Grpc.IntegrationTesting/TestCredentials.cs @@ -38,10 +38,10 @@ using System.IO; using System.Text.RegularExpressions; using System.Threading.Tasks; using Google.ProtocolBuffers; +using grpc.testing; using Grpc.Core; using Grpc.Core.Utils; using NUnit.Framework; -using grpc.testing; namespace Grpc.IntegrationTesting { @@ -77,7 +77,7 @@ namespace Grpc.IntegrationTesting var keyCertPair = new KeyCertificatePair( File.ReadAllText(ServerCertChainPath), File.ReadAllText(ServerPrivateKeyPath)); - return new SslServerCredentials(new List<KeyCertificatePair> {keyCertPair}); + return new SslServerCredentials(new List<KeyCertificatePair> { keyCertPair }); } } } diff --git a/src/csharp/Grpc.IntegrationTesting/TestServiceImpl.cs b/src/csharp/Grpc.IntegrationTesting/TestServiceImpl.cs index 176843b1305683db5e14584cc406e05e820c7855..661b31b0ee67f909c95aa9a533b97054c900b760 100644 --- a/src/csharp/Grpc.IntegrationTesting/TestServiceImpl.cs +++ b/src/csharp/Grpc.IntegrationTesting/TestServiceImpl.cs @@ -55,14 +55,14 @@ namespace grpc.testing { var response = SimpleResponse.CreateBuilder() .SetPayload(CreateZerosPayload(request.ResponseSize)).Build(); - //TODO: check we support ReponseType + // TODO: check we support ReponseType responseObserver.OnNext(response); responseObserver.OnCompleted(); } public void StreamingOutputCall(StreamingOutputCallRequest request, IObserver<StreamingOutputCallResponse> responseObserver) { - foreach(var responseParam in request.ResponseParametersList) + foreach (var responseParam in request.ResponseParametersList) { var response = StreamingOutputCallResponse.CreateBuilder() .SetPayload(CreateZerosPayload(responseParam.Size)).Build(); @@ -74,9 +74,10 @@ namespace grpc.testing public IObserver<StreamingInputCallRequest> StreamingInputCall(IObserver<StreamingInputCallResponse> responseObserver) { var recorder = new RecordingObserver<StreamingInputCallRequest>(); - Task.Run(() => { + Task.Run(() => + { int sum = 0; - foreach(var req in recorder.ToList().Result) + foreach (var req in recorder.ToList().Result) { sum += req.Payload.Body.Length; } @@ -98,8 +99,8 @@ namespace grpc.testing throw new NotImplementedException(); } - private class FullDuplexObserver : IObserver<StreamingOutputCallRequest> { - + private class FullDuplexObserver : IObserver<StreamingOutputCallRequest> + { readonly IObserver<StreamingOutputCallResponse> responseObserver; public FullDuplexObserver(IObserver<StreamingOutputCallResponse> responseObserver) @@ -119,22 +120,18 @@ namespace grpc.testing public void OnNext(StreamingOutputCallRequest value) { - // TODO: this is not in order!!! - //Task.Factory.StartNew(() => { - - foreach(var responseParam in value.ResponseParametersList) - { - var response = StreamingOutputCallResponse.CreateBuilder() - .SetPayload(CreateZerosPayload(responseParam.Size)).Build(); - responseObserver.OnNext(response); - } - //}); + foreach (var responseParam in value.ResponseParametersList) + { + var response = StreamingOutputCallResponse.CreateBuilder() + .SetPayload(CreateZerosPayload(responseParam.Size)).Build(); + responseObserver.OnNext(response); + } } } - private static Payload CreateZerosPayload(int size) { + private static Payload CreateZerosPayload(int size) + { return Payload.CreateBuilder().SetBody(ByteString.CopyFrom(new byte[size])).Build(); } } } -