From af57087245ed29594751a2cd47c3ca4d7fb8dfe9 Mon Sep 17 00:00:00 2001 From: Joe Tsai Date: Sun, 14 Jul 2019 23:04:40 -0700 Subject: [PATCH] reflect/protoregistry: provide more informative errors for conflicts The v2 implementation strictly enforces that there are no conflicts at all in the protobuf namespace unlike the prior v1 implementation. This change is almost certainly going to cause loud failures for users that were unknowingly tolerating registration conflicts. We modify internal/filedesc to be able to record the Go package path that the file descriptor is declared within. This information is used by reflect/protoregistry to print both the previous Go package that registered some declaration, and current Go package that is attempting to register some declaration. Change-Id: Ib5eb21c1c98495afc51aa08bd4404bd9d64b5b57 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/186177 Reviewed-by: Damien Neil --- .../testdata/grpc/deprecation.pb.go | 3 + .../testdata/grpc/grpc.pb.go | 3 + cmd/protoc-gen-go/internal_gengo/main.go | 3 +- cmd/protoc-gen-go/internal_gengo/reflect.go | 2 + .../testdata/annotations/annotations.pb.go | 3 + .../annotations/annotations.pb.go.meta | 2 +- .../testdata/comments/comments.pb.go | 3 + .../testdata/comments/deprecated.pb.go | 3 + .../testdata/extensions/base/base.pb.go | 3 + .../testdata/extensions/ext/ext.pb.go | 3 + .../testdata/extensions/extra/extra.pb.go | 3 + .../testdata/extensions/proto3/ext3.pb.go | 3 + .../testdata/fieldnames/fieldnames.pb.go | 3 + .../testdata/import_public/a.pb.go | 3 + .../testdata/import_public/b.pb.go | 3 + .../testdata/import_public/c.pb.go | 3 + .../testdata/import_public/sub/a.pb.go | 3 + .../testdata/import_public/sub/b.pb.go | 3 + .../testdata/import_public/sub2/a.pb.go | 3 + .../testdata/imports/fmt/m.pb.go | 3 + .../testdata/imports/test_a_1/m1.pb.go | 3 + .../testdata/imports/test_a_1/m2.pb.go | 3 + .../testdata/imports/test_a_2/m3.pb.go | 3 + .../testdata/imports/test_a_2/m4.pb.go | 3 + .../testdata/imports/test_b_1/m1.pb.go | 3 + .../testdata/imports/test_b_1/m2.pb.go | 3 + .../testdata/imports/test_import_a1m1.pb.go | 3 + .../testdata/imports/test_import_a1m2.pb.go | 3 + .../testdata/imports/test_import_all.pb.go | 3 + .../issue780_oneof_conflict/test.pb.go | 3 + .../testdata/nopackage/nopackage.pb.go | 3 + cmd/protoc-gen-go/testdata/proto2/enum.pb.go | 3 + .../testdata/proto2/fields.pb.go | 3 + .../testdata/proto2/nested_messages.pb.go | 3 + .../testdata/proto2/proto2.pb.go | 3 + cmd/protoc-gen-go/testdata/proto3/enum.pb.go | 3 + .../testdata/proto3/fields.pb.go | 3 + encoding/testprotos/pb2/test.pb.go | 3 + encoding/testprotos/pb3/test.pb.go | 3 + internal/filedesc/build.go | 3 + internal/filedesc/desc.go | 9 +++ .../testprotos/benchmarks/benchmarks.pb.go | 3 + .../proto2/benchmark_message1_proto2.pb.go | 3 + .../proto3/benchmark_message1_proto3.pb.go | 3 + .../google_message2/benchmark_message2.pb.go | 3 + .../google_message3/benchmark_message3.pb.go | 3 + .../benchmark_message3_1.pb.go | 3 + .../benchmark_message3_2.pb.go | 3 + .../benchmark_message3_3.pb.go | 3 + .../benchmark_message3_4.pb.go | 3 + .../benchmark_message3_5.pb.go | 3 + .../benchmark_message3_6.pb.go | 3 + .../benchmark_message3_7.pb.go | 3 + .../benchmark_message3_8.pb.go | 3 + .../google_message4/benchmark_message4.pb.go | 3 + .../benchmark_message4_1.pb.go | 3 + .../benchmark_message4_2.pb.go | 3 + .../benchmark_message4_3.pb.go | 3 + .../testprotos/conformance/conformance.pb.go | 3 + .../conformance/test_messages_proto2.pb.go | 3 + .../conformance/test_messages_proto3.pb.go | 3 + internal/testprotos/irregular/test.pb.go | 3 + internal/testprotos/legacy/legacy.pb.go | 3 + .../messageset/messagesetpb/message_set.pb.go | 3 + .../messageset/msetextpb/msetextpb.pb.go | 3 + internal/testprotos/test/ext.pb.go | 3 + internal/testprotos/test/test.pb.go | 3 + internal/testprotos/test/test_import.pb.go | 3 + internal/testprotos/test/test_public.pb.go | 3 + internal/testprotos/test/weak/test_weak.pb.go | 3 + .../testprotos/test/weak1/test_weak.pb.go | 3 + .../testprotos/test/weak2/test_weak.pb.go | 3 + internal/testprotos/test3/test.pb.go | 3 + internal/testprotos/test3/test_import.pb.go | 3 + reflect/protoregistry/registry.go | 55 ++++++++++++++----- reflect/protoregistry/testprotos/test.pb.go | 3 + types/descriptorpb/descriptor.pb.go | 3 + types/known/anypb/any.pb.go | 3 + types/known/apipb/api.pb.go | 3 + types/known/durationpb/duration.pb.go | 3 + types/known/emptypb/empty.pb.go | 3 + types/known/fieldmaskpb/field_mask.pb.go | 3 + .../sourcecontextpb/source_context.pb.go | 3 + types/known/structpb/struct.pb.go | 3 + types/known/timestamppb/timestamp.pb.go | 3 + types/known/typepb/type.pb.go | 3 + types/known/wrapperspb/wrappers.pb.go | 3 + types/pluginpb/plugin.pb.go | 3 + 88 files changed, 304 insertions(+), 16 deletions(-) diff --git a/cmd/protoc-gen-go-grpc/testdata/grpc/deprecation.pb.go b/cmd/protoc-gen-go-grpc/testdata/grpc/deprecation.pb.go index 8a1a6a40..33db8f20 100644 --- a/cmd/protoc-gen-go-grpc/testdata/grpc/deprecation.pb.go +++ b/cmd/protoc-gen-go-grpc/testdata/grpc/deprecation.pb.go @@ -6,6 +6,7 @@ package grpc import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -69,8 +70,10 @@ func file_grpc_deprecation_proto_init() { return } file_grpc_grpc_proto_init() + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_grpc_deprecation_proto_rawDesc, NumEnums: 0, NumMessages: 0, diff --git a/cmd/protoc-gen-go-grpc/testdata/grpc/grpc.pb.go b/cmd/protoc-gen-go-grpc/testdata/grpc/grpc.pb.go index 95134418..cdeac52c 100644 --- a/cmd/protoc-gen-go-grpc/testdata/grpc/grpc.pb.go +++ b/cmd/protoc-gen-go-grpc/testdata/grpc/grpc.pb.go @@ -6,6 +6,7 @@ package grpc import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -180,8 +181,10 @@ func file_grpc_grpc_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_grpc_grpc_proto_rawDesc, NumEnums: 0, NumMessages: 2, diff --git a/cmd/protoc-gen-go/internal_gengo/main.go b/cmd/protoc-gen-go/internal_gengo/main.go index e0ad66aa..af8c8640 100644 --- a/cmd/protoc-gen-go/internal_gengo/main.go +++ b/cmd/protoc-gen-go/internal_gengo/main.go @@ -74,8 +74,9 @@ const ( ) const ( - syncPackage = protogen.GoImportPath("sync") mathPackage = protogen.GoImportPath("math") + reflectPackage = protogen.GoImportPath("reflect") + syncPackage = protogen.GoImportPath("sync") protoifacePackage = protogen.GoImportPath("google.golang.org/protobuf/runtime/protoiface") protoimplPackage = protogen.GoImportPath("google.golang.org/protobuf/runtime/protoimpl") protoreflectPackage = protogen.GoImportPath("google.golang.org/protobuf/reflect/protoreflect") diff --git a/cmd/protoc-gen-go/internal_gengo/reflect.go b/cmd/protoc-gen-go/internal_gengo/reflect.go index df9a8d4a..5fc41ae4 100644 --- a/cmd/protoc-gen-go/internal_gengo/reflect.go +++ b/cmd/protoc-gen-go/internal_gengo/reflect.go @@ -193,8 +193,10 @@ func genReflectFileDescriptor(gen *protogen.Plugin, g *protogen.GeneratedFile, f } } + g.P("type x struct{}") g.P("out := ", protoimplPackage.Ident("TypeBuilder"), "{") g.P("File: ", protoimplPackage.Ident("DescBuilder"), "{") + g.P("GoPackagePath: ", reflectPackage.Ident("TypeOf"), "(x{}).PkgPath(),") g.P("RawDescriptor: ", rawDescVarName(f), ",") g.P("NumEnums: ", len(f.allEnums), ",") g.P("NumMessages: ", len(f.allMessages), ",") diff --git a/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go b/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go index 09b80e67..670388a5 100644 --- a/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go +++ b/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go @@ -7,6 +7,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" prototype "google.golang.org/protobuf/reflect/prototype" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -176,8 +177,10 @@ func file_annotations_annotations_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_annotations_annotations_proto_rawDesc, NumEnums: 1, NumMessages: 1, diff --git a/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go.meta b/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go.meta index ec0ec086..38184866 100644 --- a/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go.meta +++ b/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go.meta @@ -1 +1 @@ -annotation:{path:5 path:0 source_file:"annotations/annotations.proto" begin:571 end:590} annotation:{path:5 path:0 path:2 path:0 source_file:"annotations/annotations.proto" begin:607 end:654} annotation:{path:4 path:0 source_file:"annotations/annotations.proto" begin:1879 end:1901} annotation:{path:4 path:0 path:2 path:0 source_file:"annotations/annotations.proto" begin:1957 end:1977} annotation:{path:4 path:0 path:2 path:0 source_file:"annotations/annotations.proto" begin:2953 end:2976} \ No newline at end of file +annotation:{path:5 path:0 source_file:"annotations/annotations.proto" begin:590 end:609} annotation:{path:5 path:0 path:2 path:0 source_file:"annotations/annotations.proto" begin:626 end:673} annotation:{path:4 path:0 source_file:"annotations/annotations.proto" begin:1898 end:1920} annotation:{path:4 path:0 path:2 path:0 source_file:"annotations/annotations.proto" begin:1976 end:1996} annotation:{path:4 path:0 path:2 path:0 source_file:"annotations/annotations.proto" begin:2972 end:2995} \ No newline at end of file diff --git a/cmd/protoc-gen-go/testdata/comments/comments.pb.go b/cmd/protoc-gen-go/testdata/comments/comments.pb.go index 1cf3f56d..66205243 100644 --- a/cmd/protoc-gen-go/testdata/comments/comments.pb.go +++ b/cmd/protoc-gen-go/testdata/comments/comments.pb.go @@ -8,6 +8,7 @@ package comments import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -394,8 +395,10 @@ func file_comments_comments_proto_init() { file_comments_comments_proto_msgTypes[0].OneofWrappers = []interface{}{ (*Message1_Oneof1AField1)(nil), } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_comments_comments_proto_rawDesc, NumEnums: 0, NumMessages: 6, diff --git a/cmd/protoc-gen-go/testdata/comments/deprecated.pb.go b/cmd/protoc-gen-go/testdata/comments/deprecated.pb.go index c77af896..f04126d4 100644 --- a/cmd/protoc-gen-go/testdata/comments/deprecated.pb.go +++ b/cmd/protoc-gen-go/testdata/comments/deprecated.pb.go @@ -7,6 +7,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" prototype "google.golang.org/protobuf/reflect/prototype" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -166,8 +167,10 @@ func file_comments_deprecated_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_comments_deprecated_proto_rawDesc, NumEnums: 1, NumMessages: 1, diff --git a/cmd/protoc-gen-go/testdata/extensions/base/base.pb.go b/cmd/protoc-gen-go/testdata/extensions/base/base.pb.go index 7a097445..7ca5de20 100644 --- a/cmd/protoc-gen-go/testdata/extensions/base/base.pb.go +++ b/cmd/protoc-gen-go/testdata/extensions/base/base.pb.go @@ -7,6 +7,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -192,8 +193,10 @@ func file_extensions_base_base_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_extensions_base_base_proto_rawDesc, NumEnums: 0, NumMessages: 2, diff --git a/cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go b/cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go index 8972d5e0..937c3d38 100644 --- a/cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go +++ b/cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go @@ -10,6 +10,7 @@ import ( prototype "google.golang.org/protobuf/reflect/prototype" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -1374,8 +1375,10 @@ func file_extensions_ext_ext_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_extensions_ext_ext_proto_rawDesc, NumEnums: 1, NumMessages: 8, diff --git a/cmd/protoc-gen-go/testdata/extensions/extra/extra.pb.go b/cmd/protoc-gen-go/testdata/extensions/extra/extra.pb.go index dda95ce4..3bc9138b 100644 --- a/cmd/protoc-gen-go/testdata/extensions/extra/extra.pb.go +++ b/cmd/protoc-gen-go/testdata/extensions/extra/extra.pb.go @@ -6,6 +6,7 @@ package extra import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -116,8 +117,10 @@ func file_extensions_extra_extra_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_extensions_extra_extra_proto_rawDesc, NumEnums: 0, NumMessages: 1, diff --git a/cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go b/cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go index 04f050d7..a97d55d6 100644 --- a/cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go +++ b/cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go @@ -9,6 +9,7 @@ import ( protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" descriptorpb "google.golang.org/protobuf/types/descriptorpb" + reflect "reflect" sync "sync" ) @@ -764,8 +765,10 @@ func file_extensions_proto3_ext3_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_extensions_proto3_ext3_proto_rawDesc, NumEnums: 1, NumMessages: 1, diff --git a/cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go b/cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go index 59ca34df..7a0401b8 100644 --- a/cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go +++ b/cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go @@ -6,6 +6,7 @@ package fieldnames import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -423,8 +424,10 @@ func file_fieldnames_fieldnames_proto_init() { (*Message_OneofConflictB_)(nil), (*Message_OneofMessageConflict_)(nil), } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_fieldnames_fieldnames_proto_rawDesc, NumEnums: 0, NumMessages: 2, diff --git a/cmd/protoc-gen-go/testdata/import_public/a.pb.go b/cmd/protoc-gen-go/testdata/import_public/a.pb.go index 5b2e6ec1..07685a8e 100644 --- a/cmd/protoc-gen-go/testdata/import_public/a.pb.go +++ b/cmd/protoc-gen-go/testdata/import_public/a.pb.go @@ -7,6 +7,7 @@ import ( sub "google.golang.org/protobuf/cmd/protoc-gen-go/testdata/import_public/sub" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -189,8 +190,10 @@ func file_import_public_a_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_import_public_a_proto_rawDesc, NumEnums: 0, NumMessages: 1, diff --git a/cmd/protoc-gen-go/testdata/import_public/b.pb.go b/cmd/protoc-gen-go/testdata/import_public/b.pb.go index ed3e8361..5b5eae4f 100644 --- a/cmd/protoc-gen-go/testdata/import_public/b.pb.go +++ b/cmd/protoc-gen-go/testdata/import_public/b.pb.go @@ -7,6 +7,7 @@ import ( sub "google.golang.org/protobuf/cmd/protoc-gen-go/testdata/import_public/sub" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -135,8 +136,10 @@ func file_import_public_b_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_import_public_b_proto_rawDesc, NumEnums: 0, NumMessages: 1, diff --git a/cmd/protoc-gen-go/testdata/import_public/c.pb.go b/cmd/protoc-gen-go/testdata/import_public/c.pb.go index 5fa0e7df..27773986 100644 --- a/cmd/protoc-gen-go/testdata/import_public/c.pb.go +++ b/cmd/protoc-gen-go/testdata/import_public/c.pb.go @@ -7,6 +7,7 @@ import ( sub2 "google.golang.org/protobuf/cmd/protoc-gen-go/testdata/import_public/sub2" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -141,8 +142,10 @@ func file_import_public_c_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_import_public_c_proto_rawDesc, NumEnums: 0, NumMessages: 1, diff --git a/cmd/protoc-gen-go/testdata/import_public/sub/a.pb.go b/cmd/protoc-gen-go/testdata/import_public/sub/a.pb.go index 67f63cc0..96397391 100644 --- a/cmd/protoc-gen-go/testdata/import_public/sub/a.pb.go +++ b/cmd/protoc-gen-go/testdata/import_public/sub/a.pb.go @@ -10,6 +10,7 @@ import ( protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" math "math" + reflect "reflect" sync "sync" ) @@ -512,8 +513,10 @@ func file_import_public_sub_a_proto_init() { (*M_Submessage_SubmessageOneofInt32)(nil), (*M_Submessage_SubmessageOneofInt64)(nil), } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_import_public_sub_a_proto_rawDesc, NumEnums: 3, NumMessages: 2, diff --git a/cmd/protoc-gen-go/testdata/import_public/sub/b.pb.go b/cmd/protoc-gen-go/testdata/import_public/sub/b.pb.go index a461703c..b19a5506 100644 --- a/cmd/protoc-gen-go/testdata/import_public/sub/b.pb.go +++ b/cmd/protoc-gen-go/testdata/import_public/sub/b.pb.go @@ -6,6 +6,7 @@ package sub import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -106,8 +107,10 @@ func file_import_public_sub_b_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_import_public_sub_b_proto_rawDesc, NumEnums: 0, NumMessages: 1, diff --git a/cmd/protoc-gen-go/testdata/import_public/sub2/a.pb.go b/cmd/protoc-gen-go/testdata/import_public/sub2/a.pb.go index f5552739..8ca14dd9 100644 --- a/cmd/protoc-gen-go/testdata/import_public/sub2/a.pb.go +++ b/cmd/protoc-gen-go/testdata/import_public/sub2/a.pb.go @@ -6,6 +6,7 @@ package sub2 import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -107,8 +108,10 @@ func file_import_public_sub2_a_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_import_public_sub2_a_proto_rawDesc, NumEnums: 0, NumMessages: 1, diff --git a/cmd/protoc-gen-go/testdata/imports/fmt/m.pb.go b/cmd/protoc-gen-go/testdata/imports/fmt/m.pb.go index ddc787ea..baff3cc7 100644 --- a/cmd/protoc-gen-go/testdata/imports/fmt/m.pb.go +++ b/cmd/protoc-gen-go/testdata/imports/fmt/m.pb.go @@ -6,6 +6,7 @@ package fmt import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -104,8 +105,10 @@ func file_imports_fmt_m_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_imports_fmt_m_proto_rawDesc, NumEnums: 0, NumMessages: 1, diff --git a/cmd/protoc-gen-go/testdata/imports/test_a_1/m1.pb.go b/cmd/protoc-gen-go/testdata/imports/test_a_1/m1.pb.go index 3310ef1d..c2d1075b 100644 --- a/cmd/protoc-gen-go/testdata/imports/test_a_1/m1.pb.go +++ b/cmd/protoc-gen-go/testdata/imports/test_a_1/m1.pb.go @@ -7,6 +7,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" prototype "google.golang.org/protobuf/reflect/prototype" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -208,8 +209,10 @@ func file_imports_test_a_1_m1_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_imports_test_a_1_m1_proto_rawDesc, NumEnums: 1, NumMessages: 2, diff --git a/cmd/protoc-gen-go/testdata/imports/test_a_1/m2.pb.go b/cmd/protoc-gen-go/testdata/imports/test_a_1/m2.pb.go index 0e46332f..7306e0c4 100644 --- a/cmd/protoc-gen-go/testdata/imports/test_a_1/m2.pb.go +++ b/cmd/protoc-gen-go/testdata/imports/test_a_1/m2.pb.go @@ -6,6 +6,7 @@ package test_a_1 import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -105,8 +106,10 @@ func file_imports_test_a_1_m2_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_imports_test_a_1_m2_proto_rawDesc, NumEnums: 0, NumMessages: 1, diff --git a/cmd/protoc-gen-go/testdata/imports/test_a_2/m3.pb.go b/cmd/protoc-gen-go/testdata/imports/test_a_2/m3.pb.go index fbd3ae6b..66530f3e 100644 --- a/cmd/protoc-gen-go/testdata/imports/test_a_2/m3.pb.go +++ b/cmd/protoc-gen-go/testdata/imports/test_a_2/m3.pb.go @@ -6,6 +6,7 @@ package test_a_2 import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -105,8 +106,10 @@ func file_imports_test_a_2_m3_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_imports_test_a_2_m3_proto_rawDesc, NumEnums: 0, NumMessages: 1, diff --git a/cmd/protoc-gen-go/testdata/imports/test_a_2/m4.pb.go b/cmd/protoc-gen-go/testdata/imports/test_a_2/m4.pb.go index 16919af8..843164d4 100644 --- a/cmd/protoc-gen-go/testdata/imports/test_a_2/m4.pb.go +++ b/cmd/protoc-gen-go/testdata/imports/test_a_2/m4.pb.go @@ -6,6 +6,7 @@ package test_a_2 import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -105,8 +106,10 @@ func file_imports_test_a_2_m4_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_imports_test_a_2_m4_proto_rawDesc, NumEnums: 0, NumMessages: 1, diff --git a/cmd/protoc-gen-go/testdata/imports/test_b_1/m1.pb.go b/cmd/protoc-gen-go/testdata/imports/test_b_1/m1.pb.go index 8f49585b..04434d6b 100644 --- a/cmd/protoc-gen-go/testdata/imports/test_b_1/m1.pb.go +++ b/cmd/protoc-gen-go/testdata/imports/test_b_1/m1.pb.go @@ -6,6 +6,7 @@ package beta import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -106,8 +107,10 @@ func file_imports_test_b_1_m1_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_imports_test_b_1_m1_proto_rawDesc, NumEnums: 0, NumMessages: 1, diff --git a/cmd/protoc-gen-go/testdata/imports/test_b_1/m2.pb.go b/cmd/protoc-gen-go/testdata/imports/test_b_1/m2.pb.go index d8596471..b5435274 100644 --- a/cmd/protoc-gen-go/testdata/imports/test_b_1/m2.pb.go +++ b/cmd/protoc-gen-go/testdata/imports/test_b_1/m2.pb.go @@ -6,6 +6,7 @@ package beta import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -106,8 +107,10 @@ func file_imports_test_b_1_m2_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_imports_test_b_1_m2_proto_rawDesc, NumEnums: 0, NumMessages: 1, diff --git a/cmd/protoc-gen-go/testdata/imports/test_import_a1m1.pb.go b/cmd/protoc-gen-go/testdata/imports/test_import_a1m1.pb.go index 15536caf..abb01128 100644 --- a/cmd/protoc-gen-go/testdata/imports/test_import_a1m1.pb.go +++ b/cmd/protoc-gen-go/testdata/imports/test_import_a1m1.pb.go @@ -7,6 +7,7 @@ import ( test_a_1 "google.golang.org/protobuf/cmd/protoc-gen-go/testdata/imports/test_a_1" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -119,8 +120,10 @@ func file_imports_test_import_a1m1_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_imports_test_import_a1m1_proto_rawDesc, NumEnums: 0, NumMessages: 1, diff --git a/cmd/protoc-gen-go/testdata/imports/test_import_a1m2.pb.go b/cmd/protoc-gen-go/testdata/imports/test_import_a1m2.pb.go index c7c9563d..60b0153e 100644 --- a/cmd/protoc-gen-go/testdata/imports/test_import_a1m2.pb.go +++ b/cmd/protoc-gen-go/testdata/imports/test_import_a1m2.pb.go @@ -7,6 +7,7 @@ import ( test_a_1 "google.golang.org/protobuf/cmd/protoc-gen-go/testdata/imports/test_a_1" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -119,8 +120,10 @@ func file_imports_test_import_a1m2_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_imports_test_import_a1m2_proto_rawDesc, NumEnums: 0, NumMessages: 1, diff --git a/cmd/protoc-gen-go/testdata/imports/test_import_all.pb.go b/cmd/protoc-gen-go/testdata/imports/test_import_all.pb.go index abf9739e..38ea8976 100644 --- a/cmd/protoc-gen-go/testdata/imports/test_import_all.pb.go +++ b/cmd/protoc-gen-go/testdata/imports/test_import_all.pb.go @@ -10,6 +10,7 @@ import ( test_b_1 "google.golang.org/protobuf/cmd/protoc-gen-go/testdata/imports/test_b_1" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -180,8 +181,10 @@ func file_imports_test_import_all_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_imports_test_import_all_proto_rawDesc, NumEnums: 0, NumMessages: 1, diff --git a/cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.pb.go b/cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.pb.go index 91b0c27f..36089172 100644 --- a/cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.pb.go +++ b/cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.pb.go @@ -6,6 +6,7 @@ package oneoftest import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -133,8 +134,10 @@ func file_issue780_oneof_conflict_test_proto_init() { file_issue780_oneof_conflict_test_proto_msgTypes[0].OneofWrappers = []interface{}{ (*Foo_GetBar)(nil), } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_issue780_oneof_conflict_test_proto_rawDesc, NumEnums: 0, NumMessages: 1, diff --git a/cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go b/cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go index 3f084473..bb808d63 100644 --- a/cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go +++ b/cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go @@ -7,6 +7,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" prototype "google.golang.org/protobuf/reflect/prototype" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -179,8 +180,10 @@ func file_nopackage_nopackage_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_nopackage_nopackage_proto_rawDesc, NumEnums: 1, NumMessages: 1, diff --git a/cmd/protoc-gen-go/testdata/proto2/enum.pb.go b/cmd/protoc-gen-go/testdata/proto2/enum.pb.go index 7b50b3ee..fc9258ba 100644 --- a/cmd/protoc-gen-go/testdata/proto2/enum.pb.go +++ b/cmd/protoc-gen-go/testdata/proto2/enum.pb.go @@ -7,6 +7,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" prototype "google.golang.org/protobuf/reflect/prototype" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -530,8 +531,10 @@ func file_proto2_enum_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_proto2_enum_proto_rawDesc, NumEnums: 6, NumMessages: 2, diff --git a/cmd/protoc-gen-go/testdata/proto2/fields.pb.go b/cmd/protoc-gen-go/testdata/proto2/fields.pb.go index 46ecadee..4beaeb09 100644 --- a/cmd/protoc-gen-go/testdata/proto2/fields.pb.go +++ b/cmd/protoc-gen-go/testdata/proto2/fields.pb.go @@ -8,6 +8,7 @@ import ( prototype "google.golang.org/protobuf/reflect/prototype" protoimpl "google.golang.org/protobuf/runtime/protoimpl" math "math" + reflect "reflect" sync "sync" ) @@ -1827,8 +1828,10 @@ func file_proto2_fields_proto_init() { (*FieldTestMessage_OneofTwo_1)(nil), (*FieldTestMessage_OneofTwo_2)(nil), } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_proto2_fields_proto_rawDesc, NumEnums: 1, NumMessages: 9, diff --git a/cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go b/cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go index c217a2ab..eb91c1b6 100644 --- a/cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go +++ b/cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go @@ -6,6 +6,7 @@ package proto2 import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -237,8 +238,10 @@ func file_proto2_nested_messages_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_proto2_nested_messages_proto_rawDesc, NumEnums: 0, NumMessages: 3, diff --git a/cmd/protoc-gen-go/testdata/proto2/proto2.pb.go b/cmd/protoc-gen-go/testdata/proto2/proto2.pb.go index 8d20d062..ab5c1b37 100644 --- a/cmd/protoc-gen-go/testdata/proto2/proto2.pb.go +++ b/cmd/protoc-gen-go/testdata/proto2/proto2.pb.go @@ -6,6 +6,7 @@ package proto2 import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -126,8 +127,10 @@ func file_proto2_proto2_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_proto2_proto2_proto_rawDesc, NumEnums: 0, NumMessages: 1, diff --git a/cmd/protoc-gen-go/testdata/proto3/enum.pb.go b/cmd/protoc-gen-go/testdata/proto3/enum.pb.go index 3155a2b2..adb002e3 100644 --- a/cmd/protoc-gen-go/testdata/proto3/enum.pb.go +++ b/cmd/protoc-gen-go/testdata/proto3/enum.pb.go @@ -7,6 +7,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" prototype "google.golang.org/protobuf/reflect/prototype" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -108,8 +109,10 @@ func file_proto3_enum_proto_init() { if File_proto3_enum_proto != nil { return } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_proto3_enum_proto_rawDesc, NumEnums: 1, NumMessages: 0, diff --git a/cmd/protoc-gen-go/testdata/proto3/fields.pb.go b/cmd/protoc-gen-go/testdata/proto3/fields.pb.go index 406b75a2..69181830 100644 --- a/cmd/protoc-gen-go/testdata/proto3/fields.pb.go +++ b/cmd/protoc-gen-go/testdata/proto3/fields.pb.go @@ -7,6 +7,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" prototype "google.golang.org/protobuf/reflect/prototype" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -644,8 +645,10 @@ func file_proto3_fields_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_proto3_fields_proto_rawDesc, NumEnums: 1, NumMessages: 5, diff --git a/encoding/testprotos/pb2/test.pb.go b/encoding/testprotos/pb2/test.pb.go index a9231e89..2a51f54b 100644 --- a/encoding/testprotos/pb2/test.pb.go +++ b/encoding/testprotos/pb2/test.pb.go @@ -15,6 +15,7 @@ import ( structpb "google.golang.org/protobuf/types/known/structpb" timestamppb "google.golang.org/protobuf/types/known/timestamppb" wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" + reflect "reflect" sync "sync" ) @@ -2382,8 +2383,10 @@ func file_pb2_test_proto_init() { file_pb2_test_proto_msgTypes[8].OneofWrappers = []interface{}{ (*IndirectRequired_OneofNested)(nil), } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_pb2_test_proto_rawDesc, NumEnums: 2, NumMessages: 20, diff --git a/encoding/testprotos/pb3/test.pb.go b/encoding/testprotos/pb3/test.pb.go index 56e5e4a4..a6e4c58b 100644 --- a/encoding/testprotos/pb3/test.pb.go +++ b/encoding/testprotos/pb3/test.pb.go @@ -7,6 +7,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" prototype "google.golang.org/protobuf/reflect/prototype" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -878,8 +879,10 @@ func file_pb3_test_proto_init() { (*Oneofs_OneofString)(nil), (*Oneofs_OneofNested)(nil), } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_pb3_test_proto_rawDesc, NumEnums: 2, NumMessages: 12, diff --git a/internal/filedesc/build.go b/internal/filedesc/build.go index 5f46e34d..427e26e6 100644 --- a/internal/filedesc/build.go +++ b/internal/filedesc/build.go @@ -15,6 +15,9 @@ import ( // DescBuilder construct a protoreflect.FileDescriptor from the raw descriptor. type DescBuilder struct { + // GoPackagePath is the Go package path that is invoking this builder. + GoPackagePath string + // RawDescriptor is the wire-encoded bytes of FileDescriptorProto // and must be populated. RawDescriptor []byte diff --git a/internal/filedesc/desc.go b/internal/filedesc/desc.go index d42bcd72..e6985633 100644 --- a/internal/filedesc/desc.go +++ b/internal/filedesc/desc.go @@ -106,6 +106,15 @@ func (fd *File) ProtoLegacyRawDesc() []byte { return fd.builder.RawDescriptor } +// GoPackagePath is a pseudo-internal API for determining the Go package path +// that this file descriptor is declared in. +// +// WARNING: This method is exempt from the compatibility promise and may be +// removed in the future without warning. +func (fd *File) GoPackagePath() string { + return fd.builder.GoPackagePath +} + type ( Enum struct { Base diff --git a/internal/testprotos/benchmarks/benchmarks.pb.go b/internal/testprotos/benchmarks/benchmarks.pb.go index 6328f646..220ab24d 100644 --- a/internal/testprotos/benchmarks/benchmarks.pb.go +++ b/internal/testprotos/benchmarks/benchmarks.pb.go @@ -6,6 +6,7 @@ package benchmarks import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -158,8 +159,10 @@ func file_benchmarks_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_benchmarks_proto_rawDesc, NumEnums: 0, NumMessages: 1, diff --git a/internal/testprotos/benchmarks/datasets/google_message1/proto2/benchmark_message1_proto2.pb.go b/internal/testprotos/benchmarks/datasets/google_message1/proto2/benchmark_message1_proto2.pb.go index 8741be6a..c4701066 100644 --- a/internal/testprotos/benchmarks/datasets/google_message1/proto2/benchmark_message1_proto2.pb.go +++ b/internal/testprotos/benchmarks/datasets/google_message1/proto2/benchmark_message1_proto2.pb.go @@ -6,6 +6,7 @@ package proto2 import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -798,8 +799,10 @@ func file_datasets_google_message1_proto2_benchmark_message1_proto2_proto_init() } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_datasets_google_message1_proto2_benchmark_message1_proto2_proto_rawDesc, NumEnums: 0, NumMessages: 2, diff --git a/internal/testprotos/benchmarks/datasets/google_message1/proto3/benchmark_message1_proto3.pb.go b/internal/testprotos/benchmarks/datasets/google_message1/proto3/benchmark_message1_proto3.pb.go index 8957480a..440a0a33 100644 --- a/internal/testprotos/benchmarks/datasets/google_message1/proto3/benchmark_message1_proto3.pb.go +++ b/internal/testprotos/benchmarks/datasets/google_message1/proto3/benchmark_message1_proto3.pb.go @@ -6,6 +6,7 @@ package proto3 import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -753,8 +754,10 @@ func file_datasets_google_message1_proto3_benchmark_message1_proto3_proto_init() } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_datasets_google_message1_proto3_benchmark_message1_proto3_proto_rawDesc, NumEnums: 0, NumMessages: 2, diff --git a/internal/testprotos/benchmarks/datasets/google_message2/benchmark_message2.pb.go b/internal/testprotos/benchmarks/datasets/google_message2/benchmark_message2.pb.go index fe056e8e..ececca46 100644 --- a/internal/testprotos/benchmarks/datasets/google_message2/benchmark_message2.pb.go +++ b/internal/testprotos/benchmarks/datasets/google_message2/benchmark_message2.pb.go @@ -6,6 +6,7 @@ package google_message2 import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -790,8 +791,10 @@ func file_datasets_google_message2_benchmark_message2_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_datasets_google_message2_benchmark_message2_proto_rawDesc, NumEnums: 0, NumMessages: 3, diff --git a/internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3.pb.go b/internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3.pb.go index 17d473b3..54c2c45d 100644 --- a/internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3.pb.go +++ b/internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3.pb.go @@ -7,6 +7,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -6569,8 +6570,10 @@ func file_datasets_google_message3_benchmark_message3_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_datasets_google_message3_benchmark_message3_proto_rawDesc, NumEnums: 0, NumMessages: 33, diff --git a/internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_1.pb.go b/internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_1.pb.go index f4df4cab..edf87f5e 100644 --- a/internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_1.pb.go +++ b/internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_1.pb.go @@ -7,6 +7,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -8822,8 +8823,10 @@ func file_datasets_google_message3_benchmark_message3_1_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_datasets_google_message3_benchmark_message3_1_proto_rawDesc, NumEnums: 0, NumMessages: 59, diff --git a/internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_2.pb.go b/internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_2.pb.go index 1aab9e85..abdf3d15 100644 --- a/internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_2.pb.go +++ b/internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_2.pb.go @@ -7,6 +7,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -6107,8 +6108,10 @@ func file_datasets_google_message3_benchmark_message3_2_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_datasets_google_message3_benchmark_message3_2_proto_rawDesc, NumEnums: 0, NumMessages: 34, diff --git a/internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_3.pb.go b/internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_3.pb.go index 5f8bb62d..9de4c35f 100644 --- a/internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_3.pb.go +++ b/internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_3.pb.go @@ -6,6 +6,7 @@ package google_message3 import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -5789,8 +5790,10 @@ func file_datasets_google_message3_benchmark_message3_3_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_datasets_google_message3_benchmark_message3_3_proto_rawDesc, NumEnums: 0, NumMessages: 37, diff --git a/internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_4.pb.go b/internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_4.pb.go index aab46488..652affdf 100644 --- a/internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_4.pb.go +++ b/internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_4.pb.go @@ -7,6 +7,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -6349,8 +6350,10 @@ func file_datasets_google_message3_benchmark_message3_4_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_datasets_google_message3_benchmark_message3_4_proto_rawDesc, NumEnums: 0, NumMessages: 54, diff --git a/internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_5.pb.go b/internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_5.pb.go index 9cf0fa1e..484eb6e4 100644 --- a/internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_5.pb.go +++ b/internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_5.pb.go @@ -7,6 +7,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -5809,8 +5810,10 @@ func file_datasets_google_message3_benchmark_message3_5_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_datasets_google_message3_benchmark_message3_5_proto_rawDesc, NumEnums: 0, NumMessages: 49, diff --git a/internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_6.pb.go b/internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_6.pb.go index 27aa1027..7c2bd286 100644 --- a/internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_6.pb.go +++ b/internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_6.pb.go @@ -7,6 +7,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -5425,8 +5426,10 @@ func file_datasets_google_message3_benchmark_message3_6_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_datasets_google_message3_benchmark_message3_6_proto_rawDesc, NumEnums: 0, NumMessages: 42, diff --git a/internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_7.pb.go b/internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_7.pb.go index e3264241..f2c71899 100644 --- a/internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_7.pb.go +++ b/internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_7.pb.go @@ -6,6 +6,7 @@ package google_message3 import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -726,8 +727,10 @@ func file_datasets_google_message3_benchmark_message3_7_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_datasets_google_message3_benchmark_message3_7_proto_rawDesc, NumEnums: 0, NumMessages: 10, diff --git a/internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_8.pb.go b/internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_8.pb.go index 6840a38d..2205d99b 100644 --- a/internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_8.pb.go +++ b/internal/testprotos/benchmarks/datasets/google_message3/benchmark_message3_8.pb.go @@ -7,6 +7,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" prototype "google.golang.org/protobuf/reflect/prototype" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -10435,8 +10436,10 @@ func file_datasets_google_message3_benchmark_message3_8_proto_init() { if File_datasets_google_message3_benchmark_message3_8_proto != nil { return } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_datasets_google_message3_benchmark_message3_8_proto_rawDesc, NumEnums: 59, NumMessages: 0, diff --git a/internal/testprotos/benchmarks/datasets/google_message4/benchmark_message4.pb.go b/internal/testprotos/benchmarks/datasets/google_message4/benchmark_message4.pb.go index 020d2fd6..a1d6e83d 100644 --- a/internal/testprotos/benchmarks/datasets/google_message4/benchmark_message4.pb.go +++ b/internal/testprotos/benchmarks/datasets/google_message4/benchmark_message4.pb.go @@ -7,6 +7,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -5888,8 +5889,10 @@ func file_datasets_google_message4_benchmark_message4_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_datasets_google_message4_benchmark_message4_proto_rawDesc, NumEnums: 0, NumMessages: 45, diff --git a/internal/testprotos/benchmarks/datasets/google_message4/benchmark_message4_1.pb.go b/internal/testprotos/benchmarks/datasets/google_message4/benchmark_message4_1.pb.go index a6c30640..a0395e91 100644 --- a/internal/testprotos/benchmarks/datasets/google_message4/benchmark_message4_1.pb.go +++ b/internal/testprotos/benchmarks/datasets/google_message4/benchmark_message4_1.pb.go @@ -7,6 +7,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -5991,8 +5992,10 @@ func file_datasets_google_message4_benchmark_message4_1_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_datasets_google_message4_benchmark_message4_1_proto_rawDesc, NumEnums: 0, NumMessages: 44, diff --git a/internal/testprotos/benchmarks/datasets/google_message4/benchmark_message4_2.pb.go b/internal/testprotos/benchmarks/datasets/google_message4/benchmark_message4_2.pb.go index ba2380f2..18995dc2 100644 --- a/internal/testprotos/benchmarks/datasets/google_message4/benchmark_message4_2.pb.go +++ b/internal/testprotos/benchmarks/datasets/google_message4/benchmark_message4_2.pb.go @@ -6,6 +6,7 @@ package google_message4 import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -3725,8 +3726,10 @@ func file_datasets_google_message4_benchmark_message4_2_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_datasets_google_message4_benchmark_message4_2_proto_rawDesc, NumEnums: 0, NumMessages: 35, diff --git a/internal/testprotos/benchmarks/datasets/google_message4/benchmark_message4_3.pb.go b/internal/testprotos/benchmarks/datasets/google_message4/benchmark_message4_3.pb.go index 263e9b4c..36cc75aa 100644 --- a/internal/testprotos/benchmarks/datasets/google_message4/benchmark_message4_3.pb.go +++ b/internal/testprotos/benchmarks/datasets/google_message4/benchmark_message4_3.pb.go @@ -7,6 +7,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" prototype "google.golang.org/protobuf/reflect/prototype" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -4782,8 +4783,10 @@ func file_datasets_google_message4_benchmark_message4_3_proto_init() { if File_datasets_google_message4_benchmark_message4_3_proto != nil { return } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_datasets_google_message4_benchmark_message4_3_proto_rawDesc, NumEnums: 42, NumMessages: 0, diff --git a/internal/testprotos/conformance/conformance.pb.go b/internal/testprotos/conformance/conformance.pb.go index f63df25e..ab2ad726 100644 --- a/internal/testprotos/conformance/conformance.pb.go +++ b/internal/testprotos/conformance/conformance.pb.go @@ -7,6 +7,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" prototype "google.golang.org/protobuf/reflect/prototype" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -748,8 +749,10 @@ func file_conformance_conformance_proto_init() { (*ConformanceResponse_JspbPayload)(nil), (*ConformanceResponse_TextPayload)(nil), } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_conformance_conformance_proto_rawDesc, NumEnums: 2, NumMessages: 4, diff --git a/internal/testprotos/conformance/test_messages_proto2.pb.go b/internal/testprotos/conformance/test_messages_proto2.pb.go index 91d70be2..f02aa2d1 100644 --- a/internal/testprotos/conformance/test_messages_proto2.pb.go +++ b/internal/testprotos/conformance/test_messages_proto2.pb.go @@ -8,6 +8,7 @@ import ( prototype "google.golang.org/protobuf/reflect/prototype" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -2024,8 +2025,10 @@ func file_google_protobuf_test_messages_proto2_proto_init() { (*TestAllTypesProto2_OneofDouble)(nil), (*TestAllTypesProto2_OneofEnum)(nil), } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_google_protobuf_test_messages_proto2_proto_rawDesc, NumEnums: 2, NumMessages: 26, diff --git a/internal/testprotos/conformance/test_messages_proto3.pb.go b/internal/testprotos/conformance/test_messages_proto3.pb.go index 8cf6e00a..05c4ea7e 100644 --- a/internal/testprotos/conformance/test_messages_proto3.pb.go +++ b/internal/testprotos/conformance/test_messages_proto3.pb.go @@ -13,6 +13,7 @@ import ( structpb "google.golang.org/protobuf/types/known/structpb" timestamppb "google.golang.org/protobuf/types/known/timestamppb" wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" + reflect "reflect" sync "sync" ) @@ -2205,8 +2206,10 @@ func file_google_protobuf_test_messages_proto3_proto_init() { (*TestAllTypesProto3_OneofDouble)(nil), (*TestAllTypesProto3_OneofEnum)(nil), } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_google_protobuf_test_messages_proto3_proto_rawDesc, NumEnums: 3, NumMessages: 22, diff --git a/internal/testprotos/irregular/test.pb.go b/internal/testprotos/irregular/test.pb.go index efe5728a..c3985ce4 100644 --- a/internal/testprotos/irregular/test.pb.go +++ b/internal/testprotos/irregular/test.pb.go @@ -6,6 +6,7 @@ package irregular import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -211,8 +212,10 @@ func file_irregular_test_proto_init() { file_irregular_test_proto_msgTypes[0].OneofWrappers = []interface{}{ (*Message_OneofMessage)(nil), } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_irregular_test_proto_rawDesc, NumEnums: 0, NumMessages: 2, diff --git a/internal/testprotos/legacy/legacy.pb.go b/internal/testprotos/legacy/legacy.pb.go index 0cce88d2..70d095a9 100644 --- a/internal/testprotos/legacy/legacy.pb.go +++ b/internal/testprotos/legacy/legacy.pb.go @@ -18,6 +18,7 @@ import ( proto3_v1_21 "google.golang.org/protobuf/internal/testprotos/legacy/proto3.v1.2.1-20181126-8d0c54c1" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -320,8 +321,10 @@ func file_legacy_legacy_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_legacy_legacy_proto_rawDesc, NumEnums: 0, NumMessages: 1, diff --git a/internal/testprotos/messageset/messagesetpb/message_set.pb.go b/internal/testprotos/messageset/messagesetpb/message_set.pb.go index aaa14da9..75f5fe18 100644 --- a/internal/testprotos/messageset/messagesetpb/message_set.pb.go +++ b/internal/testprotos/messageset/messagesetpb/message_set.pb.go @@ -7,6 +7,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -121,8 +122,10 @@ func file_messageset_messagesetpb_message_set_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_messageset_messagesetpb_message_set_proto_rawDesc, NumEnums: 0, NumMessages: 1, diff --git a/internal/testprotos/messageset/msetextpb/msetextpb.pb.go b/internal/testprotos/messageset/msetextpb/msetextpb.pb.go index 9af5304c..098e4d6d 100644 --- a/internal/testprotos/messageset/msetextpb/msetextpb.pb.go +++ b/internal/testprotos/messageset/msetextpb/msetextpb.pb.go @@ -8,6 +8,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -233,8 +234,10 @@ func file_messageset_msetextpb_msetextpb_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_messageset_msetextpb_msetextpb_proto_rawDesc, NumEnums: 0, NumMessages: 2, diff --git a/internal/testprotos/test/ext.pb.go b/internal/testprotos/test/ext.pb.go index 7a3363cc..289c00b4 100644 --- a/internal/testprotos/test/ext.pb.go +++ b/internal/testprotos/test/ext.pb.go @@ -7,6 +7,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -79,8 +80,10 @@ func file_test_ext_proto_init() { return } file_test_test_proto_init() + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_test_ext_proto_rawDesc, NumEnums: 0, NumMessages: 0, diff --git a/internal/testprotos/test/test.pb.go b/internal/testprotos/test/test.pb.go index 8cbce0aa..d6c81f42 100644 --- a/internal/testprotos/test/test.pb.go +++ b/internal/testprotos/test/test.pb.go @@ -8,6 +8,7 @@ import ( prototype "google.golang.org/protobuf/reflect/prototype" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -4908,8 +4909,10 @@ func file_test_test_proto_init() { file_test_test_proto_msgTypes[9].OneofWrappers = []interface{}{ (*TestRequiredForeign_OneofMessage)(nil), } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_test_test_proto_rawDesc, NumEnums: 4, NumMessages: 41, diff --git a/internal/testprotos/test/test_import.pb.go b/internal/testprotos/test/test_import.pb.go index 04999234..ae164030 100644 --- a/internal/testprotos/test/test_import.pb.go +++ b/internal/testprotos/test/test_import.pb.go @@ -7,6 +7,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" prototype "google.golang.org/protobuf/reflect/prototype" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -161,8 +162,10 @@ func file_test_test_import_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_test_test_import_proto_rawDesc, NumEnums: 1, NumMessages: 1, diff --git a/internal/testprotos/test/test_public.pb.go b/internal/testprotos/test/test_public.pb.go index a6b2aa1d..3bdf5cda 100644 --- a/internal/testprotos/test/test_public.pb.go +++ b/internal/testprotos/test/test_public.pb.go @@ -6,6 +6,7 @@ package test import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -105,8 +106,10 @@ func file_test_test_public_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_test_test_public_proto_rawDesc, NumEnums: 0, NumMessages: 1, diff --git a/internal/testprotos/test/weak/test_weak.pb.go b/internal/testprotos/test/weak/test_weak.pb.go index 862b017c..5841da77 100644 --- a/internal/testprotos/test/weak/test_weak.pb.go +++ b/internal/testprotos/test/weak/test_weak.pb.go @@ -6,6 +6,7 @@ package weak import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -115,8 +116,10 @@ func file_test_weak_test_weak_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_test_weak_test_weak_proto_rawDesc, NumEnums: 0, NumMessages: 1, diff --git a/internal/testprotos/test/weak1/test_weak.pb.go b/internal/testprotos/test/weak1/test_weak.pb.go index 779998cc..1b413a75 100644 --- a/internal/testprotos/test/weak1/test_weak.pb.go +++ b/internal/testprotos/test/weak1/test_weak.pb.go @@ -6,6 +6,7 @@ package weak1 import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -115,8 +116,10 @@ func file_test_weak1_test_weak_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_test_weak1_test_weak_proto_rawDesc, NumEnums: 0, NumMessages: 1, diff --git a/internal/testprotos/test/weak2/test_weak.pb.go b/internal/testprotos/test/weak2/test_weak.pb.go index bc6f9df2..e1d6d2fe 100644 --- a/internal/testprotos/test/weak2/test_weak.pb.go +++ b/internal/testprotos/test/weak2/test_weak.pb.go @@ -6,6 +6,7 @@ package weak2 import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -115,8 +116,10 @@ func file_test_weak2_test_weak_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_test_weak2_test_weak_proto_rawDesc, NumEnums: 0, NumMessages: 1, diff --git a/internal/testprotos/test3/test.pb.go b/internal/testprotos/test3/test.pb.go index 506ccf75..6e20fd49 100644 --- a/internal/testprotos/test3/test.pb.go +++ b/internal/testprotos/test3/test.pb.go @@ -7,6 +7,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" prototype "google.golang.org/protobuf/reflect/prototype" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -1390,8 +1391,10 @@ func file_test3_test_proto_init() { (*TestAllTypes_OneofDouble)(nil), (*TestAllTypes_OneofEnum)(nil), } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_test3_test_proto_rawDesc, NumEnums: 2, NumMessages: 20, diff --git a/internal/testprotos/test3/test_import.pb.go b/internal/testprotos/test3/test_import.pb.go index b47c98f6..60f98248 100644 --- a/internal/testprotos/test3/test_import.pb.go +++ b/internal/testprotos/test3/test_import.pb.go @@ -7,6 +7,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" prototype "google.golang.org/protobuf/reflect/prototype" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -151,8 +152,10 @@ func file_test3_test_import_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_test3_test_import_proto_rawDesc, NumEnums: 1, NumMessages: 1, diff --git a/reflect/protoregistry/registry.go b/reflect/protoregistry/registry.go index f5437b24..6efc2061 100644 --- a/reflect/protoregistry/registry.go +++ b/reflect/protoregistry/registry.go @@ -24,11 +24,6 @@ import ( "google.golang.org/protobuf/reflect/protoreflect" ) -// TODO: Perhaps Register should record the frame of where the function was -// called and surface that in the error? That would help users debug duplicate -// registration issues. This presumes that we provide a way to disable automatic -// registration in generated code. - // GlobalFiles is a global registry of file descriptors. var GlobalFiles *Files = new(Files) @@ -95,21 +90,24 @@ func (r *Files) Register(files ...protoreflect.FileDescriptor) error { } func (r *Files) registerFile(fd protoreflect.FileDescriptor) error { path := fd.Path() - if r.filesByPath[path] != nil { - return errors.New("file %q is already registered", fd.Path()) + if prev := r.filesByPath[path]; prev != nil { + err := errors.New("file %q is already registered", fd.Path()) + return amendErrorWithCaller(err, prev, fd) } for name := fd.Package(); name != ""; name = name.Parent() { - switch r.descsByName[name].(type) { + switch prev := r.descsByName[name]; prev.(type) { case nil, *packageDescriptor: default: - return errors.New("file %q has a name conflict over %v", fd.Path(), name) + err := errors.New("file %q has a name conflict over %v", fd.Path(), name) + return amendErrorWithCaller(err, prev, fd) } } var err error rangeTopLevelDescriptors(fd, func(d protoreflect.Descriptor) { - if r.descsByName[d.FullName()] != nil { + if prev := r.descsByName[d.FullName()]; prev != nil { err = errors.New("file %q has a name conflict over %v", fd.Path(), d.FullName()) + err = amendErrorWithCaller(err, prev, fd) } }) if err != nil { @@ -414,9 +412,10 @@ typeLoop: default: panic(fmt.Sprintf("invalid type: %T", t)) } - if r.typesByName[name] != nil { + if prev := r.typesByName[name]; prev != nil { if firstErr == nil { - firstErr = errors.New("%v %v is already registered", typeName(typ), name) + err := errors.New("%v %v is already registered", typeName(typ), name) + firstErr = amendErrorWithCaller(err, prev, typ) } continue typeLoop } @@ -425,9 +424,10 @@ typeLoop: if xt, _ := typ.(protoreflect.ExtensionType); xt != nil { field := xt.Number() message := xt.ContainingMessage().FullName() - if r.extensionsByMessage[message][field] != nil { + if prev := r.extensionsByMessage[message][field]; prev != nil { if firstErr == nil { - firstErr = errors.New("extension %v is already registered on message %v", name, message) + err := errors.New("extension number %d is already registered on message %v", field, message) + firstErr = amendErrorWithCaller(err, prev, typ) } continue typeLoop } @@ -610,3 +610,30 @@ func typeName(t Type) string { return fmt.Sprintf("%T", t) } } + +func amendErrorWithCaller(err error, prev, curr interface{}) error { + prevPkg := goPackage(prev) + currPkg := goPackage(curr) + if prevPkg == "" || currPkg == "" || prevPkg == currPkg { + return err + } + return errors.New("%s; previously from %q, currently from %q", err, prevPkg, currPkg) +} + +func goPackage(v interface{}) string { + switch d := v.(type) { + case protoreflect.EnumType: + v = d.Descriptor() + case protoreflect.MessageType: + v = d.Descriptor() + case protoreflect.ExtensionType: + v = d.Descriptor() + } + if d, ok := v.(protoreflect.Descriptor); ok { + v = d.ParentFile() + } + if d, ok := v.(interface{ GoPackagePath() string }); ok { + return d.GoPackagePath() + } + return "" +} diff --git a/reflect/protoregistry/testprotos/test.pb.go b/reflect/protoregistry/testprotos/test.pb.go index 705af3a2..899d48b4 100644 --- a/reflect/protoregistry/testprotos/test.pb.go +++ b/reflect/protoregistry/testprotos/test.pb.go @@ -8,6 +8,7 @@ import ( prototype "google.golang.org/protobuf/reflect/prototype" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -534,8 +535,10 @@ func file_test_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_test_proto_rawDesc, NumEnums: 3, NumMessages: 4, diff --git a/types/descriptorpb/descriptor.pb.go b/types/descriptorpb/descriptor.pb.go index c9abdcbd..02ee0965 100644 --- a/types/descriptorpb/descriptor.pb.go +++ b/types/descriptorpb/descriptor.pb.go @@ -8,6 +8,7 @@ import ( prototype "google.golang.org/protobuf/reflect/prototype" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -3754,8 +3755,10 @@ func file_google_protobuf_descriptor_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_google_protobuf_descriptor_proto_rawDesc, NumEnums: 6, NumMessages: 27, diff --git a/types/known/anypb/any.pb.go b/types/known/anypb/any.pb.go index feb14733..ea4c22e4 100644 --- a/types/known/anypb/any.pb.go +++ b/types/known/anypb/any.pb.go @@ -6,6 +6,7 @@ package anypb import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -237,8 +238,10 @@ func file_google_protobuf_any_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_google_protobuf_any_proto_rawDesc, NumEnums: 0, NumMessages: 1, diff --git a/types/known/apipb/api.pb.go b/types/known/apipb/api.pb.go index 1e038ee8..7654f625 100644 --- a/types/known/apipb/api.pb.go +++ b/types/known/apipb/api.pb.go @@ -8,6 +8,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" sourcecontextpb "google.golang.org/protobuf/types/known/sourcecontextpb" typepb "google.golang.org/protobuf/types/known/typepb" + reflect "reflect" sync "sync" ) @@ -514,8 +515,10 @@ func file_google_protobuf_api_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_google_protobuf_api_proto_rawDesc, NumEnums: 0, NumMessages: 3, diff --git a/types/known/durationpb/duration.pb.go b/types/known/durationpb/duration.pb.go index ed73ce2a..5462cd64 100644 --- a/types/known/durationpb/duration.pb.go +++ b/types/known/durationpb/duration.pb.go @@ -6,6 +6,7 @@ package durationpb import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -198,8 +199,10 @@ func file_google_protobuf_duration_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_google_protobuf_duration_proto_rawDesc, NumEnums: 0, NumMessages: 1, diff --git a/types/known/emptypb/empty.pb.go b/types/known/emptypb/empty.pb.go index aad4113f..1809707a 100644 --- a/types/known/emptypb/empty.pb.go +++ b/types/known/emptypb/empty.pb.go @@ -6,6 +6,7 @@ package emptypb import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -118,8 +119,10 @@ func file_google_protobuf_empty_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_google_protobuf_empty_proto_rawDesc, NumEnums: 0, NumMessages: 1, diff --git a/types/known/fieldmaskpb/field_mask.pb.go b/types/known/fieldmaskpb/field_mask.pb.go index 02a3a627..75832c56 100644 --- a/types/known/fieldmaskpb/field_mask.pb.go +++ b/types/known/fieldmaskpb/field_mask.pb.go @@ -6,6 +6,7 @@ package fieldmaskpb import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -320,8 +321,10 @@ func file_google_protobuf_field_mask_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_google_protobuf_field_mask_proto_rawDesc, NumEnums: 0, NumMessages: 1, diff --git a/types/known/sourcecontextpb/source_context.pb.go b/types/known/sourcecontextpb/source_context.pb.go index a486c87f..25b98c08 100644 --- a/types/known/sourcecontextpb/source_context.pb.go +++ b/types/known/sourcecontextpb/source_context.pb.go @@ -6,6 +6,7 @@ package sourcecontextpb import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -125,8 +126,10 @@ func file_google_protobuf_source_context_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_google_protobuf_source_context_proto_rawDesc, NumEnums: 0, NumMessages: 1, diff --git a/types/known/structpb/struct.pb.go b/types/known/structpb/struct.pb.go index dd97bdd5..2ce2ab5c 100644 --- a/types/known/structpb/struct.pb.go +++ b/types/known/structpb/struct.pb.go @@ -7,6 +7,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" prototype "google.golang.org/protobuf/reflect/prototype" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -440,8 +441,10 @@ func file_google_protobuf_struct_proto_init() { (*Value_StructValue)(nil), (*Value_ListValue)(nil), } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_google_protobuf_struct_proto_rawDesc, NumEnums: 1, NumMessages: 4, diff --git a/types/known/timestamppb/timestamp.pb.go b/types/known/timestamppb/timestamp.pb.go index 7c292cac..bd676d39 100644 --- a/types/known/timestamppb/timestamp.pb.go +++ b/types/known/timestamppb/timestamp.pb.go @@ -6,6 +6,7 @@ package timestamppb import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -218,8 +219,10 @@ func file_google_protobuf_timestamp_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_google_protobuf_timestamp_proto_rawDesc, NumEnums: 0, NumMessages: 1, diff --git a/types/known/typepb/type.pb.go b/types/known/typepb/type.pb.go index 91f0fcdd..b57f5e50 100644 --- a/types/known/typepb/type.pb.go +++ b/types/known/typepb/type.pb.go @@ -9,6 +9,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" anypb "google.golang.org/protobuf/types/known/anypb" sourcecontextpb "google.golang.org/protobuf/types/known/sourcecontextpb" + reflect "reflect" sync "sync" ) @@ -883,8 +884,10 @@ func file_google_protobuf_type_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_google_protobuf_type_proto_rawDesc, NumEnums: 3, NumMessages: 5, diff --git a/types/known/wrapperspb/wrappers.pb.go b/types/known/wrapperspb/wrappers.pb.go index 3aa77f18..258820d5 100644 --- a/types/known/wrapperspb/wrappers.pb.go +++ b/types/known/wrapperspb/wrappers.pb.go @@ -6,6 +6,7 @@ package wrapperspb import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" sync "sync" ) @@ -606,8 +607,10 @@ func file_google_protobuf_wrappers_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_google_protobuf_wrappers_proto_rawDesc, NumEnums: 0, NumMessages: 9, diff --git a/types/pluginpb/plugin.pb.go b/types/pluginpb/plugin.pb.go index a4f242e9..50f98ca7 100644 --- a/types/pluginpb/plugin.pb.go +++ b/types/pluginpb/plugin.pb.go @@ -7,6 +7,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" descriptorpb "google.golang.org/protobuf/types/descriptorpb" + reflect "reflect" sync "sync" ) @@ -473,8 +474,10 @@ func file_google_protobuf_compiler_plugin_proto_init() { } } } + type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_google_protobuf_compiler_plugin_proto_rawDesc, NumEnums: 0, NumMessages: 4,