Merge pull request #22594 from Oshiumi/fix-nested-message-output-generation

Fix generating method output with nested resource
pull/22910/head
apolcyn 5 years ago committed by GitHub
commit 4046ee6367
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      src/compiler/ruby_generator_string-inl.h
  2. 5
      src/ruby/spec/pb/codegen/grpc/testing/package_options_ruby_style.proto
  3. 2
      src/ruby/spec/pb/codegen/package_option_spec.rb

@ -119,12 +119,13 @@ inline grpc::string RubyPackage(const grpc::protobuf::FileDescriptor* file) {
inline grpc::string RubyTypeOf(const grpc::protobuf::Descriptor* descriptor,
const grpc::string& package) {
std::string proto_type = descriptor->full_name();
ReplacePrefix(&proto_type, package,
""); // remove the leading package if present
ReplacePrefix(&proto_type, ".", ""); // remove the leading . (no package)
if (descriptor->file()->options().has_ruby_package()) {
proto_type = RubyPackage(descriptor->file()) + "." + descriptor->name();
proto_type = RubyPackage(descriptor->file()) + "." + proto_type;
}
grpc::string res(proto_type);
ReplacePrefix(&res, package, ""); // remove the leading package if present
ReplacePrefix(&res, ".", ""); // remove the leading . (no package)
if (res.find('.') == grpc::string::npos) {
return res;
} else {

@ -27,8 +27,13 @@ message AnotherTestResponse { }
message Foo { }
message Bar {
message Baz { }
}
service AnotherTestService {
rpc GetTest(AnotherTestRequest) returns (AnotherTestResponse) { }
rpc OtherTest(Thing) returns (Thing) { }
rpc FooTest(Foo) returns (Foo) { }
rpc NestedMessageTest(Foo) returns (Bar.Baz) { }
}

@ -40,6 +40,8 @@ describe 'Code Generation Options' do
expect(services[:OtherTest].output).to eq(A::Other::Thing)
expect(services[:FooTest].input).to eq(RPC::Test::New::Package::Options::Foo)
expect(services[:FooTest].output).to eq(RPC::Test::New::Package::Options::Foo)
expect(services[:NestedMessageTest].input).to eq(RPC::Test::New::Package::Options::Foo)
expect(services[:NestedMessageTest].output).to eq(RPC::Test::New::Package::Options::Bar::Baz)
end
end
end

Loading…
Cancel
Save