New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protoc-gen-go: import public should be recursive #695

Open
dsnet opened this Issue Sep 4, 2018 · 1 comment

Comments

Projects
None yet
1 participant
@dsnet
Member

dsnet commented Sep 4, 2018

Consider the following set of files.

In file test1.proto:

syntax = "proto2";
import public "google/protobuf/descriptor.proto";

In file test2.proto:

syntax = "proto2";
import public "test1.proto";

In file test3.proto:

syntax = "proto2";
import public "test2.proto";

message Foo { optional google.protobuf.FileDescriptorProto field = 1; }

Compiling these with protoc --go_out=. test3.proto produces:

2018/09/03 22:46:30 protoc-gen-go: WARNING: failed finding publicly imported dependency for .google.protobuf.FileDescriptorProto, used in test3.proto
2018/09/03 22:46:30 protoc-gen-go: WARNING: failed finding publicly imported dependency for .google.protobuf.FileDescriptorProto, used in test3.proto
2018/09/03 22:46:30 protoc-gen-go: WARNING: failed finding publicly imported dependency for .google.protobuf.FileDescriptorProto, used in test3.proto

However, C++ is able to resolve google.protobuf.FileDescriptorProto just fine when running protoc --cpp_out=. test3.proto.

It seems that the behavior is that indirectly publicly import declarations are exported.

\cc @neild

@dsnet

This comment has been minimized.

Show comment
Hide comment
@dsnet

dsnet Sep 4, 2018

Member

It seems that this can be addressed in the new API by changing protoreflect.FileDescriptor.DescriptorByName:

// DescriptorByName looks up any descriptor declared within this file
// by full name. It returns nil if not found.
DescriptorByName(FullName) Descriptor

to also search the name within any files that were publicly imported (by also calling DescriptorByName which will have the desired recursive effect).

Member

dsnet commented Sep 4, 2018

It seems that this can be addressed in the new API by changing protoreflect.FileDescriptor.DescriptorByName:

// DescriptorByName looks up any descriptor declared within this file
// by full name. It returns nil if not found.
DescriptorByName(FullName) Descriptor

to also search the name within any files that were publicly imported (by also calling DescriptorByName which will have the desired recursive effect).

@dsnet dsnet added the bug label Sep 4, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment