I was replacing internal Serializations in my application from Jil to Bond.
I'm switching simple classes with Ms Bond attributes and everything worked fine until I got one with a DateTime. I had then a Dictionary KeyNotFound Exception error during Serialization.
I suspect Bond do not support DateTime, is that so? And if it is, why is not implemented? DateTime is not a basic type but adding a custom converter is not worth it, the speed gain vs protobuf-net is minimal and I don't need generics, just simple fast de/serializer.
I hope I'm missing something, I really want to use Bond, but I need an easy tool too, I cannot risk breaking the application because something basic like a Date or Guid is not supported by default. I'm writing here after hours of researches and the Young Guide to C# bond does not clearly mention what is and what is not supported.
No, there is no built-in timestamp type in Bond. The built-in types in Bond are documented in the manual for the gbc compiler.
For GUIDs, there's Bond.GUID
, which has implicit conversions to/from System.Guid
. Note that Bond.GUID
lives in bond.bond, so if you want to refer to this from a .bond file, you'll need to use Bond's import functionality and import "bond/core/bond.bond"
There's an example showing how to use DateTime
with a custom type alias.
The reason there is no built-in timestamp type in Bond is that there are so many different ways (and standards) for representing timestamps. There's a similar C++ example that shows representing time with a boost::posix_time::ptime
, highlighting the various different ways that time is represented.
Our experience has been that projects usually already have a representation for timestamps that they want to use, so, we recommend using a converter so that you can use the representation that's appropriate for your circumstances.
As a side note, my experience has been that DateTimeOffset
is a more generally useful type, compared to DateTime
.