MessagePack-CSharp　Map型　メモ

※Windows機が必須

１：最新のリリースビルドを落として来る
https://github.com/neuecc/MessagePack-CSharp/releases

２：解凍して任意の場所に置く

３：新規Unityプロジェクトを作る。

４：メニューバーからAssets->import package->Custom Package　を選択し、
　　２：で解凍したパッケージを選択してインポートする。

![パッケージ選択.png](https://qiita-image-store.s3.amazonaws.com/0/17904/70e58de3-a21e-0ff2-fc9c-afeaa45835f9.png)
![インポート.png](https://qiita-image-store.s3.amazonaws.com/0/17904/f5378924-1560-7576-0859-cc4ab6019d87.png)


５：下記テストクラスを作成

クラス名の属性に必ず**[MessagePackObject(true)]**をつける。

```
using System.Collections.Generic;
using System.Text;
using MessagePack;


[MessagePackObject(true)]
public class ListTest
{
    public int acb;
    public StringBuilder def;
}

[MessagePackObject(true)]
public class MultiType  {

    public int aaa;
    public long bbb;
    public float ccc;
    public double ddd;
    public StringBuilder eee = new StringBuilder();
    public int[] fff =  new int[] { 1, 3, 5, 7, 9 };
    public StringBuilder[] ggg = new StringBuilder[5];
    public List<int> hhh = new List<int>();
    public List<StringBuilder> iii = new List<StringBuilder>();
    public Dictionary<int, StringBuilder> jjj = new Dictionary<int, StringBuilder>();
    public Dictionary<StringBuilder, StringBuilder> kkk = new Dictionary<StringBuilder, StringBuilder>();
    public List<ListTest> lll = new List<ListTest>();
    public Dictionary<StringBuilder, ListTest> mmm = new Dictionary<StringBuilder, ListTest>();
    public List<List<ListTest>> nnn = new List<List<ListTest>>();
    public Dictionary<StringBuilder, List<ListTest>> ooo = new Dictionary<StringBuilder, List<ListTest>>();

}

```


６：コマンドプロンプトまたはPowerShellを開く

７：２：で解凍したフォルダ内のToolsフォルダ内にあるmpc.exeのあるフォルダまでcdコマンドで遷移
　　**（mpc.exeはWindowsでしか実行できない）**

下記コマンドを実行

```
 .\mpc.exe -i 指定プロジェクトのプロジェクトファイルのパス(*.csproj) -o 指定プロジェクトの任意の名前のクラス名（フルパス）※仮にMessagePackGenerated.csとする。


例：）
.\mpc.exe -i 自分PCドキュメントフォルダ\MessagePack_CSharp_Sample_Various_Type\MessagePack_CSharp_Sample_Various_Type.csproj -o 自分PCドキュメントフォルダ\MessagePack_CSharp_Sample_Various_\Assets\Scripts\MessagePackGenerated.cs
```


８：下記クラスが作成される。
　　※コンパイルエラーになるが、名前空間のエラーなので任意のものを修正する。

```
#pragma warning disable 618
#pragma warning disable 612
#pragma warning disable 414
#pragma warning disable 168

namespace MessagePack.Resolvers
{
    using System;
    using MessagePack;

    public class GeneratedResolver : global::MessagePack.IFormatterResolver
    {
        public static readonly global::MessagePack.IFormatterResolver Instance = new GeneratedResolver();

        GeneratedResolver()
        {

        }

        public global::MessagePack.Formatters.IMessagePackFormatter<T> GetFormatter<T>()
        {
            return FormatterCache<T>.formatter;
        }

        static class FormatterCache<T>
        {
            public static readonly global::MessagePack.Formatters.IMessagePackFormatter<T> formatter;

            static FormatterCache()
            {
                var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T));
                if (f != null)
                {
                    formatter = (global::MessagePack.Formatters.IMessagePackFormatter<T>)f;
                }
            }
        }
    }

    internal static class GeneratedResolverGetFormatterHelper
    {
        static readonly global::System.Collections.Generic.Dictionary<Type, int> lookup;

        static GeneratedResolverGetFormatterHelper()
        {
            lookup = new global::System.Collections.Generic.Dictionary<Type, int>(10)
            {
                {typeof(global::System.Collections.Generic.List<int>), 0 },
                {typeof(global::System.Collections.Generic.List<string>), 1 },
                {typeof(global::System.Collections.Generic.Dictionary<int, string>), 2 },
                {typeof(global::System.Collections.Generic.Dictionary<string, string>), 3 },
                {typeof(global::System.Collections.Generic.List<global::ListTest>), 4 },
                {typeof(global::System.Collections.Generic.Dictionary<string, global::ListTest>), 5 },
                {typeof(global::System.Collections.Generic.List<global::System.Collections.Generic.List<global::ListTest>>), 6 },
                {typeof(global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.List<global::ListTest>>), 7 },
                {typeof(global::ListTest), 8 },
                {typeof(global::MultiType), 9 },
            };
        }

        internal static object GetFormatter(Type t)
        {
            int key;
            if (!lookup.TryGetValue(t, out key)) return null;

            switch (key)
            {
                case 0: return new global::MessagePack.Formatters.ListFormatter<int>();
                case 1: return new global::MessagePack.Formatters.ListFormatter<string>();
                case 2: return new global::MessagePack.Formatters.DictionaryFormatter<int, string>();
                case 3: return new global::MessagePack.Formatters.DictionaryFormatter<string, string>();
                case 4: return new global::MessagePack.Formatters.ListFormatter<global::ListTest>();
                case 5: return new global::MessagePack.Formatters.DictionaryFormatter<string, global::ListTest>();
                case 6: return new global::MessagePack.Formatters.ListFormatter<global::System.Collections.Generic.List<global::ListTest>>();
                case 7: return new global::MessagePack.Formatters.DictionaryFormatter<string, global::System.Collections.Generic.List<global::ListTest>>();
                case 8: return new MessagePack.Formatters..ListTestFormatter();
                case 9: return new MessagePack.Formatters..MultiTypeFormatter();
                default: return null;
            }
        }
    }
}

#pragma warning disable 168
#pragma warning restore 414
#pragma warning restore 618
#pragma warning restore 612



#pragma warning disable 618
#pragma warning disable 612
#pragma warning disable 414
#pragma warning disable 168

namespace MessagePack.Formatters.
{
    using System;
    using MessagePack;


    public sealed class ListTestFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::ListTest>
    {

        readonly global::System.Collections.Generic.Dictionary<string, int> ____keyMapping;

        public ListTestFormatter()
        {
            this.____keyMapping = new global::System.Collections.Generic.Dictionary<string, int>(2)
            {
                { "acb", 0},
                { "def", 1},
            };
        }


        public int Serialize(ref byte[] bytes, int offset, global::ListTest value, global::MessagePack.IFormatterResolver formatterResolver)
        {
            if (value == null)
            {
                return global::MessagePack.MessagePackBinary.WriteNil(ref bytes, offset);
            }
            
            var startOffset = offset;
            offset += global::MessagePack.MessagePackBinary.WriteFixedMapHeaderUnsafe(ref bytes, offset, 2);
            offset += global::MessagePack.MessagePackBinary.WriteStringUnsafe(ref bytes, offset, "acb", 3);
            offset += MessagePackBinary.WriteInt32(ref bytes, offset, value.acb);
            offset += global::MessagePack.MessagePackBinary.WriteStringUnsafe(ref bytes, offset, "def", 3);
            offset += formatterResolver.GetFormatterWithVerify<string>().Serialize(ref bytes, offset, value.def, formatterResolver);
            return offset - startOffset;
        }

        public global::ListTest Deserialize(byte[] bytes, int offset, global::MessagePack.IFormatterResolver formatterResolver, out int readSize)
        {
            if (global::MessagePack.MessagePackBinary.IsNil(bytes, offset))
            {
                readSize = 1;
                return null;
            }

            var startOffset = offset;
            var length = global::MessagePack.MessagePackBinary.ReadMapHeader(bytes, offset, out readSize);
            offset += readSize;

            var __acb__ = default(int);
            var __def__ = default(string);

            for (int i = 0; i < length; i++)
            {
                var stringKey = global::MessagePack.MessagePackBinary.ReadString(bytes, offset, out readSize);
                offset += readSize;
                int key;
                if (!____keyMapping.TryGetValue(stringKey, out key))
                {
                    readSize = global::MessagePack.MessagePackBinary.ReadNextBlock(bytes, offset);
                    goto NEXT_LOOP;
                }

                switch (key)
                {
                    case 0:
                        __acb__ = MessagePackBinary.ReadInt32(bytes, offset, out readSize);
                        break;
                    case 1:
                        __def__ = formatterResolver.GetFormatterWithVerify<string>().Deserialize(bytes, offset, formatterResolver, out readSize);
                        break;
                    default:
                        readSize = global::MessagePack.MessagePackBinary.ReadNextBlock(bytes, offset);
                        break;
                }
                
                NEXT_LOOP:
                offset += readSize;
            }

            readSize = offset - startOffset;

            var ____result = new global::ListTest();
            ____result.acb = __acb__;
            ____result.def = __def__;
            return ____result;
        }
    }


    public sealed class MultiTypeFormatter : global::MessagePack.Formatters.IMessagePackFormatter<global::MultiType>
    {

        readonly global::System.Collections.Generic.Dictionary<string, int> ____keyMapping;

        public MultiTypeFormatter()
        {
            this.____keyMapping = new global::System.Collections.Generic.Dictionary<string, int>(15)
            {
                { "aaa", 0},
                { "bbb", 1},
                { "ccc", 2},
                { "ddd", 3},
                { "eee", 4},
                { "fff", 5},
                { "ggg", 6},
                { "hhh", 7},
                { "iii", 8},
                { "jjj", 9},
                { "kkk", 10},
                { "lll", 11},
                { "mmm", 12},
                { "nnn", 13},
                { "ooo", 14},
            };
        }


        public int Serialize(ref byte[] bytes, int offset, global::MultiType value, global::MessagePack.IFormatterResolver formatterResolver)
        {
            if (value == null)
            {
                return global::MessagePack.MessagePackBinary.WriteNil(ref bytes, offset);
            }
            
            var startOffset = offset;
            offset += global::MessagePack.MessagePackBinary.WriteFixedMapHeaderUnsafe(ref bytes, offset, 15);
            offset += global::MessagePack.MessagePackBinary.WriteStringUnsafe(ref bytes, offset, "aaa", 3);
            offset += MessagePackBinary.WriteInt32(ref bytes, offset, value.aaa);
            offset += global::MessagePack.MessagePackBinary.WriteStringUnsafe(ref bytes, offset, "bbb", 3);
            offset += MessagePackBinary.WriteInt64(ref bytes, offset, value.bbb);
            offset += global::MessagePack.MessagePackBinary.WriteStringUnsafe(ref bytes, offset, "ccc", 3);
            offset += MessagePackBinary.WriteSingle(ref bytes, offset, value.ccc);
            offset += global::MessagePack.MessagePackBinary.WriteStringUnsafe(ref bytes, offset, "ddd", 3);
            offset += MessagePackBinary.WriteDouble(ref bytes, offset, value.ddd);
            offset += global::MessagePack.MessagePackBinary.WriteStringUnsafe(ref bytes, offset, "eee", 3);
            offset += formatterResolver.GetFormatterWithVerify<string>().Serialize(ref bytes, offset, value.eee, formatterResolver);
            offset += global::MessagePack.MessagePackBinary.WriteStringUnsafe(ref bytes, offset, "fff", 3);
            offset += formatterResolver.GetFormatterWithVerify<int[]>().Serialize(ref bytes, offset, value.fff, formatterResolver);
            offset += global::MessagePack.MessagePackBinary.WriteStringUnsafe(ref bytes, offset, "ggg", 3);
            offset += formatterResolver.GetFormatterWithVerify<string[]>().Serialize(ref bytes, offset, value.ggg, formatterResolver);
            offset += global::MessagePack.MessagePackBinary.WriteStringUnsafe(ref bytes, offset, "hhh", 3);
            offset += formatterResolver.GetFormatterWithVerify<global::System.Collections.Generic.List<int>>().Serialize(ref bytes, offset, value.hhh, formatterResolver);
            offset += global::MessagePack.MessagePackBinary.WriteStringUnsafe(ref bytes, offset, "iii", 3);
            offset += formatterResolver.GetFormatterWithVerify<global::System.Collections.Generic.List<string>>().Serialize(ref bytes, offset, value.iii, formatterResolver);
            offset += global::MessagePack.MessagePackBinary.WriteStringUnsafe(ref bytes, offset, "jjj", 3);
            offset += formatterResolver.GetFormatterWithVerify<global::System.Collections.Generic.Dictionary<int, string>>().Serialize(ref bytes, offset, value.jjj, formatterResolver);
            offset += global::MessagePack.MessagePackBinary.WriteStringUnsafe(ref bytes, offset, "kkk", 3);
            offset += formatterResolver.GetFormatterWithVerify<global::System.Collections.Generic.Dictionary<string, string>>().Serialize(ref bytes, offset, value.kkk, formatterResolver);
            offset += global::MessagePack.MessagePackBinary.WriteStringUnsafe(ref bytes, offset, "lll", 3);
            offset += formatterResolver.GetFormatterWithVerify<global::System.Collections.Generic.List<global::ListTest>>().Serialize(ref bytes, offset, value.lll, formatterResolver);
            offset += global::MessagePack.MessagePackBinary.WriteStringUnsafe(ref bytes, offset, "mmm", 3);
            offset += formatterResolver.GetFormatterWithVerify<global::System.Collections.Generic.Dictionary<string, global::ListTest>>().Serialize(ref bytes, offset, value.mmm, formatterResolver);
            offset += global::MessagePack.MessagePackBinary.WriteStringUnsafe(ref bytes, offset, "nnn", 3);
            offset += formatterResolver.GetFormatterWithVerify<global::System.Collections.Generic.List<global::System.Collections.Generic.List<global::ListTest>>>().Serialize(ref bytes, offset, value.nnn, formatterResolver);
            offset += global::MessagePack.MessagePackBinary.WriteStringUnsafe(ref bytes, offset, "ooo", 3);
            offset += formatterResolver.GetFormatterWithVerify<global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.List<global::ListTest>>>().Serialize(ref bytes, offset, value.ooo, formatterResolver);
            return offset - startOffset;
        }

        public global::MultiType Deserialize(byte[] bytes, int offset, global::MessagePack.IFormatterResolver formatterResolver, out int readSize)
        {
            if (global::MessagePack.MessagePackBinary.IsNil(bytes, offset))
            {
                readSize = 1;
                return null;
            }

            var startOffset = offset;
            var length = global::MessagePack.MessagePackBinary.ReadMapHeader(bytes, offset, out readSize);
            offset += readSize;

            var __aaa__ = default(int);
            var __bbb__ = default(long);
            var __ccc__ = default(float);
            var __ddd__ = default(double);
            var __eee__ = default(string);
            var __fff__ = default(int[]);
            var __ggg__ = default(string[]);
            var __hhh__ = default(global::System.Collections.Generic.List<int>);
            var __iii__ = default(global::System.Collections.Generic.List<string>);
            var __jjj__ = default(global::System.Collections.Generic.Dictionary<int, string>);
            var __kkk__ = default(global::System.Collections.Generic.Dictionary<string, string>);
            var __lll__ = default(global::System.Collections.Generic.List<global::ListTest>);
            var __mmm__ = default(global::System.Collections.Generic.Dictionary<string, global::ListTest>);
            var __nnn__ = default(global::System.Collections.Generic.List<global::System.Collections.Generic.List<global::ListTest>>);
            var __ooo__ = default(global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.List<global::ListTest>>);

            for (int i = 0; i < length; i++)
            {
                var stringKey = global::MessagePack.MessagePackBinary.ReadString(bytes, offset, out readSize);
                offset += readSize;
                int key;
                if (!____keyMapping.TryGetValue(stringKey, out key))
                {
                    readSize = global::MessagePack.MessagePackBinary.ReadNextBlock(bytes, offset);
                    goto NEXT_LOOP;
                }

                switch (key)
                {
                    case 0:
                        __aaa__ = MessagePackBinary.ReadInt32(bytes, offset, out readSize);
                        break;
                    case 1:
                        __bbb__ = MessagePackBinary.ReadInt64(bytes, offset, out readSize);
                        break;
                    case 2:
                        __ccc__ = MessagePackBinary.ReadSingle(bytes, offset, out readSize);
                        break;
                    case 3:
                        __ddd__ = MessagePackBinary.ReadDouble(bytes, offset, out readSize);
                        break;
                    case 4:
                        __eee__ = formatterResolver.GetFormatterWithVerify<string>().Deserialize(bytes, offset, formatterResolver, out readSize);
                        break;
                    case 5:
                        __fff__ = formatterResolver.GetFormatterWithVerify<int[]>().Deserialize(bytes, offset, formatterResolver, out readSize);
                        break;
                    case 6:
                        __ggg__ = formatterResolver.GetFormatterWithVerify<string[]>().Deserialize(bytes, offset, formatterResolver, out readSize);
                        break;
                    case 7:
                        __hhh__ = formatterResolver.GetFormatterWithVerify<global::System.Collections.Generic.List<int>>().Deserialize(bytes, offset, formatterResolver, out readSize);
                        break;
                    case 8:
                        __iii__ = formatterResolver.GetFormatterWithVerify<global::System.Collections.Generic.List<string>>().Deserialize(bytes, offset, formatterResolver, out readSize);
                        break;
                    case 9:
                        __jjj__ = formatterResolver.GetFormatterWithVerify<global::System.Collections.Generic.Dictionary<int, string>>().Deserialize(bytes, offset, formatterResolver, out readSize);
                        break;
                    case 10:
                        __kkk__ = formatterResolver.GetFormatterWithVerify<global::System.Collections.Generic.Dictionary<string, string>>().Deserialize(bytes, offset, formatterResolver, out readSize);
                        break;
                    case 11:
                        __lll__ = formatterResolver.GetFormatterWithVerify<global::System.Collections.Generic.List<global::ListTest>>().Deserialize(bytes, offset, formatterResolver, out readSize);
                        break;
                    case 12:
                        __mmm__ = formatterResolver.GetFormatterWithVerify<global::System.Collections.Generic.Dictionary<string, global::ListTest>>().Deserialize(bytes, offset, formatterResolver, out readSize);
                        break;
                    case 13:
                        __nnn__ = formatterResolver.GetFormatterWithVerify<global::System.Collections.Generic.List<global::System.Collections.Generic.List<global::ListTest>>>().Deserialize(bytes, offset, formatterResolver, out readSize);
                        break;
                    case 14:
                        __ooo__ = formatterResolver.GetFormatterWithVerify<global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.List<global::ListTest>>>().Deserialize(bytes, offset, formatterResolver, out readSize);
                        break;
                    default:
                        readSize = global::MessagePack.MessagePackBinary.ReadNextBlock(bytes, offset);
                        break;
                }
                
                NEXT_LOOP:
                offset += readSize;
            }

            readSize = offset - startOffset;

            var ____result = new global::MultiType();
            ____result.aaa = __aaa__;
            ____result.bbb = __bbb__;
            ____result.ccc = __ccc__;
            ____result.ddd = __ddd__;
            ____result.eee = __eee__;
            ____result.fff = __fff__;
            ____result.ggg = __ggg__;
            ____result.hhh = __hhh__;
            ____result.iii = __iii__;
            ____result.jjj = __jjj__;
            ____result.kkk = __kkk__;
            ____result.lll = __lll__;
            ____result.mmm = __mmm__;
            ____result.nnn = __nnn__;
            ____result.ooo = __ooo__;
            return ____result;
        }
    }

}

#pragma warning disable 168
#pragma warning restore 414
#pragma warning restore 618
#pragma warning restore 612

```


９：下記のようなテストクラスを書き、実機にてシリアライズ・デシリアライズできる事を確認

初めに、MessagePack.Resolvers.CompositeResolver.RegisterAndSetAsDefault　によってリゾルバーを登録する事

**登録は必ずStartに書く事**
下記のようなエラーが出る為
Register must call on startup(before use GetFormatter<T>).

MessagePack.MessagePackSerializer.Serialize<MultiType>(multi, MessagePack.Resolvers.CompositeResolver.Instance);　の部分は第２引数がなくても良い


```
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TypeTest : MonoBehaviour {

	// Use this for initialization
	void Start () {

        // カスタムリゾルバーを登録する。
        // CompositeResolver is singleton helper for use custom resolver.
        // Ofcourse you can also make custom resolver.
        MessagePack.Resolvers.CompositeResolver.RegisterAndSetAsDefault
        (
            // use generated resolver first, and combine many other generated/custom resolvers
            MessagePack.Resolvers.GeneratedResolver.Instance,

            // finally, use builtin/primitive resolver(don't use StandardResolver, it includes dynamic generation)
            MessagePack.Resolvers.BuiltinResolver.Instance,
            MessagePack.Resolvers.PrimitiveObjectResolver.Instance
        );
    }

    public void OnClickButton()
    {
        Debug.Log("OnClickButton");
        var multi = new MultiType();

        //*******************************************************
        Debug.Log("0");
        multi.aaa = 123;
        //*******************************************************
        Debug.Log("1");
        multi.bbb = 234;
        //*******************************************************
        Debug.Log("2");
        multi.ccc = 345.6f;
        //*******************************************************
        Debug.Log("3");
        multi.ddd = 456.789d;
        //*******************************************************
        Debug.Log("4");
        multi.eee = multi.eee.Append("あいうえおかきくけこ");
        //*******************************************************
        Debug.Log("5");
        multi.fff[0] = 999;
        //*******************************************************
        Debug.Log("6");
        multi.ggg[1] = new System.Text.StringBuilder();
        multi.ggg[1].Append("さしすせそ");
        //*******************************************************
        Debug.Log("7");
        multi.hhh.Add(12);
        multi.hhh.Add(34);
        multi.hhh.Add(56);
        //*******************************************************
        Debug.Log("8");
        var sb1 = new System.Text.StringBuilder();
        sb1.Append("たちつてと");
        multi.iii.Add(sb1);
        var sb2 = new System.Text.StringBuilder();
        sb2.Append("なにぬねの");
        multi.iii.Add(sb2);
        var sb3 = new System.Text.StringBuilder();
        sb3.Append("はひふへほ");
        multi.iii.Add(sb3);


        //*******************************************************
        Debug.Log("9");
        var sb4 = new System.Text.StringBuilder();
        sb4.Append("ああああ");
        multi.jjj.Add(0,sb4);
        var sb5 = new System.Text.StringBuilder();
        sb5.Append("いいいい");
        multi.jjj.Add(1,sb5);
        var sb6 = new System.Text.StringBuilder();
        sb6.Append("うううう");
        multi.jjj.Add(2,sb6);


        //*******************************************************
        Debug.Log("10");

        var sb7 = new System.Text.StringBuilder();
        var sb8 = new System.Text.StringBuilder();
        var sb9 = new System.Text.StringBuilder();
        var sb10 = new System.Text.StringBuilder();
        var sb11 = new System.Text.StringBuilder();
        var sb12 = new System.Text.StringBuilder();

        sb7.Append("あ");
        sb8.Append("い");
        sb9.Append("う");
        sb10.Append("え");
        sb11.Append("お");
        sb12.Append("か");

        multi.kkk.Add(sb7, sb8);
        multi.kkk.Add(sb9, sb10);
        multi.kkk.Add(sb11, sb12);

        //*******************************************************
        Debug.Log("11");
        var parts1 = new ListTest();
        parts1.acb = 123;
        parts1.def = new System.Text.StringBuilder();
        parts1.def.Append("あいうえお");
        multi.lll.Add(parts1);

        var parts2 = new ListTest();
        parts2.acb = 234;
        parts2.def = new System.Text.StringBuilder();
        parts2.def.Append("かきくけこ");
        multi.lll.Add(parts2);

        //*******************************************************
        Debug.Log("12");
        var parts3 = new ListTest();
        parts3.acb = 345;
        parts3.def = new System.Text.StringBuilder();
        parts3.def.Append("さしすせそ");

        var sb13 = new System.Text.StringBuilder();
        sb13.Append("aaa");
        multi.mmm.Add(sb13,parts3);

        var parts4 = new ListTest();
        parts4.acb = 456;
        parts4.def = new System.Text.StringBuilder();
        parts4.def.Append("たちつてと");
        var sb14 = new System.Text.StringBuilder();
        sb14.Append("bbb");
        multi.mmm.Add(sb14, parts4);

        //*******************************************************
        Debug.Log("13");
        List<ListTest> listTest1 = new List<ListTest>();
        var parts5 = new ListTest();
        parts5.acb = 456;
        parts5.def = new System.Text.StringBuilder();
        parts5.def.Append("たちつてと");
        listTest1.Add(parts5);

        var parts6 = new ListTest();
        parts6.acb = 567;
        parts6.def = new System.Text.StringBuilder();
        parts6.def.Append("なにぬねの");
        listTest1.Add(parts6);

        multi.nnn.Add(listTest1);

        List<ListTest> listTest2 = new List<ListTest>();
        var parts7 = new ListTest();
        parts7.acb = 456;
        parts7.def = new System.Text.StringBuilder();
        parts7.def.Append("たちつてと");
        listTest2.Add(parts7);

        var parts8 = new ListTest();
        parts8.acb = 567;
        parts8.def = new System.Text.StringBuilder();
        parts8.def.Append("なにぬねの");
        listTest2.Add(parts8);

        multi.nnn.Add(listTest2);

        //*******************************************************
        Debug.Log("14");
        List<ListTest> listTest3 = new List<ListTest>();
        var parts9 = new ListTest();
        parts9.acb = 456;
        parts9.def = new System.Text.StringBuilder();
        parts9.def.Append("たちつてと");
        listTest3.Add(parts9);

        var parts10 = new ListTest();
        parts10.acb = 567;
        parts10.def = new System.Text.StringBuilder();
        parts10.def.Append("なにぬねの");
        listTest3.Add(parts10);

        var sb15 = new System.Text.StringBuilder();
        sb15.Append("aaa");
        multi.ooo.Add(sb15, listTest3);

        List<ListTest> listTest4 = new List<ListTest>();
        var parts11 = new ListTest();
        parts11.acb = 456;
        parts11.def = new System.Text.StringBuilder();
        parts11.def.Append("たちつてと");
        listTest4.Add(parts11);

        var parts12 = new ListTest();
        parts12.acb = 567;
        parts12.def = new System.Text.StringBuilder();
        parts12.def.Append("なにぬねの");
        listTest3.Add(parts12);

        var sb16 = new System.Text.StringBuilder();
        sb16.Append("bbb");
        multi.ooo.Add(sb16, listTest4);

        Debug.Log("000000000000000000000000");
        MessagePack.MessagePackSerializer.Serialize<MultiType>(multi, MessagePack.Resolvers.CompositeResolver.Instance);
        Debug.Log("111111111111111111111111");

    }
}

```