FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

v1.0 ArgumentOutOfRangeException for DateTime before 1970 if has milliseconds. Works in 0.9.X · Issue #296 · msgpack/msgpack-cli · GitHub

v1.0 ArgumentOutOfRangeException for DateTime before 1970 if has milliseconds. Works in 0.9.X #296

Description

The code snippet below works with versions 0.9.0, 0.9.1, 0.9.2, but faults on 1.0.0 with this error:

System.ArgumentOutOfRangeException: 'nanoseconds must be non negative value and lessor than 999,999,999. Parameter name: nanoseconds

It seems MsgPack-CLI version 1.0 faults for certain values of DateTime.
Fails: 1969-12-31T23:59:59.001 to 1969-12-31T23:59:59.999
Works: 1969-12-31T23:59:59.000
Works: 1970-01-01

It always seems to work after 1970-01-01 and always fail to serialize dates before 1970-01-01 if and only if the milliseconds are non-zero.

    public class MyClass
    {
        public DateTime MyDate;
    }

    public static void TestBrokenMessagePack()
    {
        var serializerMPMyClass = SerializationContext.Default.GetSerializer<MyClass>();
        using (var stream = new MemoryStream())
        {
            var my = new MyClass
            {
                MyDate =
                DateTime.Parse("1969-12-31T23:59:59.001")
            };
            serializerMPMyClass.Pack(stream, my); // << This line faults
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugDetected as bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


    Back | FazBrowse Home | New Git URL