reflect/protoreflect: add helper methods to FieldDescriptor
Added API:
FieldDescriptor.IsExtension
FieldDescriptor.IsList
FieldDescriptor.MapKey
FieldDescriptor.MapValue
FieldDescriptor.ContainingOneof
FieldDescriptor.ContainingMessage
Deprecated API (to be removed in subsequent CL):
FieldDescriptor.Oneof
FieldDescriptor.Extendee
These methods help cleanup several common usage patterns.
Change-Id: I9a3ffabc2edb2173c536509b22f330f98bba7cf3
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/176977
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/internal/legacy/file_test.go b/internal/legacy/file_test.go
index 9a9a3fc..c8d9af5 100644
--- a/internal/legacy/file_test.go
+++ b/internal/legacy/file_test.go
@@ -433,7 +433,7 @@
case "HasJSONName":
// Ignore this since the semantics of the field has
// changed across protoc and protoc-gen-go releases.
- case "Oneof", "Extendee", "Enum", "Message":
+ case "ContainingOneof", "ContainingMessage", "Enum", "Message":
// Avoid descending into a dependency to avoid a cycle.
// Just record the full name if available.
//
@@ -442,6 +442,8 @@
if !v.IsNil() {
out[name] = v.Interface().(pref.Descriptor).FullName()
}
+ case "Oneof", "Extendee":
+ // TODO: Remove this.
default:
out[name] = m.Call(nil)[0].Interface()
}