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>
1 file changed
tree: a4d93dc2a22b1e58ea4334f5712ee901b506ec59
  1. cmd/
  2. internal/
  3. protogen/
  4. reflect/
  5. .gitignore
  6. .travis.yml
  7. AUTHORS
  8. CONTRIBUTING.md
  9. CONTRIBUTORS
  10. go.mod
  11. go.sum
  12. LICENSE
  13. PATENTS
  14. README.md
  15. regenerate.bash
  16. test.bash
README.md

Next Generation Go Protocol Buffers

WARNING: This repository is in active development. There are no guarantees about API stability. Breaking changes will occur until a stable release is made and announced.

This repository is for the development of the next major Go implementation of protocol buffers. This library makes breaking API changes relative to the existing Go protobuf library. Of particular note, this API aims to make protobuf reflection a first-class feature of the API and implements the protobuf ecosystem in terms of reflection.

Design Documents

List of relevant design documents:

Contributing

We appreciate community contributions. See CONTRIBUTING.md.

Reporting Issues

Issues regarding the new API can be filed at github.com/golang/protobuf. Please use a APIv2: prefix in the title to make it clear that the issue is regarding the new API work.