public void NonGeneric_BufferWriter_ReadOnlySequence()
        {
            var data = new FirstSimpleData {
                Prop1 = 9, Prop2 = "hoge", Prop3 = 999
            };
            Type t           = typeof(FirstSimpleData);
            var  ms          = new MemoryStream();
            var  writerBytes = new Sequence <byte>();

            var data1 = MessagePackSerializer.Deserialize(t, MessagePackSerializer.Serialize(t, data)) as FirstSimpleData;
            var data2 = MessagePackSerializer.Deserialize(t, MessagePackSerializer.Serialize(t, data, MessagePackSerializer.DefaultOptions)) as FirstSimpleData;

            MessagePackSerializer.Serialize(t, ms, data);
            ms.Position = 0;
            var data3 = MessagePackSerializer.Deserialize(t, ms) as FirstSimpleData;

            ms = new MemoryStream();
            MessagePackSerializer.Serialize(t, ms, data, MessagePackSerializer.DefaultOptions);
            ms.Position = 0;
            var data4 = MessagePackSerializer.Deserialize(t, ms, MessagePackSerializer.DefaultOptions) as FirstSimpleData;

            MessagePackSerializer.Serialize(t, writerBytes, data, MessagePackSerializer.DefaultOptions);
            var data5 = MessagePackSerializer.Deserialize(t, writerBytes.AsReadOnlySequence, MessagePackSerializer.DefaultOptions) as FirstSimpleData;

            new[] { data1.Prop1, data2.Prop1, data3.Prop1, data4.Prop1, data5.Prop1 }.Distinct().Is(data.Prop1);
            new[] { data1.Prop2, data2.Prop2, data3.Prop2, data4.Prop2, data5.Prop2 }.Distinct().Is(data.Prop2);
            new[] { data1.Prop3, data2.Prop3, data3.Prop3, data4.Prop3, data5.Prop3 }.Distinct().Is(data.Prop3);
        }
        public void NonGeneric()
        {
            var data = new FirstSimpleData {
                Prop1 = 9, Prop2 = "hoge", Prop3 = 999
            };
            Type t           = typeof(FirstSimpleData);
            var  ms          = new MemoryStream();
            var  writerBytes = new Sequence <byte>();
            var  writer      = new MessagePackWriter(writerBytes);

            var data1 = MessagePackSerializer.Deserialize(t, MessagePackSerializer.Serialize(t, data)) as FirstSimpleData;
            var data2 = MessagePackSerializer.Deserialize(t, MessagePackSerializer.Serialize(t, data, MessagePackSerializer.DefaultOptions)) as FirstSimpleData;

            MessagePackSerializer.Serialize(t, ms, data);
            ms.Position = 0;
            var data3 = MessagePackSerializer.Deserialize(t, ms) as FirstSimpleData;

            ms = new MemoryStream();
            MessagePackSerializer.Serialize(t, ms, data, MessagePackSerializer.DefaultOptions);
            ms.Position = 0;
            var data4 = MessagePackSerializer.Deserialize(t, ms, MessagePackSerializer.DefaultOptions) as FirstSimpleData;

#if ENABLE_IL2CPP
            var data5 = data4;
#else
            MessagePackSerializer.Serialize(t, ref writer, data, MessagePackSerializer.DefaultOptions);
            writer.Flush();
            var reader = new MessagePackReader(writerBytes.AsReadOnlySequence);
            var data5  = MessagePackSerializer.Deserialize(t, ref reader, MessagePackSerializer.DefaultOptions) as FirstSimpleData;
#endif

            new[] { data1.Prop1, data2.Prop1, data3.Prop1, data4.Prop1, data5.Prop1 }.Distinct().Is(data.Prop1);
            new[] { data1.Prop2, data2.Prop2, data3.Prop2, data4.Prop2, data5.Prop2 }.Distinct().Is(data.Prop2);
            new[] { data1.Prop3, data2.Prop3, data3.Prop3, data4.Prop3, data5.Prop3 }.Distinct().Is(data.Prop3);
        }
        public void WriterReader()
        {
            var data = new FirstSimpleData {
                Prop1 = 9, Prop2 = "hoge", Prop3 = 999
            };
            var t = typeof(FirstSimpleData);

            var data1 = JsonSerializer.NonGeneric.Deserialize(t, JsonSerializer.NonGeneric.Serialize(t, data)) as FirstSimpleData;
            var data2 = JsonSerializer.NonGeneric.Deserialize(t, JsonSerializer.NonGeneric.Serialize(t, data, StandardResolver.Default)) as FirstSimpleData;


            var ms = new JsonWriter();

            JsonSerializer.NonGeneric.Serialize(t, ref ms, data);
            var ms2   = new JsonReader(ms.ToUtf8ByteArray());
            var data3 = JsonSerializer.NonGeneric.Deserialize(t, ref ms2) as FirstSimpleData;

            ms = new JsonWriter();
            JsonSerializer.NonGeneric.Serialize(t, ref ms, data, StandardResolver.Default);
            ms2 = new JsonReader(ms.ToUtf8ByteArray());
            var data4 = JsonSerializer.NonGeneric.Deserialize(t, ref ms2, StandardResolver.Default) as FirstSimpleData;

            new[] { data1.Prop1, data2.Prop1, data3.Prop1, data4.Prop1 }.Distinct().Is(data.Prop1);
            new[] { data1.Prop2, data2.Prop2, data3.Prop2, data4.Prop2 }.Distinct().Is(data.Prop2);
            new[] { data1.Prop3, data2.Prop3, data3.Prop3, data4.Prop3 }.Distinct().Is(data.Prop3);
        }
        public async Task NonGeneric_Async()
        {
            var data = new FirstSimpleData {
                Prop1 = 9, Prop2 = "hoge", Prop3 = 999
            };
            Type t  = typeof(FirstSimpleData);
            var  ms = new MemoryStream();

            await MessagePackSerializer.SerializeAsync(t, ms, data);

            ms.Position = 0;
            var data2 = (FirstSimpleData)await MessagePackSerializer.DeserializeAsync(t, ms);

            Assert.Equal(data, data2);
        }
        public void NonGeneric()
        {
            var data = new FirstSimpleData {
                Prop1 = 9, Prop2 = "hoge", Prop3 = 999
            };
            var t  = typeof(FirstSimpleData);
            var ms = new MemoryStream();

            var data1 = MessagePackSerializer.NonGeneric.Deserialize(t, MessagePackSerializer.NonGeneric.Serialize(t, data)) as FirstSimpleData;
            var data2 = MessagePackSerializer.NonGeneric.Deserialize(t, MessagePackSerializer.NonGeneric.Serialize(t, data, DefaultResolver.Instance)) as FirstSimpleData;

            MessagePackSerializer.NonGeneric.Serialize(t, ms, data);
            ms.Position = 0;
            var data3 = MessagePackSerializer.NonGeneric.Deserialize(t, ms) as FirstSimpleData;

            ms = new MemoryStream();
            MessagePackSerializer.NonGeneric.Serialize(t, ms, data, DefaultResolver.Instance);
            ms.Position = 0;
            var data4 = MessagePackSerializer.NonGeneric.Deserialize(t, ms, DefaultResolver.Instance) as FirstSimpleData;

            new[] { data1.Prop1, data2.Prop1, data3.Prop1, data4.Prop1 }.Distinct().Is(data.Prop1);
            new[] { data1.Prop2, data2.Prop2, data3.Prop2, data4.Prop2 }.Distinct().Is(data.Prop2);
            new[] { data1.Prop3, data2.Prop3, data3.Prop3, data4.Prop3 }.Distinct().Is(data.Prop3);
        }
        public void NonGeneric()
        {
            var data = new FirstSimpleData {
                Prop1 = 9, Prop2 = "hoge", Prop3 = 999
            };
            var t  = typeof(FirstSimpleData);
            var ms = new MemoryStream();

            var data1 = JsonSerializer.NonGeneric.Deserialize(t, JsonSerializer.NonGeneric.Serialize(t, data)) as FirstSimpleData;
            var data2 = JsonSerializer.NonGeneric.Deserialize(t, JsonSerializer.NonGeneric.Serialize(t, data, StandardResolver.Default)) as FirstSimpleData;

            JsonSerializer.NonGeneric.Serialize(t, ms, data);
            ms.Position = 0;
            var data3 = JsonSerializer.NonGeneric.Deserialize(t, ms) as FirstSimpleData;

            ms = new MemoryStream();
            JsonSerializer.NonGeneric.Serialize(t, ms, data);
            ms.Position = 0;
            var data4 = JsonSerializer.NonGeneric.Deserialize(t, ms, StandardResolver.Default) as FirstSimpleData;

            new[] { data1.Prop1, data2.Prop1, data3.Prop1, data4.Prop1 }.Distinct().Is(data.Prop1);
            new[] { data1.Prop2, data2.Prop2, data3.Prop2, data4.Prop2 }.Distinct().Is(data.Prop2);
            new[] { data1.Prop3, data2.Prop3, data3.Prop3, data4.Prop3 }.Distinct().Is(data.Prop3);
        }