[protobuf] proto: support Marshal/UnmarshalBinary interfaces

64 views
Skip to first unread message

Gopher Robot (Gerrit)

unread,
Aug 8, 2023, 3:30:12 PM8/8/23
to Derek Perkins, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Congratulations on opening your first change. Thank you for your contribution!

Next steps:
A maintainer will review your change and provide feedback. See
https://go.dev/doc/contribute#review for more info and tips to get your
patch through code review.

Most changes in the Go project go through a few rounds of revision. This can be
surprising to people new to the project. The careful, iterative review process
is our way of helping mentor contributors and ensuring that their contributions
have a lasting impact.

View Change

    To view, visit change 517315. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-MessageType: comment
    Gerrit-Project: protobuf
    Gerrit-Branch: master
    Gerrit-Change-Id: Iafd236b611b0f5d96da0b4b271aa96382de8dd48
    Gerrit-Change-Number: 517315
    Gerrit-PatchSet: 1
    Gerrit-Owner: Derek Perkins <de...@nozzle.io>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-Comment-Date: Tue, 08 Aug 2023 19:30:07 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: No

    Derek Perkins (Gerrit)

    unread,
    Aug 8, 2023, 11:09:19 PM8/8/23
    to goph...@pubsubhelper.golang.org, Gopher Robot, golang-co...@googlegroups.com

    To view, visit change 517315. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-MessageType: comment
    Gerrit-Project: protobuf
    Gerrit-Branch: master
    Gerrit-Change-Id: Iafd236b611b0f5d96da0b4b271aa96382de8dd48
    Gerrit-Change-Number: 517315
    Gerrit-PatchSet: 1
    Gerrit-Owner: Derek Perkins <de...@nozzle.io>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-Comment-Date: Tue, 08 Aug 2023 19:33:33 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No

    Derek Perkins (Gerrit)

    unread,
    Aug 8, 2023, 11:14:15 PM8/8/23
    to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

    Derek Perkins has uploaded this change for review.

    View Change

    proto: support Marshal/UnmarshalBinary interfaces

    Change-Id: Iafd236b611b0f5d96da0b4b271aa96382de8dd48
    ---
    M cmd/protoc-gen-go/internal_gengo/main.go
    M cmd/protoc-gen-go/testdata/annotations/annotations.pb.go
    M cmd/protoc-gen-go/testdata/comments/comments.pb.go
    M cmd/protoc-gen-go/testdata/comments/deprecated.pb.go
    M cmd/protoc-gen-go/testdata/extensions/base/base.pb.go
    M cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go
    M cmd/protoc-gen-go/testdata/extensions/extra/extra.pb.go
    M cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go
    M cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go
    M cmd/protoc-gen-go/testdata/import_public/a.pb.go
    M cmd/protoc-gen-go/testdata/import_public/b.pb.go
    M cmd/protoc-gen-go/testdata/import_public/c.pb.go
    M cmd/protoc-gen-go/testdata/import_public/sub/a.pb.go
    M cmd/protoc-gen-go/testdata/import_public/sub/b.pb.go
    M cmd/protoc-gen-go/testdata/import_public/sub2/a.pb.go
    M cmd/protoc-gen-go/testdata/imports/fmt/m.pb.go
    M cmd/protoc-gen-go/testdata/imports/test_a_1/m1.pb.go
    M cmd/protoc-gen-go/testdata/imports/test_a_1/m2.pb.go
    M cmd/protoc-gen-go/testdata/imports/test_a_2/m3.pb.go
    M cmd/protoc-gen-go/testdata/imports/test_a_2/m4.pb.go
    M cmd/protoc-gen-go/testdata/imports/test_b_1/m1.pb.go
    M cmd/protoc-gen-go/testdata/imports/test_b_1/m2.pb.go
    M cmd/protoc-gen-go/testdata/imports/test_import_a1m1.pb.go
    M cmd/protoc-gen-go/testdata/imports/test_import_a1m2.pb.go
    M cmd/protoc-gen-go/testdata/imports/test_import_all.pb.go
    M cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.pb.go
    M cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go
    M cmd/protoc-gen-go/testdata/proto2/enum.pb.go
    M cmd/protoc-gen-go/testdata/proto2/fields.pb.go
    M cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go
    M cmd/protoc-gen-go/testdata/proto2/proto2.pb.go
    M cmd/protoc-gen-go/testdata/proto3/fields.pb.go
    M cmd/protoc-gen-go/testdata/retention/options_message.pb.go
    M cmd/protoc-gen-go/testdata/retention/retention.pb.go
    M internal/testprotos/benchmarks/micro/micro.pb.go
    M internal/testprotos/conformance/conformance.pb.go
    M internal/testprotos/conformance/test_messages_proto2.pb.go
    M internal/testprotos/conformance/test_messages_proto3.pb.go
    M internal/testprotos/fieldtrack/fieldtrack.pb.go
    M internal/testprotos/fuzz/fuzz.pb.go
    M internal/testprotos/irregular/test.pb.go
    M internal/testprotos/legacy/legacy.pb.go
    M internal/testprotos/messageset/messagesetpb/message_set.pb.go
    M internal/testprotos/messageset/msetextpb/msetextpb.pb.go
    M internal/testprotos/news/news.pb.go
    M internal/testprotos/order/order.pb.go
    M internal/testprotos/registry/test.pb.go
    M internal/testprotos/required/required.pb.go
    M internal/testprotos/test/test.pb.go
    M internal/testprotos/test/test_import.pb.go
    M internal/testprotos/test/test_public.pb.go
    M internal/testprotos/test/weak1/test_weak.pb.go
    M internal/testprotos/test/weak2/test_weak.pb.go
    M internal/testprotos/test3/test.pb.go
    M internal/testprotos/test3/test_import.pb.go
    M internal/testprotos/textpb2/test.pb.go
    M internal/testprotos/textpb3/test.pb.go
    M types/descriptorpb/descriptor.pb.go
    M types/known/anypb/any.pb.go
    M types/known/apipb/api.pb.go
    M types/known/durationpb/duration.pb.go
    M types/known/emptypb/empty.pb.go
    M types/known/fieldmaskpb/field_mask.pb.go
    M types/known/sourcecontextpb/source_context.pb.go
    M types/known/structpb/struct.pb.go
    M types/known/timestamppb/timestamp.pb.go
    M types/known/typepb/type.pb.go
    M types/known/wrapperspb/wrappers.pb.go
    M types/pluginpb/plugin.pb.go
    69 files changed, 2,563 insertions(+), 0 deletions(-)

    diff --git a/cmd/protoc-gen-go/internal_gengo/main.go b/cmd/protoc-gen-go/internal_gengo/main.go
    index 8cae432..463d718 100644
    --- a/cmd/protoc-gen-go/internal_gengo/main.go
    +++ b/cmd/protoc-gen-go/internal_gengo/main.go
    @@ -502,6 +502,8 @@
    genMessageBaseMethods(g, f, m)
    genMessageGetterMethods(g, f, m)
    genMessageSetterMethods(g, f, m)
    + genMessageMarshalBinaryMethods(g, f, m)
    + genMessageUnmarshalBinaryMethods(g, f, m)
    }

    func genMessageBaseMethods(g *protogen.GeneratedFile, f *fileInfo, m *messageInfo) {
    @@ -635,6 +637,24 @@
    }
    }

    +func genMessageMarshalBinaryMethods(g *protogen.GeneratedFile, f *fileInfo, m *messageInfo) {
    + g.P()
    + g.P("// MarshalBinary implements encoding.BinaryMarshaler")
    + g.P("func (x *", m.GoIdent, ") MarshalBinary() ([]byte, error) {")
    + g.P("return ", g.QualifiedGoIdent(protogen.GoIdent{GoName: "Marshal", GoImportPath: "google.golang.org/protobuf/proto"}), "(x)")
    + g.P("}")
    + g.P()
    +}
    +
    +func genMessageUnmarshalBinaryMethods(g *protogen.GeneratedFile, f *fileInfo, m *messageInfo) {
    + g.P()
    + g.P("// UnmarshalBinary implements encoding.BinaryUnmarshaler")
    + g.P("func (x *", m.GoIdent, ") UnmarshalBinary(data []byte) error {")
    + g.P("return ", g.QualifiedGoIdent(protogen.GoIdent{GoName: "Unmarshal", GoImportPath: "google.golang.org/protobuf/proto"}), "(data, x)")
    + g.P("}")
    + g.P()
    +}
    +
    // fieldGoType returns the Go type used for a field.
    //
    // If it returns pointer=true, the struct field is a pointer to the type.
    diff --git a/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go b/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go
    index 91caa37..6bcaab2 100644
    --- a/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go
    +++ b/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go
    @@ -133,6 +133,16 @@
    protoimpl.X.SetWeak(w, 2, "fmt.M", v)
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *AnnotationsTestMessage) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *AnnotationsTestMessage) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_cmd_protoc_gen_go_testdata_annotations_annotations_proto protoreflect.FileDescriptor

    var file_cmd_protoc_gen_go_testdata_annotations_annotations_proto_rawDesc = []byte{
    diff --git a/cmd/protoc-gen-go/testdata/comments/comments.pb.go b/cmd/protoc-gen-go/testdata/comments/comments.pb.go
    index e0e34e4..9d6bb66 100644
    --- a/cmd/protoc-gen-go/testdata/comments/comments.pb.go
    +++ b/cmd/protoc-gen-go/testdata/comments/comments.pb.go
    @@ -10,6 +10,7 @@
    package comments

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -145,6 +146,16 @@
    return ""
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Message1) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Message1) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type isMessage1_Oneof1A interface {
    isMessage1_Oneof1A()
    }
    @@ -195,6 +206,16 @@
    return file_cmd_protoc_gen_go_testdata_comments_comments_proto_rawDescGZIP(), []int{1}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Message2) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Message2) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // COMMENT: Message1A.Leading
    type Message1_Message1A struct {
    state protoimpl.MessageState
    @@ -234,6 +255,16 @@
    return file_cmd_protoc_gen_go_testdata_comments_comments_proto_rawDescGZIP(), []int{0, 0}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Message1_Message1A) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Message1_Message1A) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // COMMENT: Message1B
    type Message1_Message1B struct {
    state protoimpl.MessageState
    @@ -273,6 +304,16 @@
    return file_cmd_protoc_gen_go_testdata_comments_comments_proto_rawDescGZIP(), []int{0, 1}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Message1_Message1B) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Message1_Message1B) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // COMMENT: Message2A
    type Message2_Message2A struct {
    state protoimpl.MessageState
    @@ -312,6 +353,16 @@
    return file_cmd_protoc_gen_go_testdata_comments_comments_proto_rawDescGZIP(), []int{1, 0}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Message2_Message2A) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Message2_Message2A) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // COMMENT: Message2B
    type Message2_Message2B struct {
    state protoimpl.MessageState
    @@ -351,6 +402,16 @@
    return file_cmd_protoc_gen_go_testdata_comments_comments_proto_rawDescGZIP(), []int{1, 1}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Message2_Message2B) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Message2_Message2B) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var file_cmd_protoc_gen_go_testdata_comments_comments_proto_extTypes = []protoimpl.ExtensionInfo{
    {
    ExtendedType: (*Message1)(nil),
    diff --git a/cmd/protoc-gen-go/testdata/comments/deprecated.pb.go b/cmd/protoc-gen-go/testdata/comments/deprecated.pb.go
    index 906a421..33e25db 100644
    --- a/cmd/protoc-gen-go/testdata/comments/deprecated.pb.go
    +++ b/cmd/protoc-gen-go/testdata/comments/deprecated.pb.go
    @@ -8,6 +8,7 @@
    package comments

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -109,6 +110,16 @@
    return ""
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *DeprecatedMessage) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *DeprecatedMessage) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_cmd_protoc_gen_go_testdata_comments_deprecated_proto protoreflect.FileDescriptor

    var file_cmd_protoc_gen_go_testdata_comments_deprecated_proto_rawDesc = []byte{
    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 4e412ab..f76bb92 100644
    --- a/cmd/protoc-gen-go/testdata/extensions/base/base.pb.go
    +++ b/cmd/protoc-gen-go/testdata/extensions/base/base.pb.go
    @@ -8,6 +8,7 @@
    package base

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -62,6 +63,16 @@
    return ""
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *BaseMessage) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *BaseMessage) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type MessageSetWireFormatMessage struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -101,6 +112,16 @@
    return file_cmd_protoc_gen_go_testdata_extensions_base_base_proto_rawDescGZIP(), []int{1}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *MessageSetWireFormatMessage) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *MessageSetWireFormatMessage) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_cmd_protoc_gen_go_testdata_extensions_base_base_proto protoreflect.FileDescriptor

    var file_cmd_protoc_gen_go_testdata_extensions_base_base_proto_rawDesc = []byte{
    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 c712715..8c35119 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 (
    base "google.golang.org/protobuf/cmd/protoc-gen-go/testdata/extensions/base"
    extra "google.golang.org/protobuf/cmd/protoc-gen-go/testdata/extensions/extra"
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -116,6 +117,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Message) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Message) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type ExtensionGroup struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -163,6 +174,16 @@
    return ""
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *ExtensionGroup) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *ExtensionGroup) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Extend in the scope of another type.
    type ExtendingMessage struct {
    state protoimpl.MessageState
    @@ -202,6 +223,16 @@
    return file_cmd_protoc_gen_go_testdata_extensions_ext_ext_proto_rawDescGZIP(), []int{2}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *ExtendingMessage) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *ExtendingMessage) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type RepeatedGroup struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -249,6 +280,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *RepeatedGroup) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *RepeatedGroup) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // An extension of an extension.
    type Extendable struct {
    state protoimpl.MessageState
    @@ -289,6 +330,16 @@
    return file_cmd_protoc_gen_go_testdata_extensions_ext_ext_proto_rawDescGZIP(), []int{4}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Extendable) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Extendable) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Message set wire format.
    type MessageSetWireFormatExtension struct {
    state protoimpl.MessageState
    @@ -328,6 +379,16 @@
    return file_cmd_protoc_gen_go_testdata_extensions_ext_ext_proto_rawDescGZIP(), []int{5}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *MessageSetWireFormatExtension) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *MessageSetWireFormatExtension) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type Message_M struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -366,6 +427,16 @@
    return file_cmd_protoc_gen_go_testdata_extensions_ext_ext_proto_rawDescGZIP(), []int{0, 0}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Message_M) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Message_M) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type ExtendingMessage_ExtendingMessageSubmessage struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -404,6 +475,16 @@
    return file_cmd_protoc_gen_go_testdata_extensions_ext_ext_proto_rawDescGZIP(), []int{2, 0}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *ExtendingMessage_ExtendingMessageSubmessage) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *ExtendingMessage_ExtendingMessageSubmessage) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var file_cmd_protoc_gen_go_testdata_extensions_ext_ext_proto_extTypes = []protoimpl.ExtensionInfo{
    {
    ExtendedType: (*base.BaseMessage)(nil),
    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 c056c4b..db18425 100644
    --- a/cmd/protoc-gen-go/testdata/extensions/extra/extra.pb.go
    +++ b/cmd/protoc-gen-go/testdata/extensions/extra/extra.pb.go
    @@ -8,6 +8,7 @@
    package extra

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -61,6 +62,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *ExtraMessage) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *ExtraMessage) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_cmd_protoc_gen_go_testdata_extensions_extra_extra_proto protoreflect.FileDescriptor

    var file_cmd_protoc_gen_go_testdata_extensions_extra_extra_proto_rawDesc = []byte{
    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 586f7c8..f84eaf9 100644
    --- a/cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go
    +++ b/cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go
    @@ -8,6 +8,7 @@
    package proto3

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    descriptorpb "google.golang.org/protobuf/types/descriptorpb"
    @@ -96,6 +97,16 @@
    return file_cmd_protoc_gen_go_testdata_extensions_proto3_ext3_proto_rawDescGZIP(), []int{0}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Message) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Message) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var file_cmd_protoc_gen_go_testdata_extensions_proto3_ext3_proto_extTypes = []protoimpl.ExtensionInfo{
    {
    ExtendedType: (*descriptorpb.MessageOptions)(nil),
    diff --git a/cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go b/cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go
    index be53265..9aa1f66 100644
    --- a/cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go
    +++ b/cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go
    @@ -8,6 +8,7 @@
    package fieldnames

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -242,6 +243,16 @@
    return ""
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Message) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Message) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type isMessage_OneofConflictA_ interface {
    isMessage_OneofConflictA_()
    }
    @@ -316,6 +327,16 @@
    return file_cmd_protoc_gen_go_testdata_fieldnames_fieldnames_proto_rawDescGZIP(), []int{0, 0}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Message_OneofMessageConflict) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Message_OneofMessageConflict) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_cmd_protoc_gen_go_testdata_fieldnames_fieldnames_proto protoreflect.FileDescriptor

    var file_cmd_protoc_gen_go_testdata_fieldnames_fieldnames_proto_rawDesc = []byte{
    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 e00b548..62b9503 100644
    --- a/cmd/protoc-gen-go/testdata/import_public/a.pb.go
    +++ b/cmd/protoc-gen-go/testdata/import_public/a.pb.go
    @@ -9,6 +9,7 @@

    import (
    sub "google.golang.org/protobuf/cmd/protoc-gen-go/testdata/import_public/sub"
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -116,6 +117,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Public) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Public) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_cmd_protoc_gen_go_testdata_import_public_a_proto protoreflect.FileDescriptor

    var file_cmd_protoc_gen_go_testdata_import_public_a_proto_rawDesc = []byte{
    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 6854157..c17c3a7 100644
    --- a/cmd/protoc-gen-go/testdata/import_public/b.pb.go
    +++ b/cmd/protoc-gen-go/testdata/import_public/b.pb.go
    @@ -9,6 +9,7 @@

    import (
    sub "google.golang.org/protobuf/cmd/protoc-gen-go/testdata/import_public/sub"
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -70,6 +71,16 @@
    return sub.E(0)
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Local) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Local) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_cmd_protoc_gen_go_testdata_import_public_b_proto protoreflect.FileDescriptor

    var file_cmd_protoc_gen_go_testdata_import_public_b_proto_rawDesc = []byte{
    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 ee2dbea..43855ba 100644
    --- a/cmd/protoc-gen-go/testdata/import_public/c.pb.go
    +++ b/cmd/protoc-gen-go/testdata/import_public/c.pb.go
    @@ -9,6 +9,7 @@

    import (
    sub2 "google.golang.org/protobuf/cmd/protoc-gen-go/testdata/import_public/sub2"
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -73,6 +74,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *UsingPublicImport) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *UsingPublicImport) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_cmd_protoc_gen_go_testdata_import_public_c_proto protoreflect.FileDescriptor

    var file_cmd_protoc_gen_go_testdata_import_public_c_proto_rawDesc = []byte{
    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 7f83f6d..4890880 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
    @@ -9,6 +9,7 @@

    import (
    sub2 "google.golang.org/protobuf/cmd/protoc-gen-go/testdata/import_public/sub2"
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    math "math"
    @@ -289,6 +290,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *M) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *M) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type isM_OneofField interface {
    isM_OneofField()
    }
    @@ -370,6 +381,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *M_Submessage) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *M_Submessage) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type isM_Submessage_SubmessageOneofField interface {
    isM_Submessage_SubmessageOneofField()
    }
    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 5679e95..38dea75 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
    @@ -8,6 +8,7 @@
    package sub

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -52,6 +53,16 @@
    return file_cmd_protoc_gen_go_testdata_import_public_sub_b_proto_rawDescGZIP(), []int{0}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *M2) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *M2) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_cmd_protoc_gen_go_testdata_import_public_sub_b_proto protoreflect.FileDescriptor

    var file_cmd_protoc_gen_go_testdata_import_public_sub_b_proto_rawDesc = []byte{
    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 98499fd..10ebaee 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
    @@ -8,6 +8,7 @@
    package sub2

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -52,6 +53,16 @@
    return file_cmd_protoc_gen_go_testdata_import_public_sub2_a_proto_rawDescGZIP(), []int{0}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Sub2Message) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Sub2Message) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_cmd_protoc_gen_go_testdata_import_public_sub2_a_proto protoreflect.FileDescriptor

    var file_cmd_protoc_gen_go_testdata_import_public_sub2_a_proto_rawDesc = []byte{
    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 7d89146..0e65fbe 100644
    --- a/cmd/protoc-gen-go/testdata/imports/fmt/m.pb.go
    +++ b/cmd/protoc-gen-go/testdata/imports/fmt/m.pb.go
    @@ -8,6 +8,7 @@
    package fmt

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -52,6 +53,16 @@
    return file_cmd_protoc_gen_go_testdata_imports_fmt_m_proto_rawDescGZIP(), []int{0}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *M) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *M) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_cmd_protoc_gen_go_testdata_imports_fmt_m_proto protoreflect.FileDescriptor

    var file_cmd_protoc_gen_go_testdata_imports_fmt_m_proto_rawDesc = []byte{
    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 363f0b7..a8e6787 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
    @@ -8,6 +8,7 @@
    package test_a_1

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -95,6 +96,16 @@
    return file_cmd_protoc_gen_go_testdata_imports_test_a_1_m1_proto_rawDescGZIP(), []int{0}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *M1) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *M1) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type M1_1 struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -142,6 +153,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *M1_1) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *M1_1) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_cmd_protoc_gen_go_testdata_imports_test_a_1_m1_proto protoreflect.FileDescriptor

    var file_cmd_protoc_gen_go_testdata_imports_test_a_1_m1_proto_rawDesc = []byte{
    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 9787321..1f85430 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
    @@ -8,6 +8,7 @@
    package test_a_1

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -52,6 +53,16 @@
    return file_cmd_protoc_gen_go_testdata_imports_test_a_1_m2_proto_rawDescGZIP(), []int{0}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *M2) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *M2) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_cmd_protoc_gen_go_testdata_imports_test_a_1_m2_proto protoreflect.FileDescriptor

    var file_cmd_protoc_gen_go_testdata_imports_test_a_1_m2_proto_rawDesc = []byte{
    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 3eabde1..caf3120 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
    @@ -8,6 +8,7 @@
    package test_a_2

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -52,6 +53,16 @@
    return file_cmd_protoc_gen_go_testdata_imports_test_a_2_m3_proto_rawDescGZIP(), []int{0}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *M3) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *M3) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_cmd_protoc_gen_go_testdata_imports_test_a_2_m3_proto protoreflect.FileDescriptor

    var file_cmd_protoc_gen_go_testdata_imports_test_a_2_m3_proto_rawDesc = []byte{
    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 be5ec6c..93a343a 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
    @@ -8,6 +8,7 @@
    package test_a_2

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -52,6 +53,16 @@
    return file_cmd_protoc_gen_go_testdata_imports_test_a_2_m4_proto_rawDescGZIP(), []int{0}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *M4) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *M4) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_cmd_protoc_gen_go_testdata_imports_test_a_2_m4_proto protoreflect.FileDescriptor

    var file_cmd_protoc_gen_go_testdata_imports_test_a_2_m4_proto_rawDesc = []byte{
    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 238ee72..3071c74 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
    @@ -8,6 +8,7 @@
    package beta

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -52,6 +53,16 @@
    return file_cmd_protoc_gen_go_testdata_imports_test_b_1_m1_proto_rawDescGZIP(), []int{0}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *M1) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *M1) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_cmd_protoc_gen_go_testdata_imports_test_b_1_m1_proto protoreflect.FileDescriptor

    var file_cmd_protoc_gen_go_testdata_imports_test_b_1_m1_proto_rawDesc = []byte{
    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 7288013..25b75e6 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
    @@ -8,6 +8,7 @@
    package beta

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -52,6 +53,16 @@
    return file_cmd_protoc_gen_go_testdata_imports_test_b_1_m2_proto_rawDescGZIP(), []int{0}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *M2) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *M2) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_cmd_protoc_gen_go_testdata_imports_test_b_1_m2_proto protoreflect.FileDescriptor

    var file_cmd_protoc_gen_go_testdata_imports_test_b_1_m2_proto_rawDesc = []byte{
    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 155c285..3ceb1dc 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
    @@ -9,6 +9,7 @@

    import (
    test_a_1 "google.golang.org/protobuf/cmd/protoc-gen-go/testdata/imports/test_a_1"
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -62,6 +63,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *A1M1) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *A1M1) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_cmd_protoc_gen_go_testdata_imports_test_import_a1m1_proto protoreflect.FileDescriptor

    var file_cmd_protoc_gen_go_testdata_imports_test_import_a1m1_proto_rawDesc = []byte{
    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 bbb0cfb..bc19592 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
    @@ -9,6 +9,7 @@

    import (
    test_a_1 "google.golang.org/protobuf/cmd/protoc-gen-go/testdata/imports/test_a_1"
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -62,6 +63,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *A1M2) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *A1M2) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_cmd_protoc_gen_go_testdata_imports_test_import_a1m2_proto protoreflect.FileDescriptor

    var file_cmd_protoc_gen_go_testdata_imports_test_import_a1m2_proto_rawDesc = []byte{
    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 288e524..68ed0f4 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
    @@ -12,6 +12,7 @@
    test_a_1 "google.golang.org/protobuf/cmd/protoc-gen-go/testdata/imports/test_a_1"
    _ "google.golang.org/protobuf/cmd/protoc-gen-go/testdata/imports/test_a_2"
    test_b_1 "google.golang.org/protobuf/cmd/protoc-gen-go/testdata/imports/test_b_1"
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -97,6 +98,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *All) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *All) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_cmd_protoc_gen_go_testdata_imports_test_import_all_proto protoreflect.FileDescriptor

    var file_cmd_protoc_gen_go_testdata_imports_test_import_all_proto_rawDesc = []byte{
    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 40c0ada..486498a 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
    @@ -8,6 +8,7 @@
    package issue780_oneof_conflict

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -71,6 +72,16 @@
    return ""
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Foo) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Foo) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type isFoo_Bar interface {
    isFoo_Bar()
    }
    diff --git a/cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go b/cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go
    index a81e001..5596c0c 100644
    --- a/cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go
    +++ b/cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go
    @@ -8,6 +8,7 @@
    package nopackage

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -127,6 +128,16 @@
    return Default_Message_EnumField
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Message) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Message) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_cmd_protoc_gen_go_testdata_nopackage_nopackage_proto protoreflect.FileDescriptor

    var file_cmd_protoc_gen_go_testdata_nopackage_nopackage_proto_rawDesc = []byte{
    diff --git a/cmd/protoc-gen-go/testdata/proto2/enum.pb.go b/cmd/protoc-gen-go/testdata/proto2/enum.pb.go
    index c031b39..281d3e7 100644
    --- a/cmd/protoc-gen-go/testdata/proto2/enum.pb.go
    +++ b/cmd/protoc-gen-go/testdata/proto2/enum.pb.go
    @@ -8,6 +8,7 @@
    package proto2

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -406,6 +407,16 @@
    return Default_EnumContainerMessage1_DefaultDuplicate2
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *EnumContainerMessage1) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *EnumContainerMessage1) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type EnumContainerMessage1_EnumContainerMessage2 struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -444,6 +455,16 @@
    return file_cmd_protoc_gen_go_testdata_proto2_enum_proto_rawDescGZIP(), []int{0, 0}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *EnumContainerMessage1_EnumContainerMessage2) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *EnumContainerMessage1_EnumContainerMessage2) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_cmd_protoc_gen_go_testdata_proto2_enum_proto protoreflect.FileDescriptor

    var file_cmd_protoc_gen_go_testdata_proto2_enum_proto_rawDesc = []byte{
    diff --git a/cmd/protoc-gen-go/testdata/proto2/fields.pb.go b/cmd/protoc-gen-go/testdata/proto2/fields.pb.go
    index ee9546a..175d659 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 @@
    package proto2

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    math "math"
    @@ -978,6 +979,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *FieldTestMessage) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *FieldTestMessage) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type isFieldTestMessage_OneofField interface {
    isFieldTestMessage_OneofField()
    }
    @@ -1159,6 +1170,16 @@
    return ""
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *FieldTestMessage_OptionalGroup) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *FieldTestMessage_OptionalGroup) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type FieldTestMessage_RequiredGroup struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -1206,6 +1227,16 @@
    return ""
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *FieldTestMessage_RequiredGroup) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *FieldTestMessage_RequiredGroup) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type FieldTestMessage_RepeatedGroup struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -1253,6 +1284,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *FieldTestMessage_RepeatedGroup) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *FieldTestMessage_RepeatedGroup) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type FieldTestMessage_OneofGroup struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -1300,6 +1341,16 @@
    return ""
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *FieldTestMessage_OneofGroup) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *FieldTestMessage_OneofGroup) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type FieldTestMessage_Message struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -1338,6 +1389,16 @@
    return file_cmd_protoc_gen_go_testdata_proto2_fields_proto_rawDescGZIP(), []int{0, 7}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *FieldTestMessage_Message) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *FieldTestMessage_Message) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_cmd_protoc_gen_go_testdata_proto2_fields_proto protoreflect.FileDescriptor

    var file_cmd_protoc_gen_go_testdata_proto2_fields_proto_rawDesc = []byte{
    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 9e7137a..569f9fc 100644
    --- a/cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go
    +++ b/cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go
    @@ -8,6 +8,7 @@
    package proto2

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -69,6 +70,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Layer1) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Layer1) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type Layer1_Layer2 struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -116,6 +127,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Layer1_Layer2) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Layer1_Layer2) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type Layer1_Layer2_Layer3 struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -154,6 +175,16 @@
    return file_cmd_protoc_gen_go_testdata_proto2_nested_messages_proto_rawDescGZIP(), []int{0, 0, 0}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Layer1_Layer2_Layer3) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Layer1_Layer2_Layer3) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_cmd_protoc_gen_go_testdata_proto2_nested_messages_proto protoreflect.FileDescriptor

    var file_cmd_protoc_gen_go_testdata_proto2_nested_messages_proto_rawDesc = []byte{
    diff --git a/cmd/protoc-gen-go/testdata/proto2/proto2.pb.go b/cmd/protoc-gen-go/testdata/proto2/proto2.pb.go
    index 5a4f97d..58d9cc5 100644
    --- a/cmd/protoc-gen-go/testdata/proto2/proto2.pb.go
    +++ b/cmd/protoc-gen-go/testdata/proto2/proto2.pb.go
    @@ -8,6 +8,7 @@
    package proto2

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -69,6 +70,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Message) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Message) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_cmd_protoc_gen_go_testdata_proto2_proto2_proto protoreflect.FileDescriptor

    var file_cmd_protoc_gen_go_testdata_proto2_proto2_proto_rawDesc = []byte{
    diff --git a/cmd/protoc-gen-go/testdata/proto3/fields.pb.go b/cmd/protoc-gen-go/testdata/proto3/fields.pb.go
    index cba44b6..d11f269 100644
    --- a/cmd/protoc-gen-go/testdata/proto3/fields.pb.go
    +++ b/cmd/protoc-gen-go/testdata/proto3/fields.pb.go
    @@ -8,6 +8,7 @@
    package proto3

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -392,6 +393,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *FieldTestMessage) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *FieldTestMessage) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type FieldTestMessage_Message struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -430,6 +441,16 @@
    return file_cmd_protoc_gen_go_testdata_proto3_fields_proto_rawDescGZIP(), []int{0, 3}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *FieldTestMessage_Message) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *FieldTestMessage_Message) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_cmd_protoc_gen_go_testdata_proto3_fields_proto protoreflect.FileDescriptor

    var file_cmd_protoc_gen_go_testdata_proto3_fields_proto_rawDesc = []byte{
    diff --git a/cmd/protoc-gen-go/testdata/retention/options_message.pb.go b/cmd/protoc-gen-go/testdata/retention/options_message.pb.go
    index 5b132bf..8e336c1 100755
    --- a/cmd/protoc-gen-go/testdata/retention/options_message.pb.go
    +++ b/cmd/protoc-gen-go/testdata/retention/options_message.pb.go
    @@ -8,6 +8,7 @@
    package retention

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    descriptorpb "google.golang.org/protobuf/types/descriptorpb"
    @@ -79,6 +80,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *OptionsMessage) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *OptionsMessage) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var file_cmd_protoc_gen_go_testdata_retention_options_message_proto_extTypes = []protoimpl.ExtensionInfo{
    {
    ExtendedType: (*descriptorpb.FileOptions)(nil),
    diff --git a/cmd/protoc-gen-go/testdata/retention/retention.pb.go b/cmd/protoc-gen-go/testdata/retention/retention.pb.go
    index f9624b7..0aa61c7 100755
    --- a/cmd/protoc-gen-go/testdata/retention/retention.pb.go
    +++ b/cmd/protoc-gen-go/testdata/retention/retention.pb.go
    @@ -8,6 +8,7 @@
    package retention

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    descriptorpb "google.golang.org/protobuf/types/descriptorpb"
    @@ -160,6 +161,16 @@
    return file_cmd_protoc_gen_go_testdata_retention_retention_proto_rawDescGZIP(), []int{0}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Extendee) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Extendee) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type TopLevelMessage struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -226,6 +237,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TopLevelMessage) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TopLevelMessage) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type isTopLevelMessage_O interface {
    isTopLevelMessage_O()
    }
    @@ -274,6 +295,16 @@
    return file_cmd_protoc_gen_go_testdata_retention_retention_proto_rawDescGZIP(), []int{1, 0}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TopLevelMessage_NestedMessage) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TopLevelMessage_NestedMessage) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var file_cmd_protoc_gen_go_testdata_retention_retention_proto_extTypes = []protoimpl.ExtensionInfo{
    {
    ExtendedType: (*descriptorpb.FileOptions)(nil),
    diff --git a/internal/testprotos/benchmarks/micro/micro.pb.go b/internal/testprotos/benchmarks/micro/micro.pb.go
    index 591b8e6..37011fc 100644
    --- a/internal/testprotos/benchmarks/micro/micro.pb.go
    +++ b/internal/testprotos/benchmarks/micro/micro.pb.go
    @@ -8,6 +8,7 @@
    package micro

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -181,6 +182,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *SixteenRequired) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *SixteenRequired) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_internal_testprotos_benchmarks_micro_micro_proto protoreflect.FileDescriptor

    var file_internal_testprotos_benchmarks_micro_micro_proto_rawDesc = []byte{
    diff --git a/internal/testprotos/conformance/conformance.pb.go b/internal/testprotos/conformance/conformance.pb.go
    index 2087648..c49361a 100644
    --- a/internal/testprotos/conformance/conformance.pb.go
    +++ b/internal/testprotos/conformance/conformance.pb.go
    @@ -34,6 +34,7 @@
    package conformance

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -212,6 +213,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *FailureSet) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *FailureSet) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Represents a single test case's input. The testee should:
    //
    // 1. parse this proto (which should always succeed)
    @@ -352,6 +363,16 @@
    return false
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *ConformanceRequest) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *ConformanceRequest) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type isConformanceRequest_Payload interface {
    isConformanceRequest_Payload()
    }
    @@ -503,6 +524,16 @@
    return ""
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *ConformanceResponse) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *ConformanceResponse) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type isConformanceResponse_Result interface {
    isConformanceResponse_Result()
    }
    @@ -635,6 +666,16 @@
    return false
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *JspbEncodingConfig) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *JspbEncodingConfig) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_conformance_conformance_proto protoreflect.FileDescriptor

    var file_conformance_conformance_proto_rawDesc = []byte{
    diff --git a/internal/testprotos/conformance/test_messages_proto2.pb.go b/internal/testprotos/conformance/test_messages_proto2.pb.go
    index 3f86b10..dbe68f8 100644
    --- a/internal/testprotos/conformance/test_messages_proto2.pb.go
    +++ b/internal/testprotos/conformance/test_messages_proto2.pb.go
    @@ -41,6 +41,7 @@
    package conformance

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -1438,6 +1439,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestAllTypesProto2) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestAllTypesProto2) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type isTestAllTypesProto2_OneofField interface {
    isTestAllTypesProto2_OneofField()
    }
    @@ -1543,6 +1554,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *ForeignMessageProto2) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *ForeignMessageProto2) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type UnknownToTestAllTypes struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -1630,6 +1651,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *UnknownToTestAllTypes) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *UnknownToTestAllTypes) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type NullHypothesisProto2 struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -1668,6 +1699,16 @@
    return file_google_protobuf_test_messages_proto2_proto_rawDescGZIP(), []int{3}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *NullHypothesisProto2) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *NullHypothesisProto2) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type EnumOnlyProto2 struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -1706,6 +1747,16 @@
    return file_google_protobuf_test_messages_proto2_proto_rawDescGZIP(), []int{4}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *EnumOnlyProto2) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *EnumOnlyProto2) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type OneStringProto2 struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -1753,6 +1804,16 @@
    return ""
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *OneStringProto2) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *OneStringProto2) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type ProtoWithKeywords struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -1816,6 +1877,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *ProtoWithKeywords) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *ProtoWithKeywords) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type TestAllRequiredTypesProto2 struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -2193,6 +2264,16 @@
    return append([]byte(nil), Default_TestAllRequiredTypesProto2_DefaultBytes...)
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestAllRequiredTypesProto2) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestAllRequiredTypesProto2) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type TestAllTypesProto2_NestedMessage struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -2248,6 +2329,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestAllTypesProto2_NestedMessage) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestAllTypesProto2_NestedMessage) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // groups
    type TestAllTypesProto2_Data struct {
    state protoimpl.MessageState
    @@ -2304,6 +2395,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestAllTypesProto2_Data) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestAllTypesProto2_Data) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // message_set test case.
    type TestAllTypesProto2_MessageSetCorrect struct {
    state protoimpl.MessageState
    @@ -2344,6 +2445,16 @@
    return file_google_protobuf_test_messages_proto2_proto_rawDescGZIP(), []int{0, 21}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestAllTypesProto2_MessageSetCorrect) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestAllTypesProto2_MessageSetCorrect) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type TestAllTypesProto2_MessageSetCorrectExtension1 struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -2391,6 +2502,16 @@
    return ""
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestAllTypesProto2_MessageSetCorrectExtension1) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestAllTypesProto2_MessageSetCorrectExtension1) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type TestAllTypesProto2_MessageSetCorrectExtension2 struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -2438,6 +2559,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestAllTypesProto2_MessageSetCorrectExtension2) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestAllTypesProto2_MessageSetCorrectExtension2) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type UnknownToTestAllTypes_OptionalGroup struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -2485,6 +2616,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *UnknownToTestAllTypes_OptionalGroup) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *UnknownToTestAllTypes_OptionalGroup) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type TestAllRequiredTypesProto2_NestedMessage struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -2548,6 +2689,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestAllRequiredTypesProto2_NestedMessage) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestAllRequiredTypesProto2_NestedMessage) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // groups
    type TestAllRequiredTypesProto2_Data struct {
    state protoimpl.MessageState
    @@ -2604,6 +2755,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestAllRequiredTypesProto2_Data) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestAllRequiredTypesProto2_Data) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // message_set test case.
    type TestAllRequiredTypesProto2_MessageSetCorrect struct {
    state protoimpl.MessageState
    @@ -2644,6 +2805,16 @@
    return file_google_protobuf_test_messages_proto2_proto_rawDescGZIP(), []int{7, 2}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestAllRequiredTypesProto2_MessageSetCorrect) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestAllRequiredTypesProto2_MessageSetCorrect) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type TestAllRequiredTypesProto2_MessageSetCorrectExtension1 struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -2691,6 +2862,16 @@
    return ""
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestAllRequiredTypesProto2_MessageSetCorrectExtension1) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestAllRequiredTypesProto2_MessageSetCorrectExtension1) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type TestAllRequiredTypesProto2_MessageSetCorrectExtension2 struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -2738,6 +2919,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestAllRequiredTypesProto2_MessageSetCorrectExtension2) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestAllRequiredTypesProto2_MessageSetCorrectExtension2) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var file_google_protobuf_test_messages_proto2_proto_extTypes = []protoimpl.ExtensionInfo{
    {
    ExtendedType: (*TestAllTypesProto2)(nil),
    diff --git a/internal/testprotos/conformance/test_messages_proto3.pb.go b/internal/testprotos/conformance/test_messages_proto3.pb.go
    index 59feb2b..8091e78 100644
    --- a/internal/testprotos/conformance/test_messages_proto3.pb.go
    +++ b/internal/testprotos/conformance/test_messages_proto3.pb.go
    @@ -41,6 +41,7 @@
    package conformance

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    anypb "google.golang.org/protobuf/types/known/anypb"
    @@ -1530,6 +1531,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestAllTypesProto3) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestAllTypesProto3) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type isTestAllTypesProto3_OneofField interface {
    isTestAllTypesProto3_OneofField()
    }
    @@ -1641,6 +1652,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *ForeignMessage) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *ForeignMessage) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type NullHypothesisProto3 struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -1679,6 +1700,16 @@
    return file_google_protobuf_test_messages_proto3_proto_rawDescGZIP(), []int{2}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *NullHypothesisProto3) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *NullHypothesisProto3) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type EnumOnlyProto3 struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -1717,6 +1748,16 @@
    return file_google_protobuf_test_messages_proto3_proto_rawDescGZIP(), []int{3}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *EnumOnlyProto3) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *EnumOnlyProto3) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type TestAllTypesProto3_NestedMessage struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -1772,6 +1813,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestAllTypesProto3_NestedMessage) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestAllTypesProto3_NestedMessage) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_google_protobuf_test_messages_proto3_proto protoreflect.FileDescriptor

    var file_google_protobuf_test_messages_proto3_proto_rawDesc = []byte{
    diff --git a/internal/testprotos/fieldtrack/fieldtrack.pb.go b/internal/testprotos/fieldtrack/fieldtrack.pb.go
    index 4cbb98b..5fcdbbb 100644
    --- a/internal/testprotos/fieldtrack/fieldtrack.pb.go
    +++ b/internal/testprotos/fieldtrack/fieldtrack.pb.go
    @@ -613,6 +613,16 @@
    protoimpl.X.SetWeak(w, 101, "goproto.proto.test.weak.WeakImportMessage2", v)
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestFieldTrack) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestFieldTrack) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_internal_testprotos_fieldtrack_fieldtrack_proto protoreflect.FileDescriptor

    var file_internal_testprotos_fieldtrack_fieldtrack_proto_rawDesc = []byte{
    diff --git a/internal/testprotos/fuzz/fuzz.pb.go b/internal/testprotos/fuzz/fuzz.pb.go
    index e677f97..6fe2243 100644
    --- a/internal/testprotos/fuzz/fuzz.pb.go
    +++ b/internal/testprotos/fuzz/fuzz.pb.go
    @@ -10,6 +10,7 @@
    import (
    test "google.golang.org/protobuf/internal/testprotos/test"
    test3 "google.golang.org/protobuf/internal/testprotos/test3"
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -120,6 +121,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Fuzz) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Fuzz) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_internal_testprotos_fuzz_fuzz_proto protoreflect.FileDescriptor

    var file_internal_testprotos_fuzz_fuzz_proto_rawDesc = []byte{
    diff --git a/internal/testprotos/irregular/test.pb.go b/internal/testprotos/irregular/test.pb.go
    index f375c48..9c260d3 100644
    --- a/internal/testprotos/irregular/test.pb.go
    +++ b/internal/testprotos/irregular/test.pb.go
    @@ -12,6 +12,7 @@
    package irregular

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -147,6 +148,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Message) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Message) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type isMessage_Union interface {
    isMessage_Union()
    }
    diff --git a/internal/testprotos/legacy/legacy.pb.go b/internal/testprotos/legacy/legacy.pb.go
    index d486d3b..fcf0674 100644
    --- a/internal/testprotos/legacy/legacy.pb.go
    +++ b/internal/testprotos/legacy/legacy.pb.go
    @@ -20,6 +20,7 @@
    proto3_20180430_b4deda09 "google.golang.org/protobuf/internal/testprotos/legacy/proto3_20180430_b4deda09"
    proto3_20180814_aa810b61 "google.golang.org/protobuf/internal/testprotos/legacy/proto3_20180814_aa810b61"
    proto3_20190205_c823c79e "google.golang.org/protobuf/internal/testprotos/legacy/proto3_20190205_c823c79e"
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -161,6 +162,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Legacy) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Legacy) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_internal_testprotos_legacy_legacy_proto protoreflect.FileDescriptor

    var file_internal_testprotos_legacy_legacy_proto_rawDesc = []byte{
    diff --git a/internal/testprotos/messageset/messagesetpb/message_set.pb.go b/internal/testprotos/messageset/messagesetpb/message_set.pb.go
    index 2769be5..a9f0f11 100644
    --- a/internal/testprotos/messageset/messagesetpb/message_set.pb.go
    +++ b/internal/testprotos/messageset/messagesetpb/message_set.pb.go
    @@ -8,6 +8,7 @@
    package messagesetpb

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -53,6 +54,16 @@
    return file_internal_testprotos_messageset_messagesetpb_message_set_proto_rawDescGZIP(), []int{0}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *MessageSet) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *MessageSet) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type MessageSetContainer struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -100,6 +111,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *MessageSetContainer) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *MessageSetContainer) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_internal_testprotos_messageset_messagesetpb_message_set_proto protoreflect.FileDescriptor

    var file_internal_testprotos_messageset_messagesetpb_message_set_proto_rawDesc = []byte{
    diff --git a/internal/testprotos/messageset/msetextpb/msetextpb.pb.go b/internal/testprotos/messageset/msetextpb/msetextpb.pb.go
    index c9d2025..ecc254b 100644
    --- a/internal/testprotos/messageset/msetextpb/msetextpb.pb.go
    +++ b/internal/testprotos/messageset/msetextpb/msetextpb.pb.go
    @@ -9,6 +9,7 @@

    import (
    messagesetpb "google.golang.org/protobuf/internal/testprotos/messageset/messagesetpb"
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -70,6 +71,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Ext1) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Ext1) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type Ext2 struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -117,6 +128,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Ext2) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Ext2) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type ExtRequired struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -164,6 +185,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *ExtRequired) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *ExtRequired) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type ExtLargeNumber struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -202,6 +233,16 @@
    return file_internal_testprotos_messageset_msetextpb_msetextpb_proto_rawDescGZIP(), []int{3}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *ExtLargeNumber) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *ExtLargeNumber) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var file_internal_testprotos_messageset_msetextpb_msetextpb_proto_extTypes = []protoimpl.ExtensionInfo{
    {
    ExtendedType: (*messagesetpb.MessageSet)(nil),
    diff --git a/internal/testprotos/news/news.pb.go b/internal/testprotos/news/news.pb.go
    index bb728a6..568d8de 100644
    --- a/internal/testprotos/news/news.pb.go
    +++ b/internal/testprotos/news/news.pb.go
    @@ -8,6 +8,7 @@
    package news

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    anypb "google.golang.org/protobuf/types/known/anypb"
    @@ -160,6 +161,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Article) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Article) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type BinaryAttachment struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -215,6 +226,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *BinaryAttachment) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *BinaryAttachment) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type KeyValueAttachment struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -270,6 +291,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *KeyValueAttachment) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *KeyValueAttachment) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_internal_testprotos_news_news_proto protoreflect.FileDescriptor

    var file_internal_testprotos_news_news_proto_rawDesc = []byte{
    diff --git a/internal/testprotos/order/order.pb.go b/internal/testprotos/order/order.pb.go
    index b62ef95..dcaa549 100644
    --- a/internal/testprotos/order/order.pb.go
    +++ b/internal/testprotos/order/order.pb.go
    @@ -10,6 +10,7 @@
    package order

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -98,6 +99,16 @@
    return ""
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Message) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Message) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type isMessage_Oneof_1 interface {
    isMessage_Oneof_1()
    }
    diff --git a/internal/testprotos/registry/test.pb.go b/internal/testprotos/registry/test.pb.go
    index c2613c7..e5bdc9f 100644
    --- a/internal/testprotos/registry/test.pb.go
    +++ b/internal/testprotos/registry/test.pb.go
    @@ -10,6 +10,7 @@
    package registry

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -214,6 +215,16 @@
    return file_internal_testprotos_registry_test_proto_rawDescGZIP(), []int{0}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Message1) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Message1) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type Message2 struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -252,6 +263,16 @@
    return file_internal_testprotos_registry_test_proto_rawDescGZIP(), []int{1}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Message2) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Message2) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type Message3 struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -290,6 +311,16 @@
    return file_internal_testprotos_registry_test_proto_rawDescGZIP(), []int{2}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Message3) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Message3) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type Message4 struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -337,6 +368,16 @@
    return false
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Message4) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Message4) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var file_internal_testprotos_registry_test_proto_extTypes = []protoimpl.ExtensionInfo{
    {
    ExtendedType: (*Message1)(nil),
    diff --git a/internal/testprotos/required/required.pb.go b/internal/testprotos/required/required.pb.go
    index 065fcbf..0e3b46d 100644
    --- a/internal/testprotos/required/required.pb.go
    +++ b/internal/testprotos/required/required.pb.go
    @@ -8,6 +8,7 @@
    package required

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -61,6 +62,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Int32) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Int32) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type Int64 struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -108,6 +119,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Int64) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Int64) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type Uint32 struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -155,6 +176,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Uint32) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Uint32) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type Uint64 struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -202,6 +233,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Uint64) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Uint64) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type Sint32 struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -249,6 +290,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Sint32) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Sint32) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type Sint64 struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -296,6 +347,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Sint64) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Sint64) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type Fixed32 struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -343,6 +404,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Fixed32) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Fixed32) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type Fixed64 struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -390,6 +461,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Fixed64) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Fixed64) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type Float struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -437,6 +518,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Float) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Float) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type Double struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -484,6 +575,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Double) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Double) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type Bool struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -531,6 +632,16 @@
    return false
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Bool) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Bool) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type String struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -578,6 +689,16 @@
    return ""
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *String) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *String) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type Bytes struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -625,6 +746,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Bytes) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Bytes) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type Message struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -672,6 +803,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Message) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Message) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type Group struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -719,6 +860,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Group) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Group) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type Message_M struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -757,6 +908,16 @@
    return file_internal_testprotos_required_required_proto_rawDescGZIP(), []int{13, 0}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Message_M) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Message_M) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type Group_Group struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -804,6 +965,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Group_Group) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Group_Group) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_internal_testprotos_required_required_proto protoreflect.FileDescriptor

    var file_internal_testprotos_required_required_proto_rawDesc = []byte{
    diff --git a/internal/testprotos/test/test.pb.go b/internal/testprotos/test/test.pb.go
    index a828a51..66fd86d 100644
    --- a/internal/testprotos/test/test.pb.go
    +++ b/internal/testprotos/test/test.pb.go
    @@ -1044,6 +1044,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestAllTypes) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestAllTypes) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type isTestAllTypes_OneofField interface {
    isTestAllTypes_OneofField()
    }
    @@ -1187,6 +1197,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestDeprecatedMessage) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestDeprecatedMessage) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type isTestDeprecatedMessage_DeprecatedOneof interface {
    isTestDeprecatedMessage_DeprecatedOneof()
    }
    @@ -1253,6 +1273,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *ForeignMessage) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *ForeignMessage) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type TestReservedFields struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -1291,6 +1321,16 @@
    return file_internal_testprotos_test_test_proto_rawDescGZIP(), []int{3}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestReservedFields) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestReservedFields) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type TestAllExtensions struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -1330,6 +1370,16 @@
    return file_internal_testprotos_test_test_proto_rawDescGZIP(), []int{4}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestAllExtensions) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestAllExtensions) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type OptionalGroup struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -1393,6 +1443,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *OptionalGroup) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *OptionalGroup) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type RepeatedGroup struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -1448,6 +1508,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *RepeatedGroup) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *RepeatedGroup) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type TestNestedExtension struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -1486,6 +1556,16 @@
    return file_internal_testprotos_test_test_proto_rawDescGZIP(), []int{7}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestNestedExtension) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestNestedExtension) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type TestRequired struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -1533,6 +1613,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestRequired) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestRequired) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type TestRequiredForeign struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -1614,6 +1704,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestRequiredForeign) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestRequiredForeign) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type isTestRequiredForeign_OneofField interface {
    isTestRequiredForeign_OneofField()
    }
    @@ -1679,6 +1779,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestRequiredGroupFields) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestRequiredGroupFields) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type TestWeak struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -1753,6 +1863,16 @@
    protoimpl.X.SetWeak(w, 2, "goproto.proto.test.weak.WeakImportMessage2", v)
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestWeak) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestWeak) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type TestPackedTypes struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -1904,6 +2024,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestPackedTypes) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestPackedTypes) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type TestUnpackedTypes struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -2055,6 +2185,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestUnpackedTypes) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestUnpackedTypes) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type TestPackedExtensions struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -2094,6 +2234,16 @@
    return file_internal_testprotos_test_test_proto_rawDescGZIP(), []int{14}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestPackedExtensions) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestPackedExtensions) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type TestUnpackedExtensions struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -2133,6 +2283,16 @@
    return file_internal_testprotos_test_test_proto_rawDescGZIP(), []int{15}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestUnpackedExtensions) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestUnpackedExtensions) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Test that RPC services work.
    type FooRequest struct {
    state protoimpl.MessageState
    @@ -2172,6 +2332,16 @@
    return file_internal_testprotos_test_test_proto_rawDescGZIP(), []int{16}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *FooRequest) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *FooRequest) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type FooResponse struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -2210,6 +2380,16 @@
    return file_internal_testprotos_test_test_proto_rawDescGZIP(), []int{17}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *FooResponse) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *FooResponse) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type WeirdDefault struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -2262,6 +2442,16 @@
    return append([]byte(nil), Default_WeirdDefault_WeirdDefault...)
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *WeirdDefault) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *WeirdDefault) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type RemoteDefault struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -2376,6 +2566,16 @@
    return Default_RemoteDefault_Negative
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *RemoteDefault) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *RemoteDefault) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type TestAllTypes_NestedMessage struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -2431,6 +2631,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestAllTypes_NestedMessage) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestAllTypes_NestedMessage) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type TestAllTypes_OptionalGroup struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -2494,6 +2704,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestAllTypes_OptionalGroup) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestAllTypes_OptionalGroup) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type TestAllTypes_RepeatedGroup struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -2549,6 +2769,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestAllTypes_RepeatedGroup) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestAllTypes_RepeatedGroup) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type TestAllTypes_OneofGroup struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -2604,6 +2834,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestAllTypes_OneofGroup) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestAllTypes_OneofGroup) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type TestAllExtensions_NestedMessage struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -2659,6 +2899,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestAllExtensions_NestedMessage) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestAllExtensions_NestedMessage) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type TestRequiredGroupFields_OptionalGroup struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -2706,6 +2956,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestRequiredGroupFields_OptionalGroup) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestRequiredGroupFields_OptionalGroup) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type TestRequiredGroupFields_RepeatedGroup struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -2753,6 +3013,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestRequiredGroupFields_RepeatedGroup) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestRequiredGroupFields_RepeatedGroup) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var file_internal_testprotos_test_test_proto_extTypes = []protoimpl.ExtensionInfo{
    {
    ExtendedType: (*TestAllExtensions)(nil),
    diff --git a/internal/testprotos/test/test_import.pb.go b/internal/testprotos/test/test_import.pb.go
    index 6be93bd..4e0e1d0 100644
    --- a/internal/testprotos/test/test_import.pb.go
    +++ b/internal/testprotos/test/test_import.pb.go
    @@ -8,6 +8,7 @@
    package test

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -105,6 +106,16 @@
    return file_internal_testprotos_test_test_import_proto_rawDescGZIP(), []int{0}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *ImportMessage) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *ImportMessage) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_internal_testprotos_test_test_import_proto protoreflect.FileDescriptor

    var file_internal_testprotos_test_test_import_proto_rawDesc = []byte{
    diff --git a/internal/testprotos/test/test_public.pb.go b/internal/testprotos/test/test_public.pb.go
    index 19797ea..db3df53 100644
    --- a/internal/testprotos/test/test_public.pb.go
    +++ b/internal/testprotos/test/test_public.pb.go
    @@ -8,6 +8,7 @@
    package test

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -52,6 +53,16 @@
    return file_internal_testprotos_test_test_public_proto_rawDescGZIP(), []int{0}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *PublicImportMessage) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *PublicImportMessage) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_internal_testprotos_test_test_public_proto protoreflect.FileDescriptor

    var file_internal_testprotos_test_test_public_proto_rawDesc = []byte{
    diff --git a/internal/testprotos/test/weak1/test_weak.pb.go b/internal/testprotos/test/weak1/test_weak.pb.go
    index 63203c5..7639479 100644
    --- a/internal/testprotos/test/weak1/test_weak.pb.go
    +++ b/internal/testprotos/test/weak1/test_weak.pb.go
    @@ -8,6 +8,7 @@
    package weak1

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -61,6 +62,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *WeakImportMessage1) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *WeakImportMessage1) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_internal_testprotos_test_weak1_test_weak_proto protoreflect.FileDescriptor

    var file_internal_testprotos_test_weak1_test_weak_proto_rawDesc = []byte{
    diff --git a/internal/testprotos/test/weak2/test_weak.pb.go b/internal/testprotos/test/weak2/test_weak.pb.go
    index 7678dc9..2381f3e 100644
    --- a/internal/testprotos/test/weak2/test_weak.pb.go
    +++ b/internal/testprotos/test/weak2/test_weak.pb.go
    @@ -8,6 +8,7 @@
    package weak2

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -61,6 +62,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *WeakImportMessage2) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *WeakImportMessage2) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_internal_testprotos_test_weak2_test_weak_proto protoreflect.FileDescriptor

    var file_internal_testprotos_test_weak2_test_weak_proto_rawDesc = []byte{
    diff --git a/internal/testprotos/test3/test.pb.go b/internal/testprotos/test3/test.pb.go
    index d2ff0bf..3134a65 100644
    --- a/internal/testprotos/test3/test.pb.go
    +++ b/internal/testprotos/test3/test.pb.go
    @@ -8,6 +8,7 @@
    package test3

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -879,6 +880,16 @@
    return TestAllTypes_FOO
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestAllTypes) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestAllTypes) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type isTestAllTypes_OneofField interface {
    isTestAllTypes_OneofField()
    }
    @@ -992,6 +1003,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *ForeignMessage) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *ForeignMessage) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type TestAllTypes_NestedMessage struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -1047,6 +1068,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *TestAllTypes_NestedMessage) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *TestAllTypes_NestedMessage) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_internal_testprotos_test3_test_proto protoreflect.FileDescriptor

    var file_internal_testprotos_test3_test_proto_rawDesc = []byte{
    diff --git a/internal/testprotos/test3/test_import.pb.go b/internal/testprotos/test3/test_import.pb.go
    index 5fc6043..4461ef9 100644
    --- a/internal/testprotos/test3/test_import.pb.go
    +++ b/internal/testprotos/test3/test_import.pb.go
    @@ -8,6 +8,7 @@
    package test3

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -95,6 +96,16 @@
    return file_internal_testprotos_test3_test_import_proto_rawDescGZIP(), []int{0}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *ImportMessage) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *ImportMessage) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_internal_testprotos_test3_test_import_proto protoreflect.FileDescriptor

    var file_internal_testprotos_test3_test_import_proto_rawDesc = []byte{
    diff --git a/internal/testprotos/textpb2/test.pb.go b/internal/testprotos/textpb2/test.pb.go
    index ec25471..825c67e 100644
    --- a/internal/testprotos/textpb2/test.pb.go
    +++ b/internal/testprotos/textpb2/test.pb.go
    @@ -10,6 +10,7 @@
    package textpb2

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    anypb "google.golang.org/protobuf/types/known/anypb"
    @@ -301,6 +302,16 @@
    return ""
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Scalars) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Scalars) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Message contains enum fields.
    type Enums struct {
    state protoimpl.MessageState
    @@ -373,6 +384,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Enums) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Enums) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Message contains repeated fields.
    type Repeats struct {
    state protoimpl.MessageState
    @@ -485,6 +506,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Repeats) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Repeats) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Message contains map fields.
    type Maps struct {
    state protoimpl.MessageState
    @@ -541,6 +572,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Maps) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Maps) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Message type used as submessage.
    type Nested struct {
    state protoimpl.MessageState
    @@ -597,6 +638,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Nested) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Nested) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Message contains message and group fields.
    type Nests struct {
    state protoimpl.MessageState
    @@ -669,6 +720,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Nests) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Nests) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Message contains required fields.
    type Requireds struct {
    state protoimpl.MessageState
    @@ -757,6 +818,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Requireds) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Requireds) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Message contains both required and optional fields.
    type PartialRequired struct {
    state protoimpl.MessageState
    @@ -813,6 +884,16 @@
    return ""
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *PartialRequired) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *PartialRequired) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type NestedWithRequired struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -860,6 +941,16 @@
    return ""
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *NestedWithRequired) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *NestedWithRequired) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type IndirectRequired struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -941,6 +1032,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *IndirectRequired) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *IndirectRequired) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type isIndirectRequired_Union interface {
    isIndirectRequired_Union()
    }
    @@ -1015,6 +1116,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Extensions) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Extensions) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type ExtensionsContainer struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -1053,6 +1164,16 @@
    return file_internal_testprotos_textpb2_test_proto_rawDescGZIP(), []int{11}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *ExtensionsContainer) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *ExtensionsContainer) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type MessageSet struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -1092,6 +1213,16 @@
    return file_internal_testprotos_textpb2_test_proto_rawDescGZIP(), []int{12}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *MessageSet) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *MessageSet) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type MessageSetExtension struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -1139,6 +1270,16 @@
    return ""
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *MessageSetExtension) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *MessageSetExtension) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type FakeMessageSet struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -1178,6 +1319,16 @@
    return file_internal_testprotos_textpb2_test_proto_rawDescGZIP(), []int{14}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *FakeMessageSet) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *FakeMessageSet) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type FakeMessageSetExtension struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -1225,6 +1376,16 @@
    return ""
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *FakeMessageSetExtension) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *FakeMessageSetExtension) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Message contains well-known type fields.
    type KnownTypes struct {
    state protoimpl.MessageState
    @@ -1409,6 +1570,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *KnownTypes) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *KnownTypes) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type Nests_OptGroup struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -1472,6 +1643,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Nests_OptGroup) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Nests_OptGroup) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type Nests_RptGroup struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -1519,6 +1700,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Nests_RptGroup) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Nests_RptGroup) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type Nests_OptGroup_OptNestedGroup struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -1566,6 +1757,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Nests_OptGroup_OptNestedGroup) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Nests_OptGroup_OptNestedGroup) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var file_internal_testprotos_textpb2_test_proto_extTypes = []protoimpl.ExtensionInfo{
    {
    ExtendedType: (*Extensions)(nil),
    diff --git a/internal/testprotos/textpb3/test.pb.go b/internal/testprotos/textpb3/test.pb.go
    index be8034c..c29f70a 100644
    --- a/internal/testprotos/textpb3/test.pb.go
    +++ b/internal/testprotos/textpb3/test.pb.go
    @@ -10,6 +10,7 @@
    package textpb3

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -280,6 +281,16 @@
    return ""
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Scalars) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Scalars) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Message contains repeated fields.
    type Repeats struct {
    state protoimpl.MessageState
    @@ -392,6 +403,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Repeats) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Repeats) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type Proto3Optional struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -519,6 +540,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Proto3Optional) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Proto3Optional) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Message contains enum fields.
    type Enums struct {
    state protoimpl.MessageState
    @@ -575,6 +606,16 @@
    return Enums_CERO
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Enums) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Enums) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Message contains nested message field.
    type Nests struct {
    state protoimpl.MessageState
    @@ -623,6 +664,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Nests) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Nests) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Message type used as submessage.
    type Nested struct {
    state protoimpl.MessageState
    @@ -679,6 +730,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Nested) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Nested) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Message contains oneof field.
    type Oneofs struct {
    state protoimpl.MessageState
    @@ -753,6 +814,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Oneofs) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Oneofs) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type isOneofs_Union interface {
    isOneofs_Union()
    }
    @@ -855,6 +926,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Maps) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Maps) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Message for testing json_name option.
    type JSONNames struct {
    state protoimpl.MessageState
    @@ -903,6 +984,16 @@
    return ""
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *JSONNames) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *JSONNames) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_internal_testprotos_textpb3_test_proto protoreflect.FileDescriptor

    var file_internal_testprotos_textpb3_test_proto_rawDesc = []byte{
    diff --git a/types/descriptorpb/descriptor.pb.go b/types/descriptorpb/descriptor.pb.go
    index 1db5b2b..e0554ed 100644
    --- a/types/descriptorpb/descriptor.pb.go
    +++ b/types/descriptorpb/descriptor.pb.go
    @@ -42,6 +42,7 @@
    package descriptorpb

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -1151,6 +1152,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *FileDescriptorSet) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *FileDescriptorSet) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Describes a complete .proto file.
    type FileDescriptorProto struct {
    state protoimpl.MessageState
    @@ -1309,6 +1320,16 @@
    return ""
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *FileDescriptorProto) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *FileDescriptorProto) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Describes a message type.
    type DescriptorProto struct {
    state protoimpl.MessageState
    @@ -1431,6 +1452,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *DescriptorProto) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *DescriptorProto) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type ExtensionRangeOptions struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -1516,6 +1547,16 @@
    return Default_ExtensionRangeOptions_Verification
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *ExtensionRangeOptions) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *ExtensionRangeOptions) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Describes a field within a message.
    type FieldDescriptorProto struct {
    state protoimpl.MessageState
    @@ -1684,6 +1725,16 @@
    return false
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *FieldDescriptorProto) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *FieldDescriptorProto) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Describes a oneof.
    type OneofDescriptorProto struct {
    state protoimpl.MessageState
    @@ -1740,6 +1791,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *OneofDescriptorProto) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *OneofDescriptorProto) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Describes an enum type.
    type EnumDescriptorProto struct {
    state protoimpl.MessageState
    @@ -1825,6 +1886,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *EnumDescriptorProto) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *EnumDescriptorProto) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Describes a value within an enum.
    type EnumValueDescriptorProto struct {
    state protoimpl.MessageState
    @@ -1889,6 +1960,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *EnumValueDescriptorProto) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *EnumValueDescriptorProto) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Describes a service.
    type ServiceDescriptorProto struct {
    state protoimpl.MessageState
    @@ -1953,6 +2034,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *ServiceDescriptorProto) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *ServiceDescriptorProto) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Describes a method of a service.
    type MethodDescriptorProto struct {
    state protoimpl.MessageState
    @@ -2051,6 +2142,16 @@
    return Default_MethodDescriptorProto_ServerStreaming
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *MethodDescriptorProto) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *MethodDescriptorProto) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type FileOptions struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -2347,6 +2448,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *FileOptions) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *FileOptions) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type MessageOptions struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -2516,6 +2627,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *MessageOptions) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *MessageOptions) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type FieldOptions struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -2735,6 +2856,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *FieldOptions) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *FieldOptions) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type OneofOptions struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -2793,6 +2924,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *OneofOptions) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *OneofOptions) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type EnumOptions struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -2895,6 +3036,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *EnumOptions) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *EnumOptions) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type EnumValueOptions struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -2982,6 +3133,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *EnumValueOptions) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *EnumValueOptions) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type ServiceOptions struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -3057,6 +3218,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *ServiceOptions) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *ServiceOptions) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type MethodOptions struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -3141,6 +3312,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *MethodOptions) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *MethodOptions) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // A message representing a option the parser does not recognize. This only
    // appears in options protos created by the compiler::Parser class.
    // DescriptorPool resolves these when building Descriptor objects. Therefore,
    @@ -3244,6 +3425,16 @@
    return ""
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *UninterpretedOption) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *UninterpretedOption) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // TODO(b/274655146) Enums in C++ gencode (and potentially other languages) are
    // not well scoped. This means that each of the feature enums below can clash
    // with each other. The short names we've chosen maximize call-site
    @@ -3346,6 +3537,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *FeatureSet) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *FeatureSet) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Encapsulates information about the original source file from which a
    // FileDescriptorProto was generated.
    type SourceCodeInfo struct {
    @@ -3443,6 +3644,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *SourceCodeInfo) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *SourceCodeInfo) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Describes the relationship between generated code and its original source
    // file. A GeneratedCodeInfo message is associated with only one generated
    // source file, but may contain references to different source .proto files.
    @@ -3495,6 +3706,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *GeneratedCodeInfo) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *GeneratedCodeInfo) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type DescriptorProto_ExtensionRange struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -3558,6 +3779,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *DescriptorProto_ExtensionRange) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *DescriptorProto_ExtensionRange) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Range of reserved tag numbers. Reserved tag numbers may not be used by
    // fields or extension ranges in the same message. Reserved ranges may
    // not overlap.
    @@ -3616,6 +3847,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *DescriptorProto_ReservedRange) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *DescriptorProto_ReservedRange) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type ExtensionRangeOptions_Declaration struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -3706,6 +3947,16 @@
    return false
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *ExtensionRangeOptions_Declaration) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *ExtensionRangeOptions_Declaration) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Range of reserved numeric values. Reserved values may not be used by
    // entries in the same enum. Reserved ranges may not overlap.
    //
    @@ -3767,6 +4018,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *EnumDescriptorProto_EnumReservedRange) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *EnumDescriptorProto_EnumReservedRange) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type FieldOptions_EditionDefault struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -3822,6 +4083,16 @@
    return ""
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *FieldOptions_EditionDefault) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *FieldOptions_EditionDefault) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // The name of the uninterpreted option. Each string represents a segment in
    // a dot-separated name. is_extension is true iff a segment represents an
    // extension (denoted with parentheses in options specs in .proto files).
    @@ -3882,6 +4153,16 @@
    return false
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *UninterpretedOption_NamePart) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *UninterpretedOption_NamePart) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type SourceCodeInfo_Location struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -4047,6 +4328,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *SourceCodeInfo_Location) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *SourceCodeInfo_Location) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type GeneratedCodeInfo_Annotation struct {
    state protoimpl.MessageState
    sizeCache protoimpl.SizeCache
    @@ -4134,6 +4425,16 @@
    return GeneratedCodeInfo_Annotation_NONE
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *GeneratedCodeInfo_Annotation) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *GeneratedCodeInfo_Annotation) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_google_protobuf_descriptor_proto protoreflect.FileDescriptor

    var file_google_protobuf_descriptor_proto_rawDesc = []byte{
    diff --git a/types/known/anypb/any.pb.go b/types/known/anypb/any.pb.go
    index 9de51be..00b7296 100644
    --- a/types/known/anypb/any.pb.go
    +++ b/types/known/anypb/any.pb.go
    @@ -412,6 +412,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Any) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Any) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_google_protobuf_any_proto protoreflect.FileDescriptor

    var file_google_protobuf_any_proto_rawDesc = []byte{
    diff --git a/types/known/apipb/api.pb.go b/types/known/apipb/api.pb.go
    index 335be6e..b49c2e9 100644
    --- a/types/known/apipb/api.pb.go
    +++ b/types/known/apipb/api.pb.go
    @@ -34,6 +34,7 @@
    package apipb

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    sourcecontextpb "google.golang.org/protobuf/types/known/sourcecontextpb"
    @@ -173,6 +174,16 @@
    return typepb.Syntax(0)
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Api) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Api) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Method represents a method of an API interface.
    type Method struct {
    state protoimpl.MessageState
    @@ -276,6 +287,16 @@
    return typepb.Syntax(0)
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Method) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Method) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Declares an API Interface to be included in this interface. The including
    // interface must redeclare all the methods from the included interface, but
    // documentation and options are inherited as follows:
    @@ -412,6 +433,16 @@
    return ""
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Mixin) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Mixin) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_google_protobuf_api_proto protoreflect.FileDescriptor

    var file_google_protobuf_api_proto_rawDesc = []byte{
    diff --git a/types/known/durationpb/duration.pb.go b/types/known/durationpb/duration.pb.go
    index df709a8..a5b0a01 100644
    --- a/types/known/durationpb/duration.pb.go
    +++ b/types/known/durationpb/duration.pb.go
    @@ -74,6 +74,7 @@
    package durationpb

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    math "math"
    @@ -289,6 +290,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Duration) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Duration) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_google_protobuf_duration_proto protoreflect.FileDescriptor

    var file_google_protobuf_duration_proto_rawDesc = []byte{
    diff --git a/types/known/emptypb/empty.pb.go b/types/known/emptypb/empty.pb.go
    index 9a7277b..f5ef0bd 100644
    --- a/types/known/emptypb/empty.pb.go
    +++ b/types/known/emptypb/empty.pb.go
    @@ -34,6 +34,7 @@
    package emptypb

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -85,6 +86,16 @@
    return file_google_protobuf_empty_proto_rawDescGZIP(), []int{0}
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Empty) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Empty) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_google_protobuf_empty_proto protoreflect.FileDescriptor

    var file_google_protobuf_empty_proto_rawDesc = []byte{
    diff --git a/types/known/fieldmaskpb/field_mask.pb.go b/types/known/fieldmaskpb/field_mask.pb.go
    index e8789cb..115ecf2 100644
    --- a/types/known/fieldmaskpb/field_mask.pb.go
    +++ b/types/known/fieldmaskpb/field_mask.pb.go
    @@ -504,6 +504,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *FieldMask) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *FieldMask) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_google_protobuf_field_mask_proto protoreflect.FileDescriptor

    var file_google_protobuf_field_mask_proto_rawDesc = []byte{
    diff --git a/types/known/sourcecontextpb/source_context.pb.go b/types/known/sourcecontextpb/source_context.pb.go
    index 0980d5a..56adbe7 100644
    --- a/types/known/sourcecontextpb/source_context.pb.go
    +++ b/types/known/sourcecontextpb/source_context.pb.go
    @@ -34,6 +34,7 @@
    package sourcecontextpb

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -91,6 +92,16 @@
    return ""
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *SourceContext) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *SourceContext) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_google_protobuf_source_context_proto protoreflect.FileDescriptor

    var file_google_protobuf_source_context_proto_rawDesc = []byte{
    diff --git a/types/known/structpb/struct.pb.go b/types/known/structpb/struct.pb.go
    index d2bac8b..0e610e3 100644
    --- a/types/known/structpb/struct.pb.go
    +++ b/types/known/structpb/struct.pb.go
    @@ -121,6 +121,7 @@
    import (
    base64 "encoding/base64"
    protojson "google.golang.org/protobuf/encoding/protojson"
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    math "math"
    @@ -270,6 +271,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Struct) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Struct) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // `Value` represents a dynamically typed value which can be either
    // null, a number, a string, a boolean, a recursive struct value, or a
    // list of values. A producer of value is expected to set one of these
    @@ -520,6 +531,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Value) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Value) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    type isValue_Kind interface {
    isValue_Kind()
    }
    @@ -650,6 +671,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *ListValue) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *ListValue) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_google_protobuf_struct_proto protoreflect.FileDescriptor

    var file_google_protobuf_struct_proto_rawDesc = []byte{
    diff --git a/types/known/timestamppb/timestamp.pb.go b/types/known/timestamppb/timestamp.pb.go
    index 81511a3..56937a5 100644
    --- a/types/known/timestamppb/timestamp.pb.go
    +++ b/types/known/timestamppb/timestamp.pb.go
    @@ -73,6 +73,7 @@
    package timestamppb

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -298,6 +299,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Timestamp) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Timestamp) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_google_protobuf_timestamp_proto protoreflect.FileDescriptor

    var file_google_protobuf_timestamp_proto_rawDesc = []byte{
    diff --git a/types/known/typepb/type.pb.go b/types/known/typepb/type.pb.go
    index 4cb8d0a..20c5b35 100644
    --- a/types/known/typepb/type.pb.go
    +++ b/types/known/typepb/type.pb.go
    @@ -34,6 +34,7 @@
    package typepb

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    anypb "google.golang.org/protobuf/types/known/anypb"
    @@ -372,6 +373,16 @@
    return ""
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Type) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Type) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // A single field of a message type.
    type Field struct {
    state protoimpl.MessageState
    @@ -504,6 +515,16 @@
    return ""
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Field) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Field) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Enum type definition.
    type Enum struct {
    state protoimpl.MessageState
    @@ -598,6 +619,16 @@
    return ""
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Enum) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Enum) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Enum value definition.
    type EnumValue struct {
    state protoimpl.MessageState
    @@ -665,6 +696,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *EnumValue) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *EnumValue) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // A protocol buffer option, which can be attached to a message, field,
    // enumeration, etc.
    type Option struct {
    @@ -730,6 +771,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Option) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Option) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_google_protobuf_type_proto protoreflect.FileDescriptor

    var file_google_protobuf_type_proto_rawDesc = []byte{
    diff --git a/types/known/wrapperspb/wrappers.pb.go b/types/known/wrapperspb/wrappers.pb.go
    index 762a871..f7e709b 100644
    --- a/types/known/wrapperspb/wrappers.pb.go
    +++ b/types/known/wrapperspb/wrappers.pb.go
    @@ -44,6 +44,7 @@
    package wrapperspb

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    reflect "reflect"
    @@ -106,6 +107,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *DoubleValue) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *DoubleValue) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Wrapper message for `float`.
    //
    // The JSON representation for `FloatValue` is JSON number.
    @@ -162,6 +173,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *FloatValue) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *FloatValue) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Wrapper message for `int64`.
    //
    // The JSON representation for `Int64Value` is JSON string.
    @@ -218,6 +239,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Int64Value) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Int64Value) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Wrapper message for `uint64`.
    //
    // The JSON representation for `UInt64Value` is JSON string.
    @@ -274,6 +305,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *UInt64Value) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *UInt64Value) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Wrapper message for `int32`.
    //
    // The JSON representation for `Int32Value` is JSON number.
    @@ -330,6 +371,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Int32Value) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Int32Value) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Wrapper message for `uint32`.
    //
    // The JSON representation for `UInt32Value` is JSON number.
    @@ -386,6 +437,16 @@
    return 0
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *UInt32Value) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *UInt32Value) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Wrapper message for `bool`.
    //
    // The JSON representation for `BoolValue` is JSON `true` and `false`.
    @@ -442,6 +503,16 @@
    return false
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *BoolValue) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *BoolValue) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Wrapper message for `string`.
    //
    // The JSON representation for `StringValue` is JSON string.
    @@ -498,6 +569,16 @@
    return ""
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *StringValue) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *StringValue) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Wrapper message for `bytes`.
    //
    // The JSON representation for `BytesValue` is JSON string.
    @@ -554,6 +635,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *BytesValue) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *BytesValue) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_google_protobuf_wrappers_proto protoreflect.FileDescriptor

    var file_google_protobuf_wrappers_proto_rawDesc = []byte{
    diff --git a/types/pluginpb/plugin.pb.go b/types/pluginpb/plugin.pb.go
    index 186c02d..096328b 100644
    --- a/types/pluginpb/plugin.pb.go
    +++ b/types/pluginpb/plugin.pb.go
    @@ -47,6 +47,7 @@
    package pluginpb

    import (
    + proto "google.golang.org/protobuf/proto"
    protoreflect "google.golang.org/protobuf/reflect/protoreflect"
    protoimpl "google.golang.org/protobuf/runtime/protoimpl"
    descriptorpb "google.golang.org/protobuf/types/descriptorpb"
    @@ -188,6 +189,16 @@
    return ""
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *Version) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *Version) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // An encoded CodeGeneratorRequest is written to the plugin's stdin.
    type CodeGeneratorRequest struct {
    state protoimpl.MessageState
    @@ -295,6 +306,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *CodeGeneratorRequest) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *CodeGeneratorRequest) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // The plugin writes an encoded CodeGeneratorResponse to stdout.
    type CodeGeneratorResponse struct {
    state protoimpl.MessageState
    @@ -369,6 +390,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *CodeGeneratorResponse) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *CodeGeneratorResponse) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    // Represents a single generated file.
    type CodeGeneratorResponse_File struct {
    state protoimpl.MessageState
    @@ -497,6 +528,16 @@
    return nil
    }

    +// MarshalBinary implements encoding.BinaryMarshaler
    +func (x *CodeGeneratorResponse_File) MarshalBinary() ([]byte, error) {
    + return proto.Marshal(x)
    +}
    +
    +// UnmarshalBinary implements encoding.BinaryUnmarshaler
    +func (x *CodeGeneratorResponse_File) UnmarshalBinary(data []byte) error {
    + return proto.Unmarshal(data, x)
    +}
    +
    var File_google_protobuf_compiler_plugin_proto protoreflect.FileDescriptor

    var file_google_protobuf_compiler_plugin_proto_rawDesc = []byte{

    To view, visit change 517315. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-MessageType: newchange

    Lasse Folger (Gerrit)

    unread,
    Aug 9, 2023, 1:45:07 AM8/9/23
    to Derek Perkins, goph...@pubsubhelper.golang.org, Michael Stapelberg, Damien Neil, Joseph Tsai, Gopher Robot, golang-co...@googlegroups.com

    Attention is currently required from: Damien Neil, Derek Perkins, Joseph Tsai, Michael Stapelberg.

    View Change

    1 comment:

    • Patchset:

      • Patch Set #1:

        Thanks for the proposal.

        I'm not sure if we can accept this proposal. The problem is that this leads to a non-trivial binary size increase. I like to get some more opionion from other people but from my point of view the cost benefit is not clear.

    To view, visit change 517315. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-MessageType: comment
    Gerrit-Project: protobuf
    Gerrit-Branch: master
    Gerrit-Change-Id: Iafd236b611b0f5d96da0b4b271aa96382de8dd48
    Gerrit-Change-Number: 517315
    Gerrit-PatchSet: 1
    Gerrit-Owner: Derek Perkins <de...@nozzle.io>
    Gerrit-Reviewer: Damien Neil <dn...@google.com>
    Gerrit-Reviewer: Joseph Tsai <joe...@digital-static.net>
    Gerrit-Reviewer: Michael Stapelberg <stape...@google.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Lasse Folger <lasse...@google.com>
    Gerrit-Attention: Joseph Tsai <joe...@digital-static.net>
    Gerrit-Attention: Derek Perkins <de...@nozzle.io>
    Gerrit-Attention: Damien Neil <dn...@google.com>
    Gerrit-Attention: Michael Stapelberg <stape...@google.com>
    Gerrit-Comment-Date: Wed, 09 Aug 2023 05:45:02 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No

    Cassondra Foesch (Gerrit)

    unread,
    Aug 9, 2023, 6:08:53 AM8/9/23
    to Derek Perkins, goph...@pubsubhelper.golang.org, Lasse Folger, Michael Stapelberg, Damien Neil, Joseph Tsai, Gopher Robot, golang-co...@googlegroups.com

    Attention is currently required from: Damien Neil, Derek Perkins, Joseph Tsai, Lasse Folger, Michael Stapelberg.

    View Change

    1 comment:

    • Patchset:

      • I share the same concerns. The functions are not altogether widely used, so the code bloat is almost always going to be without utility on the other side.

        Meanwhile, a protoc plugin could very easily be coded up to emit them alongside the `.pb.go` files, and then anyone who wants the functions can just use the additional protoc plugin.

    To view, visit change 517315. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-MessageType: comment
    Gerrit-Project: protobuf
    Gerrit-Branch: master
    Gerrit-Change-Id: Iafd236b611b0f5d96da0b4b271aa96382de8dd48
    Gerrit-Change-Number: 517315
    Gerrit-PatchSet: 1
    Gerrit-Owner: Derek Perkins <de...@nozzle.io>
    Gerrit-Reviewer: Damien Neil <dn...@google.com>
    Gerrit-Reviewer: Joseph Tsai <joe...@digital-static.net>
    Gerrit-Reviewer: Lasse Folger <lasse...@google.com>
    Gerrit-Reviewer: Michael Stapelberg <stape...@google.com>
    Gerrit-CC: Cassondra Foesch <cfo...@gmail.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-Attention: Joseph Tsai <joe...@digital-static.net>
    Gerrit-Attention: Derek Perkins <de...@nozzle.io>
    Gerrit-Attention: Damien Neil <dn...@google.com>
    Gerrit-Attention: Lasse Folger <lasse...@google.com>
    Gerrit-Attention: Michael Stapelberg <stape...@google.com>
    Gerrit-Comment-Date: Wed, 09 Aug 2023 10:08:48 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Lasse Folger <lasse...@google.com>

    Damien Neil (Gerrit)

    unread,
    Aug 9, 2023, 1:11:32 PM8/9/23
    to Derek Perkins, goph...@pubsubhelper.golang.org, Cassondra Foesch, Lasse Folger, Michael Stapelberg, Joseph Tsai, Gopher Robot, golang-co...@googlegroups.com

    Attention is currently required from: Cassondra Foesch, Derek Perkins, Joseph Tsai, Lasse Folger, Michael Stapelberg.

    View Change

    1 comment:

    • Patchset:

      • Patch Set #1:

        I share the same concerns. […]

        I'm surprised the binary size increase is that noticeable, but I believe you.

        I added a comment on the issue, but my general opinion is that adding these methods isn't unreasonable, but there are several ways in which this could cause problems (binary size, adding a new dependency on the `proto` package, changed behavior) and I'm not sure about the cost/benefit.

    To view, visit change 517315. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-MessageType: comment
    Gerrit-Project: protobuf
    Gerrit-Branch: master
    Gerrit-Change-Id: Iafd236b611b0f5d96da0b4b271aa96382de8dd48
    Gerrit-Change-Number: 517315
    Gerrit-PatchSet: 1
    Gerrit-Owner: Derek Perkins <de...@nozzle.io>
    Gerrit-Reviewer: Damien Neil <dn...@google.com>
    Gerrit-Reviewer: Joseph Tsai <joe...@digital-static.net>
    Gerrit-Reviewer: Lasse Folger <lasse...@google.com>
    Gerrit-Reviewer: Michael Stapelberg <stape...@google.com>
    Gerrit-CC: Cassondra Foesch <cfo...@gmail.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-Attention: Joseph Tsai <joe...@digital-static.net>
    Gerrit-Attention: Derek Perkins <de...@nozzle.io>
    Gerrit-Attention: Cassondra Foesch <cfo...@gmail.com>
    Gerrit-Attention: Lasse Folger <lasse...@google.com>
    Gerrit-Attention: Michael Stapelberg <stape...@google.com>
    Gerrit-Comment-Date: Wed, 09 Aug 2023 17:09:19 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Cassondra Foesch <cfo...@gmail.com>
    Comment-In-Reply-To: Lasse Folger <lasse...@google.com>
    Reply all
    Reply to author
    Forward
    0 new messages