protobuf-go/internal/impl
Joe Tsai 23ccb359e1 internal/impl: add runtime support for aberrant messages
Implement support in the protobuf runtime to better understand
message types that are not generated by the official generator.

In particular:
* Add a best-effort implementation of protobuf reflection for
"non-nullable" fields which are supposed to be represented by *T,
but are instead represented by a T. "Non-nullable" message fields
report presence based on whether the message is the zero Go value.
* We do NOT implement support for "non-nullable" fields in the
table-driven implementation since we assume that the aberrant messages
that we care about have a Marshal and Unmarshal method.
* We better handle custom messages that implement Marshal and Unmarshal,
but do NOT implement Merge. In that case, we implement merge in terms of
a back-to-back marshal and unmarshal.
* We better tolerate the situations where a protobuf message field
cannot be mapped to a Go struct field since the latter is missing.
In such cases, reflection treats the field as if it were unpopulated.
Setting such fields will panic.

This change allows the runtime to handle all message types declared
in the "go.etcd.io/etcd" and "k8s.io" modules where protobuf reflection,
Marshal, Unmarshal, Reset, Merge, and Equal all work.

The only types that still do not fully work are:
	* "k8s.io/api/authentication/v1".ExtraValue
	* "k8s.io/api/authentication/v1beta1".ExtraValue
	* "k8s.io/api/authorization/v1".ExtraValue
	* "k8s.io/api/authorization/v1beta1".ExtraValue
	* "k8s.io/api/certificates/v1".ExtraValue
	* "k8s.io/api/certificates/v1beta1".ExtraValue
	* "k8s.io/apimachinery/pkg/apis/meta/v1".MicroTime
	* "k8s.io/apimachinery/pkg/apis/meta/v1".Time
	* "k8s.io/apimachinery/pkg/apis/meta/v1".Verbs
While Marshal, Unmarshal, Reset, and Merge continue to work,
protobuf reflection and any functionality that depends on it
(e.g., prototext, protojson, Equal, etc.) will not work.

Change-Id: I67a9d2f1bec35248045ad0c16220d02fc2e0e172
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/300869
Trust: Joe Tsai <joetsai@digital-static.net>
Trust: Joe Tsai <thebrokentoaster@gmail.com>
Reviewed-by: Damien Neil <dneil@google.com>
2021-03-16 02:41:12 +00:00
..
api_export.go reflect/protoreflect: add MessageFieldTypes 2020-07-23 21:24:58 +00:00
checkinit.go all: rename IsInitialized as CheckInitialized 2020-02-20 20:45:40 +00:00
codec_extension.go internal/impl: remove deprecated ExtensionField methods 2020-03-23 18:37:32 +00:00
codec_field.go internal/impl: make errInvalidUTF8 be a proto.Error 2020-07-24 21:43:34 +00:00
codec_gen.go internal/cmd/generate-types: use ConsumeBytes instead of ConsumeString 2020-10-20 20:17:50 +00:00
codec_map_go111.go
codec_map_go112.go
codec_map.go all: return less-specific, but more informative wire unmarshal errors 2020-07-23 20:09:00 +00:00
codec_message.go internal/impl: add runtime support for aberrant messages 2021-03-16 02:41:12 +00:00
codec_messageset.go internal/impl: add runtime support for *[]byte unknown representation 2020-07-28 16:36:39 +00:00
codec_reflect.go all: return less-specific, but more informative wire unmarshal errors 2020-07-23 20:09:00 +00:00
codec_tables.go internal/impl: validate UTF-8 for proto3 optional strings 2020-05-01 17:23:32 +00:00
codec_unsafe.go
convert_list.go all: improve extension validation 2020-04-23 06:01:13 +00:00
convert_map.go all: improve extension validation 2020-04-23 06:01:13 +00:00
convert.go internal/impl: add runtime support for aberrant messages 2021-03-16 02:41:12 +00:00
decode.go internal/impl: add runtime support for *[]byte unknown representation 2020-07-28 16:36:39 +00:00
encode.go internal/impl: add runtime support for *[]byte unknown representation 2020-07-28 16:36:39 +00:00
enum_test.go
enum.go
extension_test.go all: trivial formatting changes 2020-02-25 21:59:54 +00:00
extension.go
lazy_test.go all: tests, tweaks for lazy extension decoding 2020-02-06 19:43:25 +00:00
legacy_aberrant_test.go internal/impl: handle extremely old messages 2020-04-02 21:12:23 +00:00
legacy_enum.go all: minor tweaks 2020-01-12 09:18:34 +00:00
legacy_export_test.go
legacy_export.go reflect/protoreflect: add MessageFieldTypes 2020-07-23 21:24:58 +00:00
legacy_extension.go reflect/protoreflect: add FieldDescriptor.TextName 2020-07-08 23:23:57 +00:00
legacy_file_test.go all: trivial formatting changes 2020-02-25 21:59:54 +00:00
legacy_file.go
legacy_message.go internal/impl: add runtime support for aberrant messages 2021-03-16 02:41:12 +00:00
legacy_test.go all: trivial formatting changes 2020-02-25 21:59:54 +00:00
merge_gen.go all: remove stray "." from license headers 2020-02-20 18:54:38 +00:00
merge.go internal/impl: add runtime support for *[]byte unknown representation 2020-07-28 16:36:39 +00:00
message_reflect_field.go internal/impl: add runtime support for aberrant messages 2021-03-16 02:41:12 +00:00
message_reflect_gen.go all: improve panic messages for better debugability 2020-05-05 21:10:54 +00:00
message_reflect_test.go internal/impl: add runtime support for *[]byte unknown representation 2020-07-28 16:36:39 +00:00
message_reflect.go internal/impl: add runtime support for aberrant messages 2021-03-16 02:41:12 +00:00
message.go internal/impl: add runtime support for *[]byte unknown representation 2020-07-28 16:36:39 +00:00
pointer_reflect.go internal/impl: add runtime support for *[]byte unknown representation 2020-07-28 16:36:39 +00:00
pointer_unsafe.go internal/impl: add runtime support for *[]byte unknown representation 2020-07-28 16:36:39 +00:00
validate.go internal/genid: add new package for generated identifiers 2020-05-29 07:08:23 +00:00
weak.go all: use v2 Message interface for weak fields 2020-04-29 22:34:29 +00:00