Skip to content

Commit

Permalink
Generate json and custom tags for oneof (#611) (#612)
Browse files Browse the repository at this point in the history
- add test case in tags.proto file
  • Loading branch information
krhubert authored and jmarais committed Sep 8, 2019
1 parent 23325ce commit 3f2ed6d
Show file tree
Hide file tree
Showing 28 changed files with 437 additions and 436 deletions.
24 changes: 12 additions & 12 deletions conformance/internal/conformance_proto/conformance.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions jsonpb/jsonpb_test_proto/test_objects.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion proto/proto3_proto/proto3.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 25 additions & 25 deletions proto/test_proto/test.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions protoc-gen-gogo/generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2581,10 +2581,8 @@ func (g *Generator) generateOneofDecls(mc *msgCtx, topLevelFields []topLevelFiel
g.P()
for _, of := range ofields {
for i, sf := range of.subFields {
_, wiretype := g.GoType(mc.message, sf.protoField)
tag := "protobuf:" + g.goTag(mc.message, sf.protoField, wiretype)
fieldFullPath := fmt.Sprintf("%s,%d,%d", mc.message.path, messageFieldPath, i)
g.P("type ", Annotate(mc.message.file, fieldFullPath, sf.oneofTypeName), " struct{ ", Annotate(mc.message.file, fieldFullPath, sf.goName), " ", sf.goType, " `", tag, "` }")
g.P("type ", Annotate(mc.message.file, fieldFullPath, sf.oneofTypeName), " struct{ ", Annotate(mc.message.file, fieldFullPath, sf.goName), " ", sf.goType, " `", sf.tags, "` }")
if !gogoproto.IsStdType(sf.protoField) && !gogoproto.IsCustomType(sf.protoField) && !gogoproto.IsCastType(sf.protoField) {
g.RecordTypeUse(sf.protoField.GetTypeName())
}
Expand Down Expand Up @@ -2932,7 +2930,6 @@ func (g *Generator) generateMessage(message *Descriptor) {
}

oneofField := oFields[*field.OneofIndex]
tag = "protobuf:" + g.goTag(message, field, wiretype)
sf := oneofSubField{
fieldCommon: fieldCommon{
goName: fieldName,
Expand Down
2 changes: 1 addition & 1 deletion protoc-gen-gogo/testdata/deprecated/deprecated.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions protoc-gen-gogo/testdata/import_public/sub/a.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions protoc-gen-gogo/testdata/my_test/test.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/issue322/issue322.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/issue617/issue617.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3f2ed6d

Please sign in to comment.