Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Slim) Packed DateTimeOffset is equal to MinValue after deserialization #82

Open
kalteherz opened this issue Jun 27, 2019 · 1 comment

Comments

@kalteherz
Copy link

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
@kalteherz kalteherz changed the title Packed DateTimeOffset is equal to MinValue after deserialization (Slim) Packed DateTimeOffset is equal to MinValue after deserialization Jun 27, 2019
@kalteherz
Copy link
Author

I made a copy of the issue in Azos
azist/azos#151

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant