Change MessageName to check if Message has an XXX_MessageName() method, and use the name returned by that method instead of internal registry when present. PiperOrigin-RevId: 131111087
diff --git a/proto/properties.go b/proto/properties.go index 69ddda8..ec2289c 100644 --- a/proto/properties.go +++ b/proto/properties.go
@@ -844,7 +844,15 @@ } // MessageName returns the fully-qualified proto name for the given message type. -func MessageName(x Message) string { return revProtoTypes[reflect.TypeOf(x)] } +func MessageName(x Message) string { + type xname interface { + XXX_MessageName() string + } + if m, ok := x.(xname); ok { + return m.XXX_MessageName() + } + return revProtoTypes[reflect.TypeOf(x)] +} // MessageType returns the message type (pointer to struct) for a named message. func MessageType(name string) reflect.Type { return protoTypes[name] }