From 253150d44e83ce22ba6554603fbb9161bbf25a4b Mon Sep 17 00:00:00 2001 From: Jonathan Tatum Date: Wed, 25 Mar 2026 21:19:05 +0000 Subject: [PATCH 1/5] Include pb2 extensions for cel-spec in repl --- repl/evaluator.go | 13 ++++++++----- repl/evaluator_test.go | 31 +++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/repl/evaluator.go b/repl/evaluator.go index c02a3597..be16131c 100644 --- a/repl/evaluator.go +++ b/repl/evaluator.go @@ -1190,14 +1190,17 @@ func deps(d protoreflect.FileDescriptor) []*descpb.FileDescriptorProto { func (e *Evaluator) loadDescriptorFromPackage(pkg string) error { switch pkg { case "cel-spec-test-types": - fdp := (&test2pb.TestAllTypes{}).ProtoReflect().Type().Descriptor().ParentFile() - fdp2 := (&test3pb.TestAllTypes{}).ProtoReflect().Type().Descriptor().ParentFile() + fdp2 := (&test2pb.TestAllTypes{}).ProtoReflect().Type().Descriptor().ParentFile() + fdp2ext := (&test2pb.Proto2ExtensionScopedMessage{}).ProtoReflect().Type().Descriptor().ParentFile() + fdp3 := (&test3pb.TestAllTypes{}).ProtoReflect().Type().Descriptor().ParentFile() - descriptorProtos := deps(fdp) + // We only depend on WKTs. + descriptorProtos := deps(fdp2) descriptorProtos = append(descriptorProtos, - protodesc.ToFileDescriptorProto(fdp), - protodesc.ToFileDescriptorProto(fdp2)) + protodesc.ToFileDescriptorProto(fdp2), + protodesc.ToFileDescriptorProto(fdp2ext), + protodesc.ToFileDescriptorProto(fdp3)) fds := descpb.FileDescriptorSet{ File: descriptorProtos, diff --git a/repl/evaluator_test.go b/repl/evaluator_test.go index be7a774d..d3e6bf8b 100644 --- a/repl/evaluator_test.go +++ b/repl/evaluator_test.go @@ -903,6 +903,37 @@ func TestProcess(t *testing.T) { wantExit: false, wantError: false, }, + { + name: "LoadDescriptorsPackageSpecExtensions", + commands: []Cmder{ + &simpleCmd{ + cmd: "load_descriptors", + args: []string{ + "--pkg", + "cel-spec-test-types", + }, + }, + &simpleCmd{ + cmd: "option", + args: []string{ + "--container", + "cel.expr.conformance", + }, + }, + &simpleCmd{ + cmd: "option", + args: []string{ + "--enable_escaped_fields", + }, + }, + &evalCmd{ + expr: "proto2.TestAllTypes{`cel.expr.conformance.proto2.int32_ext`: 42}.`cel.expr.conformance.proto2.int32_ext` == 42", + }, + }, + wantText: `true : bool`, + wantExit: false, + wantError: false, + }, { name: "LoadDescriptorsPackageRpc", commands: []Cmder{ From 1231b76c5d555a51679c46abbecb87762abe4305 Mon Sep 17 00:00:00 2001 From: Jonathan Tatum Date: Wed, 25 Mar 2026 21:55:35 +0000 Subject: [PATCH 2/5] Update value formatting for extension fields --- common/types/object.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/common/types/object.go b/common/types/object.go index c44eaa94..bb2a09e8 100644 --- a/common/types/object.go +++ b/common/types/object.go @@ -187,8 +187,14 @@ func (o *protoObj) format(sb *strings.Builder) { if i > 0 { sb.WriteString(", ") } - sb.WriteString(fmt.Sprintf("%s: ", field.Name())) - formatTo(sb, o.Get(String(field.Name()))) + name := String(field.Name()) + if field.IsExtension() { + name = String(field.FullName()) + fmt.Fprintf(sb, "`%s`: ", name) + } else { + fmt.Fprintf(sb, "%s: ", name) + } + formatTo(sb, o.Get(name)) } sb.WriteString("}") } From a68f471d508d5212aff9c9f2f734346967af0572 Mon Sep 17 00:00:00 2001 From: Jonathan Tatum Date: Thu, 26 Mar 2026 00:40:34 +0000 Subject: [PATCH 3/5] Add REPL support for JSON names. - Fix bug for messages with extensions using json types. --- common/types/pb/type.go | 13 +++++++++---- repl/evaluator.go | 22 ++++++++++++++++++++-- repl/main/main.go | 2 ++ 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/common/types/pb/type.go b/common/types/pb/type.go index b2363db0..d461e135 100644 --- a/common/types/pb/type.go +++ b/common/types/pb/type.go @@ -111,15 +111,20 @@ func (td *TypeDescription) FieldByName(name string) (*FieldDescription, bool) { if found { return fd, true } + + if td.jsonFieldNames { + fd, found = td.jsonFieldMap[name] + if found { + return fd, true + } + } + extFieldMap, found := td.extensions[td.typeName] if found { fd, found = extFieldMap[name] return fd, found } - if td.jsonFieldNames { - fd, found = td.jsonFieldMap[name] - return fd, found - } + return nil, false } diff --git a/repl/evaluator.go b/repl/evaluator.go index be16131c..4e25670c 100644 --- a/repl/evaluator.go +++ b/repl/evaluator.go @@ -994,6 +994,10 @@ func (o *typeOption) String() string { return fmt.Sprintf("%%load_descriptors %s '%s'", flags, o.path) } +func (o *typeOption) Option() cel.EnvOption { + return cel.TypeDescs(o.fds) +} + type backtickOpt struct { enabled bool } @@ -1009,8 +1013,17 @@ func (o *backtickOpt) String() string { return "%option --enable_escaped_fields" } -func (o *typeOption) Option() cel.EnvOption { - return cel.TypeDescs(o.fds) +type jsonOpt struct { + enabled bool +} + +func (o *jsonOpt) Option() cel.EnvOption { + + return cel.JSONFieldNames(o.enabled) +} + +func (o *jsonOpt) String() string { + return "%option --enable_escaped_fields" } type containerOption struct { @@ -1083,6 +1096,11 @@ func (e *Evaluator) setOption(args []string) error { if err != nil { issues = append(issues, fmt.Sprintf("enable_escaped_fields: %v", err)) } + case "--enable_json_field_names": + err := e.AddSerializableOption(&jsonOpt{enabled: true}) + if err != nil { + issues = append(issues, fmt.Sprintf("enable_json_field_names: %v", err)) + } case "--enable_partial_eval": err := e.EnablePartialEval() if err != nil { diff --git a/repl/main/main.go b/repl/main/main.go index f10802b2..bfc00242 100644 --- a/repl/main/main.go +++ b/repl/main/main.go @@ -43,6 +43,7 @@ package main import ( "fmt" "os" + "path/filepath" "github.com/google/cel-go/repl" @@ -52,6 +53,7 @@ import ( func main() { var c readline.Config c.Prompt = "cel-repl> " + c.HistoryFile = filepath.Join(os.Getenv("HOME"), ".cel-repl.history") err := c.Init() if err != nil { From a107f2c8fa6bd3db0546bac137e7600149148b89 Mon Sep 17 00:00:00 2001 From: Jonathan Tatum Date: Thu, 26 Mar 2026 20:08:34 +0000 Subject: [PATCH 4/5] Add test cases for name collisions --- cel/cel_test.go | 38 +++- common/types/pb/type.go | 12 +- test/proto2pb/test_all_types.pb.go | 148 +++++++++------ test/proto2pb/test_all_types.proto | 3 +- test/proto2pb/test_extensions.pb.go | 5 +- test/proto3pb/test_all_types.pb.go | 284 +++++++++++++++++++++------- test/proto3pb/test_all_types.proto | 19 ++ test/proto3pb/test_import.pb.go | 4 +- test/protos.md | 13 ++ 9 files changed, 379 insertions(+), 147 deletions(-) create mode 100644 test/protos.md diff --git a/cel/cel_test.go b/cel/cel_test.go index 976ff8de..31b2a318 100644 --- a/cel/cel_test.go +++ b/cel/cel_test.go @@ -3702,6 +3702,30 @@ func TestJSONFieldNames(t *testing.T) { expr: `dyn(msg).single_int32 == dyn(msg).singleInt32`, jsonFieldNames: true, }, + { + name: "proto with extensions", + expr: `google.expr.proto2.test.ExampleType{fooBar: 'value'}.fooBar == 'value'`, + jsonFieldNames: true, + }, + { + name: "json opt fields", + expr: "jsonOptMsg.int32_snake_case_json_name == 1 && " + + "jsonOptMsg.int64CamelCaseJsonName == 2 && " + + "jsonOptMsg.uint32DefaultJsonName == 3u && " + + "jsonOptMsg.`uint64-custom-json-name` == 4u && " + + "jsonOptMsg.single_string == 'shadows' && " + + "jsonOptMsg.singleString == 'shadowed'", + jsonFieldNames: true, + }, + { + name: "json opt fields fallback", + expr: "dyn(jsonOptMsg).int32_snake_case_json_name == 1 && " + + "dyn(jsonOptMsg).`uint64-custom-json-name` == 4u && " + + "dyn(jsonOptMsg).single_string == 'shadows' && " + + "dyn(jsonOptMsg).string_json_name_shadows == 'shadows' && " + + "dyn(jsonOptMsg).singleString == 'shadowed'", + jsonFieldNames: true, + }, } msg := &proto3pb.TestAllTypes{ SingleInt32: 1, @@ -3709,14 +3733,24 @@ func TestJSONFieldNames(t *testing.T) { "key": "value", }, } + jsonOptMsg := &proto3pb.TestJsonNames{ + Int32SnakeCaseJsonName: 1, + Int64CamelCaseJsonName: 2, + Uint32DefaultJsonName: 3, + Uint64CustomJsonName: 4, + StringJsonNameShadows: "shadows", + SingleString: "shadowed", + } for _, tst := range tests { tc := tst t.Run(tc.name, func(t *testing.T) { env, err := NewEnv( + EnableIdentifierEscapeSyntax(), JSONFieldNames(tc.jsonFieldNames), - Types(msg), + Types(msg, &proto2pb.ExternalMessageType{}, jsonOptMsg), Container(string(msg.ProtoReflect().Descriptor().ParentFile().Package())), Variable("msg", ObjectType(string(msg.ProtoReflect().Descriptor().FullName()))), + Variable("jsonOptMsg", ObjectType(string(jsonOptMsg.ProtoReflect().Descriptor().FullName()))), ) if err != nil { t.Fatalf("NewEnv() failed: %v", err) @@ -3729,7 +3763,7 @@ func TestJSONFieldNames(t *testing.T) { if err != nil { t.Fatalf("env.Program() failed: %v", err) } - out, _, err := prg.Eval(map[string]any{"msg": msg}) + out, _, err := prg.Eval(map[string]any{"msg": msg, "jsonOptMsg": jsonOptMsg}) if err != nil { t.Fatalf("prg.Eval() failed: %v", err) } diff --git a/common/types/pb/type.go b/common/types/pb/type.go index d461e135..8d7d1b29 100644 --- a/common/types/pb/type.go +++ b/common/types/pb/type.go @@ -107,18 +107,18 @@ func (td *TypeDescription) FieldMap() map[string]*FieldDescription { // FieldByName returns (FieldDescription, true) if the field name is declared within the type. func (td *TypeDescription) FieldByName(name string) (*FieldDescription, bool) { - fd, found := td.fieldMap[name] - if found { - return fd, true - } - if td.jsonFieldNames { - fd, found = td.jsonFieldMap[name] + fd, found := td.jsonFieldMap[name] if found { return fd, true } } + fd, found := td.fieldMap[name] + if found { + return fd, true + } + extFieldMap, found := td.extensions[td.typeName] if found { fd, found = extFieldMap[name] diff --git a/test/proto2pb/test_all_types.pb.go b/test/proto2pb/test_all_types.pb.go index 119cb5f3..34eb3a12 100755 --- a/test/proto2pb/test_all_types.pb.go +++ b/test/proto2pb/test_all_types.pb.go @@ -1,7 +1,9 @@ +// LINT: ALLOW_GROUPS + // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.5 +// protoc-gen-go v1.28.0 +// protoc v3.21.12 // source: test/proto2pb/test_all_types.proto package proto2pb @@ -25,6 +27,7 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// This proto tests that global enums are resolved correctly. type GlobalEnum int32 const ( @@ -143,47 +146,53 @@ func (TestAllTypes_NestedEnum) EnumDescriptor() ([]byte, []int) { return file_test_proto2pb_test_all_types_proto_rawDescGZIP(), []int{0, 0} } +// This proto includes every type of field in both singular and repeated +// forms. type TestAllTypes struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - SingleInt32 *int32 `protobuf:"varint,1,opt,name=single_int32,json=singleInt32,def=-32" json:"single_int32,omitempty"` - SingleInt64 *int64 `protobuf:"varint,2,opt,name=single_int64,json=singleInt64,def=-64" json:"single_int64,omitempty"` - SingleUint32 *uint32 `protobuf:"varint,3,opt,name=single_uint32,json=singleUint32,def=32" json:"single_uint32,omitempty"` - SingleUint64 *uint64 `protobuf:"varint,4,opt,name=single_uint64,json=singleUint64,def=64" json:"single_uint64,omitempty"` - SingleSint32 *int32 `protobuf:"zigzag32,5,opt,name=single_sint32,json=singleSint32" json:"single_sint32,omitempty"` - SingleSint64 *int64 `protobuf:"zigzag64,6,opt,name=single_sint64,json=singleSint64" json:"single_sint64,omitempty"` - SingleFixed32 *uint32 `protobuf:"fixed32,7,opt,name=single_fixed32,json=singleFixed32" json:"single_fixed32,omitempty"` - SingleFixed64 *uint64 `protobuf:"fixed64,8,opt,name=single_fixed64,json=singleFixed64" json:"single_fixed64,omitempty"` - SingleSfixed32 *int32 `protobuf:"fixed32,9,opt,name=single_sfixed32,json=singleSfixed32" json:"single_sfixed32,omitempty"` - SingleSfixed64 *int64 `protobuf:"fixed64,10,opt,name=single_sfixed64,json=singleSfixed64" json:"single_sfixed64,omitempty"` - SingleFloat *float32 `protobuf:"fixed32,11,opt,name=single_float,json=singleFloat,def=3" json:"single_float,omitempty"` - SingleDouble *float64 `protobuf:"fixed64,12,opt,name=single_double,json=singleDouble,def=6.4" json:"single_double,omitempty"` - SingleBool *bool `protobuf:"varint,13,opt,name=single_bool,json=singleBool,def=1" json:"single_bool,omitempty"` - SingleString *string `protobuf:"bytes,14,opt,name=single_string,json=singleString,def=empty" json:"single_string,omitempty"` - SingleBytes []byte `protobuf:"bytes,15,opt,name=single_bytes,json=singleBytes,def=none" json:"single_bytes,omitempty"` - StandaloneEnum *TestAllTypes_NestedEnum `protobuf:"varint,22,opt,name=standalone_enum,json=standaloneEnum,enum=google.expr.proto2.test.TestAllTypes_NestedEnum" json:"standalone_enum,omitempty"` - Nestedgroup *TestAllTypes_NestedGroup `protobuf:"group,23,opt,name=NestedGroup,json=nestedgroup" json:"nestedgroup,omitempty"` - SingleAny *anypb.Any `protobuf:"bytes,100,opt,name=single_any,json=singleAny" json:"single_any,omitempty"` - SingleDuration *durationpb.Duration `protobuf:"bytes,101,opt,name=single_duration,json=singleDuration" json:"single_duration,omitempty"` - SingleTimestamp *timestamppb.Timestamp `protobuf:"bytes,102,opt,name=single_timestamp,json=singleTimestamp" json:"single_timestamp,omitempty"` - SingleStruct *structpb.Struct `protobuf:"bytes,103,opt,name=single_struct,json=singleStruct" json:"single_struct,omitempty"` - SingleValue *structpb.Value `protobuf:"bytes,104,opt,name=single_value,json=singleValue" json:"single_value,omitempty"` - SingleInt64Wrapper *wrapperspb.Int64Value `protobuf:"bytes,105,opt,name=single_int64_wrapper,json=singleInt64Wrapper" json:"single_int64_wrapper,omitempty"` - SingleInt32Wrapper *wrapperspb.Int32Value `protobuf:"bytes,106,opt,name=single_int32_wrapper,json=singleInt32Wrapper" json:"single_int32_wrapper,omitempty"` - SingleDoubleWrapper *wrapperspb.DoubleValue `protobuf:"bytes,107,opt,name=single_double_wrapper,json=singleDoubleWrapper" json:"single_double_wrapper,omitempty"` - SingleFloatWrapper *wrapperspb.FloatValue `protobuf:"bytes,108,opt,name=single_float_wrapper,json=singleFloatWrapper" json:"single_float_wrapper,omitempty"` - SingleUint64Wrapper *wrapperspb.UInt64Value `protobuf:"bytes,109,opt,name=single_uint64_wrapper,json=singleUint64Wrapper" json:"single_uint64_wrapper,omitempty"` - SingleUint32Wrapper *wrapperspb.UInt32Value `protobuf:"bytes,110,opt,name=single_uint32_wrapper,json=singleUint32Wrapper" json:"single_uint32_wrapper,omitempty"` - SingleStringWrapper *wrapperspb.StringValue `protobuf:"bytes,111,opt,name=single_string_wrapper,json=singleStringWrapper" json:"single_string_wrapper,omitempty"` - SingleBoolWrapper *wrapperspb.BoolValue `protobuf:"bytes,112,opt,name=single_bool_wrapper,json=singleBoolWrapper" json:"single_bool_wrapper,omitempty"` - SingleBytesWrapper *wrapperspb.BytesValue `protobuf:"bytes,113,opt,name=single_bytes_wrapper,json=singleBytesWrapper" json:"single_bytes_wrapper,omitempty"` - // Types that are assignable to NestedType: + // Singular + SingleInt32 *int32 `protobuf:"varint,1,opt,name=single_int32,json=singleInt32,def=-32" json:"single_int32,omitempty"` + SingleInt64 *int64 `protobuf:"varint,2,opt,name=single_int64,json=singleInt64,def=-64" json:"single_int64,omitempty"` + SingleUint32 *uint32 `protobuf:"varint,3,opt,name=single_uint32,json=singleUint32,def=32" json:"single_uint32,omitempty"` + SingleUint64 *uint64 `protobuf:"varint,4,opt,name=single_uint64,json=singleUint64,def=64" json:"single_uint64,omitempty"` + SingleSint32 *int32 `protobuf:"zigzag32,5,opt,name=single_sint32,json=singleSint32" json:"single_sint32,omitempty"` + SingleSint64 *int64 `protobuf:"zigzag64,6,opt,name=single_sint64,json=singleSint64" json:"single_sint64,omitempty"` + SingleFixed32 *uint32 `protobuf:"fixed32,7,opt,name=single_fixed32,json=singleFixed32" json:"single_fixed32,omitempty"` + SingleFixed64 *uint64 `protobuf:"fixed64,8,opt,name=single_fixed64,json=singleFixed64" json:"single_fixed64,omitempty"` + SingleSfixed32 *int32 `protobuf:"fixed32,9,opt,name=single_sfixed32,json=singleSfixed32" json:"single_sfixed32,omitempty"` + SingleSfixed64 *int64 `protobuf:"fixed64,10,opt,name=single_sfixed64,json=singleSfixed64" json:"single_sfixed64,omitempty"` + SingleFloat *float32 `protobuf:"fixed32,11,opt,name=single_float,json=singleFloat,def=3" json:"single_float,omitempty"` + SingleDouble *float64 `protobuf:"fixed64,12,opt,name=single_double,json=singleDouble,def=6.4" json:"single_double,omitempty"` + SingleBool *bool `protobuf:"varint,13,opt,name=single_bool,json=singleBool,def=1" json:"single_bool,omitempty"` + SingleString *string `protobuf:"bytes,14,opt,name=single_string,json=singleString,def=empty" json:"single_string,omitempty"` + SingleBytes []byte `protobuf:"bytes,15,opt,name=single_bytes,json=singleBytes,def=none" json:"single_bytes,omitempty"` + StandaloneEnum *TestAllTypes_NestedEnum `protobuf:"varint,22,opt,name=standalone_enum,json=standaloneEnum,enum=google.expr.proto2.test.TestAllTypes_NestedEnum" json:"standalone_enum,omitempty"` + Nestedgroup *TestAllTypes_NestedGroup `protobuf:"group,23,opt,name=NestedGroup,json=nestedgroup" json:"nestedgroup,omitempty"` + // Wellknown. + SingleAny *anypb.Any `protobuf:"bytes,100,opt,name=single_any,json=singleAny" json:"single_any,omitempty"` + SingleDuration *durationpb.Duration `protobuf:"bytes,101,opt,name=single_duration,json=singleDuration" json:"single_duration,omitempty"` + SingleTimestamp *timestamppb.Timestamp `protobuf:"bytes,102,opt,name=single_timestamp,json=singleTimestamp" json:"single_timestamp,omitempty"` + SingleStruct *structpb.Struct `protobuf:"bytes,103,opt,name=single_struct,json=singleStruct" json:"single_struct,omitempty"` + SingleValue *structpb.Value `protobuf:"bytes,104,opt,name=single_value,json=singleValue" json:"single_value,omitempty"` + SingleInt64Wrapper *wrapperspb.Int64Value `protobuf:"bytes,105,opt,name=single_int64_wrapper,json=singleInt64Wrapper" json:"single_int64_wrapper,omitempty"` + SingleInt32Wrapper *wrapperspb.Int32Value `protobuf:"bytes,106,opt,name=single_int32_wrapper,json=singleInt32Wrapper" json:"single_int32_wrapper,omitempty"` + SingleDoubleWrapper *wrapperspb.DoubleValue `protobuf:"bytes,107,opt,name=single_double_wrapper,json=singleDoubleWrapper" json:"single_double_wrapper,omitempty"` + SingleFloatWrapper *wrapperspb.FloatValue `protobuf:"bytes,108,opt,name=single_float_wrapper,json=singleFloatWrapper" json:"single_float_wrapper,omitempty"` + SingleUint64Wrapper *wrapperspb.UInt64Value `protobuf:"bytes,109,opt,name=single_uint64_wrapper,json=singleUint64Wrapper" json:"single_uint64_wrapper,omitempty"` + SingleUint32Wrapper *wrapperspb.UInt32Value `protobuf:"bytes,110,opt,name=single_uint32_wrapper,json=singleUint32Wrapper" json:"single_uint32_wrapper,omitempty"` + SingleStringWrapper *wrapperspb.StringValue `protobuf:"bytes,111,opt,name=single_string_wrapper,json=singleStringWrapper" json:"single_string_wrapper,omitempty"` + SingleBoolWrapper *wrapperspb.BoolValue `protobuf:"bytes,112,opt,name=single_bool_wrapper,json=singleBoolWrapper" json:"single_bool_wrapper,omitempty"` + SingleBytesWrapper *wrapperspb.BytesValue `protobuf:"bytes,113,opt,name=single_bytes_wrapper,json=singleBytesWrapper" json:"single_bytes_wrapper,omitempty"` + // Nested messages // + // Types that are assignable to NestedType: // *TestAllTypes_SingleNestedMessage // *TestAllTypes_SingleNestedEnum - NestedType isTestAllTypes_NestedType `protobuf_oneof:"nested_type"` + NestedType isTestAllTypes_NestedType `protobuf_oneof:"nested_type"` + // Repeated RepeatedInt32 []int32 `protobuf:"varint,31,rep,name=repeated_int32,json=repeatedInt32" json:"repeated_int32,omitempty"` RepeatedInt64 []int64 `protobuf:"varint,32,rep,name=repeated_int64,json=repeatedInt64" json:"repeated_int64,omitempty"` RepeatedUint32 []uint32 `protobuf:"varint,33,rep,name=repeated_uint32,json=repeatedUint32" json:"repeated_uint32,omitempty"` @@ -204,8 +213,9 @@ type TestAllTypes struct { RepeatedStringPiece []string `protobuf:"bytes,54,rep,name=repeated_string_piece,json=repeatedStringPiece" json:"repeated_string_piece,omitempty"` RepeatedCord []string `protobuf:"bytes,55,rep,name=repeated_cord,json=repeatedCord" json:"repeated_cord,omitempty"` RepeatedLazyMessage []*TestAllTypes_NestedMessage `protobuf:"bytes,57,rep,name=repeated_lazy_message,json=repeatedLazyMessage" json:"repeated_lazy_message,omitempty"` - MapStringString map[string]string `protobuf:"bytes,58,rep,name=map_string_string,json=mapStringString" json:"map_string_string,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` - MapInt64NestedType map[int64]*NestedTestAllTypes `protobuf:"bytes,59,rep,name=map_int64_nested_type,json=mapInt64NestedType" json:"map_int64_nested_type,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + // Map + MapStringString map[string]string `protobuf:"bytes,58,rep,name=map_string_string,json=mapStringString" json:"map_string_string,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + MapInt64NestedType map[int64]*NestedTestAllTypes `protobuf:"bytes,59,rep,name=map_int64_nested_type,json=mapInt64NestedType" json:"map_int64_nested_type,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` } // Default values for TestAllTypes fields. @@ -666,6 +676,7 @@ func (*TestAllTypes_SingleNestedMessage) isTestAllTypes_NestedType() {} func (*TestAllTypes_SingleNestedEnum) isTestAllTypes_NestedType() {} +// This proto includes a recursively nested message. type NestedTestAllTypes struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -721,14 +732,17 @@ func (x *NestedTestAllTypes) GetPayload() *TestAllTypes { return nil } +// This proto is used to show how extensions are tracked as fields +// with fully qualified names. type ExampleType struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields extensionFields protoimpl.ExtensionFields - Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` - In *int64 `protobuf:"varint,2,opt,name=in" json:"in,omitempty"` + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + FooBar *string `protobuf:"bytes,2,opt,name=foo_bar,json=fooBar" json:"foo_bar,omitempty"` + In *int64 `protobuf:"varint,3,opt,name=in" json:"in,omitempty"` } func (x *ExampleType) Reset() { @@ -770,6 +784,13 @@ func (x *ExampleType) GetName() string { return "" } +func (x *ExampleType) GetFooBar() string { + if x != nil && x.FooBar != nil { + return *x.FooBar + } + return "" +} + func (x *ExampleType) GetIn() int64 { if x != nil && x.In != nil { return *x.In @@ -777,6 +798,7 @@ func (x *ExampleType) GetIn() int64 { return 0 } +// Message scoped extensions. type ExtendedExampleType struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -820,6 +842,9 @@ type TestAllTypes_NestedMessage struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + // The field name "b" fails to compile in proto1 because it conflicts with + // a local variable named "b" in one of the generated methods. + // This file needs to compile in proto1 to test backwards-compatibility. Bb *int32 `protobuf:"varint,1,opt,name=bb" json:"bb,omitempty"` } @@ -1197,29 +1222,30 @@ var file_test_proto2pb_test_all_types_proto_rawDesc = []byte{ 0x32, 0x25, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x65, 0x78, 0x70, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x41, 0x6c, 0x6c, 0x54, 0x79, 0x70, 0x65, 0x73, 0x52, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, - 0x22, 0x3b, 0x0a, 0x0b, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, + 0x22, 0x54, 0x0a, 0x0b, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x02, 0x69, 0x6e, 0x2a, 0x08, 0x08, 0x64, 0x10, 0x80, 0x80, 0x80, 0x80, 0x02, 0x22, 0xce, 0x01, - 0x0a, 0x13, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x64, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, - 0x65, 0x54, 0x79, 0x70, 0x65, 0x32, 0x51, 0x0a, 0x11, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x64, 0x65, - 0x64, 0x5f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x12, 0x24, 0x2e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x65, 0x78, 0x70, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x2e, - 0x74, 0x65, 0x73, 0x74, 0x2e, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, - 0x18, 0x67, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x64, - 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x32, 0x64, 0x0a, 0x08, 0x65, 0x6e, 0x75, 0x6d, - 0x5f, 0x65, 0x78, 0x74, 0x12, 0x24, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x65, 0x78, - 0x70, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x45, - 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x18, 0x68, 0x20, 0x01, 0x28, 0x0e, - 0x32, 0x23, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x65, 0x78, 0x70, 0x72, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x47, 0x6c, 0x6f, 0x62, 0x61, - 0x6c, 0x45, 0x6e, 0x75, 0x6d, 0x52, 0x07, 0x65, 0x6e, 0x75, 0x6d, 0x45, 0x78, 0x74, 0x2a, 0x27, - 0x0a, 0x0a, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x07, 0x0a, 0x03, - 0x47, 0x4f, 0x4f, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x47, 0x41, 0x52, 0x10, 0x01, 0x12, 0x07, - 0x0a, 0x03, 0x47, 0x41, 0x5a, 0x10, 0x02, 0x42, 0x28, 0x5a, 0x26, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x63, 0x65, 0x6c, - 0x2d, 0x67, 0x6f, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x70, - 0x62, + 0x61, 0x6d, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x66, 0x6f, 0x6f, 0x5f, 0x62, 0x61, 0x72, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x66, 0x6f, 0x6f, 0x42, 0x61, 0x72, 0x12, 0x0e, 0x0a, 0x02, + 0x69, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x6e, 0x2a, 0x08, 0x08, 0x64, + 0x10, 0x80, 0x80, 0x80, 0x80, 0x02, 0x22, 0xce, 0x01, 0x0a, 0x13, 0x45, 0x78, 0x74, 0x65, 0x6e, + 0x64, 0x65, 0x64, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x32, 0x51, + 0x0a, 0x11, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x64, 0x5f, 0x65, 0x78, 0x61, 0x6d, 0x70, + 0x6c, 0x65, 0x73, 0x12, 0x24, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x65, 0x78, 0x70, + 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x45, 0x78, + 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x18, 0x67, 0x20, 0x03, 0x28, 0x09, 0x52, + 0x10, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x64, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, + 0x73, 0x32, 0x64, 0x0a, 0x08, 0x65, 0x6e, 0x75, 0x6d, 0x5f, 0x65, 0x78, 0x74, 0x12, 0x24, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x65, 0x78, 0x70, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x32, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x54, + 0x79, 0x70, 0x65, 0x18, 0x68, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x23, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x65, 0x78, 0x70, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x2e, 0x74, + 0x65, 0x73, 0x74, 0x2e, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x45, 0x6e, 0x75, 0x6d, 0x52, 0x07, + 0x65, 0x6e, 0x75, 0x6d, 0x45, 0x78, 0x74, 0x2a, 0x27, 0x0a, 0x0a, 0x47, 0x6c, 0x6f, 0x62, 0x61, + 0x6c, 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x07, 0x0a, 0x03, 0x47, 0x4f, 0x4f, 0x10, 0x00, 0x12, 0x07, + 0x0a, 0x03, 0x47, 0x41, 0x52, 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x47, 0x41, 0x5a, 0x10, 0x02, + 0x42, 0x28, 0x5a, 0x26, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x63, 0x65, 0x6c, 0x2d, 0x67, 0x6f, 0x2f, 0x74, 0x65, 0x73, + 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x70, 0x62, } var ( diff --git a/test/proto2pb/test_all_types.proto b/test/proto2pb/test_all_types.proto index 41dcee1a..a77cc6d8 100644 --- a/test/proto2pb/test_all_types.proto +++ b/test/proto2pb/test_all_types.proto @@ -112,7 +112,8 @@ message NestedTestAllTypes { // with fully qualified names. message ExampleType { optional string name = 1; - optional int64 in = 2; + optional string foo_bar = 2; + optional int64 in = 3; extensions 100 to max; } diff --git a/test/proto2pb/test_extensions.pb.go b/test/proto2pb/test_extensions.pb.go index c9f02730..c951eade 100755 --- a/test/proto2pb/test_extensions.pb.go +++ b/test/proto2pb/test_extensions.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.5 +// protoc-gen-go v1.28.0 +// protoc v3.21.12 // source: test/proto2pb/test_extensions.proto package proto2pb @@ -21,6 +21,7 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// Message scoped extensions. type ExternalMessageType struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache diff --git a/test/proto3pb/test_all_types.pb.go b/test/proto3pb/test_all_types.pb.go index 0822214e..c6fcebfb 100755 --- a/test/proto3pb/test_all_types.pb.go +++ b/test/proto3pb/test_all_types.pb.go @@ -1,12 +1,15 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.5 +// protoc-gen-go v1.28.0 +// protoc v3.21.12 // source: test/proto3pb/test_all_types.proto package proto3pb import ( + reflect "reflect" + sync "sync" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" anypb "google.golang.org/protobuf/types/known/anypb" @@ -14,8 +17,6 @@ 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" ) const ( @@ -25,6 +26,7 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// This proto tests that global enums are resolved correctly. type GlobalEnum int32 const ( @@ -123,27 +125,31 @@ func (TestAllTypes_NestedEnum) EnumDescriptor() ([]byte, []int) { return file_test_proto3pb_test_all_types_proto_rawDescGZIP(), []int{0, 0} } +// This proto includes every type of field in both singular and repeated +// forms. type TestAllTypes struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - SingleInt32 int32 `protobuf:"varint,1,opt,name=single_int32,json=singleInt32,proto3" json:"single_int32,omitempty"` - SingleInt64 int64 `protobuf:"varint,2,opt,name=single_int64,json=singleInt64,proto3" json:"single_int64,omitempty"` - SingleUint32 uint32 `protobuf:"varint,3,opt,name=single_uint32,json=singleUint32,proto3" json:"single_uint32,omitempty"` - SingleUint64 uint64 `protobuf:"varint,4,opt,name=single_uint64,json=singleUint64,proto3" json:"single_uint64,omitempty"` - SingleSint32 int32 `protobuf:"zigzag32,5,opt,name=single_sint32,json=singleSint32,proto3" json:"single_sint32,omitempty"` - SingleSint64 int64 `protobuf:"zigzag64,6,opt,name=single_sint64,json=singleSint64,proto3" json:"single_sint64,omitempty"` - SingleFixed32 uint32 `protobuf:"fixed32,7,opt,name=single_fixed32,json=singleFixed32,proto3" json:"single_fixed32,omitempty"` - SingleFixed64 uint64 `protobuf:"fixed64,8,opt,name=single_fixed64,json=singleFixed64,proto3" json:"single_fixed64,omitempty"` - SingleSfixed32 int32 `protobuf:"fixed32,9,opt,name=single_sfixed32,json=singleSfixed32,proto3" json:"single_sfixed32,omitempty"` - SingleSfixed64 int64 `protobuf:"fixed64,10,opt,name=single_sfixed64,json=singleSfixed64,proto3" json:"single_sfixed64,omitempty"` - SingleFloat float32 `protobuf:"fixed32,11,opt,name=single_float,json=singleFloat,proto3" json:"single_float,omitempty"` - SingleDouble float64 `protobuf:"fixed64,12,opt,name=single_double,json=singleDouble,proto3" json:"single_double,omitempty"` - SingleBool bool `protobuf:"varint,13,opt,name=single_bool,json=singleBool,proto3" json:"single_bool,omitempty"` - SingleString string `protobuf:"bytes,14,opt,name=single_string,json=singleString,proto3" json:"single_string,omitempty"` - SingleBytes []byte `protobuf:"bytes,15,opt,name=single_bytes,json=singleBytes,proto3" json:"single_bytes,omitempty"` - StandaloneEnum TestAllTypes_NestedEnum `protobuf:"varint,22,opt,name=standalone_enum,json=standaloneEnum,proto3,enum=google.expr.proto3.test.TestAllTypes_NestedEnum" json:"standalone_enum,omitempty"` + // Singular + SingleInt32 int32 `protobuf:"varint,1,opt,name=single_int32,json=singleInt32,proto3" json:"single_int32,omitempty"` + SingleInt64 int64 `protobuf:"varint,2,opt,name=single_int64,json=singleInt64,proto3" json:"single_int64,omitempty"` + SingleUint32 uint32 `protobuf:"varint,3,opt,name=single_uint32,json=singleUint32,proto3" json:"single_uint32,omitempty"` + SingleUint64 uint64 `protobuf:"varint,4,opt,name=single_uint64,json=singleUint64,proto3" json:"single_uint64,omitempty"` + SingleSint32 int32 `protobuf:"zigzag32,5,opt,name=single_sint32,json=singleSint32,proto3" json:"single_sint32,omitempty"` + SingleSint64 int64 `protobuf:"zigzag64,6,opt,name=single_sint64,json=singleSint64,proto3" json:"single_sint64,omitempty"` + SingleFixed32 uint32 `protobuf:"fixed32,7,opt,name=single_fixed32,json=singleFixed32,proto3" json:"single_fixed32,omitempty"` + SingleFixed64 uint64 `protobuf:"fixed64,8,opt,name=single_fixed64,json=singleFixed64,proto3" json:"single_fixed64,omitempty"` + SingleSfixed32 int32 `protobuf:"fixed32,9,opt,name=single_sfixed32,json=singleSfixed32,proto3" json:"single_sfixed32,omitempty"` + SingleSfixed64 int64 `protobuf:"fixed64,10,opt,name=single_sfixed64,json=singleSfixed64,proto3" json:"single_sfixed64,omitempty"` + SingleFloat float32 `protobuf:"fixed32,11,opt,name=single_float,json=singleFloat,proto3" json:"single_float,omitempty"` + SingleDouble float64 `protobuf:"fixed64,12,opt,name=single_double,json=singleDouble,proto3" json:"single_double,omitempty"` + SingleBool bool `protobuf:"varint,13,opt,name=single_bool,json=singleBool,proto3" json:"single_bool,omitempty"` + SingleString string `protobuf:"bytes,14,opt,name=single_string,json=singleString,proto3" json:"single_string,omitempty"` + SingleBytes []byte `protobuf:"bytes,15,opt,name=single_bytes,json=singleBytes,proto3" json:"single_bytes,omitempty"` + StandaloneEnum TestAllTypes_NestedEnum `protobuf:"varint,22,opt,name=standalone_enum,json=standaloneEnum,proto3,enum=google.expr.proto3.test.TestAllTypes_NestedEnum" json:"standalone_enum,omitempty"` + // Wellknown. SingleAny *anypb.Any `protobuf:"bytes,100,opt,name=single_any,json=singleAny,proto3" json:"single_any,omitempty"` SingleDuration *durationpb.Duration `protobuf:"bytes,101,opt,name=single_duration,json=singleDuration,proto3" json:"single_duration,omitempty"` SingleTimestamp *timestamppb.Timestamp `protobuf:"bytes,102,opt,name=single_timestamp,json=singleTimestamp,proto3" json:"single_timestamp,omitempty"` @@ -158,11 +164,13 @@ type TestAllTypes struct { SingleStringWrapper *wrapperspb.StringValue `protobuf:"bytes,111,opt,name=single_string_wrapper,json=singleStringWrapper,proto3" json:"single_string_wrapper,omitempty"` SingleBoolWrapper *wrapperspb.BoolValue `protobuf:"bytes,112,opt,name=single_bool_wrapper,json=singleBoolWrapper,proto3" json:"single_bool_wrapper,omitempty"` SingleBytesWrapper *wrapperspb.BytesValue `protobuf:"bytes,113,opt,name=single_bytes_wrapper,json=singleBytesWrapper,proto3" json:"single_bytes_wrapper,omitempty"` - // Types that are assignable to NestedType: + // Nested messages // + // Types that are assignable to NestedType: // *TestAllTypes_SingleNestedMessage // *TestAllTypes_SingleNestedEnum - NestedType isTestAllTypes_NestedType `protobuf_oneof:"nested_type"` + NestedType isTestAllTypes_NestedType `protobuf_oneof:"nested_type"` + // Repeated RepeatedInt32 []int32 `protobuf:"varint,31,rep,packed,name=repeated_int32,json=repeatedInt32,proto3" json:"repeated_int32,omitempty"` RepeatedInt64 []int64 `protobuf:"varint,32,rep,packed,name=repeated_int64,json=repeatedInt64,proto3" json:"repeated_int64,omitempty"` RepeatedUint32 []uint32 `protobuf:"varint,33,rep,packed,name=repeated_uint32,json=repeatedUint32,proto3" json:"repeated_uint32,omitempty"` @@ -183,9 +191,11 @@ type TestAllTypes struct { RepeatedStringPiece []string `protobuf:"bytes,54,rep,name=repeated_string_piece,json=repeatedStringPiece,proto3" json:"repeated_string_piece,omitempty"` RepeatedCord []string `protobuf:"bytes,55,rep,name=repeated_cord,json=repeatedCord,proto3" json:"repeated_cord,omitempty"` RepeatedLazyMessage []*TestAllTypes_NestedMessage `protobuf:"bytes,57,rep,name=repeated_lazy_message,json=repeatedLazyMessage,proto3" json:"repeated_lazy_message,omitempty"` - MapStringString map[string]string `protobuf:"bytes,58,rep,name=map_string_string,json=mapStringString,proto3" json:"map_string_string,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - MapInt64NestedType map[int64]*NestedTestAllTypes `protobuf:"bytes,59,rep,name=map_int64_nested_type,json=mapInt64NestedType,proto3" json:"map_int64_nested_type,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - ImportedEnums []ImportedGlobalEnum `protobuf:"varint,60,rep,packed,name=imported_enums,json=importedEnums,proto3,enum=google.expr.proto3.test.ImportedGlobalEnum" json:"imported_enums,omitempty"` + // Map + MapStringString map[string]string `protobuf:"bytes,58,rep,name=map_string_string,json=mapStringString,proto3" json:"map_string_string,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + MapInt64NestedType map[int64]*NestedTestAllTypes `protobuf:"bytes,59,rep,name=map_int64_nested_type,json=mapInt64NestedType,proto3" json:"map_int64_nested_type,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + // Imports + ImportedEnums []ImportedGlobalEnum `protobuf:"varint,60,rep,packed,name=imported_enums,json=importedEnums,proto3,enum=google.expr.proto3.test.ImportedGlobalEnum" json:"imported_enums,omitempty"` } func (x *TestAllTypes) Reset() { @@ -628,6 +638,7 @@ func (*TestAllTypes_SingleNestedMessage) isTestAllTypes_NestedType() {} func (*TestAllTypes_SingleNestedEnum) isTestAllTypes_NestedType() {} +// This proto includes a recursively nested message. type NestedTestAllTypes struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -683,18 +694,110 @@ func (x *NestedTestAllTypes) GetPayload() *TestAllTypes { return nil } +// This proto tests json_name options +type TestJsonNames struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Int32SnakeCaseJsonName int32 `protobuf:"varint,1,opt,name=int32_snake_case_json_name,proto3" json:"int32_snake_case_json_name,omitempty"` + Int64CamelCaseJsonName int64 `protobuf:"varint,2,opt,name=int64_camel_case_json_name,json=int64CamelCaseJsonName,proto3" json:"int64_camel_case_json_name,omitempty"` + Uint32DefaultJsonName uint32 `protobuf:"varint,3,opt,name=uint32_default_json_name,json=uint32DefaultJsonName,proto3" json:"uint32_default_json_name,omitempty"` + Uint64CustomJsonName uint64 `protobuf:"varint,4,opt,name=uint64_custom_json_name,json=uint64-custom-json-name,proto3" json:"uint64_custom_json_name,omitempty"` + // Collides with normal field name. + StringJsonNameShadows string `protobuf:"bytes,5,opt,name=string_json_name_shadows,json=single_string,proto3" json:"string_json_name_shadows,omitempty"` + SingleString string `protobuf:"bytes,6,opt,name=single_string,json=singleString,proto3" json:"single_string,omitempty"` +} + +func (x *TestJsonNames) Reset() { + *x = TestJsonNames{} + if protoimpl.UnsafeEnabled { + mi := &file_test_proto3pb_test_all_types_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TestJsonNames) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TestJsonNames) ProtoMessage() {} + +func (x *TestJsonNames) ProtoReflect() protoreflect.Message { + mi := &file_test_proto3pb_test_all_types_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TestJsonNames.ProtoReflect.Descriptor instead. +func (*TestJsonNames) Descriptor() ([]byte, []int) { + return file_test_proto3pb_test_all_types_proto_rawDescGZIP(), []int{2} +} + +func (x *TestJsonNames) GetInt32SnakeCaseJsonName() int32 { + if x != nil { + return x.Int32SnakeCaseJsonName + } + return 0 +} + +func (x *TestJsonNames) GetInt64CamelCaseJsonName() int64 { + if x != nil { + return x.Int64CamelCaseJsonName + } + return 0 +} + +func (x *TestJsonNames) GetUint32DefaultJsonName() uint32 { + if x != nil { + return x.Uint32DefaultJsonName + } + return 0 +} + +func (x *TestJsonNames) GetUint64CustomJsonName() uint64 { + if x != nil { + return x.Uint64CustomJsonName + } + return 0 +} + +func (x *TestJsonNames) GetStringJsonNameShadows() string { + if x != nil { + return x.StringJsonNameShadows + } + return "" +} + +func (x *TestJsonNames) GetSingleString() string { + if x != nil { + return x.SingleString + } + return "" +} + type TestAllTypes_NestedMessage struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + // The field name "b" fails to compile in proto1 because it conflicts with + // a local variable named "b" in one of the generated methods. + // This file needs to compile in proto1 to test backwards-compatibility. Bb int32 `protobuf:"varint,1,opt,name=bb,proto3" json:"bb,omitempty"` } func (x *TestAllTypes_NestedMessage) Reset() { *x = TestAllTypes_NestedMessage{} if protoimpl.UnsafeEnabled { - mi := &file_test_proto3pb_test_all_types_proto_msgTypes[2] + mi := &file_test_proto3pb_test_all_types_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -707,7 +810,7 @@ func (x *TestAllTypes_NestedMessage) String() string { func (*TestAllTypes_NestedMessage) ProtoMessage() {} func (x *TestAllTypes_NestedMessage) ProtoReflect() protoreflect.Message { - mi := &file_test_proto3pb_test_all_types_proto_msgTypes[2] + mi := &file_test_proto3pb_test_all_types_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -977,12 +1080,34 @@ var file_test_proto3pb_test_all_types_proto_rawDesc = []byte{ 0x0b, 0x32, 0x25, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x65, 0x78, 0x70, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x41, 0x6c, 0x6c, 0x54, 0x79, 0x70, 0x65, 0x73, 0x52, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, - 0x64, 0x2a, 0x27, 0x0a, 0x0a, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x45, 0x6e, 0x75, 0x6d, 0x12, - 0x07, 0x0a, 0x03, 0x47, 0x4f, 0x4f, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x47, 0x41, 0x52, 0x10, - 0x01, 0x12, 0x07, 0x0a, 0x03, 0x47, 0x41, 0x5a, 0x10, 0x02, 0x42, 0x28, 0x5a, 0x26, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, - 0x63, 0x65, 0x6c, 0x2d, 0x67, 0x6f, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x64, 0x22, 0xd4, 0x02, 0x0a, 0x0d, 0x54, 0x65, 0x73, 0x74, 0x4a, 0x73, 0x6f, 0x6e, 0x4e, 0x61, + 0x6d, 0x65, 0x73, 0x12, 0x3e, 0x0a, 0x1a, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x5f, 0x73, 0x6e, 0x61, + 0x6b, 0x65, 0x5f, 0x63, 0x61, 0x73, 0x65, 0x5f, 0x6a, 0x73, 0x6f, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x1a, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x5f, 0x73, + 0x6e, 0x61, 0x6b, 0x65, 0x5f, 0x63, 0x61, 0x73, 0x65, 0x5f, 0x6a, 0x73, 0x6f, 0x6e, 0x5f, 0x6e, + 0x61, 0x6d, 0x65, 0x12, 0x3a, 0x0a, 0x1a, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x5f, 0x63, 0x61, 0x6d, + 0x65, 0x6c, 0x5f, 0x63, 0x61, 0x73, 0x65, 0x5f, 0x6a, 0x73, 0x6f, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x16, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x43, 0x61, + 0x6d, 0x65, 0x6c, 0x43, 0x61, 0x73, 0x65, 0x4a, 0x73, 0x6f, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x12, + 0x37, 0x0a, 0x18, 0x75, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x5f, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, + 0x74, 0x5f, 0x6a, 0x73, 0x6f, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0d, 0x52, 0x15, 0x75, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, + 0x4a, 0x73, 0x6f, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x38, 0x0a, 0x17, 0x75, 0x69, 0x6e, 0x74, + 0x36, 0x34, 0x5f, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x5f, 0x6a, 0x73, 0x6f, 0x6e, 0x5f, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x17, 0x75, 0x69, 0x6e, 0x74, 0x36, + 0x34, 0x2d, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x2d, 0x6a, 0x73, 0x6f, 0x6e, 0x2d, 0x6e, 0x61, + 0x6d, 0x65, 0x12, 0x2f, 0x0a, 0x18, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x6a, 0x73, 0x6f, + 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x73, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x5f, 0x73, 0x74, 0x72, + 0x69, 0x6e, 0x67, 0x12, 0x23, 0x0a, 0x0d, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x5f, 0x73, 0x74, + 0x72, 0x69, 0x6e, 0x67, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x73, 0x69, 0x6e, 0x67, + 0x6c, 0x65, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x2a, 0x27, 0x0a, 0x0a, 0x47, 0x6c, 0x6f, 0x62, + 0x61, 0x6c, 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x07, 0x0a, 0x03, 0x47, 0x4f, 0x4f, 0x10, 0x00, 0x12, + 0x07, 0x0a, 0x03, 0x47, 0x41, 0x52, 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x47, 0x41, 0x5a, 0x10, + 0x02, 0x42, 0x28, 0x5a, 0x26, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x63, 0x65, 0x6c, 0x2d, 0x67, 0x6f, 0x2f, 0x74, 0x65, + 0x73, 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -998,55 +1123,56 @@ func file_test_proto3pb_test_all_types_proto_rawDescGZIP() []byte { } var file_test_proto3pb_test_all_types_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_test_proto3pb_test_all_types_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_test_proto3pb_test_all_types_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_test_proto3pb_test_all_types_proto_goTypes = []interface{}{ (GlobalEnum)(0), // 0: google.expr.proto3.test.GlobalEnum (TestAllTypes_NestedEnum)(0), // 1: google.expr.proto3.test.TestAllTypes.NestedEnum (*TestAllTypes)(nil), // 2: google.expr.proto3.test.TestAllTypes (*NestedTestAllTypes)(nil), // 3: google.expr.proto3.test.NestedTestAllTypes - (*TestAllTypes_NestedMessage)(nil), // 4: google.expr.proto3.test.TestAllTypes.NestedMessage - nil, // 5: google.expr.proto3.test.TestAllTypes.MapStringStringEntry - nil, // 6: google.expr.proto3.test.TestAllTypes.MapInt64NestedTypeEntry - (*anypb.Any)(nil), // 7: google.protobuf.Any - (*durationpb.Duration)(nil), // 8: google.protobuf.Duration - (*timestamppb.Timestamp)(nil), // 9: google.protobuf.Timestamp - (*structpb.Struct)(nil), // 10: google.protobuf.Struct - (*structpb.Value)(nil), // 11: google.protobuf.Value - (*wrapperspb.Int64Value)(nil), // 12: google.protobuf.Int64Value - (*wrapperspb.Int32Value)(nil), // 13: google.protobuf.Int32Value - (*wrapperspb.DoubleValue)(nil), // 14: google.protobuf.DoubleValue - (*wrapperspb.FloatValue)(nil), // 15: google.protobuf.FloatValue - (*wrapperspb.UInt64Value)(nil), // 16: google.protobuf.UInt64Value - (*wrapperspb.UInt32Value)(nil), // 17: google.protobuf.UInt32Value - (*wrapperspb.StringValue)(nil), // 18: google.protobuf.StringValue - (*wrapperspb.BoolValue)(nil), // 19: google.protobuf.BoolValue - (*wrapperspb.BytesValue)(nil), // 20: google.protobuf.BytesValue - (ImportedGlobalEnum)(0), // 21: google.expr.proto3.test.ImportedGlobalEnum + (*TestJsonNames)(nil), // 4: google.expr.proto3.test.TestJsonNames + (*TestAllTypes_NestedMessage)(nil), // 5: google.expr.proto3.test.TestAllTypes.NestedMessage + nil, // 6: google.expr.proto3.test.TestAllTypes.MapStringStringEntry + nil, // 7: google.expr.proto3.test.TestAllTypes.MapInt64NestedTypeEntry + (*anypb.Any)(nil), // 8: google.protobuf.Any + (*durationpb.Duration)(nil), // 9: google.protobuf.Duration + (*timestamppb.Timestamp)(nil), // 10: google.protobuf.Timestamp + (*structpb.Struct)(nil), // 11: google.protobuf.Struct + (*structpb.Value)(nil), // 12: google.protobuf.Value + (*wrapperspb.Int64Value)(nil), // 13: google.protobuf.Int64Value + (*wrapperspb.Int32Value)(nil), // 14: google.protobuf.Int32Value + (*wrapperspb.DoubleValue)(nil), // 15: google.protobuf.DoubleValue + (*wrapperspb.FloatValue)(nil), // 16: google.protobuf.FloatValue + (*wrapperspb.UInt64Value)(nil), // 17: google.protobuf.UInt64Value + (*wrapperspb.UInt32Value)(nil), // 18: google.protobuf.UInt32Value + (*wrapperspb.StringValue)(nil), // 19: google.protobuf.StringValue + (*wrapperspb.BoolValue)(nil), // 20: google.protobuf.BoolValue + (*wrapperspb.BytesValue)(nil), // 21: google.protobuf.BytesValue + (ImportedGlobalEnum)(0), // 22: google.expr.proto3.test.ImportedGlobalEnum } var file_test_proto3pb_test_all_types_proto_depIdxs = []int32{ 1, // 0: google.expr.proto3.test.TestAllTypes.standalone_enum:type_name -> google.expr.proto3.test.TestAllTypes.NestedEnum - 7, // 1: google.expr.proto3.test.TestAllTypes.single_any:type_name -> google.protobuf.Any - 8, // 2: google.expr.proto3.test.TestAllTypes.single_duration:type_name -> google.protobuf.Duration - 9, // 3: google.expr.proto3.test.TestAllTypes.single_timestamp:type_name -> google.protobuf.Timestamp - 10, // 4: google.expr.proto3.test.TestAllTypes.single_struct:type_name -> google.protobuf.Struct - 11, // 5: google.expr.proto3.test.TestAllTypes.single_value:type_name -> google.protobuf.Value - 12, // 6: google.expr.proto3.test.TestAllTypes.single_int64_wrapper:type_name -> google.protobuf.Int64Value - 13, // 7: google.expr.proto3.test.TestAllTypes.single_int32_wrapper:type_name -> google.protobuf.Int32Value - 14, // 8: google.expr.proto3.test.TestAllTypes.single_double_wrapper:type_name -> google.protobuf.DoubleValue - 15, // 9: google.expr.proto3.test.TestAllTypes.single_float_wrapper:type_name -> google.protobuf.FloatValue - 16, // 10: google.expr.proto3.test.TestAllTypes.single_uint64_wrapper:type_name -> google.protobuf.UInt64Value - 17, // 11: google.expr.proto3.test.TestAllTypes.single_uint32_wrapper:type_name -> google.protobuf.UInt32Value - 18, // 12: google.expr.proto3.test.TestAllTypes.single_string_wrapper:type_name -> google.protobuf.StringValue - 19, // 13: google.expr.proto3.test.TestAllTypes.single_bool_wrapper:type_name -> google.protobuf.BoolValue - 20, // 14: google.expr.proto3.test.TestAllTypes.single_bytes_wrapper:type_name -> google.protobuf.BytesValue - 4, // 15: google.expr.proto3.test.TestAllTypes.single_nested_message:type_name -> google.expr.proto3.test.TestAllTypes.NestedMessage + 8, // 1: google.expr.proto3.test.TestAllTypes.single_any:type_name -> google.protobuf.Any + 9, // 2: google.expr.proto3.test.TestAllTypes.single_duration:type_name -> google.protobuf.Duration + 10, // 3: google.expr.proto3.test.TestAllTypes.single_timestamp:type_name -> google.protobuf.Timestamp + 11, // 4: google.expr.proto3.test.TestAllTypes.single_struct:type_name -> google.protobuf.Struct + 12, // 5: google.expr.proto3.test.TestAllTypes.single_value:type_name -> google.protobuf.Value + 13, // 6: google.expr.proto3.test.TestAllTypes.single_int64_wrapper:type_name -> google.protobuf.Int64Value + 14, // 7: google.expr.proto3.test.TestAllTypes.single_int32_wrapper:type_name -> google.protobuf.Int32Value + 15, // 8: google.expr.proto3.test.TestAllTypes.single_double_wrapper:type_name -> google.protobuf.DoubleValue + 16, // 9: google.expr.proto3.test.TestAllTypes.single_float_wrapper:type_name -> google.protobuf.FloatValue + 17, // 10: google.expr.proto3.test.TestAllTypes.single_uint64_wrapper:type_name -> google.protobuf.UInt64Value + 18, // 11: google.expr.proto3.test.TestAllTypes.single_uint32_wrapper:type_name -> google.protobuf.UInt32Value + 19, // 12: google.expr.proto3.test.TestAllTypes.single_string_wrapper:type_name -> google.protobuf.StringValue + 20, // 13: google.expr.proto3.test.TestAllTypes.single_bool_wrapper:type_name -> google.protobuf.BoolValue + 21, // 14: google.expr.proto3.test.TestAllTypes.single_bytes_wrapper:type_name -> google.protobuf.BytesValue + 5, // 15: google.expr.proto3.test.TestAllTypes.single_nested_message:type_name -> google.expr.proto3.test.TestAllTypes.NestedMessage 1, // 16: google.expr.proto3.test.TestAllTypes.single_nested_enum:type_name -> google.expr.proto3.test.TestAllTypes.NestedEnum - 4, // 17: google.expr.proto3.test.TestAllTypes.repeated_nested_message:type_name -> google.expr.proto3.test.TestAllTypes.NestedMessage + 5, // 17: google.expr.proto3.test.TestAllTypes.repeated_nested_message:type_name -> google.expr.proto3.test.TestAllTypes.NestedMessage 1, // 18: google.expr.proto3.test.TestAllTypes.repeated_nested_enum:type_name -> google.expr.proto3.test.TestAllTypes.NestedEnum - 4, // 19: google.expr.proto3.test.TestAllTypes.repeated_lazy_message:type_name -> google.expr.proto3.test.TestAllTypes.NestedMessage - 5, // 20: google.expr.proto3.test.TestAllTypes.map_string_string:type_name -> google.expr.proto3.test.TestAllTypes.MapStringStringEntry - 6, // 21: google.expr.proto3.test.TestAllTypes.map_int64_nested_type:type_name -> google.expr.proto3.test.TestAllTypes.MapInt64NestedTypeEntry - 21, // 22: google.expr.proto3.test.TestAllTypes.imported_enums:type_name -> google.expr.proto3.test.ImportedGlobalEnum + 5, // 19: google.expr.proto3.test.TestAllTypes.repeated_lazy_message:type_name -> google.expr.proto3.test.TestAllTypes.NestedMessage + 6, // 20: google.expr.proto3.test.TestAllTypes.map_string_string:type_name -> google.expr.proto3.test.TestAllTypes.MapStringStringEntry + 7, // 21: google.expr.proto3.test.TestAllTypes.map_int64_nested_type:type_name -> google.expr.proto3.test.TestAllTypes.MapInt64NestedTypeEntry + 22, // 22: google.expr.proto3.test.TestAllTypes.imported_enums:type_name -> google.expr.proto3.test.ImportedGlobalEnum 3, // 23: google.expr.proto3.test.NestedTestAllTypes.child:type_name -> google.expr.proto3.test.NestedTestAllTypes 2, // 24: google.expr.proto3.test.NestedTestAllTypes.payload:type_name -> google.expr.proto3.test.TestAllTypes 3, // 25: google.expr.proto3.test.TestAllTypes.MapInt64NestedTypeEntry.value:type_name -> google.expr.proto3.test.NestedTestAllTypes @@ -1089,6 +1215,18 @@ func file_test_proto3pb_test_all_types_proto_init() { } } file_test_proto3pb_test_all_types_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TestJsonNames); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_test_proto3pb_test_all_types_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*TestAllTypes_NestedMessage); i { case 0: return &v.state @@ -1111,7 +1249,7 @@ func file_test_proto3pb_test_all_types_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_test_proto3pb_test_all_types_proto_rawDesc, NumEnums: 2, - NumMessages: 5, + NumMessages: 6, NumExtensions: 0, NumServices: 0, }, diff --git a/test/proto3pb/test_all_types.proto b/test/proto3pb/test_all_types.proto index 086f38c9..f6e8f2c1 100644 --- a/test/proto3pb/test_all_types.proto +++ b/test/proto3pb/test_all_types.proto @@ -115,3 +115,22 @@ enum GlobalEnum { GAR = 1; GAZ = 2; } + +// This proto tests json_name options +message TestJsonNames { + int32 int32_snake_case_json_name = 1 + [json_name = "int32_snake_case_json_name"]; + int64 int64_camel_case_json_name = 2 [json_name = "int64CamelCaseJsonName"]; + uint32 uint32_default_json_name = 3; + uint64 uint64_custom_json_name = 4 [json_name = "uint64-custom-json-name"]; + + // Collides with normal field name. + string string_json_name_shadows = 5 [json_name = "single_string"]; + string single_string = 6; + + // protoc should fail on cases like these + // double double_json_shadow_default = 7 [json_name = "doubleJsonDefault"] + // double double_json_default = 8; + // double double_json_swapped_a = 7 [json_name = "double_json_swapped_b"]; + // double double_json_swapped_b = 8 [json_name = "double_json_swapped_a"]; +} \ No newline at end of file diff --git a/test/proto3pb/test_import.pb.go b/test/proto3pb/test_import.pb.go index bac8bd9c..0fa68f16 100755 --- a/test/proto3pb/test_import.pb.go +++ b/test/proto3pb/test_import.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.5 +// protoc-gen-go v1.28.0 +// protoc v3.21.12 // source: test/proto3pb/test_import.proto package proto3pb diff --git a/test/protos.md b/test/protos.md new file mode 100644 index 00000000..466ac362 --- /dev/null +++ b/test/protos.md @@ -0,0 +1,13 @@ +## How to regenerate protos + +Install protoc and protoc-go plugin + +https://protobuf.dev/installation/ +https://protobuf.dev/getting-started/gotutorial/ + +Run: +``` +protoc --proto_path=$(pwd) --go_out=$(pwd) --go_opt=paths=source_relative test/proto3pb/test_import.proto test/proto3pb/test_all_types.proto + +protoc --proto_path=$(pwd) --go_out=$(pwd) --go_opt=paths=source_relative test/proto2pb/test_extensions.proto test/proto2pb/test_all_types.proto +``` \ No newline at end of file From b92875a84008af055dba1316d831f99b6c09bd3b Mon Sep 17 00:00:00 2001 From: Jonathan Tatum Date: Thu, 26 Mar 2026 22:44:22 +0000 Subject: [PATCH 5/5] Fix type list test --- common/types/pb/file_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/common/types/pb/file_test.go b/common/types/pb/file_test.go index a27d097f..d0c4da60 100644 --- a/common/types/pb/file_test.go +++ b/common/types/pb/file_test.go @@ -100,6 +100,7 @@ func TestFileDescriptionGetTypes(t *testing.T) { "google.expr.proto3.test.TestAllTypes.NestedMessage", "google.expr.proto3.test.TestAllTypes.MapStringStringEntry", "google.expr.proto3.test.TestAllTypes.MapInt64NestedTypeEntry", + "google.expr.proto3.test.TestJsonNames", "google.expr.proto3.test.NestedTestAllTypes"} if len(fd.GetTypeNames()) != len(expected) { t.Errorf("got '%v', wanted '%v'", fd.GetTypeNames(), expected)