Hi Arpit, I think you're right that the Any type could technically be updated to support storing lite protos. The original motivation for requiring non-lite protos was that we need to have the type name, which we currently get from the descriptor, though as you mentioned it appears that we can also get it from MessageLite::GetTypeName().
Here's the thing, though: we are actually thinking about removing the MessageLite::GetTypeName method at some point in the future. Lite protos are intended primarily for mobile and so in that environment it's important to keep the binary as small as possible and also avoid including symbols in the code that's distributed, whereas currently that method requires us to generate code that includes the message type names. So I think it would be best to avoid creating another dependency on that GetTypeName() method when it might be going away in the future. As a workaround you can still store lite protos inside an Any, but you just have to do it by manually setting the fields on Any <https://github.com/google/protobuf/blob/v3.1.0/src/google/protobuf/any.proto#L112> without the help of the PackFrom() and UnpackTo() methods. This might require a little bit of extra boilerplate code but it shouldn't be too bad. Adam On Tue, Oct 4, 2016 at 4:25 PM, Arpit Baldeva <[email protected]> wrote: > Hi, > > I was wondering if there is any reason that Any type is implemented in > terms of Message interface rather than MessageLite? It'd seem to me that > all this class needs to work correctly is to use GetTypeName() on > MessageLite interface. > > My motivation is, of course, to be able to use Any type with Lite run > time. > > --Arpit > > -- > You received this message because you are subscribed to the Google Groups > "Protocol Buffers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/protobuf. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
