internal/fileinit: add FileDescriptor.ProtoLegacyRawDesc method
Add a ProtoLegacyRawDesc method for v1 registration support.
Change-Id: I4f03d022854c8d79da776610cb7d75ba9976334f
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/172241
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/internal/fileinit/desc.go b/internal/fileinit/desc.go
index 199e38d..120b7b9 100644
--- a/internal/fileinit/desc.go
+++ b/internal/fileinit/desc.go
@@ -218,12 +218,12 @@
// fileInit contains a copy of certain fields in FileBuilder for use during
// lazy initialization upon first use.
fileInit struct {
- RawDescriptor []byte
GoTypes []interface{}
DependencyIndexes []int32
}
fileDesc struct {
fileInit
+ rawDesc []byte
path string
protoPackage pref.FullName
@@ -270,6 +270,15 @@
func (fd *fileDesc) ProtoType(pref.FileDescriptor) {}
func (fd *fileDesc) ProtoInternal(pragma.DoNotImplement) {}
+// ProtoLegacyRawDesc is a pseudo-internal API for allowing the v1 code
+// to be able to retrieve the raw descriptor.
+//
+// WARNING: This method is exempt from the compatibility promise and may be
+// removed in the future without warning.
+func (fd *fileDesc) ProtoLegacyRawDesc() []byte {
+ return fd.rawDesc
+}
+
type (
enumDesc struct {
baseDesc