diff --git a/src/Grpc.AspNetCore.Server.Reflection/GrpcReflectionEndpointRouteBuilderExtensions.cs b/src/Grpc.AspNetCore.Server.Reflection/GrpcReflectionEndpointRouteBuilderExtensions.cs index 490f4da9f..84fc9c008 100644 --- a/src/Grpc.AspNetCore.Server.Reflection/GrpcReflectionEndpointRouteBuilderExtensions.cs +++ b/src/Grpc.AspNetCore.Server.Reflection/GrpcReflectionEndpointRouteBuilderExtensions.cs @@ -40,7 +40,10 @@ public static IEndpointConventionBuilder MapGrpcReflectionService(this IEndpoint ValidateServicesRegistered(builder.ServiceProvider); - return builder.MapGrpcService(); + var v1AlphaConventionBuilder = builder.MapGrpcService(); + var v1ConventionBuilder = builder.MapGrpcService(); + + return new CompositeEndpointConventionBuilder(v1AlphaConventionBuilder, v1ConventionBuilder); } private static void ValidateServicesRegistered(IServiceProvider serviceProvider) @@ -52,4 +55,30 @@ private static void ValidateServicesRegistered(IServiceProvider serviceProvider) "'IServiceCollection.AddGrpcReflection()' inside the call to 'ConfigureServices(...)' in the application startup code."); } } + + private sealed class CompositeEndpointConventionBuilder : IEndpointConventionBuilder + { + private readonly IEndpointConventionBuilder[] _builders; + + public CompositeEndpointConventionBuilder(params IEndpointConventionBuilder[] builders) + { + _builders = builders; + } + + public void Add(Action convention) + { + foreach (var builder in _builders) + { + builder.Add(convention); + } + } + + public void Finally(Action finalConvention) + { + foreach (var builder in _builders) + { + builder.Finally(finalConvention); + } + } + } } diff --git a/src/Grpc.AspNetCore.Server.Reflection/GrpcReflectionServiceExtensions.cs b/src/Grpc.AspNetCore.Server.Reflection/GrpcReflectionServiceExtensions.cs index a236ab412..466588551 100644 --- a/src/Grpc.AspNetCore.Server.Reflection/GrpcReflectionServiceExtensions.cs +++ b/src/Grpc.AspNetCore.Server.Reflection/GrpcReflectionServiceExtensions.cs @@ -44,41 +44,69 @@ public static IServiceCollection AddGrpcReflection(this IServiceCollection servi services.TryAddSingleton(); - // ReflectionServiceImpl is designed to be a singleton - // Explicitly register creating it in DI using descriptors calculated from gRPC endpoints in the app - services.TryAddSingleton(serviceProvider => + // Resolve service descriptors once and share between v1alpha and v1 implementations. + services.TryAddSingleton(serviceProvider => { var logger = serviceProvider.GetRequiredService().CreateLogger(nameof(GrpcReflectionServiceExtensions)); var endpointDataSource = serviceProvider.GetRequiredService(); - var grpcEndpointMetadata = endpointDataSource.Endpoints - .Select(ep => ep.Metadata.GetMetadata()) - .OfType() - .ToList(); + return ResolveServiceDescriptors(endpointDataSource, logger); + }); + + // ReflectionServiceImpl is designed to be a singleton + // Explicitly register creating it in DI using descriptors calculated from gRPC endpoints in the app + services.TryAddSingleton(serviceProvider => + { + var descriptors = serviceProvider.GetRequiredService(); + return new ReflectionServiceImpl(descriptors.ServiceDescriptors); + }); + + services.TryAddSingleton(serviceProvider => + { + var descriptors = serviceProvider.GetRequiredService(); + return new ReflectionV1ServiceImpl(descriptors.ServiceDescriptors); + }); - var serviceTypes = grpcEndpointMetadata.Select(m => m.ServiceType).Distinct().ToList(); + return services; + } - var serviceDescriptors = new List(); + private static ResolvedServiceDescriptors ResolveServiceDescriptors(EndpointDataSource endpointDataSource, ILogger logger) + { + var grpcEndpointMetadata = endpointDataSource.Endpoints + .Select(ep => ep.Metadata.GetMetadata()) + .OfType() + .ToList(); - foreach (var serviceType in serviceTypes) + var serviceTypes = grpcEndpointMetadata.Select(m => m.ServiceType).Distinct().ToList(); + + var serviceDescriptors = new List(); + + foreach (var serviceType in serviceTypes) + { + var descriptorPropertyInfo = GetDescriptorProperty(serviceType); + if (descriptorPropertyInfo != null) { - var descriptorPropertyInfo = GetDescriptorProperty(serviceType); - if (descriptorPropertyInfo != null) + if (descriptorPropertyInfo.GetValue(null) is Google.Protobuf.Reflection.ServiceDescriptor serviceDescriptor) { - if (descriptorPropertyInfo.GetValue(null) is Google.Protobuf.Reflection.ServiceDescriptor serviceDescriptor) - { - serviceDescriptors.Add(serviceDescriptor); - continue; - } + serviceDescriptors.Add(serviceDescriptor); + continue; } - - Log.ServiceDescriptorNotResolved(logger, serviceType); } - return new ReflectionServiceImpl(serviceDescriptors); - }); + Log.ServiceDescriptorNotResolved(logger, serviceType); + } - return services; + return new ResolvedServiceDescriptors(serviceDescriptors); + } + + internal sealed class ResolvedServiceDescriptors + { + public IReadOnlyList ServiceDescriptors { get; } + + public ResolvedServiceDescriptors(IReadOnlyList serviceDescriptors) + { + ServiceDescriptors = serviceDescriptors; + } } private static PropertyInfo? GetDescriptorProperty(Type serviceType) diff --git a/src/Grpc.Reflection/Grpc.Reflection.csproj b/src/Grpc.Reflection/Grpc.Reflection.csproj index 1d33ebacb..882297fc0 100755 --- a/src/Grpc.Reflection/Grpc.Reflection.csproj +++ b/src/Grpc.Reflection/Grpc.Reflection.csproj @@ -19,8 +19,10 @@ - - + + + + diff --git a/src/Grpc.Reflection/Proto/grpc/reflection/v1/reflection.proto b/src/Grpc.Reflection/Proto/grpc/reflection/v1/reflection.proto new file mode 100644 index 000000000..1a2ceedc3 --- /dev/null +++ b/src/Grpc.Reflection/Proto/grpc/reflection/v1/reflection.proto @@ -0,0 +1,147 @@ +// Copyright 2016 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Service exported by server reflection. A more complete description of how +// server reflection works can be found at +// https://github.com/grpc/grpc/blob/master/doc/server-reflection.md +// +// The canonical version of this proto can be found at +// https://github.com/grpc/grpc-proto/blob/master/grpc/reflection/v1/reflection.proto + +syntax = "proto3"; + +package grpc.reflection.v1; + +option go_package = "google.golang.org/grpc/reflection/grpc_reflection_v1"; +option java_multiple_files = true; +option java_package = "io.grpc.reflection.v1"; +option java_outer_classname = "ServerReflectionProto"; + +service ServerReflection { + // The reflection service is structured as a bidirectional stream, ensuring + // all related requests go to a single server. + rpc ServerReflectionInfo(stream ServerReflectionRequest) + returns (stream ServerReflectionResponse); +} + +// The message sent by the client when calling ServerReflectionInfo method. +message ServerReflectionRequest { + string host = 1; + // To use reflection service, the client should set one of the following + // fields in message_request. The server distinguishes requests by their + // defined field and then handles them using corresponding methods. + oneof message_request { + // Find a proto file by the file name. + string file_by_filename = 3; + + // Find the proto file that declares the given fully-qualified symbol name. + // This field should be a fully-qualified symbol name + // (e.g. .[.] or .). + string file_containing_symbol = 4; + + // Find the proto file which defines an extension extending the given + // message type with the given field number. + ExtensionRequest file_containing_extension = 5; + + // 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 + // . + string all_extension_numbers_of_type = 6; + + // List the full names of registered services. The content will not be + // checked. + string list_services = 7; + } +} + +// The type name and extension number sent by the client when requesting +// file_containing_extension. +message ExtensionRequest { + // Fully-qualified type name. The format should be . + string containing_type = 1; + int32 extension_number = 2; +} + +// The message sent by the server to answer ServerReflectionInfo method. +message ServerReflectionResponse { + string valid_host = 1; + ServerReflectionRequest original_request = 2; + // The server sets one of the following fields according to the message_request + // in the request. + oneof message_response { + // 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. + FileDescriptorResponse file_descriptor_response = 4; + + // This message is used to answer all_extension_numbers_of_type requests. + ExtensionNumberResponse all_extension_numbers_response = 5; + + // This message is used to answer list_services requests. + ListServiceResponse list_services_response = 6; + + // This message is used when an error occurs. + ErrorResponse error_response = 7; + } +} + +// Serialized FileDescriptorProto messages sent by the server answering +// a file_by_filename, file_containing_symbol, or file_containing_extension +// request. +message FileDescriptorResponse { + // Serialized FileDescriptorProto messages. We avoid taking a dependency on + // descriptor.proto, which uses proto2 only features, by making them opaque + // bytes instead. + repeated bytes file_descriptor_proto = 1; +} + +// A list of extension numbers sent by the server answering +// all_extension_numbers_of_type request. +message ExtensionNumberResponse { + // Full name of the base type, including the package name. The format + // is . + string base_type_name = 1; + repeated int32 extension_number = 2; +} + +// A list of ServiceResponse sent by the server answering list_services request. +message ListServiceResponse { + // The information of each service may be expanded in the future, so we use + // ServiceResponse message to encapsulate it. + repeated ServiceResponse service = 1; +} + +// The information of a single service used by ListServiceResponse to answer +// list_services request. +message ServiceResponse { + // Full name of a registered service, including its package name. The format + // is . + string name = 1; +} + +// The error code and error message sent by the server when an error occurs. +message ErrorResponse { + // This field uses the error codes defined in grpc::StatusCode. + int32 error_code = 1; + string error_message = 2; +} + diff --git a/src/Grpc.Reflection/Proto/grpc/reflection/v1alpha/reflection.proto b/src/Grpc.Reflection/Proto/grpc/reflection/v1alpha/reflection.proto new file mode 100644 index 000000000..e8384db37 --- /dev/null +++ b/src/Grpc.Reflection/Proto/grpc/reflection/v1alpha/reflection.proto @@ -0,0 +1,145 @@ +// Copyright 2016 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// Service exported by server reflection + + +// Warning: this entire file is deprecated. Use this instead: +// https://github.com/grpc/grpc-proto/blob/master/grpc/reflection/v1/reflection.proto + +syntax = "proto3"; + +package grpc.reflection.v1alpha; + +option deprecated = true; +option go_package = "google.golang.org/grpc/reflection/grpc_reflection_v1alpha"; +option java_multiple_files = true; +option java_package = "io.grpc.reflection.v1alpha"; +option java_outer_classname = "ServerReflectionProto"; + +service ServerReflection { + // The reflection service is structured as a bidirectional stream, ensuring + // all related requests go to a single server. + rpc ServerReflectionInfo(stream ServerReflectionRequest) + returns (stream ServerReflectionResponse); +} + +// The message sent by the client when calling ServerReflectionInfo method. +message ServerReflectionRequest { + string host = 1; + // To use reflection service, the client should set one of the following + // fields in message_request. The server distinguishes requests by their + // defined field and then handles them using corresponding methods. + oneof message_request { + // Find a proto file by the file name. + string file_by_filename = 3; + + // Find the proto file that declares the given fully-qualified symbol name. + // This field should be a fully-qualified symbol name + // (e.g. .[.] or .). + string file_containing_symbol = 4; + + // Find the proto file which defines an extension extending the given + // message type with the given field number. + ExtensionRequest file_containing_extension = 5; + + // Finds the tag numbers used by all known extensions of extendee_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 + // . + string all_extension_numbers_of_type = 6; + + // List the full names of registered services. The content will not be + // checked. + string list_services = 7; + } +} + +// The type name and extension number sent by the client when requesting +// file_containing_extension. +message ExtensionRequest { + // Fully-qualified type name. The format should be . + string containing_type = 1; + int32 extension_number = 2; +} + +// The message sent by the server to answer ServerReflectionInfo method. +message ServerReflectionResponse { + string valid_host = 1; + ServerReflectionRequest original_request = 2; + // The server set one of the following fields according to the message_request + // in the request. + oneof message_response { + // 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. + FileDescriptorResponse file_descriptor_response = 4; + + // This message is used to answer all_extension_numbers_of_type request. + ExtensionNumberResponse all_extension_numbers_response = 5; + + // This message is used to answer list_services request. + ListServiceResponse list_services_response = 6; + + // This message is used when an error occurs. + ErrorResponse error_response = 7; + } +} + +// Serialized FileDescriptorProto messages sent by the server answering +// a file_by_filename, file_containing_symbol, or file_containing_extension +// request. +message FileDescriptorResponse { + // Serialized FileDescriptorProto messages. We avoid taking a dependency on + // descriptor.proto, which uses proto2 only features, by making them opaque + // bytes instead. + repeated bytes file_descriptor_proto = 1; +} + +// A list of extension numbers sent by the server answering +// all_extension_numbers_of_type request. +message ExtensionNumberResponse { + // Full name of the base type, including the package name. The format + // is . + string base_type_name = 1; + repeated int32 extension_number = 2; +} + +// A list of ServiceResponse sent by the server answering list_services request. +message ListServiceResponse { + // The information of each service may be expanded in the future, so we use + // ServiceResponse message to encapsulate it. + repeated ServiceResponse service = 1; +} + +// The information of a single service used by ListServiceResponse to answer +// list_services request. +message ServiceResponse { + // Full name of a registered service, including its package name. The format + // is . + string name = 1; +} + +// The error code and error message sent by the server when an error occurs. +message ErrorResponse { + // This field uses the error codes defined in grpc::StatusCode. + int32 error_code = 1; + string error_message = 2; +} diff --git a/src/Grpc.Reflection/Reflection.cs b/src/Grpc.Reflection/Reflection.cs deleted file mode 100644 index ce4b28ba1..000000000 --- a/src/Grpc.Reflection/Reflection.cs +++ /dev/null @@ -1,2290 +0,0 @@ -// -// 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 { - - /// Holder for reflection information generated from grpc/reflection/v1alpha/reflection.proto - public static partial class ReflectionReflection { - - #region Descriptor - /// File descriptor for grpc/reflection/v1alpha/reflection.proto - 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, 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, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Reflection.V1Alpha.ExtensionRequest), global::Grpc.Reflection.V1Alpha.ExtensionRequest.Parser, new[]{ "ContainingType", "ExtensionNumber" }, null, 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, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Reflection.V1Alpha.FileDescriptorResponse), global::Grpc.Reflection.V1Alpha.FileDescriptorResponse.Parser, new[]{ "FileDescriptorProto" }, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Reflection.V1Alpha.ExtensionNumberResponse), global::Grpc.Reflection.V1Alpha.ExtensionNumberResponse.Parser, new[]{ "BaseTypeName", "ExtensionNumber" }, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Reflection.V1Alpha.ListServiceResponse), global::Grpc.Reflection.V1Alpha.ListServiceResponse.Parser, new[]{ "Service" }, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Reflection.V1Alpha.ServiceResponse), global::Grpc.Reflection.V1Alpha.ServiceResponse.Parser, new[]{ "Name" }, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Reflection.V1Alpha.ErrorResponse), global::Grpc.Reflection.V1Alpha.ErrorResponse.Parser, new[]{ "ErrorCode", "ErrorMessage" }, null, null, null, null) - })); - } - #endregion - - } - #region Messages - /// - /// The message sent by the client when calling ServerReflectionInfo method. - /// - public sealed partial class ServerReflectionRequest : pb::IMessage - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage - #endif - { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ServerReflectionRequest()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::Grpc.Reflection.V1Alpha.ReflectionReflection.Descriptor.MessageTypes[0]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ServerReflectionRequest() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - 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; - } - - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ServerReflectionRequest Clone() { - return new ServerReflectionRequest(this); - } - - /// Field number for the "host" field. - public const int HostFieldNumber = 1; - private string host_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string Host { - get { return host_; } - set { - host_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "file_by_filename" field. - public const int FileByFilenameFieldNumber = 3; - /// - /// Find a proto file by the file name. - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string FileByFilename { - get { return messageRequestCase_ == MessageRequestOneofCase.FileByFilename ? (string) messageRequest_ : ""; } - set { - messageRequest_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - messageRequestCase_ = MessageRequestOneofCase.FileByFilename; - } - } - - /// Field number for the "file_containing_symbol" field. - public const int FileContainingSymbolFieldNumber = 4; - /// - /// 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>). - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string FileContainingSymbol { - get { return messageRequestCase_ == MessageRequestOneofCase.FileContainingSymbol ? (string) messageRequest_ : ""; } - set { - messageRequest_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - messageRequestCase_ = MessageRequestOneofCase.FileContainingSymbol; - } - } - - /// Field number for the "file_containing_extension" field. - public const int FileContainingExtensionFieldNumber = 5; - /// - /// Find the proto file which defines an extension extending the given - /// message type with the given field number. - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - 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; - } - } - - /// Field number for the "all_extension_numbers_of_type" field. - public const int AllExtensionNumbersOfTypeFieldNumber = 6; - /// - /// 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> - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string AllExtensionNumbersOfType { - get { return messageRequestCase_ == MessageRequestOneofCase.AllExtensionNumbersOfType ? (string) messageRequest_ : ""; } - set { - messageRequest_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - messageRequestCase_ = MessageRequestOneofCase.AllExtensionNumbersOfType; - } - } - - /// Field number for the "list_services" field. - public const int ListServicesFieldNumber = 7; - /// - /// List the full names of registered services. The content will not be - /// checked. - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string ListServices { - get { return messageRequestCase_ == MessageRequestOneofCase.ListServices ? (string) messageRequest_ : ""; } - set { - messageRequest_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - messageRequestCase_ = MessageRequestOneofCase.ListServices; - } - } - - private object messageRequest_; - /// Enum of possible cases for the "message_request" oneof. - public enum MessageRequestOneofCase { - None = 0, - FileByFilename = 3, - FileContainingSymbol = 4, - FileContainingExtension = 5, - AllExtensionNumbersOfType = 6, - ListServices = 7, - } - private MessageRequestOneofCase messageRequestCase_ = MessageRequestOneofCase.None; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public MessageRequestOneofCase MessageRequestCase { - get { return messageRequestCase_; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void ClearMessageRequest() { - messageRequestCase_ = MessageRequestOneofCase.None; - messageRequest_ = null; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as ServerReflectionRequest); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - 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 Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - 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_; - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - 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); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext 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); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - 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); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - 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: - if (FileContainingExtension == null) { - FileContainingExtension = new global::Grpc.Reflection.V1Alpha.ExtensionRequest(); - } - FileContainingExtension.MergeFrom(other.FileContainingExtension); - break; - case MessageRequestOneofCase.AllExtensionNumbersOfType: - AllExtensionNumbersOfType = other.AllExtensionNumbersOfType; - break; - case MessageRequestOneofCase.ListServices: - ListServices = other.ListServices; - break; - } - - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - 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; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - 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; - } - } - } - } - #endif - - } - - /// - /// The type name and extension number sent by the client when requesting - /// file_containing_extension. - /// - public sealed partial class ExtensionRequest : pb::IMessage - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage - #endif - { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ExtensionRequest()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::Grpc.Reflection.V1Alpha.ReflectionReflection.Descriptor.MessageTypes[1]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ExtensionRequest() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ExtensionRequest(ExtensionRequest other) : this() { - containingType_ = other.containingType_; - extensionNumber_ = other.extensionNumber_; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ExtensionRequest Clone() { - return new ExtensionRequest(this); - } - - /// Field number for the "containing_type" field. - public const int ContainingTypeFieldNumber = 1; - private string containingType_ = ""; - /// - /// Fully-qualified type name. The format should be <package>.<type> - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string ContainingType { - get { return containingType_; } - set { - containingType_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "extension_number" field. - public const int ExtensionNumberFieldNumber = 2; - private int extensionNumber_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int ExtensionNumber { - get { return extensionNumber_; } - set { - extensionNumber_ = value; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as ExtensionRequest); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - 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 Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - if (ContainingType.Length != 0) hash ^= ContainingType.GetHashCode(); - if (ExtensionNumber != 0) hash ^= ExtensionNumber.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - if (ContainingType.Length != 0) { - output.WriteRawTag(10); - output.WriteString(ContainingType); - } - if (ExtensionNumber != 0) { - output.WriteRawTag(16); - output.WriteInt32(ExtensionNumber); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - if (ContainingType.Length != 0) { - output.WriteRawTag(10); - output.WriteString(ContainingType); - } - if (ExtensionNumber != 0) { - output.WriteRawTag(16); - output.WriteInt32(ExtensionNumber); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - 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); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(ExtensionRequest other) { - if (other == null) { - return; - } - if (other.ContainingType.Length != 0) { - ContainingType = other.ContainingType; - } - if (other.ExtensionNumber != 0) { - ExtensionNumber = other.ExtensionNumber; - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 10: { - ContainingType = input.ReadString(); - break; - } - case 16: { - ExtensionNumber = input.ReadInt32(); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 10: { - ContainingType = input.ReadString(); - break; - } - case 16: { - ExtensionNumber = input.ReadInt32(); - break; - } - } - } - } - #endif - - } - - /// - /// The message sent by the server to answer ServerReflectionInfo method. - /// - public sealed partial class ServerReflectionResponse : pb::IMessage - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage - #endif - { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ServerReflectionResponse()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::Grpc.Reflection.V1Alpha.ReflectionReflection.Descriptor.MessageTypes[2]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ServerReflectionResponse() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - 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; - } - - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ServerReflectionResponse Clone() { - return new ServerReflectionResponse(this); - } - - /// Field number for the "valid_host" field. - public const int ValidHostFieldNumber = 1; - private string validHost_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string ValidHost { - get { return validHost_; } - set { - validHost_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "original_request" field. - public const int OriginalRequestFieldNumber = 2; - private global::Grpc.Reflection.V1Alpha.ServerReflectionRequest originalRequest_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public global::Grpc.Reflection.V1Alpha.ServerReflectionRequest OriginalRequest { - get { return originalRequest_; } - set { - originalRequest_ = value; - } - } - - /// Field number for the "file_descriptor_response" field. - public const int FileDescriptorResponseFieldNumber = 4; - /// - /// 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. - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - 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; - } - } - - /// Field number for the "all_extension_numbers_response" field. - public const int AllExtensionNumbersResponseFieldNumber = 5; - /// - /// This message is used to answer all_extension_numbers_of_type requst. - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - 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; - } - } - - /// Field number for the "list_services_response" field. - public const int ListServicesResponseFieldNumber = 6; - /// - /// This message is used to answer list_services request. - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - 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; - } - } - - /// Field number for the "error_response" field. - public const int ErrorResponseFieldNumber = 7; - /// - /// This message is used when an error occurs. - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - 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_; - /// Enum of possible cases for the "message_response" oneof. - public enum MessageResponseOneofCase { - None = 0, - FileDescriptorResponse = 4, - AllExtensionNumbersResponse = 5, - ListServicesResponse = 6, - ErrorResponse = 7, - } - private MessageResponseOneofCase messageResponseCase_ = MessageResponseOneofCase.None; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public MessageResponseOneofCase MessageResponseCase { - get { return messageResponseCase_; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void ClearMessageResponse() { - messageResponseCase_ = MessageResponseOneofCase.None; - messageResponse_ = null; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as ServerReflectionResponse); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - 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 Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - 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_; - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - 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); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext 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); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - 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); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - 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: - if (FileDescriptorResponse == null) { - FileDescriptorResponse = new global::Grpc.Reflection.V1Alpha.FileDescriptorResponse(); - } - FileDescriptorResponse.MergeFrom(other.FileDescriptorResponse); - break; - case MessageResponseOneofCase.AllExtensionNumbersResponse: - if (AllExtensionNumbersResponse == null) { - AllExtensionNumbersResponse = new global::Grpc.Reflection.V1Alpha.ExtensionNumberResponse(); - } - AllExtensionNumbersResponse.MergeFrom(other.AllExtensionNumbersResponse); - break; - case MessageResponseOneofCase.ListServicesResponse: - if (ListServicesResponse == null) { - ListServicesResponse = new global::Grpc.Reflection.V1Alpha.ListServiceResponse(); - } - ListServicesResponse.MergeFrom(other.ListServicesResponse); - break; - case MessageResponseOneofCase.ErrorResponse: - if (ErrorResponse == null) { - ErrorResponse = new global::Grpc.Reflection.V1Alpha.ErrorResponse(); - } - ErrorResponse.MergeFrom(other.ErrorResponse); - break; - } - - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - 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; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - 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; - } - } - } - } - #endif - - } - - /// - /// Serialized FileDescriptorProto messages sent by the server answering - /// a file_by_filename, file_containing_symbol, or file_containing_extension - /// request. - /// - public sealed partial class FileDescriptorResponse : pb::IMessage - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage - #endif - { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new FileDescriptorResponse()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::Grpc.Reflection.V1Alpha.ReflectionReflection.Descriptor.MessageTypes[3]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public FileDescriptorResponse() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public FileDescriptorResponse(FileDescriptorResponse other) : this() { - fileDescriptorProto_ = other.fileDescriptorProto_.Clone(); - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public FileDescriptorResponse Clone() { - return new FileDescriptorResponse(this); - } - - /// Field number for the "file_descriptor_proto" field. - public const int FileDescriptorProtoFieldNumber = 1; - private static readonly pb::FieldCodec _repeated_fileDescriptorProto_codec - = pb::FieldCodec.ForBytes(10); - private readonly pbc::RepeatedField fileDescriptorProto_ = new pbc::RepeatedField(); - /// - /// Serialized FileDescriptorProto messages. We avoid taking a dependency on - /// descriptor.proto, which uses proto2 only features, by making them opaque - /// bytes instead. - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public pbc::RepeatedField FileDescriptorProto { - get { return fileDescriptorProto_; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as FileDescriptorResponse); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - 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 Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - hash ^= fileDescriptorProto_.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - fileDescriptorProto_.WriteTo(output, _repeated_fileDescriptorProto_codec); - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - fileDescriptorProto_.WriteTo(ref output, _repeated_fileDescriptorProto_codec); - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - size += fileDescriptorProto_.CalculateSize(_repeated_fileDescriptorProto_codec); - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(FileDescriptorResponse other) { - if (other == null) { - return; - } - fileDescriptorProto_.Add(other.fileDescriptorProto_); - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 10: { - fileDescriptorProto_.AddEntriesFrom(input, _repeated_fileDescriptorProto_codec); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 10: { - fileDescriptorProto_.AddEntriesFrom(ref input, _repeated_fileDescriptorProto_codec); - break; - } - } - } - } - #endif - - } - - /// - /// A list of extension numbers sent by the server answering - /// all_extension_numbers_of_type request. - /// - public sealed partial class ExtensionNumberResponse : pb::IMessage - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage - #endif - { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ExtensionNumberResponse()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::Grpc.Reflection.V1Alpha.ReflectionReflection.Descriptor.MessageTypes[4]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ExtensionNumberResponse() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ExtensionNumberResponse(ExtensionNumberResponse other) : this() { - baseTypeName_ = other.baseTypeName_; - extensionNumber_ = other.extensionNumber_.Clone(); - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ExtensionNumberResponse Clone() { - return new ExtensionNumberResponse(this); - } - - /// Field number for the "base_type_name" field. - public const int BaseTypeNameFieldNumber = 1; - private string baseTypeName_ = ""; - /// - /// Full name of the base type, including the package name. The format - /// is <package>.<type> - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string BaseTypeName { - get { return baseTypeName_; } - set { - baseTypeName_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "extension_number" field. - public const int ExtensionNumberFieldNumber = 2; - private static readonly pb::FieldCodec _repeated_extensionNumber_codec - = pb::FieldCodec.ForInt32(18); - private readonly pbc::RepeatedField extensionNumber_ = new pbc::RepeatedField(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public pbc::RepeatedField ExtensionNumber { - get { return extensionNumber_; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as ExtensionNumberResponse); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - 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 Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - if (BaseTypeName.Length != 0) hash ^= BaseTypeName.GetHashCode(); - hash ^= extensionNumber_.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - if (BaseTypeName.Length != 0) { - output.WriteRawTag(10); - output.WriteString(BaseTypeName); - } - extensionNumber_.WriteTo(output, _repeated_extensionNumber_codec); - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - if (BaseTypeName.Length != 0) { - output.WriteRawTag(10); - output.WriteString(BaseTypeName); - } - extensionNumber_.WriteTo(ref output, _repeated_extensionNumber_codec); - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - if (BaseTypeName.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(BaseTypeName); - } - size += extensionNumber_.CalculateSize(_repeated_extensionNumber_codec); - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(ExtensionNumberResponse other) { - if (other == null) { - return; - } - if (other.BaseTypeName.Length != 0) { - BaseTypeName = other.BaseTypeName; - } - extensionNumber_.Add(other.extensionNumber_); - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 10: { - BaseTypeName = input.ReadString(); - break; - } - case 18: - case 16: { - extensionNumber_.AddEntriesFrom(input, _repeated_extensionNumber_codec); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 10: { - BaseTypeName = input.ReadString(); - break; - } - case 18: - case 16: { - extensionNumber_.AddEntriesFrom(ref input, _repeated_extensionNumber_codec); - break; - } - } - } - } - #endif - - } - - /// - /// A list of ServiceResponse sent by the server answering list_services request. - /// - public sealed partial class ListServiceResponse : pb::IMessage - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage - #endif - { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ListServiceResponse()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::Grpc.Reflection.V1Alpha.ReflectionReflection.Descriptor.MessageTypes[5]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ListServiceResponse() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ListServiceResponse(ListServiceResponse other) : this() { - service_ = other.service_.Clone(); - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ListServiceResponse Clone() { - return new ListServiceResponse(this); - } - - /// Field number for the "service" field. - public const int ServiceFieldNumber = 1; - private static readonly pb::FieldCodec _repeated_service_codec - = pb::FieldCodec.ForMessage(10, global::Grpc.Reflection.V1Alpha.ServiceResponse.Parser); - private readonly pbc::RepeatedField service_ = new pbc::RepeatedField(); - /// - /// The information of each service may be expanded in the future, so we use - /// ServiceResponse message to encapsulate it. - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public pbc::RepeatedField Service { - get { return service_; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as ListServiceResponse); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - 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 Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - hash ^= service_.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - service_.WriteTo(output, _repeated_service_codec); - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - service_.WriteTo(ref output, _repeated_service_codec); - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - size += service_.CalculateSize(_repeated_service_codec); - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(ListServiceResponse other) { - if (other == null) { - return; - } - service_.Add(other.service_); - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 10: { - service_.AddEntriesFrom(input, _repeated_service_codec); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 10: { - service_.AddEntriesFrom(ref input, _repeated_service_codec); - break; - } - } - } - } - #endif - - } - - /// - /// The information of a single service used by ListServiceResponse to answer - /// list_services request. - /// - public sealed partial class ServiceResponse : pb::IMessage - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage - #endif - { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ServiceResponse()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::Grpc.Reflection.V1Alpha.ReflectionReflection.Descriptor.MessageTypes[6]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ServiceResponse() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ServiceResponse(ServiceResponse other) : this() { - name_ = other.name_; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ServiceResponse Clone() { - return new ServiceResponse(this); - } - - /// Field number for the "name" field. - public const int NameFieldNumber = 1; - private string name_ = ""; - /// - /// Full name of a registered service, including its package name. The format - /// is <package>.<service> - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string Name { - get { return name_; } - set { - name_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as ServiceResponse); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public bool Equals(ServiceResponse other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Name != other.Name) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - if (Name.Length != 0) hash ^= Name.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - if (Name.Length != 0) { - output.WriteRawTag(10); - output.WriteString(Name); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - if (Name.Length != 0) { - output.WriteRawTag(10); - output.WriteString(Name); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - if (Name.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(ServiceResponse other) { - if (other == null) { - return; - } - if (other.Name.Length != 0) { - Name = other.Name; - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 10: { - Name = input.ReadString(); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 10: { - Name = input.ReadString(); - break; - } - } - } - } - #endif - - } - - /// - /// The error code and error message sent by the server when an error occurs. - /// - public sealed partial class ErrorResponse : pb::IMessage - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage - #endif - { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ErrorResponse()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::Grpc.Reflection.V1Alpha.ReflectionReflection.Descriptor.MessageTypes[7]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ErrorResponse() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ErrorResponse(ErrorResponse other) : this() { - errorCode_ = other.errorCode_; - errorMessage_ = other.errorMessage_; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ErrorResponse Clone() { - return new ErrorResponse(this); - } - - /// Field number for the "error_code" field. - public const int ErrorCodeFieldNumber = 1; - private int errorCode_; - /// - /// This field uses the error codes defined in grpc::StatusCode. - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int ErrorCode { - get { return errorCode_; } - set { - errorCode_ = value; - } - } - - /// Field number for the "error_message" field. - public const int ErrorMessageFieldNumber = 2; - private string errorMessage_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string ErrorMessage { - get { return errorMessage_; } - set { - errorMessage_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as ErrorResponse); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - 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 Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - if (ErrorCode != 0) hash ^= ErrorCode.GetHashCode(); - if (ErrorMessage.Length != 0) hash ^= ErrorMessage.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - if (ErrorCode != 0) { - output.WriteRawTag(8); - output.WriteInt32(ErrorCode); - } - if (ErrorMessage.Length != 0) { - output.WriteRawTag(18); - output.WriteString(ErrorMessage); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - if (ErrorCode != 0) { - output.WriteRawTag(8); - output.WriteInt32(ErrorCode); - } - if (ErrorMessage.Length != 0) { - output.WriteRawTag(18); - output.WriteString(ErrorMessage); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - 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); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(ErrorResponse other) { - if (other == null) { - return; - } - if (other.ErrorCode != 0) { - ErrorCode = other.ErrorCode; - } - if (other.ErrorMessage.Length != 0) { - ErrorMessage = other.ErrorMessage; - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 8: { - ErrorCode = input.ReadInt32(); - break; - } - case 18: { - ErrorMessage = input.ReadString(); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 8: { - ErrorCode = input.ReadInt32(); - break; - } - case 18: { - ErrorMessage = input.ReadString(); - break; - } - } - } - } - #endif - - } - - #endregion - -} - -#endregion Designer generated code diff --git a/src/Grpc.Reflection/ReflectionGrpc.cs b/src/Grpc.Reflection/ReflectionGrpc.cs deleted file mode 100644 index 6fd57e42c..000000000 --- a/src/Grpc.Reflection/ReflectionGrpc.cs +++ /dev/null @@ -1,184 +0,0 @@ -// -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: grpc/reflection/v1alpha/reflection.proto -// -// Original file comments: -// Copyright 2016 gRPC authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Service exported by server reflection -// -#pragma warning disable 0414, 1591 -#region Designer generated code - -using grpc = global::Grpc.Core; - -namespace Grpc.Reflection.V1Alpha { - public static partial class ServerReflection - { - static readonly string __ServiceName = "grpc.reflection.v1alpha.ServerReflection"; - - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - static void __Helper_SerializeMessage(global::Google.Protobuf.IMessage message, grpc::SerializationContext context) - { - #if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION - if (message is global::Google.Protobuf.IBufferMessage) - { - context.SetPayloadLength(message.CalculateSize()); - global::Google.Protobuf.MessageExtensions.WriteTo(message, context.GetBufferWriter()); - context.Complete(); - return; - } - #endif - context.Complete(global::Google.Protobuf.MessageExtensions.ToByteArray(message)); - } - - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - static class __Helper_MessageCache - { - public static readonly bool IsBufferMessage = global::System.Reflection.IntrospectionExtensions.GetTypeInfo(typeof(global::Google.Protobuf.IBufferMessage)).IsAssignableFrom(typeof(T)); - } - - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - static T __Helper_DeserializeMessage(grpc::DeserializationContext context, global::Google.Protobuf.MessageParser parser) where T : global::Google.Protobuf.IMessage - { - #if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION - if (__Helper_MessageCache.IsBufferMessage) - { - return parser.ParseFrom(context.PayloadAsReadOnlySequence()); - } - #endif - return parser.ParseFrom(context.PayloadAsNewBuffer()); - } - - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - static readonly grpc::Marshaller __Marshaller_grpc_reflection_v1alpha_ServerReflectionRequest = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Grpc.Reflection.V1Alpha.ServerReflectionRequest.Parser)); - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - static readonly grpc::Marshaller __Marshaller_grpc_reflection_v1alpha_ServerReflectionResponse = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Grpc.Reflection.V1Alpha.ServerReflectionResponse.Parser)); - - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - static readonly grpc::Method __Method_ServerReflectionInfo = new grpc::Method( - grpc::MethodType.DuplexStreaming, - __ServiceName, - "ServerReflectionInfo", - __Marshaller_grpc_reflection_v1alpha_ServerReflectionRequest, - __Marshaller_grpc_reflection_v1alpha_ServerReflectionResponse); - - /// Service descriptor - public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor - { - get { return global::Grpc.Reflection.V1Alpha.ReflectionReflection.Descriptor.Services[0]; } - } - - /// Base class for server-side implementations of ServerReflection - [grpc::BindServiceMethod(typeof(ServerReflection), "BindService")] - public abstract partial class ServerReflectionBase - { - /// - /// The reflection service is structured as a bidirectional stream, ensuring - /// all related requests go to a single server. - /// - /// Used for reading requests from the client. - /// Used for sending responses back to the client. - /// The context of the server-side call handler being invoked. - /// A task indicating completion of the handler. - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public virtual global::System.Threading.Tasks.Task ServerReflectionInfo(grpc::IAsyncStreamReader requestStream, grpc::IServerStreamWriter responseStream, grpc::ServerCallContext context) - { - throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); - } - - } - - /// Client for ServerReflection - public partial class ServerReflectionClient : grpc::ClientBase - { - /// Creates a new client for ServerReflection - /// The channel to use to make remote calls. - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public ServerReflectionClient(grpc::ChannelBase channel) : base(channel) - { - } - /// Creates a new client for ServerReflection that uses a custom CallInvoker. - /// The callInvoker to use to make remote calls. - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public ServerReflectionClient(grpc::CallInvoker callInvoker) : base(callInvoker) - { - } - /// Protected parameterless constructor to allow creation of test doubles. - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - protected ServerReflectionClient() : base() - { - } - /// Protected constructor to allow creation of configured clients. - /// The client configuration. - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - protected ServerReflectionClient(ClientBaseConfiguration configuration) : base(configuration) - { - } - - /// - /// The reflection service is structured as a bidirectional stream, ensuring - /// all related requests go to a single server. - /// - /// The initial metadata to send with the call. This parameter is optional. - /// An optional deadline for the call. The call will be cancelled if deadline is hit. - /// An optional token for canceling the call. - /// The call object. - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public virtual grpc::AsyncDuplexStreamingCall ServerReflectionInfo(grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) - { - return ServerReflectionInfo(new grpc::CallOptions(headers, deadline, cancellationToken)); - } - /// - /// The reflection service is structured as a bidirectional stream, ensuring - /// all related requests go to a single server. - /// - /// The options for the call. - /// The call object. - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public virtual grpc::AsyncDuplexStreamingCall ServerReflectionInfo(grpc::CallOptions options) - { - return CallInvoker.AsyncDuplexStreamingCall(__Method_ServerReflectionInfo, null, options); - } - /// Creates a new instance of client from given ClientBaseConfiguration. - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - protected override ServerReflectionClient NewInstance(ClientBaseConfiguration configuration) - { - return new ServerReflectionClient(configuration); - } - } - - /// Creates service definition that can be registered with a server - /// An object implementing the server-side handling logic. - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public static grpc::ServerServiceDefinition BindService(ServerReflectionBase serviceImpl) - { - return grpc::ServerServiceDefinition.CreateBuilder() - .AddMethod(__Method_ServerReflectionInfo, serviceImpl.ServerReflectionInfo).Build(); - } - - /// Register service method with a service binder with or without implementation. Useful when customizing the service binding logic. - /// Note: this method is part of an experimental API that can change or be removed without any prior notice. - /// Service methods will be bound by calling AddMethod on this object. - /// An object implementing the server-side handling logic. - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public static void BindService(grpc::ServiceBinderBase serviceBinder, ServerReflectionBase serviceImpl) - { - serviceBinder.AddMethod(__Method_ServerReflectionInfo, serviceImpl == null ? null : new grpc::DuplexStreamingServerMethod(serviceImpl.ServerReflectionInfo)); - } - - } -} -#endregion diff --git a/src/Grpc.Reflection/ReflectionServiceCore.cs b/src/Grpc.Reflection/ReflectionServiceCore.cs new file mode 100644 index 000000000..0eeb7414f --- /dev/null +++ b/src/Grpc.Reflection/ReflectionServiceCore.cs @@ -0,0 +1,149 @@ +#region Copyright notice and license +// Copyright 2015 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#endregion + +using Google.Protobuf; +using Google.Protobuf.Reflection; +using Grpc.Core; + +namespace Grpc.Reflection; + +internal sealed class ReflectionServiceCore +{ + readonly List services; + readonly SymbolRegistry symbolRegistry; + + public ReflectionServiceCore(IEnumerable services, SymbolRegistry symbolRegistry) + { + this.services = new List(services); + this.symbolRegistry = symbolRegistry; + } + + public ReflectionServiceCore(IEnumerable serviceDescriptors) + { + this.services = new List(serviceDescriptors.Select((serviceDescriptor) => serviceDescriptor.FullName)); + this.symbolRegistry = SymbolRegistry.FromFiles(serviceDescriptors.Select((serviceDescriptor) => serviceDescriptor.File)); + } + + public enum RequestCase + { + FileByFilename, + FileContainingSymbol, + ListServices, + Unsupported + } + + public enum ResponseCase + { + FileDescriptorResponse, + ListServicesResponse, + ErrorResponse + } + + public readonly struct Response + { + public ResponseCase Case { get; } + public IEnumerable? FileDescriptorProtos { get; } + public IEnumerable? ServiceNames { get; } + public int ErrorCode { get; } + public string? ErrorMessage { get; } + + private Response(ResponseCase responseCase, IEnumerable? fileDescriptorProtos = null, IEnumerable? serviceNames = null, int errorCode = 0, string? errorMessage = null) + { + Case = responseCase; + FileDescriptorProtos = fileDescriptorProtos; + ServiceNames = serviceNames; + ErrorCode = errorCode; + ErrorMessage = errorMessage; + } + + public static Response FileDescriptor(IEnumerable fileDescriptorProtos) + => new Response(ResponseCase.FileDescriptorResponse, fileDescriptorProtos: fileDescriptorProtos); + + public static Response Services(IEnumerable serviceNames) + => new Response(ResponseCase.ListServicesResponse, serviceNames: serviceNames); + + public static Response Error(int errorCode, string errorMessage) + => new Response(ResponseCase.ErrorResponse, errorCode: errorCode, errorMessage: errorMessage); + } + + public Response ProcessRequest(RequestCase requestCase, string? stringValue) + { + switch (requestCase) + { + case RequestCase.FileByFilename: + return FileByFilename(stringValue!); + case RequestCase.FileContainingSymbol: + return FileContainingSymbol(stringValue!); + case RequestCase.ListServices: + return ListServices(); + default: + return CreateErrorResponse(StatusCode.Unimplemented, "Request type not supported by C# reflection service."); + } + } + + Response FileByFilename(string filename) + { + FileDescriptor? file = symbolRegistry.FileByName(filename); + if (file is null) + { + return CreateErrorResponse(StatusCode.NotFound, "File not found."); + } + + return CreateFileDescriptorResponse(file); + } + + Response FileContainingSymbol(string symbol) + { + FileDescriptor? file = symbolRegistry.FileContainingSymbol(symbol); + if (file is null) + { + return CreateErrorResponse(StatusCode.NotFound, "Symbol not found."); + } + + return CreateFileDescriptorResponse(file); + } + + Response CreateFileDescriptorResponse(FileDescriptor file) + { + var transitiveDependencies = new HashSet(); + CollectTransitiveDependencies(file, transitiveDependencies); + + return Response.FileDescriptor(transitiveDependencies.Select((d) => d.SerializedData)); + } + + Response ListServices() + { + return Response.Services(services); + } + + static Response CreateErrorResponse(StatusCode status, string message) + { + return Response.Error((int)status, message); + } + + static void CollectTransitiveDependencies(FileDescriptor descriptor, HashSet 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/Grpc.Reflection/ReflectionServiceImpl.cs b/src/Grpc.Reflection/ReflectionServiceImpl.cs index a51dd73de..48e248447 100644 --- a/src/Grpc.Reflection/ReflectionServiceImpl.cs +++ b/src/Grpc.Reflection/ReflectionServiceImpl.cs @@ -21,33 +21,30 @@ namespace Grpc.Reflection; /// -/// Implementation of server reflection service. +/// Implementation of server reflection service (v1alpha). /// public class ReflectionServiceImpl : Grpc.Reflection.V1Alpha.ServerReflection.ServerReflectionBase { - readonly List services; - readonly SymbolRegistry symbolRegistry; + readonly ReflectionServiceCore core; /// - /// Creates a new instance of ReflectionServiceIml. + /// Creates a new instance of ReflectionServiceImpl. /// public ReflectionServiceImpl(IEnumerable services, SymbolRegistry symbolRegistry) { - this.services = new List(services); - this.symbolRegistry = symbolRegistry; + core = new ReflectionServiceCore(services, symbolRegistry); } /// - /// Creates a new instance of ReflectionServiceIml. + /// Creates a new instance of ReflectionServiceImpl. /// public ReflectionServiceImpl(IEnumerable serviceDescriptors) { - this.services = new List(serviceDescriptors.Select((serviceDescriptor) => serviceDescriptor.FullName)); - this.symbolRegistry = SymbolRegistry.FromFiles(serviceDescriptors.Select((serviceDescriptor) => serviceDescriptor.File)); + core = new ReflectionServiceCore(serviceDescriptors); } /// - /// Creates a new instance of ReflectionServiceIml. + /// Creates a new instance of ReflectionServiceImpl. /// public ReflectionServiceImpl(params ServiceDescriptor[] serviceDescriptors) : this((IEnumerable) serviceDescriptors) { @@ -67,87 +64,50 @@ public override async Task ServerReflectionInfo(IAsyncStreamReader(); - CollectTransitiveDependencies(file, transitiveDependencies); - - return new ServerReflectionResponse - { - FileDescriptorResponse = new FileDescriptorResponse { FileDescriptorProto = { transitiveDependencies.Select((d) => d.SerializedData) } } + ServerReflectionRequest.MessageRequestOneofCase.FileByFilename => ReflectionServiceCore.RequestCase.FileByFilename, + ServerReflectionRequest.MessageRequestOneofCase.FileContainingSymbol => ReflectionServiceCore.RequestCase.FileContainingSymbol, + ServerReflectionRequest.MessageRequestOneofCase.ListServices => ReflectionServiceCore.RequestCase.ListServices, + _ => ReflectionServiceCore.RequestCase.Unsupported }; - } - ServerReflectionResponse FileContainingSymbol(string symbol) - { - FileDescriptor? file = symbolRegistry.FileContainingSymbol(symbol); - if (file is null) + var stringValue = request.MessageRequestCase switch { - return CreateErrorResponse(StatusCode.NotFound, "Symbol not found."); - } - - var transitiveDependencies = new HashSet(); - CollectTransitiveDependencies(file, transitiveDependencies); - - return new ServerReflectionResponse - { - FileDescriptorResponse = new FileDescriptorResponse { FileDescriptorProto = { transitiveDependencies.Select((d) => d.SerializedData) } } - }; - } - - ServerReflectionResponse ListServices() - { - var serviceResponses = new ListServiceResponse(); - foreach (var serviceName in services) - { - serviceResponses.Service.Add(new ServiceResponse { Name = serviceName }); - } - - return new ServerReflectionResponse - { - ListServicesResponse = serviceResponses + ServerReflectionRequest.MessageRequestOneofCase.FileByFilename => request.FileByFilename, + ServerReflectionRequest.MessageRequestOneofCase.FileContainingSymbol => request.FileContainingSymbol, + _ => null }; - } - ServerReflectionResponse CreateErrorResponse(StatusCode status, string message) - { - return new ServerReflectionResponse - { - ErrorResponse = new ErrorResponse { ErrorCode = (int) status, ErrorMessage = message } - }; + var coreResponse = core.ProcessRequest(requestCase, stringValue); + return ToResponse(coreResponse); } - void CollectTransitiveDependencies(FileDescriptor descriptor, HashSet pool) + static ServerReflectionResponse ToResponse(ReflectionServiceCore.Response coreResponse) { - pool.Add(descriptor); - foreach (var dependency in descriptor.Dependencies) + switch (coreResponse.Case) { - if (pool.Add(dependency)) - { - // descriptors cannot have circular dependencies - CollectTransitiveDependencies(dependency, pool); - } + case ReflectionServiceCore.ResponseCase.FileDescriptorResponse: + return new ServerReflectionResponse + { + FileDescriptorResponse = new FileDescriptorResponse { FileDescriptorProto = { coreResponse.FileDescriptorProtos! } } + }; + case ReflectionServiceCore.ResponseCase.ListServicesResponse: + var serviceResponses = new ListServiceResponse(); + foreach (var serviceName in coreResponse.ServiceNames!) + { + serviceResponses.Service.Add(new ServiceResponse { Name = serviceName }); + } + return new ServerReflectionResponse + { + ListServicesResponse = serviceResponses + }; + case ReflectionServiceCore.ResponseCase.ErrorResponse: + default: + return new ServerReflectionResponse + { + ErrorResponse = new ErrorResponse { ErrorCode = coreResponse.ErrorCode, ErrorMessage = coreResponse.ErrorMessage } + }; } } } diff --git a/src/Grpc.Reflection/ReflectionV1ServiceImpl.cs b/src/Grpc.Reflection/ReflectionV1ServiceImpl.cs new file mode 100644 index 000000000..4e1e14fa2 --- /dev/null +++ b/src/Grpc.Reflection/ReflectionV1ServiceImpl.cs @@ -0,0 +1,113 @@ +#region Copyright notice and license +// Copyright 2015 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#endregion + +using Google.Protobuf.Reflection; +using Grpc.Core; +using Grpc.Reflection.V1; + +namespace Grpc.Reflection; + +/// +/// Implementation of server reflection service (v1). +/// +public class ReflectionV1ServiceImpl : Grpc.Reflection.V1.ServerReflection.ServerReflectionBase +{ + readonly ReflectionServiceCore core; + + /// + /// Creates a new instance of ReflectionV1ServiceImpl. + /// + public ReflectionV1ServiceImpl(IEnumerable services, SymbolRegistry symbolRegistry) + { + core = new ReflectionServiceCore(services, symbolRegistry); + } + + /// + /// Creates a new instance of ReflectionV1ServiceImpl. + /// + public ReflectionV1ServiceImpl(IEnumerable serviceDescriptors) + { + core = new ReflectionServiceCore(serviceDescriptors); + } + + /// + /// Creates a new instance of ReflectionV1ServiceImpl. + /// + public ReflectionV1ServiceImpl(params ServiceDescriptor[] serviceDescriptors) : this((IEnumerable) serviceDescriptors) + { + } + + /// + /// Processes a stream of server reflection requests. + /// + public override async Task ServerReflectionInfo(IAsyncStreamReader requestStream, IServerStreamWriter responseStream, ServerCallContext context) + { + while (await requestStream.MoveNext().ConfigureAwait(false)) + { + var response = ProcessRequest(requestStream.Current); + await responseStream.WriteAsync(response).ConfigureAwait(false); + } + } + + ServerReflectionResponse ProcessRequest(ServerReflectionRequest request) + { + var requestCase = request.MessageRequestCase switch + { + ServerReflectionRequest.MessageRequestOneofCase.FileByFilename => ReflectionServiceCore.RequestCase.FileByFilename, + ServerReflectionRequest.MessageRequestOneofCase.FileContainingSymbol => ReflectionServiceCore.RequestCase.FileContainingSymbol, + ServerReflectionRequest.MessageRequestOneofCase.ListServices => ReflectionServiceCore.RequestCase.ListServices, + _ => ReflectionServiceCore.RequestCase.Unsupported + }; + + var stringValue = request.MessageRequestCase switch + { + ServerReflectionRequest.MessageRequestOneofCase.FileByFilename => request.FileByFilename, + ServerReflectionRequest.MessageRequestOneofCase.FileContainingSymbol => request.FileContainingSymbol, + _ => null + }; + + var coreResponse = core.ProcessRequest(requestCase, stringValue); + return ToResponse(coreResponse); + } + + static ServerReflectionResponse ToResponse(ReflectionServiceCore.Response coreResponse) + { + switch (coreResponse.Case) + { + case ReflectionServiceCore.ResponseCase.FileDescriptorResponse: + return new ServerReflectionResponse + { + FileDescriptorResponse = new FileDescriptorResponse { FileDescriptorProto = { coreResponse.FileDescriptorProtos! } } + }; + case ReflectionServiceCore.ResponseCase.ListServicesResponse: + var serviceResponses = new ListServiceResponse(); + foreach (var serviceName in coreResponse.ServiceNames!) + { + serviceResponses.Service.Add(new ServiceResponse { Name = serviceName }); + } + return new ServerReflectionResponse + { + ListServicesResponse = serviceResponses + }; + case ReflectionServiceCore.ResponseCase.ErrorResponse: + default: + return new ServerReflectionResponse + { + ErrorResponse = new ErrorResponse { ErrorCode = coreResponse.ErrorCode, ErrorMessage = coreResponse.ErrorMessage } + }; + } + } +} diff --git a/test/Grpc.AspNetCore.Server.Tests/Reflection/ReflectionGrpcServiceActivatorTests.cs b/test/Grpc.AspNetCore.Server.Tests/Reflection/ReflectionGrpcServiceActivatorTests.cs index 8d3bc4da8..57736361e 100644 --- a/test/Grpc.AspNetCore.Server.Tests/Reflection/ReflectionGrpcServiceActivatorTests.cs +++ b/test/Grpc.AspNetCore.Server.Tests/Reflection/ReflectionGrpcServiceActivatorTests.cs @@ -26,6 +26,7 @@ using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.DependencyInjection; using NUnit.Framework; +using V1 = Grpc.Reflection.V1; namespace Grpc.AspNetCore.Server.Tests.Reflection { @@ -83,6 +84,51 @@ public async Task Create_ConfiguredGrpcEndpointWithBaseType_EndpointReturnedFrom Assert.AreEqual("greet.ThirdGreeterWithBaseType", serviceResponse.Name); } + [Test] + public async Task Create_ConfiguredGrpcEndpoint_V1EndpointReturnedFromReflectionService() + { + // Arrange and act + TestServerStreamWriter writer = await ConfigureReflectionV1ServerAndCallAsync(builder => + { + builder.MapGrpcService(); + }); + + // Assert + Assert.AreEqual(1, writer.Responses.Count); + Assert.AreEqual(1, writer.Responses[0].ListServicesResponse.Service.Count); + + var serviceResponse = writer.Responses[0].ListServicesResponse.Service[0]; + Assert.AreEqual("greet.Greeter", serviceResponse.Name); + } + + [Test] + public async Task Create_ConfiguredGrpcEndpoint_BothV1AndV1AlphaRegistered() + { + // Arrange + var endpointRouteBuilder = new TestEndpointRouteBuilder(); + + var services = ServicesHelpers.CreateServices(); + services.AddGrpcReflection(); + services.AddRouting(); + services.AddSingleton(s => + { + return new CompositeEndpointDataSource(endpointRouteBuilder.DataSources); + }); + + var serviceProvider = services.BuildServiceProvider(validateScopes: true); + + endpointRouteBuilder.ServiceProvider = serviceProvider; + endpointRouteBuilder.MapGrpcService(); + + // Act - verify both services are registered + var v1AlphaService = serviceProvider.GetRequiredService(); + var v1Service = serviceProvider.GetRequiredService(); + + // Assert + Assert.IsNotNull(v1AlphaService); + Assert.IsNotNull(v1Service); + } + private static async Task> ConfigureReflectionServerAndCallAsync(Action action) { // Arrange @@ -120,6 +166,43 @@ private static async Task> Conf return writer; } + private static async Task> ConfigureReflectionV1ServerAndCallAsync(Action action) + { + // Arrange + var endpointRouteBuilder = new TestEndpointRouteBuilder(); + + var services = ServicesHelpers.CreateServices(); + services.AddGrpcReflection(); + services.AddRouting(); + services.AddSingleton(s => + { + return new CompositeEndpointDataSource(endpointRouteBuilder.DataSources); + }); + + var serviceProvider = services.BuildServiceProvider(validateScopes: true); + + endpointRouteBuilder.ServiceProvider = serviceProvider; + + action(endpointRouteBuilder); + + // Act + var service = serviceProvider.GetRequiredService(); + + var reader = new TestV1AsyncStreamReader + { + Current = new V1.ServerReflectionRequest + { + ListServices = "" // list all services + } + }; + var writer = new TestServerStreamWriter(); + var context = HttpContextServerCallContextHelper.CreateServerCallContext(); + + await service.ServerReflectionInfo(reader, writer, context); + + return writer; + } + private class InheritGreeterService : GreeterService { } @@ -151,6 +234,24 @@ public Task MoveNext(CancellationToken cancellationToken) } } + private class TestV1AsyncStreamReader : IAsyncStreamReader + { + public V1.ServerReflectionRequest Current { get; set; } = default!; + private bool _hasNext = true; + + public void Dispose() + { + } + + public Task MoveNext(CancellationToken cancellationToken) + { + var result = Task.FromResult(_hasNext); + _hasNext = false; + + return result; + } + } + private class TestEndpointRouteBuilder : IEndpointRouteBuilder { public TestEndpointRouteBuilder()