diff options
Diffstat (limited to 'src/csharp')
83 files changed, 3617 insertions, 438 deletions
diff --git a/src/csharp/Grpc.Auth/Grpc.Auth.csproj b/src/csharp/Grpc.Auth/Grpc.Auth.csproj index a44aaf1fdd..99e8c1a3da 100644 --- a/src/csharp/Grpc.Auth/Grpc.Auth.csproj +++ b/src/csharp/Grpc.Auth/Grpc.Auth.csproj @@ -87,7 +87,6 @@ </ProjectReference> </ItemGroup> <ItemGroup> - <None Include="Grpc.Auth.nuspec" /> <None Include="Grpc.Auth.project.json" /> <None Include="packages.config" /> </ItemGroup> diff --git a/src/csharp/Grpc.Auth/Grpc.Auth.nuspec b/src/csharp/Grpc.Auth/Grpc.Auth.nuspec deleted file mode 100644 index a1f5668e2e..0000000000 --- a/src/csharp/Grpc.Auth/Grpc.Auth.nuspec +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<package> - <metadata> - <id>Grpc.Auth</id> - <title>gRPC C# Auth</title> - <summary>Auth library for C# implementation of gRPC - an RPC library and framework</summary> - <description>Auth library for C# implementation of gRPC - an RPC library and framework. See project site for more info.</description> - <version>$version$</version> - <authors>Google Inc.</authors> - <owners>grpc-packages</owners> - <licenseUrl>https://github.com/grpc/grpc/blob/master/LICENSE</licenseUrl> - <projectUrl>https://github.com/grpc/grpc</projectUrl> - <requireLicenseAcceptance>false</requireLicenseAcceptance> - <releaseNotes>Release $version$ of gRPC C#</releaseNotes> - <copyright>Copyright 2015, Google Inc.</copyright> - <tags>gRPC RPC Protocol HTTP/2 Auth OAuth2</tags> - <dependencies> - <dependency id="Google.Apis.Auth" version="1.15.0" /> - <dependency id="Grpc.Core" version="$version$" /> - </dependencies> - </metadata> - <files> - <file src="bin/ReleaseSigned/Grpc.Auth.dll" target="lib/net45" /> - <file src="bin/ReleaseSigned/Grpc.Auth.pdb" target="lib/net45" /> - <file src="bin/ReleaseSigned/Grpc.Auth.xml" target="lib/net45" /> - <file src="**\*.cs" target="src" /> - </files> -</package> diff --git a/src/csharp/Grpc.Auth/project.json b/src/csharp/Grpc.Auth/project.json index 595e29f50a..4052ec8398 100644 --- a/src/csharp/Grpc.Auth/project.json +++ b/src/csharp/Grpc.Auth/project.json @@ -15,7 +15,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.Core.Tests/CallOptionsTest.cs b/src/csharp/Grpc.Core.Tests/CallOptionsTest.cs index 99a2d47e6e..3c3b9f7745 100644 --- a/src/csharp/Grpc.Core.Tests/CallOptionsTest.cs +++ b/src/csharp/Grpc.Core.Tests/CallOptionsTest.cs @@ -67,6 +67,9 @@ namespace Grpc.Core.Tests var credentials = new FakeCallCredentials(); Assert.AreSame(credentials, options.WithCredentials(credentials).Credentials); + var flags = CallFlags.WaitForReady | CallFlags.CacheableRequest; + Assert.AreEqual(flags, options.WithFlags(flags).Flags); + // Check that the original instance is unchanged. Assert.IsNull(options.Headers); Assert.IsNull(options.Deadline); @@ -74,6 +77,7 @@ namespace Grpc.Core.Tests Assert.IsNull(options.WriteOptions); Assert.IsNull(options.PropagationToken); Assert.IsNull(options.Credentials); + Assert.AreEqual(default(CallFlags), options.Flags); } [Test] @@ -94,5 +98,16 @@ namespace Grpc.Core.Tests Assert.AreEqual(token, new CallOptions(propagationToken: propagationToken2).Normalize().CancellationToken); Assert.Throws(typeof(ArgumentException), () => new CallOptions(cancellationToken: token, propagationToken: propagationToken2).Normalize()); } + + [Test] + public void WaitForReady() + { + var callOptions = new CallOptions(); + Assert.IsFalse(callOptions.IsWaitForReady); + + Assert.AreEqual(CallFlags.WaitForReady, callOptions.WithWaitForReady().Flags); + Assert.IsTrue(callOptions.WithWaitForReady().IsWaitForReady); + Assert.IsFalse(callOptions.WithWaitForReady(true).WithWaitForReady(false).IsWaitForReady); + } } } diff --git a/src/csharp/Grpc.Core.Tests/Grpc.Core.Tests.csproj b/src/csharp/Grpc.Core.Tests/Grpc.Core.Tests.csproj index d99bf8e4e1..19a68ab9ea 100644 --- a/src/csharp/Grpc.Core.Tests/Grpc.Core.Tests.csproj +++ b/src/csharp/Grpc.Core.Tests/Grpc.Core.Tests.csproj @@ -39,15 +39,15 @@ <Reference Include="nunit.framework"> <HintPath>..\packages\NUnit.3.2.0\lib\net45\nunit.framework.dll</HintPath> </Reference> - <Reference Include="System.Interactive.Async"> - <HintPath>..\packages\System.Interactive.Async.3.0.0\lib\net45\System.Interactive.Async.dll</HintPath> - </Reference> <Reference Include="nunitlite"> <HintPath>..\packages\NUnitLite.3.2.0\lib\net45\nunitlite.dll</HintPath> </Reference> <Reference Include="Newtonsoft.Json"> <HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath> </Reference> + <Reference Include="System.Interactive.Async"> + <HintPath>..\packages\System.Interactive.Async.3.1.1\lib\net45\System.Interactive.Async.dll</HintPath> + </Reference> </ItemGroup> <ItemGroup> <Compile Include="..\Grpc.Core\Version.cs"> diff --git a/src/csharp/Grpc.Core.Tests/Internal/FakeNativeCall.cs b/src/csharp/Grpc.Core.Tests/Internal/FakeNativeCall.cs index 909112a47c..fe067fe8b0 100644 --- a/src/csharp/Grpc.Core.Tests/Internal/FakeNativeCall.cs +++ b/src/csharp/Grpc.Core.Tests/Internal/FakeNativeCall.cs @@ -115,27 +115,27 @@ namespace Grpc.Core.Internal.Tests return "PEER"; } - public void StartUnary(UnaryResponseClientHandler callback, byte[] payload, MetadataArraySafeHandle metadataArray, WriteFlags writeFlags) + public void StartUnary(UnaryResponseClientHandler callback, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags) { UnaryResponseClientHandler = callback; } - public void StartUnary(BatchContextSafeHandle ctx, byte[] payload, MetadataArraySafeHandle metadataArray, WriteFlags writeFlags) + public void StartUnary(BatchContextSafeHandle ctx, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags) { throw new NotImplementedException(); } - public void StartClientStreaming(UnaryResponseClientHandler callback, MetadataArraySafeHandle metadataArray) + public void StartClientStreaming(UnaryResponseClientHandler callback, MetadataArraySafeHandle metadataArray, CallFlags callFlags) { UnaryResponseClientHandler = callback; } - public void StartServerStreaming(ReceivedStatusOnClientHandler callback, byte[] payload, MetadataArraySafeHandle metadataArray, WriteFlags writeFlags) + public void StartServerStreaming(ReceivedStatusOnClientHandler callback, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags) { ReceivedStatusOnClientHandler = callback; } - public void StartDuplexStreaming(ReceivedStatusOnClientHandler callback, MetadataArraySafeHandle metadataArray) + public void StartDuplexStreaming(ReceivedStatusOnClientHandler callback, MetadataArraySafeHandle metadataArray, CallFlags callFlags) { ReceivedStatusOnClientHandler = callback; } diff --git a/src/csharp/Grpc.Core.Tests/SanityTest.cs b/src/csharp/Grpc.Core.Tests/SanityTest.cs index f1eb13dffc..1c28277df5 100644 --- a/src/csharp/Grpc.Core.Tests/SanityTest.cs +++ b/src/csharp/Grpc.Core.Tests/SanityTest.cs @@ -115,7 +115,8 @@ namespace Grpc.Core.Tests var otherAssemblies = new[] { "Grpc.Examples.Tests", "Grpc.HealthCheck.Tests", - "Grpc.IntegrationTesting" + "Grpc.IntegrationTesting", + "Grpc.Reflection.Tests", }; foreach (var assemblyName in otherAssemblies) { diff --git a/src/csharp/Grpc.Core.Tests/packages.config b/src/csharp/Grpc.Core.Tests/packages.config index 456ffcd8d0..4750735fad 100644 --- a/src/csharp/Grpc.Core.Tests/packages.config +++ b/src/csharp/Grpc.Core.Tests/packages.config @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="utf-8"?> <packages> - <package id="System.Interactive.Async" version="3.0.0" targetFramework="net45" /> <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" /> <package id="NUnit" version="3.2.0" targetFramework="net45" /> - <package id="NUnitLite" version="3.2.0" targetFramework="net45" /> <package id="NUnit.ConsoleRunner" version="3.2.0" /> + <package id="NUnitLite" version="3.2.0" targetFramework="net45" /> <package id="OpenCover" version="4.6.519" /> <package id="ReportGenerator" version="2.4.4.0" /> -</packages> + <package id="System.Interactive.Async" version="3.1.1" targetFramework="net45" /> +</packages>
\ No newline at end of file diff --git a/src/csharp/Grpc.Core.Tests/project.json b/src/csharp/Grpc.Core.Tests/project.json index faf28dcee8..509084a71a 100644 --- a/src/csharp/Grpc.Core.Tests/project.json +++ b/src/csharp/Grpc.Core.Tests/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -26,7 +25,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.Core/CallOptions.cs b/src/csharp/Grpc.Core/CallOptions.cs index 35548cfc96..ce43dae171 100644 --- a/src/csharp/Grpc.Core/CallOptions.cs +++ b/src/csharp/Grpc.Core/CallOptions.cs @@ -50,6 +50,7 @@ namespace Grpc.Core WriteOptions writeOptions; ContextPropagationToken propagationToken; CallCredentials credentials; + CallFlags flags; /// <summary> /// Creates a new instance of <c>CallOptions</c> struct. @@ -69,6 +70,7 @@ namespace Grpc.Core this.writeOptions = writeOptions; this.propagationToken = propagationToken; this.credentials = credentials; + this.flags = default(CallFlags); } /// <summary> @@ -126,6 +128,24 @@ namespace Grpc.Core } /// <summary> + /// If <c>true</c> and and channel is in <c>ChannelState.TransientFailure</c>, the call will attempt waiting for the channel to recover + /// instead of failing immediately (which is the default "FailFast" semantics). + /// Note: experimental API that can change or be removed without any prior notice. + /// </summary> + public bool IsWaitForReady + { + get { return (this.flags & CallFlags.WaitForReady) == CallFlags.WaitForReady; } + } + + /// <summary> + /// Flags to use for this call. + /// </summary> + internal CallFlags Flags + { + get { return this.flags; } + } + + /// <summary> /// Returns new instance of <see cref="CallOptions"/> with /// <c>Headers</c> set to the value provided. Values of all other fields are preserved. /// </summary> @@ -198,6 +218,32 @@ namespace Grpc.Core } /// <summary> + /// Returns new instance of <see cref="CallOptions"/> with "WaitForReady" semantics enabled/disabled. + /// <see cref="IsWaitForReady"/>. + /// Note: experimental API that can change or be removed without any prior notice. + /// </summary> + public CallOptions WithWaitForReady(bool waitForReady = true) + { + if (waitForReady) + { + return WithFlags(this.flags | CallFlags.WaitForReady); + } + return WithFlags(this.flags & ~CallFlags.WaitForReady); + } + + /// <summary> + /// Returns new instance of <see cref="CallOptions"/> with + /// <c>Flags</c> set to the value provided. Values of all other fields are preserved. + /// </summary> + /// <param name="flags">The call flags.</param> + internal CallOptions WithFlags(CallFlags flags) + { + var newOptions = this; + newOptions.flags = flags; + return newOptions; + } + + /// <summary> /// Returns a new instance of <see cref="CallOptions"/> with /// all previously unset values set to their defaults and deadline and cancellation /// token propagated when appropriate. diff --git a/src/csharp/Grpc.Core/Grpc.Core.csproj b/src/csharp/Grpc.Core/Grpc.Core.csproj index d315e6d667..5bfb978ca6 100644 --- a/src/csharp/Grpc.Core/Grpc.Core.csproj +++ b/src/csharp/Grpc.Core/Grpc.Core.csproj @@ -40,7 +40,7 @@ <ItemGroup> <Reference Include="System" /> <Reference Include="System.Interactive.Async"> - <HintPath>..\packages\System.Interactive.Async.3.0.0\lib\net45\System.Interactive.Async.dll</HintPath> + <HintPath>..\packages\System.Interactive.Async.3.1.1\lib\net45\System.Interactive.Async.dll</HintPath> </Reference> </ItemGroup> <ItemGroup> @@ -140,9 +140,9 @@ <Compile Include="Logging\LogLevelFilterLogger.cs" /> <Compile Include="Internal\RequestCallContextSafeHandle.cs" /> <Compile Include="Utils\TaskUtils.cs" /> + <Compile Include="Internal\CallFlags.cs" /> </ItemGroup> <ItemGroup> - <None Include="Grpc.Core.nuspec" /> <None Include="Grpc.Core.project.json" /> <None Include="packages.config" /> </ItemGroup> @@ -154,4 +154,4 @@ <Link>roots.pem</Link> </EmbeddedResource> </ItemGroup> -</Project> +</Project>
\ No newline at end of file diff --git a/src/csharp/Grpc.Core/Grpc.Core.nuspec b/src/csharp/Grpc.Core/Grpc.Core.nuspec deleted file mode 100644 index a8459c4d9c..0000000000 --- a/src/csharp/Grpc.Core/Grpc.Core.nuspec +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<package> - <metadata> - <id>Grpc.Core</id> - <title>gRPC C# Core</title> - <summary>Core C# implementation of gRPC - an RPC library and framework</summary> - <description>Core C# implementation of gRPC - an RPC library and framework. See project site for more info.</description> - <version>$version$</version> - <authors>Google Inc.</authors> - <owners>grpc-packages</owners> - <licenseUrl>https://github.com/grpc/grpc/blob/master/LICENSE</licenseUrl> - <projectUrl>https://github.com/grpc/grpc</projectUrl> - <requireLicenseAcceptance>false</requireLicenseAcceptance> - <releaseNotes>Release $version$ of gRPC C#</releaseNotes> - <copyright>Copyright 2015, Google Inc.</copyright> - <tags>gRPC RPC Protocol HTTP/2</tags> - <dependencies> - <dependency id="System.Interactive.Async" version="3.0.0" /> - </dependencies> - </metadata> - <files> - <file src="bin/ReleaseSigned/Grpc.Core.dll" target="lib/net45" /> - <file src="bin/ReleaseSigned/Grpc.Core.pdb" target="lib/net45" /> - <file src="bin/ReleaseSigned/Grpc.Core.xml" target="lib/net45" /> - <file src="**\*.cs" target="src" /> - <file src="Grpc.Core.targets" target="\build\net45\Grpc.Core.targets" /> - <!-- without backslashes in the the source path, nuget won't copy the files --> - <file src="..\nativelibs\windows_x86\grpc_csharp_ext.dll" target="/runtimes/win/native/grpc_csharp_ext.x86.dll" /> - <file src="..\nativelibs\windows_x64\grpc_csharp_ext.dll" target="/runtimes/win/native/grpc_csharp_ext.x64.dll" /> - <file src="..\nativelibs\linux_x86\libgrpc_csharp_ext.so" target="/runtimes/linux/native/libgrpc_csharp_ext.x86.so" /> - <file src="..\nativelibs\linux_x64\libgrpc_csharp_ext.so" target="/runtimes/linux/native/libgrpc_csharp_ext.x64.so" /> - <file src="..\nativelibs\macosx_x86\libgrpc_csharp_ext.dylib" target="/runtimes/osx/native/libgrpc_csharp_ext.x86.dylib" /> - <file src="..\nativelibs\macosx_x64\libgrpc_csharp_ext.dylib" target="/runtimes/osx/native/libgrpc_csharp_ext.x64.dylib" /> - </files> -</package> diff --git a/src/csharp/Grpc.Core/Internal/AsyncCall.cs b/src/csharp/Grpc.Core/Internal/AsyncCall.cs index 5e61e9ec12..1f738a3b6f 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCall.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCall.cs @@ -106,7 +106,7 @@ namespace Grpc.Core.Internal using (var metadataArray = MetadataArraySafeHandle.Create(details.Options.Headers)) using (var ctx = BatchContextSafeHandle.Create()) { - call.StartUnary(ctx, payload, metadataArray, GetWriteFlagsForCall()); + call.StartUnary(ctx, payload, GetWriteFlagsForCall(), metadataArray, details.Options.Flags); var ev = cq.Pluck(ctx.Handle); @@ -150,7 +150,7 @@ namespace Grpc.Core.Internal unaryResponseTcs = new TaskCompletionSource<TResponse>(); using (var metadataArray = MetadataArraySafeHandle.Create(details.Options.Headers)) { - call.StartUnary(HandleUnaryResponse, payload, metadataArray, GetWriteFlagsForCall()); + call.StartUnary(HandleUnaryResponse, payload, GetWriteFlagsForCall(), metadataArray, details.Options.Flags); } return unaryResponseTcs.Task; } @@ -174,7 +174,7 @@ namespace Grpc.Core.Internal unaryResponseTcs = new TaskCompletionSource<TResponse>(); using (var metadataArray = MetadataArraySafeHandle.Create(details.Options.Headers)) { - call.StartClientStreaming(HandleUnaryResponse, metadataArray); + call.StartClientStreaming(HandleUnaryResponse, metadataArray, details.Options.Flags); } return unaryResponseTcs.Task; @@ -200,7 +200,7 @@ namespace Grpc.Core.Internal streamingResponseCallFinishedTcs = new TaskCompletionSource<object>(); using (var metadataArray = MetadataArraySafeHandle.Create(details.Options.Headers)) { - call.StartServerStreaming(HandleFinished, payload, metadataArray, GetWriteFlagsForCall()); + call.StartServerStreaming(HandleFinished, payload, GetWriteFlagsForCall(), metadataArray, details.Options.Flags); } call.StartReceiveInitialMetadata(HandleReceivedResponseHeaders); } @@ -222,7 +222,7 @@ namespace Grpc.Core.Internal streamingResponseCallFinishedTcs = new TaskCompletionSource<object>(); using (var metadataArray = MetadataArraySafeHandle.Create(details.Options.Headers)) { - call.StartDuplexStreaming(HandleFinished, metadataArray); + call.StartDuplexStreaming(HandleFinished, metadataArray, details.Options.Flags); } call.StartReceiveInitialMetadata(HandleReceivedResponseHeaders); } @@ -388,35 +388,29 @@ namespace Grpc.Core.Internal private void Initialize(CompletionQueueSafeHandle cq) { - using (Profilers.ForCurrentThread().NewScope("AsyncCall.Initialize")) - { - var call = CreateNativeCall(cq); + var call = CreateNativeCall(cq); - details.Channel.AddCallReference(this); - InitializeInternal(call); - RegisterCancellationCallback(); - } + details.Channel.AddCallReference(this); + InitializeInternal(call); + RegisterCancellationCallback(); } private INativeCall CreateNativeCall(CompletionQueueSafeHandle cq) { - using (Profilers.ForCurrentThread().NewScope("AsyncCall.CreateNativeCall")) - { - if (injectedNativeCall != null) - { - return injectedNativeCall; // allows injecting a mock INativeCall in tests. - } + if (injectedNativeCall != null) + { + return injectedNativeCall; // allows injecting a mock INativeCall in tests. + } - var parentCall = details.Options.PropagationToken != null ? details.Options.PropagationToken.ParentCall : CallSafeHandle.NullInstance; + var parentCall = details.Options.PropagationToken != null ? details.Options.PropagationToken.ParentCall : CallSafeHandle.NullInstance; - var credentials = details.Options.Credentials; - using (var nativeCredentials = credentials != null ? credentials.ToNativeCredentials() : null) - { - var result = details.Channel.Handle.CreateCall( - parentCall, ContextPropagationToken.DefaultMask, cq, - details.Method, details.Host, Timespec.FromDateTime(details.Options.Deadline.Value), nativeCredentials); - return result; - } + var credentials = details.Options.Credentials; + using (var nativeCredentials = credentials != null ? credentials.ToNativeCredentials() : null) + { + var result = details.Channel.Handle.CreateCall( + parentCall, ContextPropagationToken.DefaultMask, cq, + details.Method, details.Host, Timespec.FromDateTime(details.Options.Deadline.Value), nativeCredentials); + return result; } } @@ -456,47 +450,44 @@ namespace Grpc.Core.Internal // NOTE: because this event is a result of batch containing GRPC_OP_RECV_STATUS_ON_CLIENT, // success will be always set to true. - using (Profilers.ForCurrentThread().NewScope("AsyncCall.HandleUnaryResponse")) + TaskCompletionSource<object> delayedStreamingWriteTcs = null; + TResponse msg = default(TResponse); + var deserializeException = TryDeserialize(receivedMessage, out msg); + + lock (myLock) { - TaskCompletionSource<object> delayedStreamingWriteTcs = null; - TResponse msg = default(TResponse); - var deserializeException = TryDeserialize(receivedMessage, out msg); + finished = true; - lock (myLock) + if (deserializeException != null && receivedStatus.Status.StatusCode == StatusCode.OK) { - finished = true; - - if (deserializeException != null && receivedStatus.Status.StatusCode == StatusCode.OK) - { - receivedStatus = new ClientSideStatus(DeserializeResponseFailureStatus, receivedStatus.Trailers); - } - finishedStatus = receivedStatus; - - if (isStreamingWriteCompletionDelayed) - { - delayedStreamingWriteTcs = streamingWriteTcs; - streamingWriteTcs = null; - } - - ReleaseResourcesIfPossible(); + receivedStatus = new ClientSideStatus(DeserializeResponseFailureStatus, receivedStatus.Trailers); } + finishedStatus = receivedStatus; - responseHeadersTcs.SetResult(responseHeaders); - - if (delayedStreamingWriteTcs != null) + if (isStreamingWriteCompletionDelayed) { - delayedStreamingWriteTcs.SetException(GetRpcExceptionClientOnly()); + delayedStreamingWriteTcs = streamingWriteTcs; + streamingWriteTcs = null; } - var status = receivedStatus.Status; - if (status.StatusCode != StatusCode.OK) - { - unaryResponseTcs.SetException(new RpcException(status)); - return; - } + ReleaseResourcesIfPossible(); + } + + responseHeadersTcs.SetResult(responseHeaders); - unaryResponseTcs.SetResult(msg); + if (delayedStreamingWriteTcs != null) + { + delayedStreamingWriteTcs.SetException(GetRpcExceptionClientOnly()); + } + + var status = receivedStatus.Status; + if (status.StatusCode != StatusCode.OK) + { + unaryResponseTcs.SetException(new RpcException(status)); + return; } + + unaryResponseTcs.SetResult(msg); } /// <summary> diff --git a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs index 9f9d260e7e..8668903f6e 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs @@ -181,19 +181,16 @@ namespace Grpc.Core.Internal /// </summary> protected bool ReleaseResourcesIfPossible() { - using (Profilers.ForCurrentThread().NewScope("AsyncCallBase.ReleaseResourcesIfPossible")) + if (!disposed && call != null) { - if (!disposed && call != null) + bool noMoreSendCompletions = streamingWriteTcs == null && (halfcloseRequested || cancelRequested || finished); + if (noMoreSendCompletions && readingDone && finished) { - bool noMoreSendCompletions = streamingWriteTcs == null && (halfcloseRequested || cancelRequested || finished); - if (noMoreSendCompletions && readingDone && finished) - { - ReleaseResources(); - return true; - } + ReleaseResources(); + return true; } - return false; } + return false; } protected abstract bool IsClient @@ -229,28 +226,20 @@ namespace Grpc.Core.Internal protected byte[] UnsafeSerialize(TWrite msg) { - using (Profilers.ForCurrentThread().NewScope("AsyncCallBase.UnsafeSerialize")) - { - return serializer(msg); - } + return serializer(msg); } protected Exception TryDeserialize(byte[] payload, out TRead msg) { - using (Profilers.ForCurrentThread().NewScope("AsyncCallBase.TryDeserialize")) + try { - try - { - - msg = deserializer(payload); - return null; - - } - catch (Exception e) - { - msg = default(TRead); - return e; - } + msg = deserializer(payload); + return null; + } + catch (Exception e) + { + msg = default(TRead); + return e; } } diff --git a/src/csharp/Grpc.Core/Internal/CallFlags.cs b/src/csharp/Grpc.Core/Internal/CallFlags.cs new file mode 100644 index 0000000000..454fa9b1f4 --- /dev/null +++ b/src/csharp/Grpc.Core/Internal/CallFlags.cs @@ -0,0 +1,60 @@ +#region Copyright notice and license + +// Copyright 2015, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#endregion + +using System; + +namespace Grpc.Core.Internal +{ + /// <summary> + /// Flags to enable special call behaviors (client-side only). + /// </summary> + [Flags] + internal enum CallFlags + { + /// <summary> + /// The call is idempotent (retrying the call doesn't change the outcome of the operation). + /// </summary> + IdempotentRequest = 0x10, + + /// <summary> + /// If channel is in <c>ChannelState.TransientFailure</c>, attempt waiting for the channel to recover + /// instead of failing the call immediately. + /// </summary> + WaitForReady = 0x20, + + /// <summary> + /// The call is cacheable. gRPC is free to use GET verb */ + /// </summary> + CacheableRequest = 0x40 + } +} diff --git a/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs b/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs index 82361f5797..6bfcc7fa74 100644 --- a/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs @@ -63,53 +63,50 @@ namespace Grpc.Core.Internal Native.grpcsharp_call_set_credentials(this, credentials).CheckOk(); } - public void StartUnary(UnaryResponseClientHandler callback, byte[] payload, MetadataArraySafeHandle metadataArray, WriteFlags writeFlags) + public void StartUnary(UnaryResponseClientHandler callback, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags) { using (completionQueue.NewScope()) { var ctx = BatchContextSafeHandle.Create(); completionQueue.CompletionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success, context.GetReceivedStatusOnClient(), context.GetReceivedMessage(), context.GetReceivedInitialMetadata())); - Native.grpcsharp_call_start_unary(this, ctx, payload, new UIntPtr((ulong)payload.Length), metadataArray, writeFlags) + Native.grpcsharp_call_start_unary(this, ctx, payload, new UIntPtr((ulong)payload.Length), writeFlags, metadataArray, callFlags) .CheckOk(); } } - public void StartUnary(BatchContextSafeHandle ctx, byte[] payload, MetadataArraySafeHandle metadataArray, WriteFlags writeFlags) + public void StartUnary(BatchContextSafeHandle ctx, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags) { - using (Profilers.ForCurrentThread().NewScope("CallSafeHandle.StartUnary")) - { - Native.grpcsharp_call_start_unary(this, ctx, payload, new UIntPtr((ulong)payload.Length), metadataArray, writeFlags) - .CheckOk(); - } + Native.grpcsharp_call_start_unary(this, ctx, payload, new UIntPtr((ulong)payload.Length), writeFlags, metadataArray, callFlags) + .CheckOk(); } - public void StartClientStreaming(UnaryResponseClientHandler callback, MetadataArraySafeHandle metadataArray) + public void StartClientStreaming(UnaryResponseClientHandler callback, MetadataArraySafeHandle metadataArray, CallFlags callFlags) { using (completionQueue.NewScope()) { var ctx = BatchContextSafeHandle.Create(); completionQueue.CompletionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success, context.GetReceivedStatusOnClient(), context.GetReceivedMessage(), context.GetReceivedInitialMetadata())); - Native.grpcsharp_call_start_client_streaming(this, ctx, metadataArray).CheckOk(); + Native.grpcsharp_call_start_client_streaming(this, ctx, metadataArray, callFlags).CheckOk(); } } - public void StartServerStreaming(ReceivedStatusOnClientHandler callback, byte[] payload, MetadataArraySafeHandle metadataArray, WriteFlags writeFlags) + public void StartServerStreaming(ReceivedStatusOnClientHandler callback, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags) { using (completionQueue.NewScope()) { var ctx = BatchContextSafeHandle.Create(); completionQueue.CompletionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success, context.GetReceivedStatusOnClient())); - Native.grpcsharp_call_start_server_streaming(this, ctx, payload, new UIntPtr((ulong)payload.Length), metadataArray, writeFlags).CheckOk(); + Native.grpcsharp_call_start_server_streaming(this, ctx, payload, new UIntPtr((ulong)payload.Length), writeFlags, metadataArray, callFlags).CheckOk(); } } - public void StartDuplexStreaming(ReceivedStatusOnClientHandler callback, MetadataArraySafeHandle metadataArray) + public void StartDuplexStreaming(ReceivedStatusOnClientHandler callback, MetadataArraySafeHandle metadataArray, CallFlags callFlags) { using (completionQueue.NewScope()) { var ctx = BatchContextSafeHandle.Create(); completionQueue.CompletionRegistry.RegisterBatchCompletion(ctx, (success, context) => callback(success, context.GetReceivedStatusOnClient())); - Native.grpcsharp_call_start_duplex_streaming(this, ctx, metadataArray).CheckOk(); + Native.grpcsharp_call_start_duplex_streaming(this, ctx, metadataArray, callFlags).CheckOk(); } } diff --git a/src/csharp/Grpc.Core/Internal/ChannelSafeHandle.cs b/src/csharp/Grpc.Core/Internal/ChannelSafeHandle.cs index 62864dff0c..0fb6360a23 100644 --- a/src/csharp/Grpc.Core/Internal/ChannelSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/ChannelSafeHandle.cs @@ -65,16 +65,13 @@ namespace Grpc.Core.Internal public CallSafeHandle CreateCall(CallSafeHandle parentCall, ContextPropagationFlags propagationMask, CompletionQueueSafeHandle cq, string method, string host, Timespec deadline, CallCredentialsSafeHandle credentials) { - using (Profilers.ForCurrentThread().NewScope("ChannelSafeHandle.CreateCall")) + var result = Native.grpcsharp_channel_create_call(this, parentCall, propagationMask, cq, method, host, deadline); + if (credentials != null) { - var result = Native.grpcsharp_channel_create_call(this, parentCall, propagationMask, cq, method, host, deadline); - if (credentials != null) - { - result.SetCredentials(credentials); - } - result.Initialize(cq); - return result; + result.SetCredentials(credentials); } + result.Initialize(cq); + return result; } public ChannelState CheckConnectivityState(bool tryToConnect) diff --git a/src/csharp/Grpc.Core/Internal/CompletionQueueSafeHandle.cs b/src/csharp/Grpc.Core/Internal/CompletionQueueSafeHandle.cs index 46f5624223..6c9a31921e 100644 --- a/src/csharp/Grpc.Core/Internal/CompletionQueueSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/CompletionQueueSafeHandle.cs @@ -70,10 +70,7 @@ namespace Grpc.Core.Internal public CompletionQueueEvent Pluck(IntPtr tag) { - using (Profilers.ForCurrentThread().NewScope("CompletionQueueSafeHandle.Pluck")) - { - return Native.grpcsharp_completion_queue_pluck(this, tag); - } + return Native.grpcsharp_completion_queue_pluck(this, tag); } /// <summary> diff --git a/src/csharp/Grpc.Core/Internal/GrpcThreadPool.cs b/src/csharp/Grpc.Core/Internal/GrpcThreadPool.cs index a446c1f99f..25a6589f11 100644 --- a/src/csharp/Grpc.Core/Internal/GrpcThreadPool.cs +++ b/src/csharp/Grpc.Core/Internal/GrpcThreadPool.cs @@ -37,6 +37,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using Grpc.Core.Logging; +using Grpc.Core.Profiling; using Grpc.Core.Utils; namespace Grpc.Core.Internal @@ -54,6 +55,8 @@ namespace Grpc.Core.Internal readonly int poolSize; readonly int completionQueueCount; + readonly List<BasicProfiler> threadProfilers = new List<BasicProfiler>(); // profilers assigned to threadpool threads + bool stopRequested; IReadOnlyCollection<CompletionQueueSafeHandle> completionQueues; @@ -82,7 +85,8 @@ namespace Grpc.Core.Internal for (int i = 0; i < poolSize; i++) { - threads.Add(CreateAndStartThread(i)); + var optionalProfiler = i < threadProfilers.Count ? threadProfilers[i] : null; + threads.Add(CreateAndStartThread(i, optionalProfiler)); } } } @@ -111,6 +115,11 @@ namespace Grpc.Core.Internal { cq.Dispose(); } + + for (int i = 0; i < threadProfilers.Count; i++) + { + threadProfilers[i].Dump(string.Format("grpc_trace_thread_{0}.txt", i)); + } }); } @@ -137,12 +146,12 @@ namespace Grpc.Core.Internal } } - private Thread CreateAndStartThread(int threadIndex) + private Thread CreateAndStartThread(int threadIndex, IProfiler optionalProfiler) { var cqIndex = threadIndex % completionQueues.Count; var cq = completionQueues.ElementAt(cqIndex); - var thread = new Thread(new ThreadStart(() => RunHandlerLoop(cq))); + var thread = new Thread(new ThreadStart(() => RunHandlerLoop(cq, optionalProfiler))); thread.IsBackground = true; thread.Name = string.Format("grpc {0} (cq {1})", threadIndex, cqIndex); thread.Start(); @@ -153,8 +162,13 @@ namespace Grpc.Core.Internal /// <summary> /// Body of the polling thread. /// </summary> - private void RunHandlerLoop(CompletionQueueSafeHandle cq) + private void RunHandlerLoop(CompletionQueueSafeHandle cq, IProfiler optionalProfiler) { + if (optionalProfiler != null) + { + Profilers.SetForCurrentThread(optionalProfiler); + } + CompletionQueueEvent ev; do { diff --git a/src/csharp/Grpc.Core/Internal/INativeCall.cs b/src/csharp/Grpc.Core/Internal/INativeCall.cs index cd3719cb50..94fbb08feb 100644 --- a/src/csharp/Grpc.Core/Internal/INativeCall.cs +++ b/src/csharp/Grpc.Core/Internal/INativeCall.cs @@ -31,6 +31,7 @@ #endregion using System; +using Grpc.Core; namespace Grpc.Core.Internal { @@ -54,19 +55,19 @@ namespace Grpc.Core.Internal { void Cancel(); - void CancelWithStatus(Grpc.Core.Status status); + void CancelWithStatus(Status status); string GetPeer(); - void StartUnary(UnaryResponseClientHandler callback, byte[] payload, MetadataArraySafeHandle metadataArray, Grpc.Core.WriteFlags writeFlags); + void StartUnary(UnaryResponseClientHandler callback, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags); - void StartUnary(BatchContextSafeHandle ctx, byte[] payload, MetadataArraySafeHandle metadataArray, Grpc.Core.WriteFlags writeFlags); + void StartUnary(BatchContextSafeHandle ctx, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags); - void StartClientStreaming(UnaryResponseClientHandler callback, MetadataArraySafeHandle metadataArray); + void StartClientStreaming(UnaryResponseClientHandler callback, MetadataArraySafeHandle metadataArray, CallFlags callFlags); - void StartServerStreaming(ReceivedStatusOnClientHandler callback, byte[] payload, MetadataArraySafeHandle metadataArray, Grpc.Core.WriteFlags writeFlags); + void StartServerStreaming(ReceivedStatusOnClientHandler callback, byte[] payload, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags callFlags); - void StartDuplexStreaming(ReceivedStatusOnClientHandler callback, MetadataArraySafeHandle metadataArray); + void StartDuplexStreaming(ReceivedStatusOnClientHandler callback, MetadataArraySafeHandle metadataArray, CallFlags callFlags); void StartReceiveMessage(ReceivedMessageHandler callback); @@ -74,11 +75,11 @@ namespace Grpc.Core.Internal void StartSendInitialMetadata(SendCompletionHandler callback, MetadataArraySafeHandle metadataArray); - void StartSendMessage(SendCompletionHandler callback, byte[] payload, Grpc.Core.WriteFlags writeFlags, bool sendEmptyInitialMetadata); + void StartSendMessage(SendCompletionHandler callback, byte[] payload, WriteFlags writeFlags, bool sendEmptyInitialMetadata); void StartSendCloseFromClient(SendCompletionHandler callback); - void StartSendStatusFromServer(SendCompletionHandler callback, Grpc.Core.Status status, MetadataArraySafeHandle metadataArray, bool sendEmptyInitialMetadata, byte[] optionalPayload, Grpc.Core.WriteFlags writeFlags); + void StartSendStatusFromServer(SendCompletionHandler callback, Status status, MetadataArraySafeHandle metadataArray, bool sendEmptyInitialMetadata, byte[] optionalPayload, WriteFlags writeFlags); void StartServerSide(ReceivedCloseOnServerHandler callback); } diff --git a/src/csharp/Grpc.Core/Internal/MetadataArraySafeHandle.cs b/src/csharp/Grpc.Core/Internal/MetadataArraySafeHandle.cs index dc9f62fdab..05dda5b148 100644 --- a/src/csharp/Grpc.Core/Internal/MetadataArraySafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/MetadataArraySafeHandle.cs @@ -48,22 +48,19 @@ namespace Grpc.Core.Internal public static MetadataArraySafeHandle Create(Metadata metadata) { - using (Profilers.ForCurrentThread().NewScope("MetadataArraySafeHandle.Create")) + if (metadata.Count == 0) { - if (metadata.Count == 0) - { - return new MetadataArraySafeHandle(); - } + return new MetadataArraySafeHandle(); + } - // TODO(jtattermusch): we might wanna check that the metadata is readonly - var metadataArray = Native.grpcsharp_metadata_array_create(new UIntPtr((ulong)metadata.Count)); - for (int i = 0; i < metadata.Count; i++) - { - var valueBytes = metadata[i].GetSerializedValueUnsafe(); - Native.grpcsharp_metadata_array_add(metadataArray, metadata[i].Key, valueBytes, new UIntPtr((ulong)valueBytes.Length)); - } - return metadataArray; + // TODO(jtattermusch): we might wanna check that the metadata is readonly + var metadataArray = Native.grpcsharp_metadata_array_create(new UIntPtr((ulong)metadata.Count)); + for (int i = 0; i < metadata.Count; i++) + { + var valueBytes = metadata[i].GetSerializedValueUnsafe(); + Native.grpcsharp_metadata_array_add(metadataArray, metadata[i].Key, valueBytes, new UIntPtr((ulong)valueBytes.Length)); } + return metadataArray; } /// <summary> diff --git a/src/csharp/Grpc.Core/Internal/NativeMethods.cs b/src/csharp/Grpc.Core/Internal/NativeMethods.cs index 40ba7e30cb..ce38e37093 100644 --- a/src/csharp/Grpc.Core/Internal/NativeMethods.cs +++ b/src/csharp/Grpc.Core/Internal/NativeMethods.cs @@ -325,14 +325,14 @@ namespace Grpc.Core.Internal public delegate CallError grpcsharp_call_cancel_delegate(CallSafeHandle call); public delegate CallError grpcsharp_call_cancel_with_status_delegate(CallSafeHandle call, StatusCode status, string description); public delegate CallError grpcsharp_call_start_unary_delegate(CallSafeHandle call, - BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, MetadataArraySafeHandle metadataArray, WriteFlags writeFlags); + BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); public delegate CallError grpcsharp_call_start_client_streaming_delegate(CallSafeHandle call, - BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray); + BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); public delegate CallError grpcsharp_call_start_server_streaming_delegate(CallSafeHandle call, - BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, - MetadataArraySafeHandle metadataArray, WriteFlags writeFlags); + BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, + MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); public delegate CallError grpcsharp_call_start_duplex_streaming_delegate(CallSafeHandle call, - BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray); + BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); public delegate CallError grpcsharp_call_send_message_delegate(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, bool sendEmptyInitialMetadata); public delegate CallError grpcsharp_call_send_close_from_client_delegate(CallSafeHandle call, diff --git a/src/csharp/Grpc.Core/Profiling/Profilers.cs b/src/csharp/Grpc.Core/Profiling/Profilers.cs index aa0d96c0e0..6afabff6a7 100644 --- a/src/csharp/Grpc.Core/Profiling/Profilers.cs +++ b/src/csharp/Grpc.Core/Profiling/Profilers.cs @@ -80,7 +80,7 @@ namespace Grpc.Core.Profiling ProfilerEntry[] entries; int count; - public BasicProfiler() : this(1024*1024) + public BasicProfiler() : this(20*1024*1024) { } diff --git a/src/csharp/Grpc.Core/packages.config b/src/csharp/Grpc.Core/packages.config index 6514774021..53cfad52f0 100644 --- a/src/csharp/Grpc.Core/packages.config +++ b/src/csharp/Grpc.Core/packages.config @@ -1,4 +1,4 @@ <?xml version="1.0" encoding="utf-8"?> <packages> - <package id="System.Interactive.Async" version="3.0.0" targetFramework="net45" /> + <package id="System.Interactive.Async" version="3.1.1" targetFramework="net45" /> </packages>
\ No newline at end of file diff --git a/src/csharp/Grpc.Core/project.json b/src/csharp/Grpc.Core/project.json index aa1e4cc7fb..4405ecc5a2 100644 --- a/src/csharp/Grpc.Core/project.json +++ b/src/csharp/Grpc.Core/project.json @@ -27,11 +27,10 @@ "embed": [ "../../../etc/roots.pem" ], "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true }, "dependencies": { - "System.Interactive.Async": "3.0.0" + "System.Interactive.Async": "3.1.1" }, "frameworks": { "net45": { }, diff --git a/src/csharp/Grpc.Dotnet.sln b/src/csharp/Grpc.Dotnet.sln index 98b3cd54ab..824c6822f7 100644 --- a/src/csharp/Grpc.Dotnet.sln +++ b/src/csharp/Grpc.Dotnet.sln @@ -1,7 +1,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.25123.0 +VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Grpc.Core", "Grpc.Core\Grpc.Core.xproj", "{DC9908B6-F291-4FC8-A46D-2EA2551790EC}" EndProject @@ -31,6 +31,10 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Grpc.IntegrationTesting.Ser EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Grpc.IntegrationTesting.StressClient", "Grpc.IntegrationTesting.StressClient\Grpc.IntegrationTesting.StressClient.xproj", "{0EBC910B-8867-4D3E-8686-91F34183D839}" EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Grpc.Reflection", "Grpc.Reflection\Grpc.Reflection.xproj", "{2B372155-80BA-4CF9-82D6-4B938E8EC3A0}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Grpc.Reflection.Tests", "Grpc.Reflection.Tests\Grpc.Reflection.Tests.xproj", "{FE90181D-A4B3-4A5C-8490-F07561E18E3B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -93,6 +97,14 @@ Global {0EBC910B-8867-4D3E-8686-91F34183D839}.Debug|Any CPU.Build.0 = Debug|Any CPU {0EBC910B-8867-4D3E-8686-91F34183D839}.Release|Any CPU.ActiveCfg = Release|Any CPU {0EBC910B-8867-4D3E-8686-91F34183D839}.Release|Any CPU.Build.0 = Release|Any CPU + {2B372155-80BA-4CF9-82D6-4B938E8EC3A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2B372155-80BA-4CF9-82D6-4B938E8EC3A0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2B372155-80BA-4CF9-82D6-4B938E8EC3A0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2B372155-80BA-4CF9-82D6-4B938E8EC3A0}.Release|Any CPU.Build.0 = Release|Any CPU + {FE90181D-A4B3-4A5C-8490-F07561E18E3B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FE90181D-A4B3-4A5C-8490-F07561E18E3B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FE90181D-A4B3-4A5C-8490-F07561E18E3B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FE90181D-A4B3-4A5C-8490-F07561E18E3B}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/csharp/Grpc.Examples.MathClient/project.json b/src/csharp/Grpc.Examples.MathClient/project.json index 628f532966..9a8880b5d4 100644 --- a/src/csharp/Grpc.Examples.MathClient/project.json +++ b/src/csharp/Grpc.Examples.MathClient/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -26,7 +25,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.Examples.MathServer/project.json b/src/csharp/Grpc.Examples.MathServer/project.json index 628f532966..9a8880b5d4 100644 --- a/src/csharp/Grpc.Examples.MathServer/project.json +++ b/src/csharp/Grpc.Examples.MathServer/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -26,7 +25,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.Examples.Tests/Grpc.Examples.Tests.csproj b/src/csharp/Grpc.Examples.Tests/Grpc.Examples.Tests.csproj index a114d96127..16d7a44f92 100644 --- a/src/csharp/Grpc.Examples.Tests/Grpc.Examples.Tests.csproj +++ b/src/csharp/Grpc.Examples.Tests/Grpc.Examples.Tests.csproj @@ -39,15 +39,15 @@ <Reference Include="nunit.framework"> <HintPath>..\packages\NUnit.3.2.0\lib\net45\nunit.framework.dll</HintPath> </Reference> - <Reference Include="System.Interactive.Async"> - <HintPath>..\packages\System.Interactive.Async.3.0.0\lib\net45\System.Interactive.Async.dll</HintPath> - </Reference> <Reference Include="nunitlite"> <HintPath>..\packages\NUnitLite.3.2.0\lib\net45\nunitlite.dll</HintPath> </Reference> <Reference Include="Google.Protobuf"> <HintPath>..\packages\Google.Protobuf.3.0.0\lib\net45\Google.Protobuf.dll</HintPath> </Reference> + <Reference Include="System.Interactive.Async"> + <HintPath>..\packages\System.Interactive.Async.3.1.1\lib\net45\System.Interactive.Async.dll</HintPath> + </Reference> </ItemGroup> <ItemGroup> <Compile Include="..\Grpc.Core\Version.cs"> diff --git a/src/csharp/Grpc.Examples.Tests/packages.config b/src/csharp/Grpc.Examples.Tests/packages.config index f14517d2e2..0fed4dbd41 100644 --- a/src/csharp/Grpc.Examples.Tests/packages.config +++ b/src/csharp/Grpc.Examples.Tests/packages.config @@ -3,5 +3,5 @@ <package id="Google.Protobuf" version="3.0.0" targetFramework="net45" /> <package id="NUnit" version="3.2.0" targetFramework="net45" /> <package id="NUnitLite" version="3.2.0" targetFramework="net45" /> - <package id="System.Interactive.Async" version="3.0.0" targetFramework="net45" /> + <package id="System.Interactive.Async" version="3.1.1" targetFramework="net45" /> </packages>
\ No newline at end of file diff --git a/src/csharp/Grpc.Examples.Tests/project.json b/src/csharp/Grpc.Examples.Tests/project.json index 0109617e6b..3e130beeac 100644 --- a/src/csharp/Grpc.Examples.Tests/project.json +++ b/src/csharp/Grpc.Examples.Tests/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -26,7 +25,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.Examples/Grpc.Examples.csproj b/src/csharp/Grpc.Examples/Grpc.Examples.csproj index dcbef5fc0b..c1ea2e2833 100644 --- a/src/csharp/Grpc.Examples/Grpc.Examples.csproj +++ b/src/csharp/Grpc.Examples/Grpc.Examples.csproj @@ -42,13 +42,12 @@ </Reference> <Reference Include="System" /> <Reference Include="System.Data.Linq" /> - <Reference Include="System.Interactive.Async, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> - <SpecificVersion>False</SpecificVersion> - <HintPath>..\packages\System.Interactive.Async.3.0.0\lib\net45\System.Interactive.Async.dll</HintPath> - </Reference> <Reference Include="Google.Protobuf"> <HintPath>..\packages\Google.Protobuf.3.0.0\lib\net45\Google.Protobuf.dll</HintPath> </Reference> + <Reference Include="System.Interactive.Async"> + <HintPath>..\packages\System.Interactive.Async.3.1.1\lib\net45\System.Interactive.Async.dll</HintPath> + </Reference> </ItemGroup> <ItemGroup> <Compile Include="..\Grpc.Core\Version.cs"> diff --git a/src/csharp/Grpc.Examples/Math.cs b/src/csharp/Grpc.Examples/Math.cs index fae4fd3c26..e5b76f8305 100644 --- a/src/csharp/Grpc.Examples/Math.cs +++ b/src/csharp/Grpc.Examples/Math.cs @@ -1,5 +1,5 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! -// source: math.proto +// source: math/math.proto #pragma warning disable 1591, 0612, 3021 #region Designer generated code @@ -9,11 +9,11 @@ using pbr = global::Google.Protobuf.Reflection; using scg = global::System.Collections.Generic; namespace Math { - /// <summary>Holder for reflection information generated from math.proto</summary> + /// <summary>Holder for reflection information generated from math/math.proto</summary> public static partial class MathReflection { #region Descriptor - /// <summary>File descriptor for math.proto</summary> + /// <summary>File descriptor for math/math.proto</summary> public static pbr::FileDescriptor Descriptor { get { return descriptor; } } @@ -22,15 +22,15 @@ namespace Math { static MathReflection() { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( - "CgptYXRoLnByb3RvEgRtYXRoIiwKB0RpdkFyZ3MSEAoIZGl2aWRlbmQYASAB", - "KAMSDwoHZGl2aXNvchgCIAEoAyIvCghEaXZSZXBseRIQCghxdW90aWVudBgB", - "IAEoAxIRCglyZW1haW5kZXIYAiABKAMiGAoHRmliQXJncxINCgVsaW1pdBgB", - "IAEoAyISCgNOdW0SCwoDbnVtGAEgASgDIhkKCEZpYlJlcGx5Eg0KBWNvdW50", - "GAEgASgDMqQBCgRNYXRoEiYKA0RpdhINLm1hdGguRGl2QXJncxoOLm1hdGgu", - "RGl2UmVwbHkiABIuCgdEaXZNYW55Eg0ubWF0aC5EaXZBcmdzGg4ubWF0aC5E", - "aXZSZXBseSIAKAEwARIjCgNGaWISDS5tYXRoLkZpYkFyZ3MaCS5tYXRoLk51", - "bSIAMAESHwoDU3VtEgkubWF0aC5OdW0aCS5tYXRoLk51bSIAKAFiBnByb3Rv", - "Mw==")); + "Cg9tYXRoL21hdGgucHJvdG8SBG1hdGgiLAoHRGl2QXJncxIQCghkaXZpZGVu", + "ZBgBIAEoAxIPCgdkaXZpc29yGAIgASgDIi8KCERpdlJlcGx5EhAKCHF1b3Rp", + "ZW50GAEgASgDEhEKCXJlbWFpbmRlchgCIAEoAyIYCgdGaWJBcmdzEg0KBWxp", + "bWl0GAEgASgDIhIKA051bRILCgNudW0YASABKAMiGQoIRmliUmVwbHkSDQoF", + "Y291bnQYASABKAMypAEKBE1hdGgSJgoDRGl2Eg0ubWF0aC5EaXZBcmdzGg4u", + "bWF0aC5EaXZSZXBseSIAEi4KB0Rpdk1hbnkSDS5tYXRoLkRpdkFyZ3MaDi5t", + "YXRoLkRpdlJlcGx5IgAoATABEiMKA0ZpYhINLm1hdGguRmliQXJncxoJLm1h", + "dGguTnVtIgAwARIfCgNTdW0SCS5tYXRoLk51bRoJLm1hdGguTnVtIgAoAWIG", + "cHJvdG8z")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { diff --git a/src/csharp/Grpc.Examples/MathGrpc.cs b/src/csharp/Grpc.Examples/MathGrpc.cs index d6ba61e7dc..8b431c7218 100644 --- a/src/csharp/Grpc.Examples/MathGrpc.cs +++ b/src/csharp/Grpc.Examples/MathGrpc.cs @@ -1,5 +1,5 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! -// source: math.proto +// source: math/math.proto // Original file comments: // Copyright 2015, Google Inc. // All rights reserved. @@ -38,7 +38,7 @@ using System.Threading.Tasks; using Grpc.Core; namespace Math { - public static class Math + public static partial class Math { static readonly string __ServiceName = "math.Math"; @@ -82,7 +82,7 @@ namespace Math { } /// <summary>Base class for server-side implementations of Math</summary> - public abstract class MathBase + public abstract partial class MathBase { /// <summary> /// Div divides DivArgs.dividend by DivArgs.divisor and returns the quotient @@ -126,7 +126,7 @@ namespace Math { } /// <summary>Client for Math</summary> - public class MathClient : ClientBase<MathClient> + public partial class MathClient : ClientBase<MathClient> { /// <summary>Creates a new client for Math</summary> /// <param name="channel">The channel to use to make remote calls.</param> diff --git a/src/csharp/Grpc.Examples/packages.config b/src/csharp/Grpc.Examples/packages.config index d17347f08f..c7db26bd64 100644 --- a/src/csharp/Grpc.Examples/packages.config +++ b/src/csharp/Grpc.Examples/packages.config @@ -2,5 +2,5 @@ <packages> <package id="Google.Protobuf" version="3.0.0" targetFramework="net45" /> <package id="NUnit" version="3.2.0" targetFramework="net45" /> - <package id="System.Interactive.Async" version="3.0.0" targetFramework="net45" /> + <package id="System.Interactive.Async" version="3.1.1" targetFramework="net45" /> </packages>
\ No newline at end of file diff --git a/src/csharp/Grpc.HealthCheck.Tests/project.json b/src/csharp/Grpc.HealthCheck.Tests/project.json index 66dcd79a39..addc782afe 100644 --- a/src/csharp/Grpc.HealthCheck.Tests/project.json +++ b/src/csharp/Grpc.HealthCheck.Tests/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -26,7 +25,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.HealthCheck/Grpc.HealthCheck.csproj b/src/csharp/Grpc.HealthCheck/Grpc.HealthCheck.csproj index 54a2984964..7418768316 100644 --- a/src/csharp/Grpc.HealthCheck/Grpc.HealthCheck.csproj +++ b/src/csharp/Grpc.HealthCheck/Grpc.HealthCheck.csproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> @@ -40,10 +40,6 @@ <ItemGroup> <Reference Include="System" /> <Reference Include="System.Core" /> - <Reference Include="System.Interactive.Async, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> - <SpecificVersion>False</SpecificVersion> - <HintPath>..\packages\System.Interactive.Async.3.0.0\lib\net45\System.Interactive.Async.dll</HintPath> - </Reference> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Data.DataSetExtensions" /> <Reference Include="Microsoft.CSharp" /> @@ -52,6 +48,9 @@ <Reference Include="Google.Protobuf"> <HintPath>..\packages\Google.Protobuf.3.0.0\lib\net45\Google.Protobuf.dll</HintPath> </Reference> + <Reference Include="System.Interactive.Async"> + <HintPath>..\packages\System.Interactive.Async.3.1.1\lib\net45\System.Interactive.Async.dll</HintPath> + </Reference> </ItemGroup> <ItemGroup> <Compile Include="..\Grpc.Core\Version.cs"> @@ -63,13 +62,12 @@ <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> - <None Include="Grpc.HealthCheck.nuspec" /> <None Include="Grpc.HealthCheck.project.json" /> <None Include="packages.config" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\Grpc.Core\Grpc.Core.csproj"> - <Project>{ccc4440e-49f7-4790-b0af-feabb0837ae7}</Project> + <Project>{CCC4440E-49F7-4790-B0AF-FEABB0837AE7}</Project> <Name>Grpc.Core</Name> </ProjectReference> </ItemGroup> diff --git a/src/csharp/Grpc.HealthCheck/Grpc.HealthCheck.nuspec b/src/csharp/Grpc.HealthCheck/Grpc.HealthCheck.nuspec deleted file mode 100644 index 4ffd18ccb2..0000000000 --- a/src/csharp/Grpc.HealthCheck/Grpc.HealthCheck.nuspec +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<package> - <metadata> - <id>Grpc.HealthCheck</id> - <title>gRPC C# Healthchecking</title> - <summary>Implementation of gRPC health service</summary> - <description>Example implementation of grpc.health.v1 service that can be used for health-checking.</description> - <version>$version$</version> - <authors>Google Inc.</authors> - <owners>grpc-packages</owners> - <licenseUrl>https://github.com/grpc/grpc/blob/master/LICENSE</licenseUrl> - <projectUrl>https://github.com/grpc/grpc</projectUrl> - <requireLicenseAcceptance>false</requireLicenseAcceptance> - <copyright>Copyright 2015, Google Inc.</copyright> - <tags>gRPC health check</tags> - <dependencies> - <dependency id="Google.Protobuf" version="$ProtobufVersion$" /> - <dependency id="Grpc.Core" version="$version$" /> - <dependency id="System.Interactive.Async" version="3.0.0" /> - </dependencies> - </metadata> - <files> - <file src="bin/ReleaseSigned/Grpc.HealthCheck.dll" target="lib/net45" /> - <file src="bin/ReleaseSigned/Grpc.HealthCheck.pdb" target="lib/net45" /> - <file src="bin/ReleaseSigned/Grpc.HealthCheck.xml" target="lib/net45" /> - <file src="**\*.cs" target="src" /> - </files> -</package> diff --git a/src/csharp/Grpc.HealthCheck/Health.cs b/src/csharp/Grpc.HealthCheck/Health.cs index b8e2e2274c..b9880d9636 100644 --- a/src/csharp/Grpc.HealthCheck/Health.cs +++ b/src/csharp/Grpc.HealthCheck/Health.cs @@ -1,5 +1,5 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! -// source: health.proto +// source: grpc/health/v1/health.proto #pragma warning disable 1591, 0612, 3021 #region Designer generated code @@ -9,11 +9,11 @@ using pbr = global::Google.Protobuf.Reflection; using scg = global::System.Collections.Generic; namespace Grpc.Health.V1 { - /// <summary>Holder for reflection information generated from health.proto</summary> + /// <summary>Holder for reflection information generated from grpc/health/v1/health.proto</summary> public static partial class HealthReflection { #region Descriptor - /// <summary>File descriptor for health.proto</summary> + /// <summary>File descriptor for grpc/health/v1/health.proto</summary> public static pbr::FileDescriptor Descriptor { get { return descriptor; } } @@ -22,14 +22,14 @@ namespace Grpc.Health.V1 { static HealthReflection() { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( - "CgxoZWFsdGgucHJvdG8SDmdycGMuaGVhbHRoLnYxIiUKEkhlYWx0aENoZWNr", - "UmVxdWVzdBIPCgdzZXJ2aWNlGAEgASgJIpQBChNIZWFsdGhDaGVja1Jlc3Bv", - "bnNlEkEKBnN0YXR1cxgBIAEoDjIxLmdycGMuaGVhbHRoLnYxLkhlYWx0aENo", - "ZWNrUmVzcG9uc2UuU2VydmluZ1N0YXR1cyI6Cg1TZXJ2aW5nU3RhdHVzEgsK", - "B1VOS05PV04QABILCgdTRVJWSU5HEAESDwoLTk9UX1NFUlZJTkcQAjJaCgZI", - "ZWFsdGgSUAoFQ2hlY2sSIi5ncnBjLmhlYWx0aC52MS5IZWFsdGhDaGVja1Jl", - "cXVlc3QaIy5ncnBjLmhlYWx0aC52MS5IZWFsdGhDaGVja1Jlc3BvbnNlQhGq", - "Ag5HcnBjLkhlYWx0aC5WMWIGcHJvdG8z")); + "ChtncnBjL2hlYWx0aC92MS9oZWFsdGgucHJvdG8SDmdycGMuaGVhbHRoLnYx", + "IiUKEkhlYWx0aENoZWNrUmVxdWVzdBIPCgdzZXJ2aWNlGAEgASgJIpQBChNI", + "ZWFsdGhDaGVja1Jlc3BvbnNlEkEKBnN0YXR1cxgBIAEoDjIxLmdycGMuaGVh", + "bHRoLnYxLkhlYWx0aENoZWNrUmVzcG9uc2UuU2VydmluZ1N0YXR1cyI6Cg1T", + "ZXJ2aW5nU3RhdHVzEgsKB1VOS05PV04QABILCgdTRVJWSU5HEAESDwoLTk9U", + "X1NFUlZJTkcQAjJaCgZIZWFsdGgSUAoFQ2hlY2sSIi5ncnBjLmhlYWx0aC52", + "MS5IZWFsdGhDaGVja1JlcXVlc3QaIy5ncnBjLmhlYWx0aC52MS5IZWFsdGhD", + "aGVja1Jlc3BvbnNlQhGqAg5HcnBjLkhlYWx0aC5WMWIGcHJvdG8z")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { diff --git a/src/csharp/Grpc.HealthCheck/HealthGrpc.cs b/src/csharp/Grpc.HealthCheck/HealthGrpc.cs index b2a35a79be..ad5cf11b75 100644 --- a/src/csharp/Grpc.HealthCheck/HealthGrpc.cs +++ b/src/csharp/Grpc.HealthCheck/HealthGrpc.cs @@ -1,5 +1,5 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! -// source: health.proto +// source: grpc/health/v1/health.proto // Original file comments: // Copyright 2015, Google Inc. // All rights reserved. @@ -38,7 +38,7 @@ using System.Threading.Tasks; using Grpc.Core; namespace Grpc.Health.V1 { - public static class Health + public static partial class Health { static readonly string __ServiceName = "grpc.health.v1.Health"; @@ -59,7 +59,7 @@ namespace Grpc.Health.V1 { } /// <summary>Base class for server-side implementations of Health</summary> - public abstract class HealthBase + public abstract partial class HealthBase { public virtual global::System.Threading.Tasks.Task<global::Grpc.Health.V1.HealthCheckResponse> Check(global::Grpc.Health.V1.HealthCheckRequest request, ServerCallContext context) { @@ -69,7 +69,7 @@ namespace Grpc.Health.V1 { } /// <summary>Client for Health</summary> - public class HealthClient : ClientBase<HealthClient> + public partial class HealthClient : ClientBase<HealthClient> { /// <summary>Creates a new client for Health</summary> /// <param name="channel">The channel to use to make remote calls.</param> diff --git a/src/csharp/Grpc.HealthCheck/packages.config b/src/csharp/Grpc.HealthCheck/packages.config index f8e353bf26..5ab40b7a8c 100644 --- a/src/csharp/Grpc.HealthCheck/packages.config +++ b/src/csharp/Grpc.HealthCheck/packages.config @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> <packages> <package id="Google.Protobuf" version="3.0.0" targetFramework="net45" /> - <package id="System.Interactive.Async" version="3.0.0" targetFramework="net45" /> + <package id="System.Interactive.Async" version="3.1.1" targetFramework="net45" /> </packages>
\ No newline at end of file diff --git a/src/csharp/Grpc.HealthCheck/project.json b/src/csharp/Grpc.HealthCheck/project.json index 9d631229d8..8f1237d003 100644 --- a/src/csharp/Grpc.HealthCheck/project.json +++ b/src/csharp/Grpc.HealthCheck/project.json @@ -15,7 +15,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.IntegrationTesting.Client/project.json b/src/csharp/Grpc.IntegrationTesting.Client/project.json index 1b900c8af3..ad81cbc48b 100644 --- a/src/csharp/Grpc.IntegrationTesting.Client/project.json +++ b/src/csharp/Grpc.IntegrationTesting.Client/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -29,7 +28,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.IntegrationTesting.QpsWorker/project.json b/src/csharp/Grpc.IntegrationTesting.QpsWorker/project.json index fe200f8d44..2c7643b74f 100644 --- a/src/csharp/Grpc.IntegrationTesting.QpsWorker/project.json +++ b/src/csharp/Grpc.IntegrationTesting.QpsWorker/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -29,7 +28,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.IntegrationTesting.Server/project.json b/src/csharp/Grpc.IntegrationTesting.Server/project.json index 1b900c8af3..ad81cbc48b 100644 --- a/src/csharp/Grpc.IntegrationTesting.Server/project.json +++ b/src/csharp/Grpc.IntegrationTesting.Server/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -29,7 +28,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.IntegrationTesting.StressClient/project.json b/src/csharp/Grpc.IntegrationTesting.StressClient/project.json index 1b900c8af3..ad81cbc48b 100644 --- a/src/csharp/Grpc.IntegrationTesting.StressClient/project.json +++ b/src/csharp/Grpc.IntegrationTesting.StressClient/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -29,7 +28,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.IntegrationTesting/Control.cs b/src/csharp/Grpc.IntegrationTesting/Control.cs index 7928b51ba5..3f4862d567 100644 --- a/src/csharp/Grpc.IntegrationTesting/Control.cs +++ b/src/csharp/Grpc.IntegrationTesting/Control.cs @@ -45,44 +45,48 @@ namespace Grpc.Testing { "dGF0cxgBIAEoCzIZLmdycGMudGVzdGluZy5DbGllbnRTdGF0cyIVCgRNYXJr", "Eg0KBXJlc2V0GAEgASgIImgKCkNsaWVudEFyZ3MSKwoFc2V0dXAYASABKAsy", "Gi5ncnBjLnRlc3RpbmcuQ2xpZW50Q29uZmlnSAASIgoEbWFyaxgCIAEoCzIS", - "LmdycGMudGVzdGluZy5NYXJrSABCCQoHYXJndHlwZSKWAgoMU2VydmVyQ29u", + "LmdycGMudGVzdGluZy5NYXJrSABCCQoHYXJndHlwZSK0AgoMU2VydmVyQ29u", "ZmlnEi0KC3NlcnZlcl90eXBlGAEgASgOMhguZ3JwYy50ZXN0aW5nLlNlcnZl", "clR5cGUSNQoPc2VjdXJpdHlfcGFyYW1zGAIgASgLMhwuZ3JwYy50ZXN0aW5n", "LlNlY3VyaXR5UGFyYW1zEgwKBHBvcnQYBCABKAUSHAoUYXN5bmNfc2VydmVy", "X3RocmVhZHMYByABKAUSEgoKY29yZV9saW1pdBgIIAEoBRIzCg5wYXlsb2Fk", "X2NvbmZpZxgJIAEoCzIbLmdycGMudGVzdGluZy5QYXlsb2FkQ29uZmlnEhEK", - "CWNvcmVfbGlzdBgKIAMoBRIYChBvdGhlcl9zZXJ2ZXJfYXBpGAsgASgJImgK", - "ClNlcnZlckFyZ3MSKwoFc2V0dXAYASABKAsyGi5ncnBjLnRlc3RpbmcuU2Vy", - "dmVyQ29uZmlnSAASIgoEbWFyaxgCIAEoCzISLmdycGMudGVzdGluZy5NYXJr", - "SABCCQoHYXJndHlwZSJVCgxTZXJ2ZXJTdGF0dXMSKAoFc3RhdHMYASABKAsy", - "GS5ncnBjLnRlc3RpbmcuU2VydmVyU3RhdHMSDAoEcG9ydBgCIAEoBRINCgVj", - "b3JlcxgDIAEoBSINCgtDb3JlUmVxdWVzdCIdCgxDb3JlUmVzcG9uc2USDQoF", - "Y29yZXMYASABKAUiBgoEVm9pZCL9AQoIU2NlbmFyaW8SDAoEbmFtZRgBIAEo", - "CRIxCg1jbGllbnRfY29uZmlnGAIgASgLMhouZ3JwYy50ZXN0aW5nLkNsaWVu", - "dENvbmZpZxITCgtudW1fY2xpZW50cxgDIAEoBRIxCg1zZXJ2ZXJfY29uZmln", - "GAQgASgLMhouZ3JwYy50ZXN0aW5nLlNlcnZlckNvbmZpZxITCgtudW1fc2Vy", - "dmVycxgFIAEoBRIWCg53YXJtdXBfc2Vjb25kcxgGIAEoBRIZChFiZW5jaG1h", - "cmtfc2Vjb25kcxgHIAEoBRIgChhzcGF3bl9sb2NhbF93b3JrZXJfY291bnQY", - "CCABKAUiNgoJU2NlbmFyaW9zEikKCXNjZW5hcmlvcxgBIAMoCzIWLmdycGMu", - "dGVzdGluZy5TY2VuYXJpbyKSAgoVU2NlbmFyaW9SZXN1bHRTdW1tYXJ5EgsK", - "A3FwcxgBIAEoARIbChNxcHNfcGVyX3NlcnZlcl9jb3JlGAIgASgBEhoKEnNl", - "cnZlcl9zeXN0ZW1fdGltZRgDIAEoARIYChBzZXJ2ZXJfdXNlcl90aW1lGAQg", - "ASgBEhoKEmNsaWVudF9zeXN0ZW1fdGltZRgFIAEoARIYChBjbGllbnRfdXNl", - "cl90aW1lGAYgASgBEhIKCmxhdGVuY3lfNTAYByABKAESEgoKbGF0ZW5jeV85", - "MBgIIAEoARISCgpsYXRlbmN5Xzk1GAkgASgBEhIKCmxhdGVuY3lfOTkYCiAB", - "KAESEwoLbGF0ZW5jeV85OTkYCyABKAEiyAIKDlNjZW5hcmlvUmVzdWx0EigK", - "CHNjZW5hcmlvGAEgASgLMhYuZ3JwYy50ZXN0aW5nLlNjZW5hcmlvEi4KCWxh", - "dGVuY2llcxgCIAEoCzIbLmdycGMudGVzdGluZy5IaXN0b2dyYW1EYXRhEi8K", - "DGNsaWVudF9zdGF0cxgDIAMoCzIZLmdycGMudGVzdGluZy5DbGllbnRTdGF0", - "cxIvCgxzZXJ2ZXJfc3RhdHMYBCADKAsyGS5ncnBjLnRlc3RpbmcuU2VydmVy", - "U3RhdHMSFAoMc2VydmVyX2NvcmVzGAUgAygFEjQKB3N1bW1hcnkYBiABKAsy", - "Iy5ncnBjLnRlc3RpbmcuU2NlbmFyaW9SZXN1bHRTdW1tYXJ5EhYKDmNsaWVu", - "dF9zdWNjZXNzGAcgAygIEhYKDnNlcnZlcl9zdWNjZXNzGAggAygIKkEKCkNs", - "aWVudFR5cGUSDwoLU1lOQ19DTElFTlQQABIQCgxBU1lOQ19DTElFTlQQARIQ", - "CgxPVEhFUl9DTElFTlQQAipbCgpTZXJ2ZXJUeXBlEg8KC1NZTkNfU0VSVkVS", - "EAASEAoMQVNZTkNfU0VSVkVSEAESGAoUQVNZTkNfR0VORVJJQ19TRVJWRVIQ", - "AhIQCgxPVEhFUl9TRVJWRVIQAyojCgdScGNUeXBlEgkKBVVOQVJZEAASDQoJ", - "U1RSRUFNSU5HEAFiBnByb3RvMw==")); + "CWNvcmVfbGlzdBgKIAMoBRIYChBvdGhlcl9zZXJ2ZXJfYXBpGAsgASgJEhwK", + "E3Jlc291cmNlX3F1b3RhX3NpemUY6QcgASgFImgKClNlcnZlckFyZ3MSKwoF", + "c2V0dXAYASABKAsyGi5ncnBjLnRlc3RpbmcuU2VydmVyQ29uZmlnSAASIgoE", + "bWFyaxgCIAEoCzISLmdycGMudGVzdGluZy5NYXJrSABCCQoHYXJndHlwZSJV", + "CgxTZXJ2ZXJTdGF0dXMSKAoFc3RhdHMYASABKAsyGS5ncnBjLnRlc3Rpbmcu", + "U2VydmVyU3RhdHMSDAoEcG9ydBgCIAEoBRINCgVjb3JlcxgDIAEoBSINCgtD", + "b3JlUmVxdWVzdCIdCgxDb3JlUmVzcG9uc2USDQoFY29yZXMYASABKAUiBgoE", + "Vm9pZCL9AQoIU2NlbmFyaW8SDAoEbmFtZRgBIAEoCRIxCg1jbGllbnRfY29u", + "ZmlnGAIgASgLMhouZ3JwYy50ZXN0aW5nLkNsaWVudENvbmZpZxITCgtudW1f", + "Y2xpZW50cxgDIAEoBRIxCg1zZXJ2ZXJfY29uZmlnGAQgASgLMhouZ3JwYy50", + "ZXN0aW5nLlNlcnZlckNvbmZpZxITCgtudW1fc2VydmVycxgFIAEoBRIWCg53", + "YXJtdXBfc2Vjb25kcxgGIAEoBRIZChFiZW5jaG1hcmtfc2Vjb25kcxgHIAEo", + "BRIgChhzcGF3bl9sb2NhbF93b3JrZXJfY291bnQYCCABKAUiNgoJU2NlbmFy", + "aW9zEikKCXNjZW5hcmlvcxgBIAMoCzIWLmdycGMudGVzdGluZy5TY2VuYXJp", + "byL4AgoVU2NlbmFyaW9SZXN1bHRTdW1tYXJ5EgsKA3FwcxgBIAEoARIbChNx", + "cHNfcGVyX3NlcnZlcl9jb3JlGAIgASgBEhoKEnNlcnZlcl9zeXN0ZW1fdGlt", + "ZRgDIAEoARIYChBzZXJ2ZXJfdXNlcl90aW1lGAQgASgBEhoKEmNsaWVudF9z", + "eXN0ZW1fdGltZRgFIAEoARIYChBjbGllbnRfdXNlcl90aW1lGAYgASgBEhIK", + "CmxhdGVuY3lfNTAYByABKAESEgoKbGF0ZW5jeV85MBgIIAEoARISCgpsYXRl", + "bmN5Xzk1GAkgASgBEhIKCmxhdGVuY3lfOTkYCiABKAESEwoLbGF0ZW5jeV85", + "OTkYCyABKAESGAoQc2VydmVyX2NwdV91c2FnZRgMIAEoARImCh5zdWNjZXNz", + "ZnVsX3JlcXVlc3RzX3Blcl9zZWNvbmQYDSABKAESIgoaZmFpbGVkX3JlcXVl", + "c3RzX3Blcl9zZWNvbmQYDiABKAEigwMKDlNjZW5hcmlvUmVzdWx0EigKCHNj", + "ZW5hcmlvGAEgASgLMhYuZ3JwYy50ZXN0aW5nLlNjZW5hcmlvEi4KCWxhdGVu", + "Y2llcxgCIAEoCzIbLmdycGMudGVzdGluZy5IaXN0b2dyYW1EYXRhEi8KDGNs", + "aWVudF9zdGF0cxgDIAMoCzIZLmdycGMudGVzdGluZy5DbGllbnRTdGF0cxIv", + "CgxzZXJ2ZXJfc3RhdHMYBCADKAsyGS5ncnBjLnRlc3RpbmcuU2VydmVyU3Rh", + "dHMSFAoMc2VydmVyX2NvcmVzGAUgAygFEjQKB3N1bW1hcnkYBiABKAsyIy5n", + "cnBjLnRlc3RpbmcuU2NlbmFyaW9SZXN1bHRTdW1tYXJ5EhYKDmNsaWVudF9z", + "dWNjZXNzGAcgAygIEhYKDnNlcnZlcl9zdWNjZXNzGAggAygIEjkKD3JlcXVl", + "c3RfcmVzdWx0cxgJIAMoCzIgLmdycGMudGVzdGluZy5SZXF1ZXN0UmVzdWx0", + "Q291bnQqQQoKQ2xpZW50VHlwZRIPCgtTWU5DX0NMSUVOVBAAEhAKDEFTWU5D", + "X0NMSUVOVBABEhAKDE9USEVSX0NMSUVOVBACKlsKClNlcnZlclR5cGUSDwoL", + "U1lOQ19TRVJWRVIQABIQCgxBU1lOQ19TRVJWRVIQARIYChRBU1lOQ19HRU5F", + "UklDX1NFUlZFUhACEhAKDE9USEVSX1NFUlZFUhADKiMKB1JwY1R5cGUSCQoF", + "VU5BUlkQABINCglTVFJFQU1JTkcQAWIGcHJvdG8z")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Grpc.Testing.PayloadsReflection.Descriptor, global::Grpc.Testing.StatsReflection.Descriptor, }, new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Grpc.Testing.ClientType), typeof(global::Grpc.Testing.ServerType), typeof(global::Grpc.Testing.RpcType), }, new pbr::GeneratedClrTypeInfo[] { @@ -94,7 +98,7 @@ namespace Grpc.Testing { new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ClientStatus), global::Grpc.Testing.ClientStatus.Parser, new[]{ "Stats" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.Mark), global::Grpc.Testing.Mark.Parser, new[]{ "Reset" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ClientArgs), global::Grpc.Testing.ClientArgs.Parser, new[]{ "Setup", "Mark" }, new[]{ "Argtype" }, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ServerConfig), global::Grpc.Testing.ServerConfig.Parser, new[]{ "ServerType", "SecurityParams", "Port", "AsyncServerThreads", "CoreLimit", "PayloadConfig", "CoreList", "OtherServerApi" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ServerConfig), global::Grpc.Testing.ServerConfig.Parser, new[]{ "ServerType", "SecurityParams", "Port", "AsyncServerThreads", "CoreLimit", "PayloadConfig", "CoreList", "OtherServerApi", "ResourceQuotaSize" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ServerArgs), global::Grpc.Testing.ServerArgs.Parser, new[]{ "Setup", "Mark" }, new[]{ "Argtype" }, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ServerStatus), global::Grpc.Testing.ServerStatus.Parser, new[]{ "Stats", "Port", "Cores" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.CoreRequest), global::Grpc.Testing.CoreRequest.Parser, null, null, null, null), @@ -102,8 +106,8 @@ namespace Grpc.Testing { new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.Void), global::Grpc.Testing.Void.Parser, null, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.Scenario), global::Grpc.Testing.Scenario.Parser, new[]{ "Name", "ClientConfig", "NumClients", "ServerConfig", "NumServers", "WarmupSeconds", "BenchmarkSeconds", "SpawnLocalWorkerCount" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.Scenarios), global::Grpc.Testing.Scenarios.Parser, new[]{ "Scenarios_" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ScenarioResultSummary), global::Grpc.Testing.ScenarioResultSummary.Parser, new[]{ "Qps", "QpsPerServerCore", "ServerSystemTime", "ServerUserTime", "ClientSystemTime", "ClientUserTime", "Latency50", "Latency90", "Latency95", "Latency99", "Latency999" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ScenarioResult), global::Grpc.Testing.ScenarioResult.Parser, new[]{ "Scenario", "Latencies", "ClientStats", "ServerStats", "ServerCores", "Summary", "ClientSuccess", "ServerSuccess" }, null, null, null) + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ScenarioResultSummary), global::Grpc.Testing.ScenarioResultSummary.Parser, new[]{ "Qps", "QpsPerServerCore", "ServerSystemTime", "ServerUserTime", "ClientSystemTime", "ClientUserTime", "Latency50", "Latency90", "Latency95", "Latency99", "Latency999", "ServerCpuUsage", "SuccessfulRequestsPerSecond", "FailedRequestsPerSecond" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ScenarioResult), global::Grpc.Testing.ScenarioResult.Parser, new[]{ "Scenario", "Latencies", "ClientStats", "ServerStats", "ServerCores", "Summary", "ClientSuccess", "ServerSuccess", "RequestResults" }, null, null, null) })); } #endregion @@ -1641,6 +1645,7 @@ namespace Grpc.Testing { PayloadConfig = other.payloadConfig_ != null ? other.PayloadConfig.Clone() : null; coreList_ = other.coreList_.Clone(); otherServerApi_ = other.otherServerApi_; + resourceQuotaSize_ = other.resourceQuotaSize_; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1753,6 +1758,20 @@ namespace Grpc.Testing { } } + /// <summary>Field number for the "resource_quota_size" field.</summary> + public const int ResourceQuotaSizeFieldNumber = 1001; + private int resourceQuotaSize_; + /// <summary> + /// Buffer pool size (no buffer pool specified if unset) + /// </summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int ResourceQuotaSize { + get { return resourceQuotaSize_; } + set { + resourceQuotaSize_ = value; + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as ServerConfig); @@ -1774,6 +1793,7 @@ namespace Grpc.Testing { if (!object.Equals(PayloadConfig, other.PayloadConfig)) return false; if(!coreList_.Equals(other.coreList_)) return false; if (OtherServerApi != other.OtherServerApi) return false; + if (ResourceQuotaSize != other.ResourceQuotaSize) return false; return true; } @@ -1788,6 +1808,7 @@ namespace Grpc.Testing { if (payloadConfig_ != null) hash ^= PayloadConfig.GetHashCode(); hash ^= coreList_.GetHashCode(); if (OtherServerApi.Length != 0) hash ^= OtherServerApi.GetHashCode(); + if (ResourceQuotaSize != 0) hash ^= ResourceQuotaSize.GetHashCode(); return hash; } @@ -1827,6 +1848,10 @@ namespace Grpc.Testing { output.WriteRawTag(90); output.WriteString(OtherServerApi); } + if (ResourceQuotaSize != 0) { + output.WriteRawTag(200, 62); + output.WriteInt32(ResourceQuotaSize); + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1854,6 +1879,9 @@ namespace Grpc.Testing { if (OtherServerApi.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeStringSize(OtherServerApi); } + if (ResourceQuotaSize != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(ResourceQuotaSize); + } return size; } @@ -1890,6 +1918,9 @@ namespace Grpc.Testing { if (other.OtherServerApi.Length != 0) { OtherServerApi = other.OtherServerApi; } + if (other.ResourceQuotaSize != 0) { + ResourceQuotaSize = other.ResourceQuotaSize; + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1939,6 +1970,10 @@ namespace Grpc.Testing { OtherServerApi = input.ReadString(); break; } + case 8008: { + ResourceQuotaSize = input.ReadInt32(); + break; + } } } } @@ -3117,6 +3152,9 @@ namespace Grpc.Testing { latency95_ = other.latency95_; latency99_ = other.latency99_; latency999_ = other.latency999_; + serverCpuUsage_ = other.serverCpuUsage_; + successfulRequestsPerSecond_ = other.successfulRequestsPerSecond_; + failedRequestsPerSecond_ = other.failedRequestsPerSecond_; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -3266,6 +3304,45 @@ namespace Grpc.Testing { } } + /// <summary>Field number for the "server_cpu_usage" field.</summary> + public const int ServerCpuUsageFieldNumber = 12; + private double serverCpuUsage_; + /// <summary> + /// server cpu usage percentage + /// </summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double ServerCpuUsage { + get { return serverCpuUsage_; } + set { + serverCpuUsage_ = value; + } + } + + /// <summary>Field number for the "successful_requests_per_second" field.</summary> + public const int SuccessfulRequestsPerSecondFieldNumber = 13; + private double successfulRequestsPerSecond_; + /// <summary> + /// Number of requests that succeeded/failed + /// </summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double SuccessfulRequestsPerSecond { + get { return successfulRequestsPerSecond_; } + set { + successfulRequestsPerSecond_ = value; + } + } + + /// <summary>Field number for the "failed_requests_per_second" field.</summary> + public const int FailedRequestsPerSecondFieldNumber = 14; + private double failedRequestsPerSecond_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double FailedRequestsPerSecond { + get { return failedRequestsPerSecond_; } + set { + failedRequestsPerSecond_ = value; + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as ScenarioResultSummary); @@ -3290,6 +3367,9 @@ namespace Grpc.Testing { if (Latency95 != other.Latency95) return false; if (Latency99 != other.Latency99) return false; if (Latency999 != other.Latency999) return false; + if (ServerCpuUsage != other.ServerCpuUsage) return false; + if (SuccessfulRequestsPerSecond != other.SuccessfulRequestsPerSecond) return false; + if (FailedRequestsPerSecond != other.FailedRequestsPerSecond) return false; return true; } @@ -3307,6 +3387,9 @@ namespace Grpc.Testing { if (Latency95 != 0D) hash ^= Latency95.GetHashCode(); if (Latency99 != 0D) hash ^= Latency99.GetHashCode(); if (Latency999 != 0D) hash ^= Latency999.GetHashCode(); + if (ServerCpuUsage != 0D) hash ^= ServerCpuUsage.GetHashCode(); + if (SuccessfulRequestsPerSecond != 0D) hash ^= SuccessfulRequestsPerSecond.GetHashCode(); + if (FailedRequestsPerSecond != 0D) hash ^= FailedRequestsPerSecond.GetHashCode(); return hash; } @@ -3361,6 +3444,18 @@ namespace Grpc.Testing { output.WriteRawTag(89); output.WriteDouble(Latency999); } + if (ServerCpuUsage != 0D) { + output.WriteRawTag(97); + output.WriteDouble(ServerCpuUsage); + } + if (SuccessfulRequestsPerSecond != 0D) { + output.WriteRawTag(105); + output.WriteDouble(SuccessfulRequestsPerSecond); + } + if (FailedRequestsPerSecond != 0D) { + output.WriteRawTag(113); + output.WriteDouble(FailedRequestsPerSecond); + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -3399,6 +3494,15 @@ namespace Grpc.Testing { if (Latency999 != 0D) { size += 1 + 8; } + if (ServerCpuUsage != 0D) { + size += 1 + 8; + } + if (SuccessfulRequestsPerSecond != 0D) { + size += 1 + 8; + } + if (FailedRequestsPerSecond != 0D) { + size += 1 + 8; + } return size; } @@ -3440,6 +3544,15 @@ namespace Grpc.Testing { if (other.Latency999 != 0D) { Latency999 = other.Latency999; } + if (other.ServerCpuUsage != 0D) { + ServerCpuUsage = other.ServerCpuUsage; + } + if (other.SuccessfulRequestsPerSecond != 0D) { + SuccessfulRequestsPerSecond = other.SuccessfulRequestsPerSecond; + } + if (other.FailedRequestsPerSecond != 0D) { + FailedRequestsPerSecond = other.FailedRequestsPerSecond; + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -3494,6 +3607,18 @@ namespace Grpc.Testing { Latency999 = input.ReadDouble(); break; } + case 97: { + ServerCpuUsage = input.ReadDouble(); + break; + } + case 105: { + SuccessfulRequestsPerSecond = input.ReadDouble(); + break; + } + case 113: { + FailedRequestsPerSecond = input.ReadDouble(); + break; + } } } } @@ -3535,6 +3660,7 @@ namespace Grpc.Testing { Summary = other.summary_ != null ? other.Summary.Clone() : null; clientSuccess_ = other.clientSuccess_.Clone(); serverSuccess_ = other.serverSuccess_.Clone(); + requestResults_ = other.requestResults_.Clone(); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -3646,6 +3772,19 @@ namespace Grpc.Testing { get { return serverSuccess_; } } + /// <summary>Field number for the "request_results" field.</summary> + public const int RequestResultsFieldNumber = 9; + private static readonly pb::FieldCodec<global::Grpc.Testing.RequestResultCount> _repeated_requestResults_codec + = pb::FieldCodec.ForMessage(74, global::Grpc.Testing.RequestResultCount.Parser); + private readonly pbc::RepeatedField<global::Grpc.Testing.RequestResultCount> requestResults_ = new pbc::RepeatedField<global::Grpc.Testing.RequestResultCount>(); + /// <summary> + /// Number of failed requests (one row per status code seen) + /// </summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<global::Grpc.Testing.RequestResultCount> RequestResults { + get { return requestResults_; } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as ScenarioResult); @@ -3667,6 +3806,7 @@ namespace Grpc.Testing { if (!object.Equals(Summary, other.Summary)) return false; if(!clientSuccess_.Equals(other.clientSuccess_)) return false; if(!serverSuccess_.Equals(other.serverSuccess_)) return false; + if(!requestResults_.Equals(other.requestResults_)) return false; return true; } @@ -3681,6 +3821,7 @@ namespace Grpc.Testing { if (summary_ != null) hash ^= Summary.GetHashCode(); hash ^= clientSuccess_.GetHashCode(); hash ^= serverSuccess_.GetHashCode(); + hash ^= requestResults_.GetHashCode(); return hash; } @@ -3708,6 +3849,7 @@ namespace Grpc.Testing { } clientSuccess_.WriteTo(output, _repeated_clientSuccess_codec); serverSuccess_.WriteTo(output, _repeated_serverSuccess_codec); + requestResults_.WriteTo(output, _repeated_requestResults_codec); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -3727,6 +3869,7 @@ namespace Grpc.Testing { } size += clientSuccess_.CalculateSize(_repeated_clientSuccess_codec); size += serverSuccess_.CalculateSize(_repeated_serverSuccess_codec); + size += requestResults_.CalculateSize(_repeated_requestResults_codec); return size; } @@ -3758,6 +3901,7 @@ namespace Grpc.Testing { } clientSuccess_.Add(other.clientSuccess_); serverSuccess_.Add(other.serverSuccess_); + requestResults_.Add(other.requestResults_); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -3812,6 +3956,10 @@ namespace Grpc.Testing { serverSuccess_.AddEntriesFrom(input, _repeated_serverSuccess_codec); break; } + case 74: { + requestResults_.AddEntriesFrom(input, _repeated_requestResults_codec); + break; + } } } } diff --git a/src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj b/src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj index afd85fb484..161b015300 100644 --- a/src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj +++ b/src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj @@ -51,9 +51,6 @@ <Reference Include="nunit.framework"> <HintPath>..\packages\NUnit.3.2.0\lib\net45\nunit.framework.dll</HintPath> </Reference> - <Reference Include="System.Interactive.Async"> - <HintPath>..\packages\System.Interactive.Async.3.0.0\lib\net45\System.Interactive.Async.dll</HintPath> - </Reference> <Reference Include="nunitlite"> <HintPath>..\packages\NUnitLite.3.2.0\lib\net45\nunitlite.dll</HintPath> </Reference> @@ -90,6 +87,9 @@ <Reference Include="Moq"> <HintPath>..\packages\Moq.4.6.38-alpha\lib\net45\Moq.dll</HintPath> </Reference> + <Reference Include="System.Interactive.Async"> + <HintPath>..\packages\System.Interactive.Async.3.1.1\lib\net45\System.Interactive.Async.dll</HintPath> + </Reference> </ItemGroup> <ItemGroup> <Compile Include="..\Grpc.Core\Version.cs"> diff --git a/src/csharp/Grpc.IntegrationTesting/MetadataCredentialsTest.cs b/src/csharp/Grpc.IntegrationTesting/MetadataCredentialsTest.cs index eb3bb8a28b..d55e658d94 100644 --- a/src/csharp/Grpc.IntegrationTesting/MetadataCredentialsTest.cs +++ b/src/csharp/Grpc.IntegrationTesting/MetadataCredentialsTest.cs @@ -103,6 +103,34 @@ namespace Grpc.IntegrationTesting client.UnaryCall(new SimpleRequest { }, new CallOptions(credentials: callCredentials)); } + [Test] + public void MetadataCredentials_InterceptorLeavesMetadataEmpty() + { + var channelCredentials = ChannelCredentials.Create(TestCredentials.CreateSslCredentials(), + CallCredentials.FromInterceptor(new AsyncAuthInterceptor((context, metadata) => TaskUtils.CompletedTask))); + channel = new Channel(Host, server.Ports.Single().BoundPort, channelCredentials, options); + client = new TestService.TestServiceClient(channel); + + var ex = Assert.Throws<RpcException>(() => client.UnaryCall(new SimpleRequest { })); + // StatusCode.Unknown as the server-side handler throws an exception after not receiving the authorization header. + Assert.AreEqual(StatusCode.Unknown, ex.Status.StatusCode); + } + + [Test] + public void MetadataCredentials_InterceptorThrows() + { + var callCredentials = CallCredentials.FromInterceptor(new AsyncAuthInterceptor((context, metadata) => + { + throw new Exception("Auth interceptor throws"); + })); + var channelCredentials = ChannelCredentials.Create(TestCredentials.CreateSslCredentials(), callCredentials); + channel = new Channel(Host, server.Ports.Single().BoundPort, channelCredentials, options); + client = new TestService.TestServiceClient(channel); + + var ex = Assert.Throws<RpcException>(() => client.UnaryCall(new SimpleRequest { })); + Assert.AreEqual(StatusCode.Unauthenticated, ex.Status.StatusCode); + } + private class FakeTestService : TestService.TestServiceBase { public override Task<SimpleResponse> UnaryCall(SimpleRequest request, ServerCallContext context) diff --git a/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs b/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs index bcd7e3c040..d0bf0afc1d 100644 --- a/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs +++ b/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs @@ -44,7 +44,7 @@ using System.Threading.Tasks; using Grpc.Core; namespace Grpc.Testing { - public static class MetricsService + public static partial class MetricsService { static readonly string __ServiceName = "grpc.testing.MetricsService"; @@ -73,7 +73,7 @@ namespace Grpc.Testing { } /// <summary>Base class for server-side implementations of MetricsService</summary> - public abstract class MetricsServiceBase + public abstract partial class MetricsServiceBase { /// <summary> /// Returns the values of all the gauges that are currently being maintained by @@ -95,7 +95,7 @@ namespace Grpc.Testing { } /// <summary>Client for MetricsService</summary> - public class MetricsServiceClient : ClientBase<MetricsServiceClient> + public partial class MetricsServiceClient : ClientBase<MetricsServiceClient> { /// <summary>Creates a new client for MetricsService</summary> /// <param name="channel">The channel to use to make remote calls.</param> diff --git a/src/csharp/Grpc.IntegrationTesting/ServicesGrpc.cs b/src/csharp/Grpc.IntegrationTesting/ServicesGrpc.cs index 848dd04fa7..3cc4ed9f3c 100644 --- a/src/csharp/Grpc.IntegrationTesting/ServicesGrpc.cs +++ b/src/csharp/Grpc.IntegrationTesting/ServicesGrpc.cs @@ -40,7 +40,7 @@ using System.Threading.Tasks; using Grpc.Core; namespace Grpc.Testing { - public static class BenchmarkService + public static partial class BenchmarkService { static readonly string __ServiceName = "grpc.testing.BenchmarkService"; @@ -68,7 +68,7 @@ namespace Grpc.Testing { } /// <summary>Base class for server-side implementations of BenchmarkService</summary> - public abstract class BenchmarkServiceBase + public abstract partial class BenchmarkServiceBase { /// <summary> /// One request followed by one response. @@ -91,7 +91,7 @@ namespace Grpc.Testing { } /// <summary>Client for BenchmarkService</summary> - public class BenchmarkServiceClient : ClientBase<BenchmarkServiceClient> + public partial class BenchmarkServiceClient : ClientBase<BenchmarkServiceClient> { /// <summary>Creates a new client for BenchmarkService</summary> /// <param name="channel">The channel to use to make remote calls.</param> @@ -177,7 +177,7 @@ namespace Grpc.Testing { } } - public static class WorkerService + public static partial class WorkerService { static readonly string __ServiceName = "grpc.testing.WorkerService"; @@ -224,7 +224,7 @@ namespace Grpc.Testing { } /// <summary>Base class for server-side implementations of WorkerService</summary> - public abstract class WorkerServiceBase + public abstract partial class WorkerServiceBase { /// <summary> /// Start server with specified workload. @@ -271,7 +271,7 @@ namespace Grpc.Testing { } /// <summary>Client for WorkerService</summary> - public class WorkerServiceClient : ClientBase<WorkerServiceClient> + public partial class WorkerServiceClient : ClientBase<WorkerServiceClient> { /// <summary>Creates a new client for WorkerService</summary> /// <param name="channel">The channel to use to make remote calls.</param> diff --git a/src/csharp/Grpc.IntegrationTesting/Stats.cs b/src/csharp/Grpc.IntegrationTesting/Stats.cs index 0ae77cfb92..504aa11d8a 100644 --- a/src/csharp/Grpc.IntegrationTesting/Stats.cs +++ b/src/csharp/Grpc.IntegrationTesting/Stats.cs @@ -23,22 +23,27 @@ namespace Grpc.Testing { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( "CiJzcmMvcHJvdG8vZ3JwYy90ZXN0aW5nL3N0YXRzLnByb3RvEgxncnBjLnRl", - "c3RpbmciSwoLU2VydmVyU3RhdHMSFAoMdGltZV9lbGFwc2VkGAEgASgBEhEK", - "CXRpbWVfdXNlchgCIAEoARITCgt0aW1lX3N5c3RlbRgDIAEoASI7Cg9IaXN0", - "b2dyYW1QYXJhbXMSEgoKcmVzb2x1dGlvbhgBIAEoARIUCgxtYXhfcG9zc2li", - "bGUYAiABKAEidwoNSGlzdG9ncmFtRGF0YRIOCgZidWNrZXQYASADKA0SEAoI", - "bWluX3NlZW4YAiABKAESEAoIbWF4X3NlZW4YAyABKAESCwoDc3VtGAQgASgB", - "EhYKDnN1bV9vZl9zcXVhcmVzGAUgASgBEg0KBWNvdW50GAYgASgBInsKC0Ns", - "aWVudFN0YXRzEi4KCWxhdGVuY2llcxgBIAEoCzIbLmdycGMudGVzdGluZy5I", - "aXN0b2dyYW1EYXRhEhQKDHRpbWVfZWxhcHNlZBgCIAEoARIRCgl0aW1lX3Vz", - "ZXIYAyABKAESEwoLdGltZV9zeXN0ZW0YBCABKAFiBnByb3RvMw==")); + "c3RpbmciegoLU2VydmVyU3RhdHMSFAoMdGltZV9lbGFwc2VkGAEgASgBEhEK", + "CXRpbWVfdXNlchgCIAEoARITCgt0aW1lX3N5c3RlbRgDIAEoARIWCg50b3Rh", + "bF9jcHVfdGltZRgEIAEoBBIVCg1pZGxlX2NwdV90aW1lGAUgASgEIjsKD0hp", + "c3RvZ3JhbVBhcmFtcxISCgpyZXNvbHV0aW9uGAEgASgBEhQKDG1heF9wb3Nz", + "aWJsZRgCIAEoASJ3Cg1IaXN0b2dyYW1EYXRhEg4KBmJ1Y2tldBgBIAMoDRIQ", + "CghtaW5fc2VlbhgCIAEoARIQCghtYXhfc2VlbhgDIAEoARILCgNzdW0YBCAB", + "KAESFgoOc3VtX29mX3NxdWFyZXMYBSABKAESDQoFY291bnQYBiABKAEiOAoS", + "UmVxdWVzdFJlc3VsdENvdW50EhMKC3N0YXR1c19jb2RlGAEgASgFEg0KBWNv", + "dW50GAIgASgDIrYBCgtDbGllbnRTdGF0cxIuCglsYXRlbmNpZXMYASABKAsy", + "Gy5ncnBjLnRlc3RpbmcuSGlzdG9ncmFtRGF0YRIUCgx0aW1lX2VsYXBzZWQY", + "AiABKAESEQoJdGltZV91c2VyGAMgASgBEhMKC3RpbWVfc3lzdGVtGAQgASgB", + "EjkKD3JlcXVlc3RfcmVzdWx0cxgFIAMoCzIgLmdycGMudGVzdGluZy5SZXF1", + "ZXN0UmVzdWx0Q291bnRiBnByb3RvMw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ServerStats), global::Grpc.Testing.ServerStats.Parser, new[]{ "TimeElapsed", "TimeUser", "TimeSystem" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ServerStats), global::Grpc.Testing.ServerStats.Parser, new[]{ "TimeElapsed", "TimeUser", "TimeSystem", "TotalCpuTime", "IdleCpuTime" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.HistogramParams), global::Grpc.Testing.HistogramParams.Parser, new[]{ "Resolution", "MaxPossible" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.HistogramData), global::Grpc.Testing.HistogramData.Parser, new[]{ "Bucket", "MinSeen", "MaxSeen", "Sum", "SumOfSquares", "Count" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ClientStats), global::Grpc.Testing.ClientStats.Parser, new[]{ "Latencies", "TimeElapsed", "TimeUser", "TimeSystem" }, null, null, null) + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.RequestResultCount), global::Grpc.Testing.RequestResultCount.Parser, new[]{ "StatusCode", "Count" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ClientStats), global::Grpc.Testing.ClientStats.Parser, new[]{ "Latencies", "TimeElapsed", "TimeUser", "TimeSystem", "RequestResults" }, null, null, null) })); } #endregion @@ -72,6 +77,8 @@ namespace Grpc.Testing { timeElapsed_ = other.timeElapsed_; timeUser_ = other.timeUser_; timeSystem_ = other.timeSystem_; + totalCpuTime_ = other.totalCpuTime_; + idleCpuTime_ = other.idleCpuTime_; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -122,6 +129,34 @@ namespace Grpc.Testing { } } + /// <summary>Field number for the "total_cpu_time" field.</summary> + public const int TotalCpuTimeFieldNumber = 4; + private ulong totalCpuTime_; + /// <summary> + /// change in total cpu time of the server (data from proc/stat) + /// </summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ulong TotalCpuTime { + get { return totalCpuTime_; } + set { + totalCpuTime_ = value; + } + } + + /// <summary>Field number for the "idle_cpu_time" field.</summary> + public const int IdleCpuTimeFieldNumber = 5; + private ulong idleCpuTime_; + /// <summary> + /// change in idle time of the server (data from proc/stat) + /// </summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ulong IdleCpuTime { + get { return idleCpuTime_; } + set { + idleCpuTime_ = value; + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as ServerStats); @@ -138,6 +173,8 @@ namespace Grpc.Testing { if (TimeElapsed != other.TimeElapsed) return false; if (TimeUser != other.TimeUser) return false; if (TimeSystem != other.TimeSystem) return false; + if (TotalCpuTime != other.TotalCpuTime) return false; + if (IdleCpuTime != other.IdleCpuTime) return false; return true; } @@ -147,6 +184,8 @@ namespace Grpc.Testing { if (TimeElapsed != 0D) hash ^= TimeElapsed.GetHashCode(); if (TimeUser != 0D) hash ^= TimeUser.GetHashCode(); if (TimeSystem != 0D) hash ^= TimeSystem.GetHashCode(); + if (TotalCpuTime != 0UL) hash ^= TotalCpuTime.GetHashCode(); + if (IdleCpuTime != 0UL) hash ^= IdleCpuTime.GetHashCode(); return hash; } @@ -169,6 +208,14 @@ namespace Grpc.Testing { output.WriteRawTag(25); output.WriteDouble(TimeSystem); } + if (TotalCpuTime != 0UL) { + output.WriteRawTag(32); + output.WriteUInt64(TotalCpuTime); + } + if (IdleCpuTime != 0UL) { + output.WriteRawTag(40); + output.WriteUInt64(IdleCpuTime); + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -183,6 +230,12 @@ namespace Grpc.Testing { if (TimeSystem != 0D) { size += 1 + 8; } + if (TotalCpuTime != 0UL) { + size += 1 + pb::CodedOutputStream.ComputeUInt64Size(TotalCpuTime); + } + if (IdleCpuTime != 0UL) { + size += 1 + pb::CodedOutputStream.ComputeUInt64Size(IdleCpuTime); + } return size; } @@ -200,6 +253,12 @@ namespace Grpc.Testing { if (other.TimeSystem != 0D) { TimeSystem = other.TimeSystem; } + if (other.TotalCpuTime != 0UL) { + TotalCpuTime = other.TotalCpuTime; + } + if (other.IdleCpuTime != 0UL) { + IdleCpuTime = other.IdleCpuTime; + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -222,6 +281,14 @@ namespace Grpc.Testing { TimeSystem = input.ReadDouble(); break; } + case 32: { + TotalCpuTime = input.ReadUInt64(); + break; + } + case 40: { + IdleCpuTime = input.ReadUInt64(); + break; + } } } } @@ -635,6 +702,151 @@ namespace Grpc.Testing { } + public sealed partial class RequestResultCount : pb::IMessage<RequestResultCount> { + private static readonly pb::MessageParser<RequestResultCount> _parser = new pb::MessageParser<RequestResultCount>(() => new RequestResultCount()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser<RequestResultCount> Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Grpc.Testing.StatsReflection.Descriptor.MessageTypes[3]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public RequestResultCount() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public RequestResultCount(RequestResultCount other) : this() { + statusCode_ = other.statusCode_; + count_ = other.count_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public RequestResultCount Clone() { + return new RequestResultCount(this); + } + + /// <summary>Field number for the "status_code" field.</summary> + public const int StatusCodeFieldNumber = 1; + private int statusCode_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int StatusCode { + get { return statusCode_; } + set { + statusCode_ = value; + } + } + + /// <summary>Field number for the "count" field.</summary> + public const int CountFieldNumber = 2; + private long count_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Count { + get { return count_; } + set { + count_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as RequestResultCount); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(RequestResultCount other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (StatusCode != other.StatusCode) return false; + if (Count != other.Count) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (StatusCode != 0) hash ^= StatusCode.GetHashCode(); + if (Count != 0L) hash ^= Count.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (StatusCode != 0) { + output.WriteRawTag(8); + output.WriteInt32(StatusCode); + } + if (Count != 0L) { + output.WriteRawTag(16); + output.WriteInt64(Count); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (StatusCode != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(StatusCode); + } + if (Count != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(Count); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(RequestResultCount other) { + if (other == null) { + return; + } + if (other.StatusCode != 0) { + StatusCode = other.StatusCode; + } + if (other.Count != 0L) { + Count = other.Count; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 8: { + StatusCode = input.ReadInt32(); + break; + } + case 16: { + Count = input.ReadInt64(); + break; + } + } + } + } + + } + public sealed partial class ClientStats : pb::IMessage<ClientStats> { private static readonly pb::MessageParser<ClientStats> _parser = new pb::MessageParser<ClientStats>(() => new ClientStats()); [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -642,7 +854,7 @@ namespace Grpc.Testing { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Grpc.Testing.StatsReflection.Descriptor.MessageTypes[3]; } + get { return global::Grpc.Testing.StatsReflection.Descriptor.MessageTypes[4]; } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -663,6 +875,7 @@ namespace Grpc.Testing { timeElapsed_ = other.timeElapsed_; timeUser_ = other.timeUser_; timeSystem_ = other.timeSystem_; + requestResults_ = other.requestResults_.Clone(); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -720,6 +933,19 @@ namespace Grpc.Testing { } } + /// <summary>Field number for the "request_results" field.</summary> + public const int RequestResultsFieldNumber = 5; + private static readonly pb::FieldCodec<global::Grpc.Testing.RequestResultCount> _repeated_requestResults_codec + = pb::FieldCodec.ForMessage(42, global::Grpc.Testing.RequestResultCount.Parser); + private readonly pbc::RepeatedField<global::Grpc.Testing.RequestResultCount> requestResults_ = new pbc::RepeatedField<global::Grpc.Testing.RequestResultCount>(); + /// <summary> + /// Number of failed requests (one row per status code seen) + /// </summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<global::Grpc.Testing.RequestResultCount> RequestResults { + get { return requestResults_; } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as ClientStats); @@ -737,6 +963,7 @@ namespace Grpc.Testing { if (TimeElapsed != other.TimeElapsed) return false; if (TimeUser != other.TimeUser) return false; if (TimeSystem != other.TimeSystem) return false; + if(!requestResults_.Equals(other.requestResults_)) return false; return true; } @@ -747,6 +974,7 @@ namespace Grpc.Testing { if (TimeElapsed != 0D) hash ^= TimeElapsed.GetHashCode(); if (TimeUser != 0D) hash ^= TimeUser.GetHashCode(); if (TimeSystem != 0D) hash ^= TimeSystem.GetHashCode(); + hash ^= requestResults_.GetHashCode(); return hash; } @@ -773,6 +1001,7 @@ namespace Grpc.Testing { output.WriteRawTag(33); output.WriteDouble(TimeSystem); } + requestResults_.WriteTo(output, _repeated_requestResults_codec); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -790,6 +1019,7 @@ namespace Grpc.Testing { if (TimeSystem != 0D) { size += 1 + 8; } + size += requestResults_.CalculateSize(_repeated_requestResults_codec); return size; } @@ -813,6 +1043,7 @@ namespace Grpc.Testing { if (other.TimeSystem != 0D) { TimeSystem = other.TimeSystem; } + requestResults_.Add(other.requestResults_); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -842,6 +1073,10 @@ namespace Grpc.Testing { TimeSystem = input.ReadDouble(); break; } + case 42: { + requestResults_.AddEntriesFrom(input, _repeated_requestResults_codec); + break; + } } } } diff --git a/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs b/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs index 8d649bf5c5..43dbc2865f 100644 --- a/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs +++ b/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs @@ -45,7 +45,7 @@ namespace Grpc.Testing { /// A simple service to test the various types of RPCs and experiment with /// performance with various types of payload. /// </summary> - public static class TestService + public static partial class TestService { static readonly string __ServiceName = "grpc.testing.TestService"; @@ -120,7 +120,7 @@ namespace Grpc.Testing { } /// <summary>Base class for server-side implementations of TestService</summary> - public abstract class TestServiceBase + public abstract partial class TestServiceBase { /// <summary> /// One empty request followed by one empty response. @@ -199,7 +199,7 @@ namespace Grpc.Testing { } /// <summary>Client for TestService</summary> - public class TestServiceClient : ClientBase<TestServiceClient> + public partial class TestServiceClient : ClientBase<TestServiceClient> { /// <summary>Creates a new client for TestService</summary> /// <param name="channel">The channel to use to make remote calls.</param> @@ -441,7 +441,7 @@ namespace Grpc.Testing { /// A simple service NOT implemented at servers so clients can test for /// that case. /// </summary> - public static class UnimplementedService + public static partial class UnimplementedService { static readonly string __ServiceName = "grpc.testing.UnimplementedService"; @@ -461,7 +461,7 @@ namespace Grpc.Testing { } /// <summary>Base class for server-side implementations of UnimplementedService</summary> - public abstract class UnimplementedServiceBase + public abstract partial class UnimplementedServiceBase { /// <summary> /// A call that no server should implement @@ -474,7 +474,7 @@ namespace Grpc.Testing { } /// <summary>Client for UnimplementedService</summary> - public class UnimplementedServiceClient : ClientBase<UnimplementedServiceClient> + public partial class UnimplementedServiceClient : ClientBase<UnimplementedServiceClient> { /// <summary>Creates a new client for UnimplementedService</summary> /// <param name="channel">The channel to use to make remote calls.</param> @@ -542,7 +542,7 @@ namespace Grpc.Testing { /// <summary> /// A service used to control reconnect server. /// </summary> - public static class ReconnectService + public static partial class ReconnectService { static readonly string __ServiceName = "grpc.testing.ReconnectService"; @@ -571,7 +571,7 @@ namespace Grpc.Testing { } /// <summary>Base class for server-side implementations of ReconnectService</summary> - public abstract class ReconnectServiceBase + public abstract partial class ReconnectServiceBase { public virtual global::System.Threading.Tasks.Task<global::Grpc.Testing.Empty> Start(global::Grpc.Testing.ReconnectParams request, ServerCallContext context) { @@ -586,7 +586,7 @@ namespace Grpc.Testing { } /// <summary>Client for ReconnectService</summary> - public class ReconnectServiceClient : ClientBase<ReconnectServiceClient> + public partial class ReconnectServiceClient : ClientBase<ReconnectServiceClient> { /// <summary>Creates a new client for ReconnectService</summary> /// <param name="channel">The channel to use to make remote calls.</param> diff --git a/src/csharp/Grpc.IntegrationTesting/packages.config b/src/csharp/Grpc.IntegrationTesting/packages.config index a39fb3a23e..a03ee926f4 100644 --- a/src/csharp/Grpc.IntegrationTesting/packages.config +++ b/src/csharp/Grpc.IntegrationTesting/packages.config @@ -12,6 +12,6 @@ <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" /> <package id="NUnit" version="3.2.0" targetFramework="net45" /> <package id="NUnitLite" version="3.2.0" targetFramework="net45" /> - <package id="System.Interactive.Async" version="3.0.0" targetFramework="net45" /> + <package id="System.Interactive.Async" version="3.1.1" targetFramework="net45" /> <package id="Zlib.Portable.Signed" version="1.11.0" targetFramework="net45" /> </packages>
\ No newline at end of file diff --git a/src/csharp/Grpc.IntegrationTesting/project.json b/src/csharp/Grpc.IntegrationTesting/project.json index 0225abb414..e47b5953da 100644 --- a/src/csharp/Grpc.IntegrationTesting/project.json +++ b/src/csharp/Grpc.IntegrationTesting/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -29,7 +28,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.Reflection.Tests/.gitignore b/src/csharp/Grpc.Reflection.Tests/.gitignore new file mode 100644 index 0000000000..1746e3269e --- /dev/null +++ b/src/csharp/Grpc.Reflection.Tests/.gitignore @@ -0,0 +1,2 @@ +bin +obj diff --git a/src/csharp/Grpc.Reflection.Tests/Grpc.Reflection.Tests.csproj b/src/csharp/Grpc.Reflection.Tests/Grpc.Reflection.Tests.csproj new file mode 100644 index 0000000000..cebcf59ce8 --- /dev/null +++ b/src/csharp/Grpc.Reflection.Tests/Grpc.Reflection.Tests.csproj @@ -0,0 +1,94 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{B88F91D6-436D-4C78-8B99-47800FA8DE03}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>Grpc.Reflection.Tests</RootNamespace> + <AssemblyName>Grpc.Reflection.Tests</AssemblyName> + <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseSigned|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\ReleaseSigned</OutputPath> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <SignAssembly>True</SignAssembly> + <AssemblyOriginatorKeyFile>..\keys\Grpc.snk</AssemblyOriginatorKeyFile> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + <Reference Include="System.Core" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="System.Data" /> + <Reference Include="System.Xml" /> + <Reference Include="nunit.framework"> + <HintPath>..\packages\NUnit.3.2.0\lib\net45\nunit.framework.dll</HintPath> + </Reference> + <Reference Include="nunitlite"> + <HintPath>..\packages\NUnitLite.3.2.0\lib\net45\nunitlite.dll</HintPath> + </Reference> + <Reference Include="Google.Protobuf"> + <HintPath>..\packages\Google.Protobuf.3.0.0\lib\net45\Google.Protobuf.dll</HintPath> + </Reference> + <Reference Include="System.Interactive.Async"> + <HintPath>..\packages\System.Interactive.Async.3.1.1\lib\net45\System.Interactive.Async.dll</HintPath> + </Reference> + </ItemGroup> + <ItemGroup> + <Compile Include="..\Grpc.Core\Version.cs"> + <Link>Version.cs</Link> + </Compile> + <Compile Include="SymbolRegistryTest.cs" /> + <Compile Include="ReflectionClientServerTest.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="NUnitMain.cs" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\Grpc.Core\Grpc.Core.csproj"> + <Project>{CCC4440E-49F7-4790-B0AF-FEABB0837AE7}</Project> + <Name>Grpc.Core</Name> + </ProjectReference> + <ProjectReference Include="..\Grpc.Reflection\Grpc.Reflection.csproj"> + <Project>{4F18CF52-B3DB-4A77-97C5-7F7F4B6C1715}</Project> + <Name>Grpc.Reflection</Name> + </ProjectReference> + </ItemGroup> + <ItemGroup> + <None Include="Grpc.Reflection.Tests.project.json" /> + <None Include="packages.config" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project>
\ No newline at end of file diff --git a/src/csharp/Grpc.Reflection.Tests/Grpc.Reflection.Tests.project.json b/src/csharp/Grpc.Reflection.Tests/Grpc.Reflection.Tests.project.json new file mode 100644 index 0000000000..c2f5bcb163 --- /dev/null +++ b/src/csharp/Grpc.Reflection.Tests/Grpc.Reflection.Tests.project.json @@ -0,0 +1,8 @@ +{ + "frameworks": { + "net45": { } + }, + "runtimes": { + "win": { } + } +} diff --git a/src/csharp/Grpc.Reflection.Tests/Grpc.Reflection.Tests.xproj b/src/csharp/Grpc.Reflection.Tests/Grpc.Reflection.Tests.xproj new file mode 100644 index 0000000000..4a3100853d --- /dev/null +++ b/src/csharp/Grpc.Reflection.Tests/Grpc.Reflection.Tests.xproj @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="14.0.25123" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.25123</VisualStudioVersion> + <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> + </PropertyGroup> + <Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" /> + <PropertyGroup Label="Globals"> + <ProjectGuid>fe90181d-a4b3-4a5c-8490-f07561e18e3b</ProjectGuid> + <RootNamespace>Grpc.Reflection.Tests</RootNamespace> + <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath> + <OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath> + </PropertyGroup> + <PropertyGroup> + <SchemaVersion>2.0</SchemaVersion> + </PropertyGroup> + <Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" /> +</Project>
\ No newline at end of file diff --git a/src/csharp/Grpc.Reflection.Tests/NUnitMain.cs b/src/csharp/Grpc.Reflection.Tests/NUnitMain.cs new file mode 100644 index 0000000000..a60d7b03eb --- /dev/null +++ b/src/csharp/Grpc.Reflection.Tests/NUnitMain.cs @@ -0,0 +1,59 @@ +#region Copyright notice and license + +// Copyright 2016, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#endregion + +using System; +using System.Reflection; +using Grpc.Core; +using Grpc.Core.Logging; +using NUnit.Common; +using NUnitLite; + +namespace Grpc.Reflection.Tests +{ + /// <summary> + /// Provides entry point for NUnitLite + /// </summary> + public class NUnitMain + { + public static int Main(string[] args) + { + // Make logger immune to NUnit capturing stdout and stderr to workaround https://github.com/nunit/nunit/issues/1406. + GrpcEnvironment.SetLogger(new TextWriterLogger(Console.Error)); +#if NETCOREAPP1_0 + return new AutoRun(typeof(NUnitMain).GetTypeInfo().Assembly).Execute(args, new ExtendedTextWrapper(Console.Out), Console.In); +#else + return new AutoRun().Execute(args); +#endif + } + } +} diff --git a/src/csharp/Grpc.Reflection.Tests/Properties/AssemblyInfo.cs b/src/csharp/Grpc.Reflection.Tests/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..d29054a4d1 --- /dev/null +++ b/src/csharp/Grpc.Reflection.Tests/Properties/AssemblyInfo.cs @@ -0,0 +1,44 @@ +#region Copyright notice and license + +// Copyright 2015, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#endregion + +using System.Reflection; +using System.Runtime.CompilerServices; + +[assembly: AssemblyTitle("Grpc.Reflection.Tests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("Google Inc. All rights reserved.")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] diff --git a/src/csharp/Grpc.Reflection.Tests/ReflectionClientServerTest.cs b/src/csharp/Grpc.Reflection.Tests/ReflectionClientServerTest.cs new file mode 100644 index 0000000000..1d0845e276 --- /dev/null +++ b/src/csharp/Grpc.Reflection.Tests/ReflectionClientServerTest.cs @@ -0,0 +1,154 @@ +#region Copyright notice and license +// Copyright 2015, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using Grpc.Core; +using Grpc.Reflection; +using Grpc.Reflection.V1Alpha; +using NUnit.Framework; + +namespace Grpc.Reflection.Tests +{ + /// <summary> + /// Reflection client talks to reflection server. + /// </summary> + public class ReflectionClientServerTest + { + const string Host = "localhost"; + Server server; + Channel channel; + ServerReflection.ServerReflectionClient client; + ReflectionServiceImpl serviceImpl; + + [TestFixtureSetUp] + public void Init() + { + serviceImpl = new ReflectionServiceImpl(ServerReflection.Descriptor); + + server = new Server + { + Services = { ServerReflection.BindService(serviceImpl) }, + Ports = { { Host, ServerPort.PickUnused, ServerCredentials.Insecure } } + }; + server.Start(); + channel = new Channel(Host, server.Ports.Single().BoundPort, ChannelCredentials.Insecure); + + client = new ServerReflection.ServerReflectionClient(channel); + } + + [TestFixtureTearDown] + public void Cleanup() + { + channel.ShutdownAsync().Wait(); + server.ShutdownAsync().Wait(); + } + + [Test] + public async Task FileByFilename_NotFound() + { + var response = await SingleRequestAsync(new ServerReflectionRequest + { + FileByFilename = "somepackage/nonexistent.proto" + }); + Assert.AreEqual((int)StatusCode.NotFound, response.ErrorResponse.ErrorCode); + } + + [Test] + public async Task FileByFilename() + { + var response = await SingleRequestAsync(new ServerReflectionRequest + { + FileByFilename = "grpc/reflection/v1alpha/reflection.proto" + }); + Assert.AreEqual(1, response.FileDescriptorResponse.FileDescriptorProto.Count); + Assert.AreEqual(ReflectionReflection.Descriptor.SerializedData, response.FileDescriptorResponse.FileDescriptorProto[0]); + } + + [Test] + public async Task FileContainingSymbol() + { + var response = await SingleRequestAsync(new ServerReflectionRequest + { + FileContainingSymbol = "grpc.reflection.v1alpha.ServerReflection" + }); + Assert.AreEqual(1, response.FileDescriptorResponse.FileDescriptorProto.Count); + Assert.AreEqual(ReflectionReflection.Descriptor.SerializedData, response.FileDescriptorResponse.FileDescriptorProto[0]); + } + + [Test] + public async Task FileContainingSymbol_NotFound() + { + var response = await SingleRequestAsync(new ServerReflectionRequest + { + FileContainingSymbol = "somepackage.Nonexistent" + }); + Assert.AreEqual((int)StatusCode.NotFound, response.ErrorResponse.ErrorCode); + } + + [Test] + public async Task ListServices() + { + var response = await SingleRequestAsync(new ServerReflectionRequest + { + ListServices = "" + }); + Assert.AreEqual(1, response.ListServicesResponse.Service.Count); + Assert.AreEqual(ServerReflection.Descriptor.FullName, response.ListServicesResponse.Service[0].Name); + } + + [Test] + public async Task FileContainingExtension() + { + var response = await SingleRequestAsync(new ServerReflectionRequest + { + FileContainingExtension = new ExtensionRequest() + }); + Assert.AreEqual((int)StatusCode.Unimplemented, response.ErrorResponse.ErrorCode); + } + + private async Task<ServerReflectionResponse> SingleRequestAsync(ServerReflectionRequest request) + { + var call = client.ServerReflectionInfo(); + await call.RequestStream.WriteAsync(request); + Assert.IsTrue(await call.ResponseStream.MoveNext()); + + var response = call.ResponseStream.Current; + await call.RequestStream.CompleteAsync(); + Assert.IsFalse(await call.ResponseStream.MoveNext()); + return response; + } + } +} diff --git a/src/csharp/Grpc.Reflection.Tests/SymbolRegistryTest.cs b/src/csharp/Grpc.Reflection.Tests/SymbolRegistryTest.cs new file mode 100644 index 0000000000..68ee6dc10d --- /dev/null +++ b/src/csharp/Grpc.Reflection.Tests/SymbolRegistryTest.cs @@ -0,0 +1,63 @@ +#region Copyright notice and license +// Copyright 2015, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using Grpc.Reflection; +using Grpc.Reflection.V1Alpha; +using NUnit.Framework; + + +namespace Grpc.Reflection.Tests +{ + /// <summary> + /// Tests for ReflectionServiceImpl + /// </summary> + public class SymbolRegistryTest + { + SymbolRegistry registry = SymbolRegistry.FromFiles(new[] { ReflectionReflection.Descriptor, Google.Protobuf.WellKnownTypes.Duration.Descriptor.File }); + + [Test] + public void FileByName() + { + Assert.AreSame(Google.Protobuf.WellKnownTypes.Duration.Descriptor.File, registry.FileByName("google/protobuf/duration.proto")); + Assert.IsNull(registry.FileByName("somepackage/nonexistent.proto")); + } + + [Test] + public void FileContainingSymbol() + { + Assert.AreSame(Google.Protobuf.WellKnownTypes.Duration.Descriptor.File, registry.FileContainingSymbol("google.protobuf.Duration")); + Assert.AreSame(ReflectionReflection.Descriptor, registry.FileContainingSymbol("grpc.reflection.v1alpha.ServerReflection.ServerReflectionInfo")); // method + Assert.AreSame(ReflectionReflection.Descriptor, registry.FileContainingSymbol("grpc.reflection.v1alpha.ServerReflection")); // service + Assert.AreSame(ReflectionReflection.Descriptor, registry.FileContainingSymbol("grpc.reflection.v1alpha.ServerReflectionRequest")); // message + Assert.IsNull(registry.FileContainingSymbol("somepackage.Nonexistent")); + } + } +} diff --git a/src/csharp/Grpc.Reflection.Tests/packages.config b/src/csharp/Grpc.Reflection.Tests/packages.config new file mode 100644 index 0000000000..0fed4dbd41 --- /dev/null +++ b/src/csharp/Grpc.Reflection.Tests/packages.config @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="Google.Protobuf" version="3.0.0" targetFramework="net45" /> + <package id="NUnit" version="3.2.0" targetFramework="net45" /> + <package id="NUnitLite" version="3.2.0" targetFramework="net45" /> + <package id="System.Interactive.Async" version="3.1.1" targetFramework="net45" /> +</packages>
\ No newline at end of file diff --git a/src/csharp/Grpc.Reflection.Tests/project.json b/src/csharp/Grpc.Reflection.Tests/project.json new file mode 100644 index 0000000000..61d3b7e47b --- /dev/null +++ b/src/csharp/Grpc.Reflection.Tests/project.json @@ -0,0 +1,65 @@ +{ + "buildOptions": { + "emitEntryPoint": true + }, + "configurations": { + "Debug": { + "buildOptions": { + "define": [ "SIGNED" ], + "keyFile": "../keys/Grpc.snk", + "xmlDoc": true, + "compile": { + "includeFiles": [ "../Grpc.Core/Version.cs" ] + }, + "copyToOutput": { + "mappings": { + "grpc_csharp_ext.x64.dll": "../../../vsprojects/x64/Debug/grpc_csharp_ext.dll", + "grpc_csharp_ext.x86.dll": "../../../vsprojects/Debug/grpc_csharp_ext.dll", + "libgrpc_csharp_ext.x64.so": "../../../libs/dbg/libgrpc_csharp_ext.so", + "libgrpc_csharp_ext.x64.dylib": "../../../libs/dbg/libgrpc_csharp_ext.dylib" + } + } + } + }, + "Release": { + "buildOptions": { + "define": [ "SIGNED" ], + "keyFile": "../keys/Grpc.snk", + "xmlDoc": true, + "compile": { + "includeFiles": [ "../Grpc.Core/Version.cs" ] + }, + "copyToOutput": { + "mappings": { + "grpc_csharp_ext.x64.dll": "../../../vsprojects/x64/Release/grpc_csharp_ext.dll", + "grpc_csharp_ext.x86.dll": "../../../vsprojects/Release/grpc_csharp_ext.dll", + "libgrpc_csharp_ext.x64.so": "../../../libs/opt/libgrpc_csharp_ext.so", + "libgrpc_csharp_ext.x64.dylib": "../../../libs/opt/libgrpc_csharp_ext.dylib" + } + } + } + } + }, + + "dependencies": { + "Grpc.Reflection": { + "target": "project" + }, + "NUnit": "3.2.0", + "NUnitLite": "3.2.0-*" + }, + "frameworks": { + "net45": { }, + "netcoreapp1.0": { + "imports": [ + "portable-net45" + ], + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.0" + } + } + } + } +} diff --git a/src/csharp/Grpc.Reflection/.gitignore b/src/csharp/Grpc.Reflection/.gitignore new file mode 100644 index 0000000000..1746e3269e --- /dev/null +++ b/src/csharp/Grpc.Reflection/.gitignore @@ -0,0 +1,2 @@ +bin +obj diff --git a/src/csharp/Grpc.Reflection/Grpc.Reflection.csproj b/src/csharp/Grpc.Reflection/Grpc.Reflection.csproj new file mode 100644 index 0000000000..ea65998ce3 --- /dev/null +++ b/src/csharp/Grpc.Reflection/Grpc.Reflection.csproj @@ -0,0 +1,83 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{4F18CF52-B3DB-4A77-97C5-7F7F4B6C1715}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>Grpc.Reflection</RootNamespace> + <AssemblyName>Grpc.Reflection</AssemblyName> + <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <DocumentationFile>bin\$(Configuration)\Grpc.Reflection.Xml</DocumentationFile> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseSigned|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\ReleaseSigned</OutputPath> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <SignAssembly>True</SignAssembly> + <AssemblyOriginatorKeyFile>..\keys\Grpc.snk</AssemblyOriginatorKeyFile> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + <Reference Include="System.Core" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="System.Data" /> + <Reference Include="System.Xml" /> + <Reference Include="Google.Protobuf"> + <HintPath>..\packages\Google.Protobuf.3.0.0\lib\net45\Google.Protobuf.dll</HintPath> + </Reference> + <Reference Include="System.Interactive.Async"> + <HintPath>..\packages\System.Interactive.Async.3.1.1\lib\net45\System.Interactive.Async.dll</HintPath> + </Reference> + </ItemGroup> + <ItemGroup> + <Compile Include="..\Grpc.Core\Version.cs"> + <Link>Version.cs</Link> + </Compile> + <Compile Include="SymbolRegistry.cs" /> + <Compile Include="ReflectionServiceImpl.cs" /> + <Compile Include="Reflection.cs" /> + <Compile Include="ReflectionGrpc.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="Grpc.Reflection.project.json" /> + <None Include="packages.config" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\Grpc.Core\Grpc.Core.csproj"> + <Project>{CCC4440E-49F7-4790-B0AF-FEABB0837AE7}</Project> + <Name>Grpc.Core</Name> + </ProjectReference> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project>
\ No newline at end of file diff --git a/src/csharp/Grpc.Reflection/Grpc.Reflection.project.json b/src/csharp/Grpc.Reflection/Grpc.Reflection.project.json new file mode 100644 index 0000000000..c2f5bcb163 --- /dev/null +++ b/src/csharp/Grpc.Reflection/Grpc.Reflection.project.json @@ -0,0 +1,8 @@ +{ + "frameworks": { + "net45": { } + }, + "runtimes": { + "win": { } + } +} diff --git a/src/csharp/Grpc.Reflection/Grpc.Reflection.xproj b/src/csharp/Grpc.Reflection/Grpc.Reflection.xproj new file mode 100644 index 0000000000..833d98b121 --- /dev/null +++ b/src/csharp/Grpc.Reflection/Grpc.Reflection.xproj @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="14.0.25123" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.25123</VisualStudioVersion> + <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> + </PropertyGroup> + <Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" /> + <PropertyGroup Label="Globals"> + <ProjectGuid>2b372155-80ba-4cf9-82d6-4b938e8ec3a0</ProjectGuid> + <RootNamespace>Grpc.Reflection</RootNamespace> + <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath> + <OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath> + </PropertyGroup> + <PropertyGroup> + <SchemaVersion>2.0</SchemaVersion> + </PropertyGroup> + <Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" /> +</Project>
\ No newline at end of file diff --git a/src/csharp/Grpc.Reflection/Properties/AssemblyInfo.cs b/src/csharp/Grpc.Reflection/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..3104ecdd54 --- /dev/null +++ b/src/csharp/Grpc.Reflection/Properties/AssemblyInfo.cs @@ -0,0 +1,44 @@ +#region Copyright notice and license + +// Copyright 2015, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#endregion + +using System.Reflection; +using System.Runtime.CompilerServices; + +[assembly: AssemblyTitle("Grpc.Reflection")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("Google Inc. All rights reserved.")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] diff --git a/src/csharp/Grpc.Reflection/Reflection.cs b/src/csharp/Grpc.Reflection/Reflection.cs new file mode 100644 index 0000000000..06c5d08030 --- /dev/null +++ b/src/csharp/Grpc.Reflection/Reflection.cs @@ -0,0 +1,1556 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: grpc/reflection/v1alpha/reflection.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Grpc.Reflection.V1Alpha { + + /// <summary>Holder for reflection information generated from grpc/reflection/v1alpha/reflection.proto</summary> + public static partial class ReflectionReflection { + + #region Descriptor + /// <summary>File descriptor for grpc/reflection/v1alpha/reflection.proto</summary> + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static ReflectionReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CihncnBjL3JlZmxlY3Rpb24vdjFhbHBoYS9yZWZsZWN0aW9uLnByb3RvEhdn", + "cnBjLnJlZmxlY3Rpb24udjFhbHBoYSKKAgoXU2VydmVyUmVmbGVjdGlvblJl", + "cXVlc3QSDAoEaG9zdBgBIAEoCRIaChBmaWxlX2J5X2ZpbGVuYW1lGAMgASgJ", + "SAASIAoWZmlsZV9jb250YWluaW5nX3N5bWJvbBgEIAEoCUgAEk4KGWZpbGVf", + "Y29udGFpbmluZ19leHRlbnNpb24YBSABKAsyKS5ncnBjLnJlZmxlY3Rpb24u", + "djFhbHBoYS5FeHRlbnNpb25SZXF1ZXN0SAASJwodYWxsX2V4dGVuc2lvbl9u", + "dW1iZXJzX29mX3R5cGUYBiABKAlIABIXCg1saXN0X3NlcnZpY2VzGAcgASgJ", + "SABCEQoPbWVzc2FnZV9yZXF1ZXN0IkUKEEV4dGVuc2lvblJlcXVlc3QSFwoP", + "Y29udGFpbmluZ190eXBlGAEgASgJEhgKEGV4dGVuc2lvbl9udW1iZXIYAiAB", + "KAUi0QMKGFNlcnZlclJlZmxlY3Rpb25SZXNwb25zZRISCgp2YWxpZF9ob3N0", + "GAEgASgJEkoKEG9yaWdpbmFsX3JlcXVlc3QYAiABKAsyMC5ncnBjLnJlZmxl", + "Y3Rpb24udjFhbHBoYS5TZXJ2ZXJSZWZsZWN0aW9uUmVxdWVzdBJTChhmaWxl", + "X2Rlc2NyaXB0b3JfcmVzcG9uc2UYBCABKAsyLy5ncnBjLnJlZmxlY3Rpb24u", + "djFhbHBoYS5GaWxlRGVzY3JpcHRvclJlc3BvbnNlSAASWgoeYWxsX2V4dGVu", + "c2lvbl9udW1iZXJzX3Jlc3BvbnNlGAUgASgLMjAuZ3JwYy5yZWZsZWN0aW9u", + "LnYxYWxwaGEuRXh0ZW5zaW9uTnVtYmVyUmVzcG9uc2VIABJOChZsaXN0X3Nl", + "cnZpY2VzX3Jlc3BvbnNlGAYgASgLMiwuZ3JwYy5yZWZsZWN0aW9uLnYxYWxw", + "aGEuTGlzdFNlcnZpY2VSZXNwb25zZUgAEkAKDmVycm9yX3Jlc3BvbnNlGAcg", + "ASgLMiYuZ3JwYy5yZWZsZWN0aW9uLnYxYWxwaGEuRXJyb3JSZXNwb25zZUgA", + "QhIKEG1lc3NhZ2VfcmVzcG9uc2UiNwoWRmlsZURlc2NyaXB0b3JSZXNwb25z", + "ZRIdChVmaWxlX2Rlc2NyaXB0b3JfcHJvdG8YASADKAwiSwoXRXh0ZW5zaW9u", + "TnVtYmVyUmVzcG9uc2USFgoOYmFzZV90eXBlX25hbWUYASABKAkSGAoQZXh0", + "ZW5zaW9uX251bWJlchgCIAMoBSJQChNMaXN0U2VydmljZVJlc3BvbnNlEjkK", + "B3NlcnZpY2UYASADKAsyKC5ncnBjLnJlZmxlY3Rpb24udjFhbHBoYS5TZXJ2", + "aWNlUmVzcG9uc2UiHwoPU2VydmljZVJlc3BvbnNlEgwKBG5hbWUYASABKAki", + "OgoNRXJyb3JSZXNwb25zZRISCgplcnJvcl9jb2RlGAEgASgFEhUKDWVycm9y", + "X21lc3NhZ2UYAiABKAkykwEKEFNlcnZlclJlZmxlY3Rpb24SfwoUU2VydmVy", + "UmVmbGVjdGlvbkluZm8SMC5ncnBjLnJlZmxlY3Rpb24udjFhbHBoYS5TZXJ2", + "ZXJSZWZsZWN0aW9uUmVxdWVzdBoxLmdycGMucmVmbGVjdGlvbi52MWFscGhh", + "LlNlcnZlclJlZmxlY3Rpb25SZXNwb25zZSgBMAFiBnByb3RvMw==")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Reflection.V1Alpha.ServerReflectionRequest), global::Grpc.Reflection.V1Alpha.ServerReflectionRequest.Parser, new[]{ "Host", "FileByFilename", "FileContainingSymbol", "FileContainingExtension", "AllExtensionNumbersOfType", "ListServices" }, new[]{ "MessageRequest" }, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Reflection.V1Alpha.ExtensionRequest), global::Grpc.Reflection.V1Alpha.ExtensionRequest.Parser, new[]{ "ContainingType", "ExtensionNumber" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Reflection.V1Alpha.ServerReflectionResponse), global::Grpc.Reflection.V1Alpha.ServerReflectionResponse.Parser, new[]{ "ValidHost", "OriginalRequest", "FileDescriptorResponse", "AllExtensionNumbersResponse", "ListServicesResponse", "ErrorResponse" }, new[]{ "MessageResponse" }, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Reflection.V1Alpha.FileDescriptorResponse), global::Grpc.Reflection.V1Alpha.FileDescriptorResponse.Parser, new[]{ "FileDescriptorProto" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Reflection.V1Alpha.ExtensionNumberResponse), global::Grpc.Reflection.V1Alpha.ExtensionNumberResponse.Parser, new[]{ "BaseTypeName", "ExtensionNumber" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Reflection.V1Alpha.ListServiceResponse), global::Grpc.Reflection.V1Alpha.ListServiceResponse.Parser, new[]{ "Service" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Reflection.V1Alpha.ServiceResponse), global::Grpc.Reflection.V1Alpha.ServiceResponse.Parser, new[]{ "Name" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Reflection.V1Alpha.ErrorResponse), global::Grpc.Reflection.V1Alpha.ErrorResponse.Parser, new[]{ "ErrorCode", "ErrorMessage" }, null, null, null) + })); + } + #endregion + + } + #region Messages + /// <summary> + /// The message sent by the client when calling ServerReflectionInfo method. + /// </summary> + public sealed partial class ServerReflectionRequest : pb::IMessage<ServerReflectionRequest> { + private static readonly pb::MessageParser<ServerReflectionRequest> _parser = new pb::MessageParser<ServerReflectionRequest>(() => new ServerReflectionRequest()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser<ServerReflectionRequest> Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Grpc.Reflection.V1Alpha.ReflectionReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ServerReflectionRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ServerReflectionRequest(ServerReflectionRequest other) : this() { + host_ = other.host_; + switch (other.MessageRequestCase) { + case MessageRequestOneofCase.FileByFilename: + FileByFilename = other.FileByFilename; + break; + case MessageRequestOneofCase.FileContainingSymbol: + FileContainingSymbol = other.FileContainingSymbol; + break; + case MessageRequestOneofCase.FileContainingExtension: + FileContainingExtension = other.FileContainingExtension.Clone(); + break; + case MessageRequestOneofCase.AllExtensionNumbersOfType: + AllExtensionNumbersOfType = other.AllExtensionNumbersOfType; + break; + case MessageRequestOneofCase.ListServices: + ListServices = other.ListServices; + break; + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ServerReflectionRequest Clone() { + return new ServerReflectionRequest(this); + } + + /// <summary>Field number for the "host" field.</summary> + public const int HostFieldNumber = 1; + private string host_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Host { + get { return host_; } + set { + host_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// <summary>Field number for the "file_by_filename" field.</summary> + public const int FileByFilenameFieldNumber = 3; + /// <summary> + /// Find a proto file by the file name. + /// </summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string FileByFilename { + get { return messageRequestCase_ == MessageRequestOneofCase.FileByFilename ? (string) messageRequest_ : ""; } + set { + messageRequest_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + messageRequestCase_ = MessageRequestOneofCase.FileByFilename; + } + } + + /// <summary>Field number for the "file_containing_symbol" field.</summary> + public const int FileContainingSymbolFieldNumber = 4; + /// <summary> + /// Find the proto file that declares the given fully-qualified symbol name. + /// This field should be a fully-qualified symbol name + /// (e.g. <package>.<service>[.<method>] or <package>.<type>). + /// </summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string FileContainingSymbol { + get { return messageRequestCase_ == MessageRequestOneofCase.FileContainingSymbol ? (string) messageRequest_ : ""; } + set { + messageRequest_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + messageRequestCase_ = MessageRequestOneofCase.FileContainingSymbol; + } + } + + /// <summary>Field number for the "file_containing_extension" field.</summary> + public const int FileContainingExtensionFieldNumber = 5; + /// <summary> + /// Find the proto file which defines an extension extending the given + /// message type with the given field number. + /// </summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Grpc.Reflection.V1Alpha.ExtensionRequest FileContainingExtension { + get { return messageRequestCase_ == MessageRequestOneofCase.FileContainingExtension ? (global::Grpc.Reflection.V1Alpha.ExtensionRequest) messageRequest_ : null; } + set { + messageRequest_ = value; + messageRequestCase_ = value == null ? MessageRequestOneofCase.None : MessageRequestOneofCase.FileContainingExtension; + } + } + + /// <summary>Field number for the "all_extension_numbers_of_type" field.</summary> + public const int AllExtensionNumbersOfTypeFieldNumber = 6; + /// <summary> + /// Finds the tag numbers used by all known extensions of the given message + /// type, and appends them to ExtensionNumberResponse in an undefined order. + /// Its corresponding method is best-effort: it's not guaranteed that the + /// reflection service will implement this method, and it's not guaranteed + /// that this method will provide all extensions. Returns + /// StatusCode::UNIMPLEMENTED if it's not implemented. + /// This field should be a fully-qualified type name. The format is + /// <package>.<type> + /// </summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string AllExtensionNumbersOfType { + get { return messageRequestCase_ == MessageRequestOneofCase.AllExtensionNumbersOfType ? (string) messageRequest_ : ""; } + set { + messageRequest_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + messageRequestCase_ = MessageRequestOneofCase.AllExtensionNumbersOfType; + } + } + + /// <summary>Field number for the "list_services" field.</summary> + public const int ListServicesFieldNumber = 7; + /// <summary> + /// List the full names of registered services. The content will not be + /// checked. + /// </summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string ListServices { + get { return messageRequestCase_ == MessageRequestOneofCase.ListServices ? (string) messageRequest_ : ""; } + set { + messageRequest_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + messageRequestCase_ = MessageRequestOneofCase.ListServices; + } + } + + private object messageRequest_; + /// <summary>Enum of possible cases for the "message_request" oneof.</summary> + public enum MessageRequestOneofCase { + None = 0, + FileByFilename = 3, + FileContainingSymbol = 4, + FileContainingExtension = 5, + AllExtensionNumbersOfType = 6, + ListServices = 7, + } + private MessageRequestOneofCase messageRequestCase_ = MessageRequestOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public MessageRequestOneofCase MessageRequestCase { + get { return messageRequestCase_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearMessageRequest() { + messageRequestCase_ = MessageRequestOneofCase.None; + messageRequest_ = null; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as ServerReflectionRequest); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(ServerReflectionRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Host != other.Host) return false; + if (FileByFilename != other.FileByFilename) return false; + if (FileContainingSymbol != other.FileContainingSymbol) return false; + if (!object.Equals(FileContainingExtension, other.FileContainingExtension)) return false; + if (AllExtensionNumbersOfType != other.AllExtensionNumbersOfType) return false; + if (ListServices != other.ListServices) return false; + if (MessageRequestCase != other.MessageRequestCase) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Host.Length != 0) hash ^= Host.GetHashCode(); + if (messageRequestCase_ == MessageRequestOneofCase.FileByFilename) hash ^= FileByFilename.GetHashCode(); + if (messageRequestCase_ == MessageRequestOneofCase.FileContainingSymbol) hash ^= FileContainingSymbol.GetHashCode(); + if (messageRequestCase_ == MessageRequestOneofCase.FileContainingExtension) hash ^= FileContainingExtension.GetHashCode(); + if (messageRequestCase_ == MessageRequestOneofCase.AllExtensionNumbersOfType) hash ^= AllExtensionNumbersOfType.GetHashCode(); + if (messageRequestCase_ == MessageRequestOneofCase.ListServices) hash ^= ListServices.GetHashCode(); + hash ^= (int) messageRequestCase_; + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Host.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Host); + } + if (messageRequestCase_ == MessageRequestOneofCase.FileByFilename) { + output.WriteRawTag(26); + output.WriteString(FileByFilename); + } + if (messageRequestCase_ == MessageRequestOneofCase.FileContainingSymbol) { + output.WriteRawTag(34); + output.WriteString(FileContainingSymbol); + } + if (messageRequestCase_ == MessageRequestOneofCase.FileContainingExtension) { + output.WriteRawTag(42); + output.WriteMessage(FileContainingExtension); + } + if (messageRequestCase_ == MessageRequestOneofCase.AllExtensionNumbersOfType) { + output.WriteRawTag(50); + output.WriteString(AllExtensionNumbersOfType); + } + if (messageRequestCase_ == MessageRequestOneofCase.ListServices) { + output.WriteRawTag(58); + output.WriteString(ListServices); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Host.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Host); + } + if (messageRequestCase_ == MessageRequestOneofCase.FileByFilename) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(FileByFilename); + } + if (messageRequestCase_ == MessageRequestOneofCase.FileContainingSymbol) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(FileContainingSymbol); + } + if (messageRequestCase_ == MessageRequestOneofCase.FileContainingExtension) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(FileContainingExtension); + } + if (messageRequestCase_ == MessageRequestOneofCase.AllExtensionNumbersOfType) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(AllExtensionNumbersOfType); + } + if (messageRequestCase_ == MessageRequestOneofCase.ListServices) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(ListServices); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ServerReflectionRequest other) { + if (other == null) { + return; + } + if (other.Host.Length != 0) { + Host = other.Host; + } + switch (other.MessageRequestCase) { + case MessageRequestOneofCase.FileByFilename: + FileByFilename = other.FileByFilename; + break; + case MessageRequestOneofCase.FileContainingSymbol: + FileContainingSymbol = other.FileContainingSymbol; + break; + case MessageRequestOneofCase.FileContainingExtension: + FileContainingExtension = other.FileContainingExtension; + break; + case MessageRequestOneofCase.AllExtensionNumbersOfType: + AllExtensionNumbersOfType = other.AllExtensionNumbersOfType; + break; + case MessageRequestOneofCase.ListServices: + ListServices = other.ListServices; + break; + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + Host = input.ReadString(); + break; + } + case 26: { + FileByFilename = input.ReadString(); + break; + } + case 34: { + FileContainingSymbol = input.ReadString(); + break; + } + case 42: { + global::Grpc.Reflection.V1Alpha.ExtensionRequest subBuilder = new global::Grpc.Reflection.V1Alpha.ExtensionRequest(); + if (messageRequestCase_ == MessageRequestOneofCase.FileContainingExtension) { + subBuilder.MergeFrom(FileContainingExtension); + } + input.ReadMessage(subBuilder); + FileContainingExtension = subBuilder; + break; + } + case 50: { + AllExtensionNumbersOfType = input.ReadString(); + break; + } + case 58: { + ListServices = input.ReadString(); + break; + } + } + } + } + + } + + /// <summary> + /// The type name and extension number sent by the client when requesting + /// file_containing_extension. + /// </summary> + public sealed partial class ExtensionRequest : pb::IMessage<ExtensionRequest> { + private static readonly pb::MessageParser<ExtensionRequest> _parser = new pb::MessageParser<ExtensionRequest>(() => new ExtensionRequest()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser<ExtensionRequest> Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Grpc.Reflection.V1Alpha.ReflectionReflection.Descriptor.MessageTypes[1]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ExtensionRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ExtensionRequest(ExtensionRequest other) : this() { + containingType_ = other.containingType_; + extensionNumber_ = other.extensionNumber_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ExtensionRequest Clone() { + return new ExtensionRequest(this); + } + + /// <summary>Field number for the "containing_type" field.</summary> + public const int ContainingTypeFieldNumber = 1; + private string containingType_ = ""; + /// <summary> + /// Fully-qualified type name. The format should be <package>.<type> + /// </summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string ContainingType { + get { return containingType_; } + set { + containingType_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// <summary>Field number for the "extension_number" field.</summary> + public const int ExtensionNumberFieldNumber = 2; + private int extensionNumber_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int ExtensionNumber { + get { return extensionNumber_; } + set { + extensionNumber_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as ExtensionRequest); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(ExtensionRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (ContainingType != other.ContainingType) return false; + if (ExtensionNumber != other.ExtensionNumber) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (ContainingType.Length != 0) hash ^= ContainingType.GetHashCode(); + if (ExtensionNumber != 0) hash ^= ExtensionNumber.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (ContainingType.Length != 0) { + output.WriteRawTag(10); + output.WriteString(ContainingType); + } + if (ExtensionNumber != 0) { + output.WriteRawTag(16); + output.WriteInt32(ExtensionNumber); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (ContainingType.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(ContainingType); + } + if (ExtensionNumber != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(ExtensionNumber); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ExtensionRequest other) { + if (other == null) { + return; + } + if (other.ContainingType.Length != 0) { + ContainingType = other.ContainingType; + } + if (other.ExtensionNumber != 0) { + ExtensionNumber = other.ExtensionNumber; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + ContainingType = input.ReadString(); + break; + } + case 16: { + ExtensionNumber = input.ReadInt32(); + break; + } + } + } + } + + } + + /// <summary> + /// The message sent by the server to answer ServerReflectionInfo method. + /// </summary> + public sealed partial class ServerReflectionResponse : pb::IMessage<ServerReflectionResponse> { + private static readonly pb::MessageParser<ServerReflectionResponse> _parser = new pb::MessageParser<ServerReflectionResponse>(() => new ServerReflectionResponse()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser<ServerReflectionResponse> Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Grpc.Reflection.V1Alpha.ReflectionReflection.Descriptor.MessageTypes[2]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ServerReflectionResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ServerReflectionResponse(ServerReflectionResponse other) : this() { + validHost_ = other.validHost_; + OriginalRequest = other.originalRequest_ != null ? other.OriginalRequest.Clone() : null; + switch (other.MessageResponseCase) { + case MessageResponseOneofCase.FileDescriptorResponse: + FileDescriptorResponse = other.FileDescriptorResponse.Clone(); + break; + case MessageResponseOneofCase.AllExtensionNumbersResponse: + AllExtensionNumbersResponse = other.AllExtensionNumbersResponse.Clone(); + break; + case MessageResponseOneofCase.ListServicesResponse: + ListServicesResponse = other.ListServicesResponse.Clone(); + break; + case MessageResponseOneofCase.ErrorResponse: + ErrorResponse = other.ErrorResponse.Clone(); + break; + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ServerReflectionResponse Clone() { + return new ServerReflectionResponse(this); + } + + /// <summary>Field number for the "valid_host" field.</summary> + public const int ValidHostFieldNumber = 1; + private string validHost_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string ValidHost { + get { return validHost_; } + set { + validHost_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// <summary>Field number for the "original_request" field.</summary> + public const int OriginalRequestFieldNumber = 2; + private global::Grpc.Reflection.V1Alpha.ServerReflectionRequest originalRequest_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Grpc.Reflection.V1Alpha.ServerReflectionRequest OriginalRequest { + get { return originalRequest_; } + set { + originalRequest_ = value; + } + } + + /// <summary>Field number for the "file_descriptor_response" field.</summary> + public const int FileDescriptorResponseFieldNumber = 4; + /// <summary> + /// This message is used to answer file_by_filename, file_containing_symbol, + /// file_containing_extension requests with transitive dependencies. As + /// the repeated label is not allowed in oneof fields, we use a + /// FileDescriptorResponse message to encapsulate the repeated fields. + /// The reflection service is allowed to avoid sending FileDescriptorProtos + /// that were previously sent in response to earlier requests in the stream. + /// </summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Grpc.Reflection.V1Alpha.FileDescriptorResponse FileDescriptorResponse { + get { return messageResponseCase_ == MessageResponseOneofCase.FileDescriptorResponse ? (global::Grpc.Reflection.V1Alpha.FileDescriptorResponse) messageResponse_ : null; } + set { + messageResponse_ = value; + messageResponseCase_ = value == null ? MessageResponseOneofCase.None : MessageResponseOneofCase.FileDescriptorResponse; + } + } + + /// <summary>Field number for the "all_extension_numbers_response" field.</summary> + public const int AllExtensionNumbersResponseFieldNumber = 5; + /// <summary> + /// This message is used to answer all_extension_numbers_of_type requst. + /// </summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Grpc.Reflection.V1Alpha.ExtensionNumberResponse AllExtensionNumbersResponse { + get { return messageResponseCase_ == MessageResponseOneofCase.AllExtensionNumbersResponse ? (global::Grpc.Reflection.V1Alpha.ExtensionNumberResponse) messageResponse_ : null; } + set { + messageResponse_ = value; + messageResponseCase_ = value == null ? MessageResponseOneofCase.None : MessageResponseOneofCase.AllExtensionNumbersResponse; + } + } + + /// <summary>Field number for the "list_services_response" field.</summary> + public const int ListServicesResponseFieldNumber = 6; + /// <summary> + /// This message is used to answer list_services request. + /// </summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Grpc.Reflection.V1Alpha.ListServiceResponse ListServicesResponse { + get { return messageResponseCase_ == MessageResponseOneofCase.ListServicesResponse ? (global::Grpc.Reflection.V1Alpha.ListServiceResponse) messageResponse_ : null; } + set { + messageResponse_ = value; + messageResponseCase_ = value == null ? MessageResponseOneofCase.None : MessageResponseOneofCase.ListServicesResponse; + } + } + + /// <summary>Field number for the "error_response" field.</summary> + public const int ErrorResponseFieldNumber = 7; + /// <summary> + /// This message is used when an error occurs. + /// </summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Grpc.Reflection.V1Alpha.ErrorResponse ErrorResponse { + get { return messageResponseCase_ == MessageResponseOneofCase.ErrorResponse ? (global::Grpc.Reflection.V1Alpha.ErrorResponse) messageResponse_ : null; } + set { + messageResponse_ = value; + messageResponseCase_ = value == null ? MessageResponseOneofCase.None : MessageResponseOneofCase.ErrorResponse; + } + } + + private object messageResponse_; + /// <summary>Enum of possible cases for the "message_response" oneof.</summary> + public enum MessageResponseOneofCase { + None = 0, + FileDescriptorResponse = 4, + AllExtensionNumbersResponse = 5, + ListServicesResponse = 6, + ErrorResponse = 7, + } + private MessageResponseOneofCase messageResponseCase_ = MessageResponseOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public MessageResponseOneofCase MessageResponseCase { + get { return messageResponseCase_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearMessageResponse() { + messageResponseCase_ = MessageResponseOneofCase.None; + messageResponse_ = null; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as ServerReflectionResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(ServerReflectionResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (ValidHost != other.ValidHost) return false; + if (!object.Equals(OriginalRequest, other.OriginalRequest)) return false; + if (!object.Equals(FileDescriptorResponse, other.FileDescriptorResponse)) return false; + if (!object.Equals(AllExtensionNumbersResponse, other.AllExtensionNumbersResponse)) return false; + if (!object.Equals(ListServicesResponse, other.ListServicesResponse)) return false; + if (!object.Equals(ErrorResponse, other.ErrorResponse)) return false; + if (MessageResponseCase != other.MessageResponseCase) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (ValidHost.Length != 0) hash ^= ValidHost.GetHashCode(); + if (originalRequest_ != null) hash ^= OriginalRequest.GetHashCode(); + if (messageResponseCase_ == MessageResponseOneofCase.FileDescriptorResponse) hash ^= FileDescriptorResponse.GetHashCode(); + if (messageResponseCase_ == MessageResponseOneofCase.AllExtensionNumbersResponse) hash ^= AllExtensionNumbersResponse.GetHashCode(); + if (messageResponseCase_ == MessageResponseOneofCase.ListServicesResponse) hash ^= ListServicesResponse.GetHashCode(); + if (messageResponseCase_ == MessageResponseOneofCase.ErrorResponse) hash ^= ErrorResponse.GetHashCode(); + hash ^= (int) messageResponseCase_; + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (ValidHost.Length != 0) { + output.WriteRawTag(10); + output.WriteString(ValidHost); + } + if (originalRequest_ != null) { + output.WriteRawTag(18); + output.WriteMessage(OriginalRequest); + } + if (messageResponseCase_ == MessageResponseOneofCase.FileDescriptorResponse) { + output.WriteRawTag(34); + output.WriteMessage(FileDescriptorResponse); + } + if (messageResponseCase_ == MessageResponseOneofCase.AllExtensionNumbersResponse) { + output.WriteRawTag(42); + output.WriteMessage(AllExtensionNumbersResponse); + } + if (messageResponseCase_ == MessageResponseOneofCase.ListServicesResponse) { + output.WriteRawTag(50); + output.WriteMessage(ListServicesResponse); + } + if (messageResponseCase_ == MessageResponseOneofCase.ErrorResponse) { + output.WriteRawTag(58); + output.WriteMessage(ErrorResponse); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (ValidHost.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(ValidHost); + } + if (originalRequest_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(OriginalRequest); + } + if (messageResponseCase_ == MessageResponseOneofCase.FileDescriptorResponse) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(FileDescriptorResponse); + } + if (messageResponseCase_ == MessageResponseOneofCase.AllExtensionNumbersResponse) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(AllExtensionNumbersResponse); + } + if (messageResponseCase_ == MessageResponseOneofCase.ListServicesResponse) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(ListServicesResponse); + } + if (messageResponseCase_ == MessageResponseOneofCase.ErrorResponse) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(ErrorResponse); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ServerReflectionResponse other) { + if (other == null) { + return; + } + if (other.ValidHost.Length != 0) { + ValidHost = other.ValidHost; + } + if (other.originalRequest_ != null) { + if (originalRequest_ == null) { + originalRequest_ = new global::Grpc.Reflection.V1Alpha.ServerReflectionRequest(); + } + OriginalRequest.MergeFrom(other.OriginalRequest); + } + switch (other.MessageResponseCase) { + case MessageResponseOneofCase.FileDescriptorResponse: + FileDescriptorResponse = other.FileDescriptorResponse; + break; + case MessageResponseOneofCase.AllExtensionNumbersResponse: + AllExtensionNumbersResponse = other.AllExtensionNumbersResponse; + break; + case MessageResponseOneofCase.ListServicesResponse: + ListServicesResponse = other.ListServicesResponse; + break; + case MessageResponseOneofCase.ErrorResponse: + ErrorResponse = other.ErrorResponse; + break; + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + ValidHost = input.ReadString(); + break; + } + case 18: { + if (originalRequest_ == null) { + originalRequest_ = new global::Grpc.Reflection.V1Alpha.ServerReflectionRequest(); + } + input.ReadMessage(originalRequest_); + break; + } + case 34: { + global::Grpc.Reflection.V1Alpha.FileDescriptorResponse subBuilder = new global::Grpc.Reflection.V1Alpha.FileDescriptorResponse(); + if (messageResponseCase_ == MessageResponseOneofCase.FileDescriptorResponse) { + subBuilder.MergeFrom(FileDescriptorResponse); + } + input.ReadMessage(subBuilder); + FileDescriptorResponse = subBuilder; + break; + } + case 42: { + global::Grpc.Reflection.V1Alpha.ExtensionNumberResponse subBuilder = new global::Grpc.Reflection.V1Alpha.ExtensionNumberResponse(); + if (messageResponseCase_ == MessageResponseOneofCase.AllExtensionNumbersResponse) { + subBuilder.MergeFrom(AllExtensionNumbersResponse); + } + input.ReadMessage(subBuilder); + AllExtensionNumbersResponse = subBuilder; + break; + } + case 50: { + global::Grpc.Reflection.V1Alpha.ListServiceResponse subBuilder = new global::Grpc.Reflection.V1Alpha.ListServiceResponse(); + if (messageResponseCase_ == MessageResponseOneofCase.ListServicesResponse) { + subBuilder.MergeFrom(ListServicesResponse); + } + input.ReadMessage(subBuilder); + ListServicesResponse = subBuilder; + break; + } + case 58: { + global::Grpc.Reflection.V1Alpha.ErrorResponse subBuilder = new global::Grpc.Reflection.V1Alpha.ErrorResponse(); + if (messageResponseCase_ == MessageResponseOneofCase.ErrorResponse) { + subBuilder.MergeFrom(ErrorResponse); + } + input.ReadMessage(subBuilder); + ErrorResponse = subBuilder; + break; + } + } + } + } + + } + + /// <summary> + /// Serialized FileDescriptorProto messages sent by the server answering + /// a file_by_filename, file_containing_symbol, or file_containing_extension + /// request. + /// </summary> + public sealed partial class FileDescriptorResponse : pb::IMessage<FileDescriptorResponse> { + private static readonly pb::MessageParser<FileDescriptorResponse> _parser = new pb::MessageParser<FileDescriptorResponse>(() => new FileDescriptorResponse()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser<FileDescriptorResponse> Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Grpc.Reflection.V1Alpha.ReflectionReflection.Descriptor.MessageTypes[3]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public FileDescriptorResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public FileDescriptorResponse(FileDescriptorResponse other) : this() { + fileDescriptorProto_ = other.fileDescriptorProto_.Clone(); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public FileDescriptorResponse Clone() { + return new FileDescriptorResponse(this); + } + + /// <summary>Field number for the "file_descriptor_proto" field.</summary> + public const int FileDescriptorProtoFieldNumber = 1; + private static readonly pb::FieldCodec<pb::ByteString> _repeated_fileDescriptorProto_codec + = pb::FieldCodec.ForBytes(10); + private readonly pbc::RepeatedField<pb::ByteString> fileDescriptorProto_ = new pbc::RepeatedField<pb::ByteString>(); + /// <summary> + /// Serialized FileDescriptorProto messages. We avoid taking a dependency on + /// descriptor.proto, which uses proto2 only features, by making them opaque + /// bytes instead. + /// </summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<pb::ByteString> FileDescriptorProto { + get { return fileDescriptorProto_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as FileDescriptorResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(FileDescriptorResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if(!fileDescriptorProto_.Equals(other.fileDescriptorProto_)) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + hash ^= fileDescriptorProto_.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + fileDescriptorProto_.WriteTo(output, _repeated_fileDescriptorProto_codec); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + size += fileDescriptorProto_.CalculateSize(_repeated_fileDescriptorProto_codec); + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(FileDescriptorResponse other) { + if (other == null) { + return; + } + fileDescriptorProto_.Add(other.fileDescriptorProto_); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + fileDescriptorProto_.AddEntriesFrom(input, _repeated_fileDescriptorProto_codec); + break; + } + } + } + } + + } + + /// <summary> + /// A list of extension numbers sent by the server answering + /// all_extension_numbers_of_type request. + /// </summary> + public sealed partial class ExtensionNumberResponse : pb::IMessage<ExtensionNumberResponse> { + private static readonly pb::MessageParser<ExtensionNumberResponse> _parser = new pb::MessageParser<ExtensionNumberResponse>(() => new ExtensionNumberResponse()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser<ExtensionNumberResponse> Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Grpc.Reflection.V1Alpha.ReflectionReflection.Descriptor.MessageTypes[4]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ExtensionNumberResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ExtensionNumberResponse(ExtensionNumberResponse other) : this() { + baseTypeName_ = other.baseTypeName_; + extensionNumber_ = other.extensionNumber_.Clone(); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ExtensionNumberResponse Clone() { + return new ExtensionNumberResponse(this); + } + + /// <summary>Field number for the "base_type_name" field.</summary> + public const int BaseTypeNameFieldNumber = 1; + private string baseTypeName_ = ""; + /// <summary> + /// Full name of the base type, including the package name. The format + /// is <package>.<type> + /// </summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string BaseTypeName { + get { return baseTypeName_; } + set { + baseTypeName_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// <summary>Field number for the "extension_number" field.</summary> + public const int ExtensionNumberFieldNumber = 2; + private static readonly pb::FieldCodec<int> _repeated_extensionNumber_codec + = pb::FieldCodec.ForInt32(18); + private readonly pbc::RepeatedField<int> extensionNumber_ = new pbc::RepeatedField<int>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<int> ExtensionNumber { + get { return extensionNumber_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as ExtensionNumberResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(ExtensionNumberResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (BaseTypeName != other.BaseTypeName) return false; + if(!extensionNumber_.Equals(other.extensionNumber_)) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (BaseTypeName.Length != 0) hash ^= BaseTypeName.GetHashCode(); + hash ^= extensionNumber_.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (BaseTypeName.Length != 0) { + output.WriteRawTag(10); + output.WriteString(BaseTypeName); + } + extensionNumber_.WriteTo(output, _repeated_extensionNumber_codec); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (BaseTypeName.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(BaseTypeName); + } + size += extensionNumber_.CalculateSize(_repeated_extensionNumber_codec); + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ExtensionNumberResponse other) { + if (other == null) { + return; + } + if (other.BaseTypeName.Length != 0) { + BaseTypeName = other.BaseTypeName; + } + extensionNumber_.Add(other.extensionNumber_); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + BaseTypeName = input.ReadString(); + break; + } + case 18: + case 16: { + extensionNumber_.AddEntriesFrom(input, _repeated_extensionNumber_codec); + break; + } + } + } + } + + } + + /// <summary> + /// A list of ServiceResponse sent by the server answering list_services request. + /// </summary> + public sealed partial class ListServiceResponse : pb::IMessage<ListServiceResponse> { + private static readonly pb::MessageParser<ListServiceResponse> _parser = new pb::MessageParser<ListServiceResponse>(() => new ListServiceResponse()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser<ListServiceResponse> Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Grpc.Reflection.V1Alpha.ReflectionReflection.Descriptor.MessageTypes[5]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ListServiceResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ListServiceResponse(ListServiceResponse other) : this() { + service_ = other.service_.Clone(); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ListServiceResponse Clone() { + return new ListServiceResponse(this); + } + + /// <summary>Field number for the "service" field.</summary> + public const int ServiceFieldNumber = 1; + private static readonly pb::FieldCodec<global::Grpc.Reflection.V1Alpha.ServiceResponse> _repeated_service_codec + = pb::FieldCodec.ForMessage(10, global::Grpc.Reflection.V1Alpha.ServiceResponse.Parser); + private readonly pbc::RepeatedField<global::Grpc.Reflection.V1Alpha.ServiceResponse> service_ = new pbc::RepeatedField<global::Grpc.Reflection.V1Alpha.ServiceResponse>(); + /// <summary> + /// The information of each service may be expanded in the future, so we use + /// ServiceResponse message to encapsulate it. + /// </summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<global::Grpc.Reflection.V1Alpha.ServiceResponse> Service { + get { return service_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as ListServiceResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(ListServiceResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if(!service_.Equals(other.service_)) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + hash ^= service_.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + service_.WriteTo(output, _repeated_service_codec); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + size += service_.CalculateSize(_repeated_service_codec); + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ListServiceResponse other) { + if (other == null) { + return; + } + service_.Add(other.service_); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + service_.AddEntriesFrom(input, _repeated_service_codec); + break; + } + } + } + } + + } + + /// <summary> + /// The information of a single service used by ListServiceResponse to answer + /// list_services request. + /// </summary> + public sealed partial class ServiceResponse : pb::IMessage<ServiceResponse> { + private static readonly pb::MessageParser<ServiceResponse> _parser = new pb::MessageParser<ServiceResponse>(() => new ServiceResponse()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser<ServiceResponse> Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Grpc.Reflection.V1Alpha.ReflectionReflection.Descriptor.MessageTypes[6]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ServiceResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ServiceResponse(ServiceResponse other) : this() { + name_ = other.name_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ServiceResponse Clone() { + return new ServiceResponse(this); + } + + /// <summary>Field number for the "name" field.</summary> + public const int NameFieldNumber = 1; + private string name_ = ""; + /// <summary> + /// Full name of a registered service, including its package name. The format + /// is <package>.<service> + /// </summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Name { + get { return name_; } + set { + name_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as ServiceResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(ServiceResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Name != other.Name) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ServiceResponse other) { + if (other == null) { + return; + } + if (other.Name.Length != 0) { + Name = other.Name; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + Name = input.ReadString(); + break; + } + } + } + } + + } + + /// <summary> + /// The error code and error message sent by the server when an error occurs. + /// </summary> + public sealed partial class ErrorResponse : pb::IMessage<ErrorResponse> { + private static readonly pb::MessageParser<ErrorResponse> _parser = new pb::MessageParser<ErrorResponse>(() => new ErrorResponse()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser<ErrorResponse> Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Grpc.Reflection.V1Alpha.ReflectionReflection.Descriptor.MessageTypes[7]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ErrorResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ErrorResponse(ErrorResponse other) : this() { + errorCode_ = other.errorCode_; + errorMessage_ = other.errorMessage_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ErrorResponse Clone() { + return new ErrorResponse(this); + } + + /// <summary>Field number for the "error_code" field.</summary> + public const int ErrorCodeFieldNumber = 1; + private int errorCode_; + /// <summary> + /// This field uses the error codes defined in grpc::StatusCode. + /// </summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int ErrorCode { + get { return errorCode_; } + set { + errorCode_ = value; + } + } + + /// <summary>Field number for the "error_message" field.</summary> + public const int ErrorMessageFieldNumber = 2; + private string errorMessage_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string ErrorMessage { + get { return errorMessage_; } + set { + errorMessage_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as ErrorResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(ErrorResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (ErrorCode != other.ErrorCode) return false; + if (ErrorMessage != other.ErrorMessage) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (ErrorCode != 0) hash ^= ErrorCode.GetHashCode(); + if (ErrorMessage.Length != 0) hash ^= ErrorMessage.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (ErrorCode != 0) { + output.WriteRawTag(8); + output.WriteInt32(ErrorCode); + } + if (ErrorMessage.Length != 0) { + output.WriteRawTag(18); + output.WriteString(ErrorMessage); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (ErrorCode != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(ErrorCode); + } + if (ErrorMessage.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(ErrorMessage); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ErrorResponse other) { + if (other == null) { + return; + } + if (other.ErrorCode != 0) { + ErrorCode = other.ErrorCode; + } + if (other.ErrorMessage.Length != 0) { + ErrorMessage = other.ErrorMessage; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 8: { + ErrorCode = input.ReadInt32(); + break; + } + case 18: { + ErrorMessage = input.ReadString(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/src/csharp/Grpc.Reflection/ReflectionGrpc.cs b/src/csharp/Grpc.Reflection/ReflectionGrpc.cs new file mode 100644 index 0000000000..1b6f96ce7c --- /dev/null +++ b/src/csharp/Grpc.Reflection/ReflectionGrpc.cs @@ -0,0 +1,132 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: grpc/reflection/v1alpha/reflection.proto +// Original file comments: +// Copyright 2016, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Service exported by server reflection +// +#region Designer generated code + +using System; +using System.Threading; +using System.Threading.Tasks; +using Grpc.Core; + +namespace Grpc.Reflection.V1Alpha { + public static partial class ServerReflection + { + static readonly string __ServiceName = "grpc.reflection.v1alpha.ServerReflection"; + + static readonly Marshaller<global::Grpc.Reflection.V1Alpha.ServerReflectionRequest> __Marshaller_ServerReflectionRequest = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Reflection.V1Alpha.ServerReflectionRequest.Parser.ParseFrom); + static readonly Marshaller<global::Grpc.Reflection.V1Alpha.ServerReflectionResponse> __Marshaller_ServerReflectionResponse = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Reflection.V1Alpha.ServerReflectionResponse.Parser.ParseFrom); + + static readonly Method<global::Grpc.Reflection.V1Alpha.ServerReflectionRequest, global::Grpc.Reflection.V1Alpha.ServerReflectionResponse> __Method_ServerReflectionInfo = new Method<global::Grpc.Reflection.V1Alpha.ServerReflectionRequest, global::Grpc.Reflection.V1Alpha.ServerReflectionResponse>( + MethodType.DuplexStreaming, + __ServiceName, + "ServerReflectionInfo", + __Marshaller_ServerReflectionRequest, + __Marshaller_ServerReflectionResponse); + + /// <summary>Service descriptor</summary> + public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor + { + get { return global::Grpc.Reflection.V1Alpha.ReflectionReflection.Descriptor.Services[0]; } + } + + /// <summary>Base class for server-side implementations of ServerReflection</summary> + public abstract partial class ServerReflectionBase + { + /// <summary> + /// The reflection service is structured as a bidirectional stream, ensuring + /// all related requests go to a single server. + /// </summary> + public virtual global::System.Threading.Tasks.Task ServerReflectionInfo(IAsyncStreamReader<global::Grpc.Reflection.V1Alpha.ServerReflectionRequest> requestStream, IServerStreamWriter<global::Grpc.Reflection.V1Alpha.ServerReflectionResponse> responseStream, ServerCallContext context) + { + throw new RpcException(new Status(StatusCode.Unimplemented, "")); + } + + } + + /// <summary>Client for ServerReflection</summary> + public partial class ServerReflectionClient : ClientBase<ServerReflectionClient> + { + /// <summary>Creates a new client for ServerReflection</summary> + /// <param name="channel">The channel to use to make remote calls.</param> + public ServerReflectionClient(Channel channel) : base(channel) + { + } + /// <summary>Creates a new client for ServerReflection that uses a custom <c>CallInvoker</c>.</summary> + /// <param name="callInvoker">The callInvoker to use to make remote calls.</param> + public ServerReflectionClient(CallInvoker callInvoker) : base(callInvoker) + { + } + /// <summary>Protected parameterless constructor to allow creation of test doubles.</summary> + protected ServerReflectionClient() : base() + { + } + /// <summary>Protected constructor to allow creation of configured clients.</summary> + /// <param name="configuration">The client configuration.</param> + protected ServerReflectionClient(ClientBaseConfiguration configuration) : base(configuration) + { + } + + /// <summary> + /// The reflection service is structured as a bidirectional stream, ensuring + /// all related requests go to a single server. + /// </summary> + public virtual AsyncDuplexStreamingCall<global::Grpc.Reflection.V1Alpha.ServerReflectionRequest, global::Grpc.Reflection.V1Alpha.ServerReflectionResponse> ServerReflectionInfo(Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + { + return ServerReflectionInfo(new CallOptions(headers, deadline, cancellationToken)); + } + /// <summary> + /// The reflection service is structured as a bidirectional stream, ensuring + /// all related requests go to a single server. + /// </summary> + public virtual AsyncDuplexStreamingCall<global::Grpc.Reflection.V1Alpha.ServerReflectionRequest, global::Grpc.Reflection.V1Alpha.ServerReflectionResponse> ServerReflectionInfo(CallOptions options) + { + return CallInvoker.AsyncDuplexStreamingCall(__Method_ServerReflectionInfo, null, options); + } + /// <summary>Creates a new instance of client from given <c>ClientBaseConfiguration</c>.</summary> + protected override ServerReflectionClient NewInstance(ClientBaseConfiguration configuration) + { + return new ServerReflectionClient(configuration); + } + } + + /// <summary>Creates service definition that can be registered with a server</summary> + public static ServerServiceDefinition BindService(ServerReflectionBase serviceImpl) + { + return ServerServiceDefinition.CreateBuilder() + .AddMethod(__Method_ServerReflectionInfo, serviceImpl.ServerReflectionInfo).Build(); + } + + } +} +#endregion diff --git a/src/csharp/Grpc.Reflection/ReflectionServiceImpl.cs b/src/csharp/Grpc.Reflection/ReflectionServiceImpl.cs new file mode 100644 index 0000000000..105c4c963b --- /dev/null +++ b/src/csharp/Grpc.Reflection/ReflectionServiceImpl.cs @@ -0,0 +1,173 @@ +#region Copyright notice and license +// Copyright 2015, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using Grpc.Core; +using Grpc.Core.Utils; +using Grpc.Reflection.V1Alpha; +using Google.Protobuf.Reflection; + +namespace Grpc.Reflection +{ + /// <summary> + /// Implementation of server reflection service. + /// </summary> + public class ReflectionServiceImpl : Grpc.Reflection.V1Alpha.ServerReflection.ServerReflectionBase + { + readonly List<string> services; + readonly SymbolRegistry symbolRegistry; + + /// <summary> + /// Creates a new instance of <c>ReflectionServiceIml</c>. + /// </summary> + public ReflectionServiceImpl(IEnumerable<string> services, SymbolRegistry symbolRegistry) + { + this.services = new List<string>(services); + this.symbolRegistry = symbolRegistry; + } + + /// <summary> + /// Creates a new instance of <c>ReflectionServiceIml</c>. + /// </summary> + public ReflectionServiceImpl(IEnumerable<ServiceDescriptor> serviceDescriptors) + { + this.services = new List<string>(serviceDescriptors.Select((serviceDescriptor) => serviceDescriptor.FullName)); + this.symbolRegistry = SymbolRegistry.FromFiles(serviceDescriptors.Select((serviceDescriptor) => serviceDescriptor.File)); + } + + /// <summary> + /// Creates a new instance of <c>ReflectionServiceIml</c>. + /// </summary> + public ReflectionServiceImpl(params ServiceDescriptor[] serviceDescriptors) : this((IEnumerable<ServiceDescriptor>) serviceDescriptors) + { + } + + public override async Task ServerReflectionInfo(IAsyncStreamReader<ServerReflectionRequest> requestStream, IServerStreamWriter<ServerReflectionResponse> responseStream, ServerCallContext context) + { + while (await requestStream.MoveNext()) + { + var response = ProcessRequest(requestStream.Current); + await responseStream.WriteAsync(response); + } + } + + ServerReflectionResponse ProcessRequest(ServerReflectionRequest request) + { + switch (request.MessageRequestCase) + { + case ServerReflectionRequest.MessageRequestOneofCase.FileByFilename: + return FileByFilename(request.FileByFilename); + case ServerReflectionRequest.MessageRequestOneofCase.FileContainingSymbol: + return FileContainingSymbol(request.FileContainingSymbol); + case ServerReflectionRequest.MessageRequestOneofCase.ListServices: + return ListServices(); + case ServerReflectionRequest.MessageRequestOneofCase.AllExtensionNumbersOfType: + case ServerReflectionRequest.MessageRequestOneofCase.FileContainingExtension: + default: + return CreateErrorResponse(StatusCode.Unimplemented, "Request type not supported by C# reflection service."); + } + } + + ServerReflectionResponse FileByFilename(string filename) + { + FileDescriptor file = symbolRegistry.FileByName(filename); + if (file == null) + { + return CreateErrorResponse(StatusCode.NotFound, "File not found."); + } + + var transitiveDependencies = new HashSet<FileDescriptor>(); + CollectTransitiveDependencies(file, transitiveDependencies); + + return new ServerReflectionResponse + { + FileDescriptorResponse = new FileDescriptorResponse { FileDescriptorProto = { transitiveDependencies.Select((d) => d.SerializedData) } } + }; + } + + ServerReflectionResponse FileContainingSymbol(string symbol) + { + FileDescriptor file = symbolRegistry.FileContainingSymbol(symbol); + if (file == null) + { + return CreateErrorResponse(StatusCode.NotFound, "Symbol not found."); + } + + var transitiveDependencies = new HashSet<FileDescriptor>(); + CollectTransitiveDependencies(file, transitiveDependencies); + + return new ServerReflectionResponse + { + FileDescriptorResponse = new FileDescriptorResponse { FileDescriptorProto = { transitiveDependencies.Select((d) => d.SerializedData) } } + }; + } + + ServerReflectionResponse ListServices() + { + var serviceResponses = new ListServiceResponse(); + foreach (string serviceName in services) + { + serviceResponses.Service.Add(new ServiceResponse { Name = serviceName }); + } + + return new ServerReflectionResponse + { + ListServicesResponse = serviceResponses + }; + } + + ServerReflectionResponse CreateErrorResponse(StatusCode status, string message) + { + return new ServerReflectionResponse + { + ErrorResponse = new ErrorResponse { ErrorCode = (int) status, ErrorMessage = message } + }; + } + + void CollectTransitiveDependencies(FileDescriptor descriptor, HashSet<FileDescriptor> pool) + { + pool.Add(descriptor); + foreach (var dependency in descriptor.Dependencies) + { + if (pool.Add(dependency)) + { + // descriptors cannot have circular dependencies + CollectTransitiveDependencies(dependency, pool); + } + } + } + } +} diff --git a/src/csharp/Grpc.Reflection/Settings.StyleCop b/src/csharp/Grpc.Reflection/Settings.StyleCop new file mode 100644 index 0000000000..2942add962 --- /dev/null +++ b/src/csharp/Grpc.Reflection/Settings.StyleCop @@ -0,0 +1,10 @@ +<StyleCopSettings Version="105"> + <SourceFileList> + <SourceFile>Health.cs</SourceFile> + <Settings> + <GlobalSettings> + <BooleanProperty Name="RulesEnabledByDefault">False</BooleanProperty> + </GlobalSettings> + </Settings> + </SourceFileList> +</StyleCopSettings> diff --git a/src/csharp/Grpc.Reflection/SymbolRegistry.cs b/src/csharp/Grpc.Reflection/SymbolRegistry.cs new file mode 100644 index 0000000000..b7104ab2f9 --- /dev/null +++ b/src/csharp/Grpc.Reflection/SymbolRegistry.cs @@ -0,0 +1,160 @@ +#region Copyright notice and license +// Copyright 2015, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System.Collections.Generic; +using Grpc.Core.Utils; +using Google.Protobuf.Reflection; + +namespace Grpc.Reflection +{ + /// <summary>Registry of protobuf symbols</summary> + public class SymbolRegistry + { + private readonly Dictionary<string, FileDescriptor> filesByName; + private readonly Dictionary<string, FileDescriptor> filesBySymbol; + + private SymbolRegistry(Dictionary<string, FileDescriptor> filesByName, Dictionary<string, FileDescriptor> filesBySymbol) + { + this.filesByName = new Dictionary<string, FileDescriptor>(filesByName); + this.filesBySymbol = new Dictionary<string, FileDescriptor>(filesBySymbol); + } + + /// <summary> + /// Creates a symbol registry from the specified set of file descriptors. + /// </summary> + /// <param name="fileDescriptors">The set of files to include in the registry. Must not contain null values.</param> + /// <returns>A symbol registry for the given files.</returns> + public static SymbolRegistry FromFiles(IEnumerable<FileDescriptor> fileDescriptors) + { + GrpcPreconditions.CheckNotNull(fileDescriptors); + var builder = new Builder(); + foreach (var file in fileDescriptors) + { + builder.AddFile(file); + } + return builder.Build(); + } + + /// <summary> + /// Gets file descriptor for given file name (including package path). Returns <c>null</c> if not found. + /// </summary> + public FileDescriptor FileByName(string filename) + { + FileDescriptor file; + filesByName.TryGetValue(filename, out file); + return file; + } + + /// <summary> + /// Gets file descriptor that contains definition of given symbol full name (including package path). Returns <c>null</c> if not found. + /// </summary> + public FileDescriptor FileContainingSymbol(string symbol) + { + FileDescriptor file; + filesBySymbol.TryGetValue(symbol, out file); + return file; + } + + /// <summary> + /// Builder class which isn't exposed, but acts as a convenient alternative to passing round two dictionaries in recursive calls. + /// </summary> + private class Builder + { + private readonly Dictionary<string, FileDescriptor> filesByName; + private readonly Dictionary<string, FileDescriptor> filesBySymbol; + + + internal Builder() + { + filesByName = new Dictionary<string, FileDescriptor>(); + filesBySymbol = new Dictionary<string, FileDescriptor>(); + } + + internal void AddFile(FileDescriptor fileDescriptor) + { + if (filesByName.ContainsKey(fileDescriptor.Name)) + { + return; + } + filesByName.Add(fileDescriptor.Name, fileDescriptor); + + foreach (var dependency in fileDescriptor.Dependencies) + { + AddFile(dependency); + } + foreach (var enumeration in fileDescriptor.EnumTypes) + { + AddEnum(enumeration); + } + foreach (var message in fileDescriptor.MessageTypes) + { + AddMessage(message); + } + foreach (var service in fileDescriptor.Services) + { + AddService(service); + } + } + + private void AddEnum(EnumDescriptor enumDescriptor) + { + filesBySymbol[enumDescriptor.FullName] = enumDescriptor.File; + } + + private void AddMessage(MessageDescriptor messageDescriptor) + { + foreach (var nestedEnum in messageDescriptor.EnumTypes) + { + AddEnum(nestedEnum); + } + foreach (var nestedType in messageDescriptor.NestedTypes) + { + AddMessage(nestedType); + } + filesBySymbol[messageDescriptor.FullName] = messageDescriptor.File; + } + + private void AddService(ServiceDescriptor serviceDescriptor) + { + foreach (var method in serviceDescriptor.Methods) + { + filesBySymbol[method.FullName] = method.File; + } + filesBySymbol[serviceDescriptor.FullName] = serviceDescriptor.File; + } + + internal SymbolRegistry Build() + { + return new SymbolRegistry(filesByName, filesBySymbol); + } + } + } +} diff --git a/src/csharp/Grpc.Reflection/packages.config b/src/csharp/Grpc.Reflection/packages.config new file mode 100644 index 0000000000..5ab40b7a8c --- /dev/null +++ b/src/csharp/Grpc.Reflection/packages.config @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="Google.Protobuf" version="3.0.0" targetFramework="net45" /> + <package id="System.Interactive.Async" version="3.1.1" targetFramework="net45" /> +</packages>
\ No newline at end of file diff --git a/src/csharp/Grpc.Reflection/project.json b/src/csharp/Grpc.Reflection/project.json new file mode 100644 index 0000000000..2fe617cc7a --- /dev/null +++ b/src/csharp/Grpc.Reflection/project.json @@ -0,0 +1,40 @@ +{ + "version": "1.1.0-dev", + "title": "gRPC C# Reflection", + "authors": [ "Google Inc." ], + "copyright": "Copyright 2016, Google Inc.", + "packOptions": { + "summary": "Implementation of gRPC reflection service", + "description": "Provides information about services running on a gRPC C# server.", + "owners": [ "grpc-packages" ], + "licenseUrl": "https://github.com/grpc/grpc/blob/master/LICENSE", + "projectUrl": "https://github.com/grpc/grpc", + "requireLicenseAcceptance": false, + "tags": [ "gRPC reflection" ] + }, + "buildOptions": { + "define": [ "SIGNED" ], + "keyFile": "../keys/Grpc.snk", + "xmlDoc": true, + "compile": { + "includeFiles": [ "../Grpc.Core/Version.cs" ] + } + }, + "dependencies": { + "Grpc.Core": "1.1.0-dev", + "Google.Protobuf": "3.0.0" + }, + "frameworks": { + "net45": { + "frameworkAssemblies": { + "System.Runtime": "", + "System.IO": "" + } + }, + "netstandard1.5": { + "dependencies": { + "NETStandard.Library": "1.6.0" + } + } + } +} diff --git a/src/csharp/Grpc.sln b/src/csharp/Grpc.sln index 9be36c0caa..2e6a8fd435 100644 --- a/src/csharp/Grpc.sln +++ b/src/csharp/Grpc.sln @@ -36,6 +36,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Grpc.IntegrationTesting.Qps EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Grpc.IntegrationTesting.StressClient", "Grpc.IntegrationTesting.StressClient\Grpc.IntegrationTesting.StressClient.csproj", "{ADEBA147-80AE-4710-82E9-5B7F93690266}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Grpc.Reflection", "Grpc.Reflection\Grpc.Reflection.csproj", "{4F18CF52-B3DB-4A77-97C5-7F7F4B6C1715}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Grpc.Reflection.Tests", "Grpc.Reflection.Tests\Grpc.Reflection.Tests.csproj", "{B88F91D6-436D-4C78-8B99-47800FA8DE03}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -55,6 +59,12 @@ Global {3D166931-BA2D-416E-95A3-D36E8F6E90B9}.Release|Any CPU.Build.0 = Release|Any CPU
{3D166931-BA2D-416E-95A3-D36E8F6E90B9}.ReleaseSigned|Any CPU.ActiveCfg = ReleaseSigned|Any CPU
{3D166931-BA2D-416E-95A3-D36E8F6E90B9}.ReleaseSigned|Any CPU.Build.0 = ReleaseSigned|Any CPU
+ {4F18CF52-B3DB-4A77-97C5-7F7F4B6C1715}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4F18CF52-B3DB-4A77-97C5-7F7F4B6C1715}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4F18CF52-B3DB-4A77-97C5-7F7F4B6C1715}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4F18CF52-B3DB-4A77-97C5-7F7F4B6C1715}.Release|Any CPU.Build.0 = Release|Any CPU
+ {4F18CF52-B3DB-4A77-97C5-7F7F4B6C1715}.ReleaseSigned|Any CPU.ActiveCfg = ReleaseSigned|Any CPU
+ {4F18CF52-B3DB-4A77-97C5-7F7F4B6C1715}.ReleaseSigned|Any CPU.Build.0 = ReleaseSigned|Any CPU
{61ECB8EE-0C96-4F8E-B187-8E4D227417C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{61ECB8EE-0C96-4F8E-B187-8E4D227417C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{61ECB8EE-0C96-4F8E-B187-8E4D227417C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -103,6 +113,12 @@ Global {B82B7DFE-7F7B-40EF-B3D6-064FF2B01294}.Release|Any CPU.Build.0 = Release|Any CPU
{B82B7DFE-7F7B-40EF-B3D6-064FF2B01294}.ReleaseSigned|Any CPU.ActiveCfg = Release|Any CPU
{B82B7DFE-7F7B-40EF-B3D6-064FF2B01294}.ReleaseSigned|Any CPU.Build.0 = Release|Any CPU
+ {B88F91D6-436D-4C78-8B99-47800FA8DE03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B88F91D6-436D-4C78-8B99-47800FA8DE03}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B88F91D6-436D-4C78-8B99-47800FA8DE03}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B88F91D6-436D-4C78-8B99-47800FA8DE03}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B88F91D6-436D-4C78-8B99-47800FA8DE03}.ReleaseSigned|Any CPU.ActiveCfg = ReleaseSigned|Any CPU
+ {B88F91D6-436D-4C78-8B99-47800FA8DE03}.ReleaseSigned|Any CPU.Build.0 = ReleaseSigned|Any CPU
{BF62FE08-373A-43D6-9D73-41CAA38B7011}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BF62FE08-373A-43D6-9D73-41CAA38B7011}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BF62FE08-373A-43D6-9D73-41CAA38B7011}.Release|Any CPU.ActiveCfg = Release|Any CPU
diff --git a/src/csharp/build_packages.bat b/src/csharp/build_packages_dotnetcli.bat index c0036df13f..9e8c045a1f 100644..100755 --- a/src/csharp/build_packages.bat +++ b/src/csharp/build_packages_dotnetcli.bat @@ -27,18 +27,17 @@ @rem (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE @rem OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -@rem Builds gRPC NuGet packages - -@rem This way of building nuget packages is now obsolete. C# nuget packages -@rem with CoreCLR support are now being built using the dotnet cli -@rem in build_packages_dotnetcli.sh - @rem Current package versions set VERSION=1.1.0-dev set PROTOBUF_VERSION=3.0.0 @rem Adjust the location of nuget.exe set NUGET=C:\nuget\nuget.exe +set DOTNET=C:\dotnet\dotnet.exe + +set -ex + +mkdir -p ..\..\artifacts\ @rem Collect the artifacts built by the previous build step if running on Jenkins @rem TODO(jtattermusch): is there a better way to do this? @@ -57,32 +56,22 @@ xcopy /Y /I ..\..\architecture=x64,language=protoc,platform=linux\artifacts\* pr xcopy /Y /I ..\..\architecture=x86,language=protoc,platform=macos\artifacts\* protoc_plugins\macosx_x86\ xcopy /Y /I ..\..\architecture=x64,language=protoc,platform=macos\artifacts\* protoc_plugins\macosx_x64\ -@rem Fetch all dependencies -%NUGET% restore ..\..\vsprojects\grpc_csharp_ext.sln || goto :error - -setlocal - -@call "%VS120COMNTOOLS%\..\..\vc\vcvarsall.bat" x86 - -@rem We won't use the native libraries from this step, but without this Grpc.sln will fail. -msbuild ..\..\vsprojects\grpc_csharp_ext.sln /p:Configuration=Release /p:PlatformToolset=v120 || goto :error - -msbuild Grpc.sln /p:Configuration=ReleaseSigned || goto :error +%DOTNET% restore . || goto :error -endlocal +%DOTNET% pack --configuration Release Grpc.Core\project.json --output ..\..\artifacts || goto :error +%DOTNET% pack --configuration Release Grpc.Auth\project.json --output ..\..\artifacts || goto :error +%DOTNET% pack --configuration Release Grpc.HealthCheck\project.json --output ..\..\artifacts || goto :error +%DOTNET% pack --configuration Release Grpc.Reflection\project.json --output ..\..\artifacts || goto :error -%NUGET% pack Grpc.Auth\Grpc.Auth.nuspec -Symbols -Version %VERSION% || goto :error -%NUGET% pack Grpc.Core\Grpc.Core.nuspec -Symbols -Version %VERSION% || goto :error -%NUGET% pack Grpc.HealthCheck\Grpc.HealthCheck.nuspec -Symbols -Version %VERSION% -Properties ProtobufVersion=%PROTOBUF_VERSION% || goto :error -%NUGET% pack Grpc.nuspec -Version %VERSION% || goto :error -%NUGET% pack Grpc.Tools.nuspec -Version %VERSION% || goto :error +%NUGET% pack Grpc.nuspec -Version %VERSION% -OutputDirectory ..\..\artifacts || goto :error +%NUGET% pack Grpc.Tools.nuspec -Version %VERSION% -OutputDirectory ..\..\artifacts @rem copy resulting nuget packages to artifacts directory -xcopy /Y /I *.nupkg ..\..\artifacts\ +xcopy /Y /I *.nupkg ..\..\artifacts\ || goto :error @rem create a zipfile with the artifacts as well -powershell -Command "Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::CreateFromDirectory('..\..\artifacts', 'csharp_nugets_obsolete.zip');" -xcopy /Y /I csharp_nugets_obsolete.zip ..\..\artifacts\ +powershell -Command "Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::CreateFromDirectory('..\..\artifacts', 'csharp_nugets_windows_dotnetcli.zip');" +xcopy /Y /I csharp_nugets_windows_dotnetcli.zip ..\..\artifacts\ || goto :error goto :EOF diff --git a/src/csharp/build_packages_dotnetcli.sh b/src/csharp/build_packages_dotnetcli.sh index 3c127f320b..52cf2f9ddc 100755 --- a/src/csharp/build_packages_dotnetcli.sh +++ b/src/csharp/build_packages_dotnetcli.sh @@ -63,6 +63,7 @@ dotnet restore . dotnet pack --configuration Release Grpc.Core/project.json --output ../../artifacts dotnet pack --configuration Release Grpc.Auth/project.json --output ../../artifacts dotnet pack --configuration Release Grpc.HealthCheck/project.json --output ../../artifacts +dotnet pack --configuration Release Grpc.Reflection/project.json --output ../../artifacts nuget pack Grpc.nuspec -Version "1.1.0-dev" -OutputDirectory ../../artifacts nuget pack Grpc.Tools.nuspec -Version "1.1.0-dev" -OutputDirectory ../../artifacts diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c index 9a5d7869d3..946f5872c0 100644 --- a/src/csharp/ext/grpc_csharp_ext.c +++ b/src/csharp/ext/grpc_csharp_ext.c @@ -37,7 +37,7 @@ #include <grpc/support/port_platform.h> #include <grpc/support/alloc.h> #include <grpc/support/log.h> -#include <grpc/support/slice.h> +#include <grpc/slice.h> #include <grpc/support/string_util.h> #include <grpc/support/thd.h> #include <grpc/grpc.h> @@ -59,9 +59,9 @@ #endif grpc_byte_buffer *string_to_byte_buffer(const char *buffer, size_t len) { - gpr_slice slice = gpr_slice_from_copied_buffer(buffer, len); + grpc_slice slice = grpc_slice_from_copied_buffer(buffer, len); grpc_byte_buffer *bb = grpc_raw_byte_buffer_create(&slice, 1); - gpr_slice_unref(slice); + grpc_slice_unref(slice); return bb; } @@ -282,18 +282,18 @@ GPR_EXPORT intptr_t GPR_CALLTYPE grpcsharp_batch_context_recv_message_length( GPR_EXPORT void GPR_CALLTYPE grpcsharp_batch_context_recv_message_to_buffer( const grpcsharp_batch_context *ctx, char *buffer, size_t buffer_len) { grpc_byte_buffer_reader reader; - gpr_slice slice; + grpc_slice slice; size_t offset = 0; GPR_ASSERT(grpc_byte_buffer_reader_init(&reader, ctx->recv_message)); while (grpc_byte_buffer_reader_next(&reader, &slice)) { - size_t len = GPR_SLICE_LENGTH(slice); + size_t len = GRPC_SLICE_LENGTH(slice); GPR_ASSERT(offset + len <= buffer_len); - memcpy(buffer + offset, GPR_SLICE_START_PTR(slice), - GPR_SLICE_LENGTH(slice)); + memcpy(buffer + offset, GRPC_SLICE_START_PTR(slice), + GRPC_SLICE_LENGTH(slice)); offset += len; - gpr_slice_unref(slice); + grpc_slice_unref(slice); } grpc_byte_buffer_reader_destroy(&reader); @@ -521,8 +521,8 @@ GPR_EXPORT void GPR_CALLTYPE grpcsharp_call_destroy(grpc_call *call) { GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_unary(grpc_call *call, grpcsharp_batch_context *ctx, - const char *send_buffer, size_t send_buffer_len, - grpc_metadata_array *initial_metadata, uint32_t write_flags) { + const char *send_buffer, size_t send_buffer_len, uint32_t write_flags, + grpc_metadata_array *initial_metadata, uint32_t initial_metadata_flags) { /* TODO: don't use magic number */ grpc_op ops[6]; memset(ops, 0, sizeof(ops)); @@ -532,7 +532,7 @@ grpcsharp_call_start_unary(grpc_call *call, grpcsharp_batch_context *ctx, ops[0].data.send_initial_metadata.count = ctx->send_initial_metadata.count; ops[0].data.send_initial_metadata.metadata = ctx->send_initial_metadata.metadata; - ops[0].flags = 0; + ops[0].flags = initial_metadata_flags; ops[0].reserved = NULL; ops[1].op = GRPC_OP_SEND_MESSAGE; @@ -575,7 +575,8 @@ grpcsharp_call_start_unary(grpc_call *call, grpcsharp_batch_context *ctx, GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_client_streaming(grpc_call *call, grpcsharp_batch_context *ctx, - grpc_metadata_array *initial_metadata) { + grpc_metadata_array *initial_metadata, + uint32_t initial_metadata_flags) { /* TODO: don't use magic number */ grpc_op ops[4]; memset(ops, 0, sizeof(ops)); @@ -585,7 +586,7 @@ grpcsharp_call_start_client_streaming(grpc_call *call, ops[0].data.send_initial_metadata.count = ctx->send_initial_metadata.count; ops[0].data.send_initial_metadata.metadata = ctx->send_initial_metadata.metadata; - ops[0].flags = 0; + ops[0].flags = initial_metadata_flags; ops[0].reserved = NULL; ops[1].op = GRPC_OP_RECV_INITIAL_METADATA; @@ -617,7 +618,8 @@ grpcsharp_call_start_client_streaming(grpc_call *call, GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_server_streaming( grpc_call *call, grpcsharp_batch_context *ctx, const char *send_buffer, - size_t send_buffer_len, grpc_metadata_array *initial_metadata, uint32_t write_flags) { + size_t send_buffer_len, uint32_t write_flags, + grpc_metadata_array *initial_metadata, uint32_t initial_metadata_flags) { /* TODO: don't use magic number */ grpc_op ops[4]; memset(ops, 0, sizeof(ops)); @@ -627,7 +629,7 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_server_streaming( ops[0].data.send_initial_metadata.count = ctx->send_initial_metadata.count; ops[0].data.send_initial_metadata.metadata = ctx->send_initial_metadata.metadata; - ops[0].flags = 0; + ops[0].flags = initial_metadata_flags; ops[0].reserved = NULL; ops[1].op = GRPC_OP_SEND_MESSAGE; @@ -660,7 +662,8 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_server_streaming( GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_duplex_streaming(grpc_call *call, grpcsharp_batch_context *ctx, - grpc_metadata_array *initial_metadata) { + grpc_metadata_array *initial_metadata, + uint32_t initial_metadata_flags) { /* TODO: don't use magic number */ grpc_op ops[2]; memset(ops, 0, sizeof(ops)); @@ -670,7 +673,7 @@ grpcsharp_call_start_duplex_streaming(grpc_call *call, ops[0].data.send_initial_metadata.count = ctx->send_initial_metadata.count; ops[0].data.send_initial_metadata.metadata = ctx->send_initial_metadata.metadata; - ops[0].flags = 0; + ops[0].flags = initial_metadata_flags; ops[0].reserved = NULL; ops[1].op = GRPC_OP_RECV_STATUS_ON_CLIENT; @@ -991,7 +994,11 @@ GPR_EXPORT void GPR_CALLTYPE grpcsharp_metadata_credentials_notify_from_plugin( grpc_credentials_plugin_metadata_cb cb, void *user_data, grpc_metadata_array *metadata, grpc_status_code status, const char *error_details) { - cb(user_data, metadata->metadata, metadata->count, status, error_details); + if (metadata) { + cb(user_data, metadata->metadata, metadata->count, status, error_details); + } else { + cb(user_data, NULL, 0, status, error_details); + } } typedef void(GPR_CALLTYPE *grpcsharp_metadata_interceptor_func)( diff --git a/src/csharp/generate_proto_csharp.sh b/src/csharp/generate_proto_csharp.sh index 79488e02a5..ea5d678cba 100755 --- a/src/csharp/generate_proto_csharp.sh +++ b/src/csharp/generate_proto_csharp.sh @@ -36,13 +36,20 @@ PROTOC=bins/opt/protobuf/protoc PLUGIN=protoc-gen-grpc=bins/opt/grpc_csharp_plugin EXAMPLES_DIR=src/csharp/Grpc.Examples HEALTHCHECK_DIR=src/csharp/Grpc.HealthCheck +REFLECTION_DIR=src/csharp/Grpc.Reflection TESTING_DIR=src/csharp/Grpc.IntegrationTesting $PROTOC --plugin=$PLUGIN --csharp_out=$EXAMPLES_DIR --grpc_out=$EXAMPLES_DIR \ - -I src/proto/math src/proto/math/math.proto + -I src/proto src/proto/math/math.proto $PROTOC --plugin=$PLUGIN --csharp_out=$HEALTHCHECK_DIR --grpc_out=$HEALTHCHECK_DIR \ - -I src/proto/grpc/health/v1 src/proto/grpc/health/v1/health.proto + -I src/proto src/proto/grpc/health/v1/health.proto + +$PROTOC --plugin=$PLUGIN --csharp_out=$REFLECTION_DIR --grpc_out=$REFLECTION_DIR \ + -I src/proto src/proto/grpc/reflection/v1alpha/reflection.proto +# TODO(jtattermusch): following .proto files are a bit broken and import paths +# don't match the package names. Setting -I to the correct value src/proto +# breaks the code generation. $PROTOC --plugin=$PLUGIN --csharp_out=$TESTING_DIR --grpc_out=$TESTING_DIR \ -I . src/proto/grpc/testing/{control,empty,messages,metrics,payloads,services,stats,test}.proto diff --git a/src/csharp/tests.json b/src/csharp/tests.json index 7e7aee1093..4ce6769eee 100644 --- a/src/csharp/tests.json +++ b/src/csharp/tests.json @@ -48,5 +48,9 @@ "Grpc.IntegrationTesting.MetadataCredentialsTest", "Grpc.IntegrationTesting.RunnerClientServerTest", "Grpc.IntegrationTesting.SslCredentialsTest" + ], + "Grpc.Reflection.Tests": [ + "Grpc.Reflection.Tests.ReflectionClientServerTest", + "Grpc.Reflection.Tests.SymbolRegistryTest" ] }
\ No newline at end of file |