protobuf-go/reflect
Joe Tsai 2cdb23da01 reflect/prototype: remove TODO about custom extensions constructors
Most usages extensions are only for fields that have a singular message
as the type. In such a sitation, the Go type and constructors are determined
by the provided protoreflect.MessageType and is certainly what the user wanted.

Custom extensions constructors are mainly useful if the user wants to use their
own type to represent repeated fields. For example, we use *[]T to represent
repeated fields, while a user may want to use their own opaque type.

However, this is such a niche use-case that it is not worth supporting given
that there is a workaround:

	type MyExtensionType struct {
		protoreflect.ExtensionType
	}
	func (x MyExtensionType) GoNew() interface{} {
		... // return my custom value
	}
	func (x MyExtensionType) GoType() reflect.Type {
		... // return my custom type
	}
	func (x MyExtensionType) ValueOf(v interface{}) protoreflect.Value {
		... // convert my custom type to a protoreflect.Value
	}
	func (x MyExtensionType) InterfaceOf(v protoreflect.Value) interface{} {
		... // convert a protoreflect.Value to my custom type
	}

Change-Id: Iafc838b1c95b0ffc8583461ee9eb327bd3ce9c3c
Reviewed-on: https://go-review.googlesource.com/c/148820
Reviewed-by: Herbie Ong <herbie@google.com>
2018-11-10 00:59:49 +00:00
..
protoreflect reflect/protoreflect: clarify Clear and Remove operation on missing entries 2018-11-08 02:34:04 +00:00
protoregistry go.mod: rename google.golang.org/proto as github.com/golang/protobuf/v2 2018-09-24 16:11:50 +00:00
prototype reflect/prototype: remove TODO about custom extensions constructors 2018-11-10 00:59:49 +00:00