The Descriptor classes don't support this as typically we want to enforce
that the Descriptor objects are in fact the same instances. In the protobuf
code you'll see simple pointer comparisons.

You could convert the descriptors back to DescriptorProtos and compare
those: however, this won't account for any extensions of those descriptors.
You might also want to find all known extensions for those particular
descriptors, and check the compatibility of those FieldDescriptors. And if
you are asking about wire compatibility, rather than strictly being the same
descriptors, the comparison is quite a bit more complicated.

On Fri, Apr 8, 2011 at 12:21 PM, Toby Schneider <tes.auberg...@gmail.com>wrote:

> I have a multi-process application where one of the processes needs to
> work on arbitrary message types provided by one of the other processes
> via FileDescriptorProto.
>
> Is there a way to check that a given Descriptor is compatible with
> another Descriptor with the same full_name()?
>
> For example:
>
> ************
> Scenario 1
>
> Application 1:
>
> message Foo
> {
>   optional int32 a = 1;
>   optional int32 b = 2;
> }
>
> Application 2:
>
> // updated but compatible Foo
> message Foo
> {
>   optional int32 a = 1;
>   optional int32 b = 2;
>   optional int32 c = 3;
> }
>
> Application 3: Gets Foo from 1 & 2 via a FileDescriptorProto (which
> are then converted to Descriptors via DescriptorPool::BuildFile() )
> and wants to check that they are compatible.
> ************
>
>
> ************
> Scenario 1
>
> Application 1:
>
> message Foo
> {
>   optional int32 a = 1;
>   optional int32 b = 2;
> }
>
> Application 2:
>
> // updated but incompatible Foo
> message Foo
> {
>   optional int32 a = 1;
>   optional string b = 2;
> }
>
> Application 3: Gets Foo from 1 & 2 via a FileDescriptorProto (which
> are then converted to Descriptors via DescriptorPool::BuildFile() )
> and wants to check that they are compatible.
> ************
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To post to this group, send email to protobuf@googlegroups.com.
> To unsubscribe from this group, send email to
> protobuf+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/protobuf?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to