7

Is there a preferred method for serializing Guids in protobuf-net? It doesn't seem to be a supported type?

Steve
  • 1,605
  • 1
  • 18
  • 29
  • I have been serializing it as a string but am having some strange problems that seem related to that property. I haven't been able to validate the exact issue yet but thought maybe there was a better way to handle Guids. – Steve Aug 31 '10 at 16:07
  • I had a problem where the "first" property in my object was a Guid type (like ID, UID, etc...). On deserialization, it was always an empty GUID. I found out that I had set the order in the attribute at 0 (thinking zero-based-index). Must be positive integer, starting at 1. Once I shifted the numbers, it all worked. – Chris Ray Jun 21 '13 at 20:44

1 Answers1

11

Apologies for the delay - holiday etc. In protobuf-net, Guid should work fine - it is treated pretty much as a byte[]. To confirm: do you mean protobuf-net (a specific implementation)? Or just protobuf generally (where it isn't a core type).

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
  • Yes, I was meaning the specific protobuf-net implementation. My apologies, my problems must have been "user error". I tried serializing a Guid in sandboxed tests this morning and was able to successfully serialize Guid and Guid? with the current versions I have of V1 and V2. I'm more stumped now, but I am definitely able to serialize Guids as Guids. Thank you! – Steve Sep 08 '10 at 15:40