Hi, we've been using protobuf-net with much joy for sometime but have a 
tiny issue which I'm hoping someone might be able to guide us on...

when using enums, is there a way to get protobuf-net fallback to a default 
value when its using a older model version for backwards compatibility, for 
example, given

enum ReqRepType
{
    UnknownReqRepType = 0;
    Login = 1;
    SayHello = 2; //added in a later version of the model
}

message Batch
{
    repeated Request requests = 1;
}

message Request
{
    optional ReqRepType rrType = 1 [default = UnknownReqRepType];
}

if we deserialize a proto binary that has the enum value "SayHello" in a 
batch's request collection on an older binary that is not aware of the enum 
value 2 - we'd like it to fallback to the default "UnknownReqRepType" but 
we get an error:

Failed to load ..\..\..\datafiles\v2.proto
ProtoBuf.ProtoException: No com.spaceape.proto.test.ReqRepType enum is 
mapped to the wire-value 2
   at ProtoBuf.ProtoReader.ThrowEnumException(Type type, Int32 value)
   at PersistenceSerializer.Read(Request , ProtoReader )
   at PersistenceSerializer.Read(Batch , ProtoReader )
   at PersistenceSerializer.Deserialize(Int32 , Object , ProtoReader )
   at ProtoBuf.Meta.TypeModel.DeserializeCore(ProtoReader reader, Type 
type, Object value, Boolean noAutoCreate)
   at ProtoBuf.Meta.TypeModel.Deserialize(Stream source, Object value, Type 
type, SerializationContext context)
   at ProtoBuf.Meta.TypeModel.Deserialize(Stream source, Object value, Type 
type)
   at prototest.Program.Load[T](String path) in 
c:\temp\proto\prototest-v1\Program.cs:line 74Failed to load file

our Java version works ok and it gracefully falls back to UnknownReqRepType.

Are we missing an option in the code gen? (Tested against protobuf-net 
2.0.0.668 and protoc 2.4.1)

Can provide a simple project to demo this issue if needed.


thanks,
Andy

-- 
This email and any attachments may be confidential and/or legally 
privileged. If you have received this e-mail and you are not a named 
addressee, please inform the sender. If you are not a named addressee you 
must not use, disclose, distribute, copy, print or rely on this e-mail. Any 
views or opinions presented are solely those of the author. Any statements 
made, or intentions expressed in this communication may not necessarily 
reflect the view of Space Ape Games. Although Space Ape Games routinely 
screen for viruses, addressees should scan this e-mail and any attachments 
for viruses. Space Ape Games make no representation or warranty as to the 
absence of viruses in this e-mail or any attachments.

Space Ape Games (UK) Limited is registered in England and Wales 7956131. 
Space Ape Games, 25 Soho Square, London, UK, W1D 3QR  www.spaceapegames.com

-- 
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 http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to