Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Typeless.Deserialize does not return equivalent dynamic object #224

Copy link
Copy link
Closed
@sudsy

Description

@sudsy
Issue body actions

I came across something a little strange about the way the dynamic objects are structured. The following test fails with the exception Microsoft.CSharp.RuntimeBinder.RuntimeBinderException : 'System.Collections.Generic.Dictionary<object,object>' does not contain a definition for 'Amount':

 [Fact]
        public void testDynamic()
        {
            var v = new { Amount = 108, Message = "Hello" };
            var bin = MessagePackSerializer.Typeless.Serialize(v);
            dynamic newV = MessagePackSerializer.Typeless.Deserialize(bin);
            Assert.Equal(v.Amount, (int)newV.Amount);
            Assert.Equal(v.Message, (string)newV.Message);
        }

While an equivalent test using Newtonsoft passes

 [Fact]
        public void testDynamicJson()
        {
            var v = new { Amount = 108, Message = "Hello" };
            var json = JsonConvert.SerializeObject(v);
            dynamic newV = JsonConvert.DeserializeObject(json);
            Assert.Equal(v.Amount, (int)newV.Amount);
            Assert.Equal(v.Message, (string)newV.Message);
        }

I can see that this would be a breaking change so I didn't even attempt a fix and pull request.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.