Open kalteherz opened 5 years ago
static readonly SlimSerializer serializer = new SlimSerializer(); static byte[] Serialize(object obj) { using (var ms = new MemoryStream()) { serializer.Serialize(ms, obj); return ms.ToArray(); } } static object Deserialize(byte[] data) { using (var ms = new MemoryStream(data)) { return serializer.Deserialize(ms); } } static void Main(string[] args) { var dateTimeOffsetNow = DateTimeOffset.Now; var packedDateTimeOffset = new {Now = dateTimeOffsetNow}; var serializedDateTimeOffset = Serialize(dateTimeOffsetNow); var serializedPackedDateTimeOffset = Serialize(packedDateTimeOffset); var deserializedDateTimeOffsetNow = Deserialize(serializedDateTimeOffset); var deserializedPackedDateTimeOffset = (dynamic) Deserialize(serializedPackedDateTimeOffset); } // dateTimeOffsetNow: 6/27/2019 1:02:12 PM +03:00 // deserializedDateTimeOffsetNow: 6/27/2019 1:02:12 PM +03:00 // packedDateTimeOffset.Now: 6/27/2019 1:02:12 PM +03:00 // deserializedPackedDateTimeOffset.Now: 1/1/0001 12:00:00 AM +00:00
I made a copy of the issue in Azos https://github.com/azist/azos/issues/151