Просмотр исходного кода

合并ilruntime ios await支持

tanghai 8 лет назад
Родитель
Сommit
48379caee0
100 измененных файлов с 2043 добавлено и 455 удалено
  1. BIN
      Unity/Assets/Res/Code/Hotfix.dll.bytes
  2. BIN
      Unity/Assets/Res/Code/Hotfix.mdb.bytes
  3. BIN
      Unity/Assets/Res/Code/Hotfix.pdb.bytes
  4. 76 0
      Unity/Assets/ThirdParty/ILRuntime/Editor/ILRuntimeCLRBinding.cs
  5. 12 0
      Unity/Assets/ThirdParty/ILRuntime/Editor/ILRuntimeCLRBinding.cs.meta
  6. 20 8
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/CLR/Method/CLRMethod.cs
  7. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/CLR/Method/CLRMethod.cs.meta
  8. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/CLR/Method/ExceptionHandler.cs.meta
  9. 46 22
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/CLR/Method/ILMethod.cs
  10. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/CLR/Method/ILMethod.cs.meta
  11. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/CLR/Method/IMethod.cs.meta
  12. 60 34
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/CLR/TypeSystem/CLRType.cs
  13. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/CLR/TypeSystem/CLRType.cs.meta
  14. 6 1
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/CLR/TypeSystem/ILGenericParameterType.cs
  15. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/CLR/TypeSystem/ILGenericParameterType.cs.meta
  16. 21 11
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/CLR/TypeSystem/ILType.cs
  17. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/CLR/TypeSystem/ILType.cs.meta
  18. 3 1
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/CLR/TypeSystem/IType.cs
  19. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/CLR/TypeSystem/IType.cs.meta
  20. 8 4
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/CLR/Utils/Extensions.cs
  21. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/CLR/Utils/Extensions.cs.meta
  22. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Other/ByReferenceKeyComparer.cs.meta
  23. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Other/DelegateExportAttribute.cs.meta
  24. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Other/NeedAdaptorAttribute.cs.meta
  25. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Other/ThreadSafeDictionary.cs.meta
  26. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Other/UncheckedList.cs.meta
  27. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Reflection/Extensions.cs.meta
  28. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Reflection/ILRuntimeConstructorInfo.cs.meta
  29. 9 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Reflection/ILRuntimeFieldInfo.cs
  30. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Reflection/ILRuntimeFieldInfo.cs.meta
  31. 10 1
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Reflection/ILRuntimeMethodInfo.cs
  32. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Reflection/ILRuntimeMethodInfo.cs.meta
  33. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Reflection/ILRuntimeParameterInfo.cs.meta
  34. 9 3
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Reflection/ILRuntimePropertyInfo.cs
  35. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Reflection/ILRuntimePropertyInfo.cs.meta
  36. 12 7
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Reflection/ILRuntimeType.cs
  37. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Reflection/ILRuntimeType.cs.meta
  38. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Reflection/ILRuntimeWrapperType.cs.meta
  39. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Adaptors/CLRCrossBindingAdaptors.cs.meta
  40. 17 3
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/CLRBinding/BindingCodeGenerator.cs
  41. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/CLRBinding/BindingCodeGenerator.cs.meta
  42. 36 9
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/CLRBinding/BindingGeneratorExtensions.cs
  43. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/CLRBinding/BindingGeneratorExtensions.cs.meta
  44. 19 1
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/CLRBinding/CommonBindingGenerator.cs
  45. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/CLRBinding/CommonBindingGenerator.cs.meta
  46. 21 6
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/CLRBinding/ConstructorBindingGenerator.cs
  47. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/CLRBinding/ConstructorBindingGenerator.cs.meta
  48. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/CLRBinding/FieldBindingGenerator.cs.meta
  49. 139 32
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/CLRBinding/MethodBindingGenerator.cs
  50. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/CLRBinding/MethodBindingGenerator.cs.meta
  51. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/CLRBinding/ValueTypeBindingGenerator.cs.meta
  52. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/BreakPointContext.cs.meta
  53. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/BreakpointInfo.cs.meta
  54. 5 1
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/DebugMessageType.cs
  55. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/DebugMessageType.cs.meta
  56. 551 82
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/DebugService.cs
  57. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/DebugService.cs.meta
  58. 9 3
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/DebugSocket.cs
  59. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/DebugSocket.cs.meta
  60. 161 22
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/DebuggerServer/DebuggerServer.cs
  61. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/DebuggerServer/DebuggerServer.cs.meta
  62. 1 0
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/CSBindBreakpoint.cs
  63. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/CSBindBreakpoint.cs.meta
  64. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/CSDeleteBreakpoint.cs.meta
  65. 13 0
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/CSEnumChildren.cs
  66. 12 0
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/CSEnumChildren.cs.meta
  67. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/CSExecute.cs.meta
  68. 14 0
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/CSResolveIndexer.cs
  69. 12 0
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/CSResolveIndexer.cs.meta
  70. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/CSResolveVariable.cs
  71. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/CSResolveVariable.cs.meta
  72. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/CSStep.cs.meta
  73. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/SCAttachResult.cs.meta
  74. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/SCBindBreakpointResult.cs.meta
  75. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/SCBreakpointHit.cs.meta
  76. 12 0
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/SCEnumChildrenResult.cs
  77. 12 0
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/SCEnumChildrenResult.cs.meta
  78. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/SCModuleLoaded.cs.meta
  79. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/SCResolveVariableResult.cs.meta
  80. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/SCStepComplete.cs.meta
  81. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/SCThreadStarted.cs.meta
  82. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/StackFrameInfo.cs.meta
  83. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/StepTypes.cs.meta
  84. 246 0
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/VariableInfo.cs
  85. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/VariableInfo.cs.meta
  86. 22 10
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Enviorment/AppDomain.cs
  87. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Enviorment/AppDomain.cs.meta
  88. 62 1
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Enviorment/CLRRedirections.cs
  89. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Enviorment/CLRRedirections.cs.meta
  90. 7 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Enviorment/CrossBindingAdaptor.cs
  91. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Enviorment/CrossBindingAdaptor.cs.meta
  92. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Enviorment/DelegateManager.cs.meta
  93. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Enviorment/ValueTypeBinder.cs.meta
  94. 55 4
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Extensions.cs
  95. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Extensions.cs.meta
  96. 6 0
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Intepreter/DelegateAdapter.cs
  97. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Intepreter/DelegateAdapter.cs.meta
  98. 197 63
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Intepreter/ILIntepreter.cs
  99. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Intepreter/ILIntepreter.cs.meta
  100. 2 2
      Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Intepreter/ILRuntimeException.cs.meta

BIN
Unity/Assets/Res/Code/Hotfix.dll.bytes


BIN
Unity/Assets/Res/Code/Hotfix.mdb.bytes


BIN
Unity/Assets/Res/Code/Hotfix.pdb.bytes


+ 76 - 0
Unity/Assets/ThirdParty/ILRuntime/Editor/ILRuntimeCLRBinding.cs

@@ -0,0 +1,76 @@
+#if UNITY_EDITOR
+using UnityEditor;
+using UnityEngine;
+using System;
+using System.Text;
+using System.Collections.Generic;
+using System.Reflection;
+using ILRuntime.Runtime.Enviorment;
+using Model;
+
+[System.Reflection.Obfuscation(Exclude = true)]
+public class ILRuntimeCLRBinding
+{
+    [MenuItem("Tools/ILRuntime/Generate CLR Binding Code")]
+    static void GenerateCLRBinding()
+    {
+        List<Type> types = new List<Type>();
+        types.Add(typeof(int));
+        types.Add(typeof(float));
+        types.Add(typeof(long));
+        types.Add(typeof(object));
+        types.Add(typeof(string));
+        types.Add(typeof(Array));
+        types.Add(typeof(Vector2));
+        types.Add(typeof(Vector3));
+        types.Add(typeof(Quaternion));
+        types.Add(typeof(GameObject));
+        types.Add(typeof(UnityEngine.Object));
+        types.Add(typeof(Transform));
+        types.Add(typeof(RectTransform));
+        types.Add(typeof(Time));
+        types.Add(typeof(Debug));
+        //所有DLL内的类型的真实C#类型都是ILTypeInstance
+        types.Add(typeof(List<ILRuntime.Runtime.Intepreter.ILTypeInstance>));
+
+        ILRuntime.Runtime.CLRBinding.BindingCodeGenerator.GenerateBindingCode(types, "Assets/ThirdParty/ILRuntime/Generated");
+
+    }
+
+    [MenuItem("Tools/ILRuntime/Generate CLR Binding Code by Analysis")]
+    static void GenerateCLRBindingByAnalysis()
+    {
+        //用新的分析热更dll调用引用来生成绑定代码
+        ILRuntime.Runtime.Enviorment.AppDomain domain = new ILRuntime.Runtime.Enviorment.AppDomain();
+        using (System.IO.FileStream fs = new System.IO.FileStream("Assets/Res/Code/Hotfix.dll.bytes", System.IO.FileMode.Open, System.IO.FileAccess.Read))
+        {
+            domain.LoadAssembly(fs);
+        }
+        //Crossbind Adapter is needed to generate the correct binding code
+        InitILRuntime(domain);
+        ILRuntime.Runtime.CLRBinding.BindingCodeGenerator.GenerateBindingCode(domain, "Assets/ThirdParty/ILRuntime/Generated");
+    }
+
+    static void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain domain)
+    {
+        //这里需要注册所有热更DLL中用到的跨域继承Adapter,否则无法正确抓取引用
+        // 注册适配器
+        Assembly assembly = typeof(Init).Assembly;
+        foreach (Type type in assembly.GetTypes())
+        {
+            object[] attrs = type.GetCustomAttributes(typeof(ILAdapterAttribute), false);
+            if (attrs.Length == 0)
+            {
+                continue;
+            }
+            object obj = Activator.CreateInstance(type);
+            CrossBindingAdaptor adaptor = obj as CrossBindingAdaptor;
+            if (adaptor == null)
+            {
+                continue;
+            }
+            domain.RegisterCrossBindingAdaptor(adaptor);
+        }
+    }
+}
+#endif

+ 12 - 0
Unity/Assets/ThirdParty/ILRuntime/Editor/ILRuntimeCLRBinding.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 970393f1bc06b0a4a8572b5eae410a9a
+timeCreated: 1481621267
+licenseType: Free
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 20 - 8
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/CLR/Method/CLRMethod.cs

@@ -111,7 +111,9 @@ namespace ILRuntime.CLR.Method
             {
                 if (def.IsGenericMethod && !def.IsGenericMethodDefinition)
                 {
-                    appdomain.RedirectMap.TryGetValue(def.GetGenericMethodDefinition(), out redirect);
+                    //Redirection of Generic method Definition will be prioritized
+                    if(!appdomain.RedirectMap.TryGetValue(def.GetGenericMethodDefinition(), out redirect))
+                        appdomain.RedirectMap.TryGetValue(def, out redirect);
                 }
                 else
                     appdomain.RedirectMap.TryGetValue(def, out redirect);
@@ -220,7 +222,8 @@ namespace ILRuntime.CLR.Method
             for (int i = paramCount; i >= 1; i--)
             {
                 var p = Minus(esp, i);
-                var obj = this.param[paramCount - i].ParameterType.CheckCLRTypes(StackObject.ToObject(p, appdomain, mStack));
+                var pt = this.param[paramCount - i].ParameterType;
+                var obj = pt.CheckCLRTypes(StackObject.ToObject(p, appdomain, mStack));
                 obj = ILIntepreter.CheckAndCloneValueType(obj, appdomain);
                 param[paramCount - i] = obj;
             }
@@ -248,7 +251,7 @@ namespace ILRuntime.CLR.Method
                 {
                     var res = cDef.Invoke(param);
 
-                    FixReference(paramCount, esp, param, mStack);
+                    FixReference(paramCount, esp, param, mStack, null, false);
                     return res;
                 }
 
@@ -260,6 +263,8 @@ namespace ILRuntime.CLR.Method
                 if (!def.IsStatic)
                 {
                     instance = declaringType.TypeForCLR.CheckCLRTypes(StackObject.ToObject((Minus(esp, paramCount + 1)), appdomain, mStack));
+                    if (declaringType.IsValueType)
+                        instance = ILIntepreter.CheckAndCloneValueType(instance, appdomain);
                     if (instance == null)
                         throw new NullReferenceException();
                 }
@@ -271,17 +276,18 @@ namespace ILRuntime.CLR.Method
                     res = def.Invoke(instance, param);
                 }
 
-                FixReference(paramCount, esp, param, mStack);
+                FixReference(paramCount, esp, param, mStack, instance, !def.IsStatic);
                 return res;
             }
         }
 
-        unsafe void FixReference(int paramCount, StackObject* esp, object[] param, IList<object> mStack)
+        unsafe void FixReference(int paramCount, StackObject* esp, object[] param, IList<object> mStack,object instance, bool hasThis)
         {
-            for (int i = paramCount; i >= 1; i--)
+            var cnt = hasThis ? paramCount + 1 : paramCount;
+            for (int i = cnt; i >= 1; i--)
             {
                 var p = Minus(esp, i);
-                var val = param[paramCount - i];
+                var val = i <= paramCount ? param[paramCount - i] : instance;
                 switch (p->ObjectType)
                 {
                     case ObjectTypes.StackObjectReference:
@@ -296,7 +302,7 @@ namespace ILRuntime.CLR.Method
                             }
                             else
                             {
-                                ILIntepreter.UnboxObject(dst, val);
+                                ILIntepreter.UnboxObject(dst, val, mStack, appdomain);
                             }
                         }
                         break;
@@ -327,6 +333,12 @@ namespace ILRuntime.CLR.Method
                             }
                         }
                         break;
+                    case ObjectTypes.ArrayReference:
+                        {
+                            var arr = mStack[p->Value] as Array;
+                            arr.SetValue(val, p->ValueLow);
+                        }
+                        break;
                 }
             }
         }

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/CLR/Method/CLRMethod.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: e3a93984f12c9da43b98d43930dd8c49
-timeCreated: 1509525195
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/CLR/Method/ExceptionHandler.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 99ef6f3b1f4f7894ebd5e1878c08fcb5
-timeCreated: 1509525194
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 46 - 22
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/CLR/Method/ILMethod.cs

@@ -139,14 +139,14 @@ namespace ILRuntime.CLR.Method
                 isDelegateInvoke = true;
             this.appdomain = domain;
             paramCnt = def.HasParameters ? def.Parameters.Count : 0;
-#if DEBUG
+#if DEBUG && !DISABLE_ILRUNTIME_DEBUG
             if (def.HasBody)
             {
-                var sp = DebugService.FindSequencePoint(def.Body.Instructions[0]);
+                var sp = GetValidSequence(0, 1);
                 if (sp != null)
                 {
                     StartLine = sp.StartLine;
-                    sp = DebugService.FindSequencePoint(def.Body.Instructions[def.Body.Instructions.Count - 1]);
+                    sp = GetValidSequence(def.Body.Instructions.Count - 1, -1);
                     if (sp != null)
                     {
                         EndLine = sp.EndLine;
@@ -156,6 +156,23 @@ namespace ILRuntime.CLR.Method
 #endif
         }
 
+        Mono.Cecil.Cil.SequencePoint GetValidSequence(int startIdx, int dir)
+        {
+            var cur = DebugService.FindSequencePoint(def.Body.Instructions[startIdx]);
+            while (cur != null && cur.StartLine == 0x0feefee)
+            {
+                startIdx += dir;
+                if (startIdx >= 0 && startIdx < def.Body.Instructions.Count)
+                {
+                    cur = DebugService.FindSequencePoint(def.Body.Instructions[startIdx]);
+                }
+                else
+                    break;
+            }
+
+            return cur;
+        }
+
         public IType FindGenericArgument(string name)
         {
             IType res = declaringType.FindGenericArgument(name);
@@ -536,6 +553,7 @@ namespace ILRuntime.CLR.Method
                 IType type = null;
                 bool isByRef = false;
                 bool isArray = false;
+                int rank = 1;
                 TypeReference pt = i.ParameterType;
                 if (i.ParameterType.IsByReference)
                 {
@@ -545,6 +563,7 @@ namespace ILRuntime.CLR.Method
                 if (i.ParameterType.IsArray)
                 {
                     isArray = true;
+                    rank = ((ArrayType)pt).Rank;
                     pt = pt.GetElementType();
                 }
                 if (pt.IsGenericParameter)
@@ -572,7 +591,7 @@ namespace ILRuntime.CLR.Method
                     if (isByRef)
                         type = type.MakeByRefType();
                     if (isArray)
-                        type = type.MakeArrayType();
+                        type = type.MakeArrayType(rank);
                 }
                 else
                     type = appdomain.GetType(i.ParameterType, declaringType, this);
@@ -600,28 +619,33 @@ namespace ILRuntime.CLR.Method
             return m;
         }
 
+        string cachedName;
         public override string ToString()
         {
-            StringBuilder sb = new StringBuilder();
-            sb.Append(declaringType.FullName);
-            sb.Append('.');
-            sb.Append(Name);
-            sb.Append('(');
-            bool isFirst = true;
-            if (parameters == null)
-                InitParameters();
-            for (int i = 0; i < parameters.Count; i++)
+            if (cachedName == null)
             {
-                if (isFirst)
-                    isFirst = false;
-                else
-                    sb.Append(", ");
-                sb.Append(parameters[i].Name);
-                sb.Append(' ');
-                sb.Append(def.Parameters[i].Name);
+                StringBuilder sb = new StringBuilder();
+                sb.Append(declaringType.FullName);
+                sb.Append('.');
+                sb.Append(Name);
+                sb.Append('(');
+                bool isFirst = true;
+                if (parameters == null)
+                    InitParameters();
+                for (int i = 0; i < parameters.Count; i++)
+                {
+                    if (isFirst)
+                        isFirst = false;
+                    else
+                        sb.Append(", ");
+                    sb.Append(parameters[i].Name);
+                    sb.Append(' ');
+                    sb.Append(def.Parameters[i].Name);
+                }
+                sb.Append(')');
+                cachedName = sb.ToString();
             }
-            sb.Append(')');
-            return sb.ToString();
+            return cachedName;
         }
 
         public override int GetHashCode()

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/CLR/Method/ILMethod.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 4d61dbf18ea786940ad2dda2466cde64
-timeCreated: 1509525193
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/CLR/Method/IMethod.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 3ee73b411c3d8c34cbcc5578441c854a
-timeCreated: 1509525193
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 60 - 34
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/CLR/TypeSystem/CLRType.cs

@@ -31,7 +31,8 @@ namespace ILRuntime.CLR.TypeSystem
         CLRCreateDefaultInstanceDelegate createDefaultInstanceDelegate;
         CLRCreateArrayInstanceDelegate createArrayInstanceDelegate;
         Dictionary<int, int> fieldTokenMapping;
-        IType byRefType, arrayType, elementType;
+        IType byRefType, elementType;
+        Dictionary<int, IType> arrayTypes;
         IType[] interfaces;
         bool isDelegate;
         IType baseType;
@@ -73,7 +74,11 @@ namespace ILRuntime.CLR.TypeSystem
             {
                 if (fieldMapping == null)
                     InitializeFields();
-                return fieldIdxMapping.Count;
+
+                if (fieldIdxMapping != null)
+                    return fieldIdxMapping.Count;
+                else
+                    throw new NotSupportedException("Cannot find ValueTypeBinder for type:" + clrType.FullName);
             }
         }
 
@@ -148,7 +153,7 @@ namespace ILRuntime.CLR.TypeSystem
         {
             get
             {
-                return arrayType;
+                return arrayTypes != null ? arrayTypes[1] : null;
             }
         }
 
@@ -157,6 +162,11 @@ namespace ILRuntime.CLR.TypeSystem
             get;private set;
         }
 
+        public int ArrayRank
+        {
+            get;private set;
+        }
+
         public bool IsValueType
         {
             get
@@ -223,8 +233,7 @@ namespace ILRuntime.CLR.TypeSystem
                     if (!valueTypeBinderGot)
                     {
                         valueTypeBinderGot = true;
-                        if (appdomain.ValueTypeBinders.TryGetValue(clrType, out valueTypeBinder))
-                            valueTypeBinder.CLRType = this;
+                        appdomain.ValueTypeBinders.TryGetValue(clrType, out valueTypeBinder);
                     }
                     return valueTypeBinder;
                 }
@@ -570,7 +579,14 @@ namespace ILRuntime.CLR.TypeSystem
                             }
                             if (match)
                             {
-                                match = returnType == null || i.ReturnType.TypeForCLR == returnType.TypeForCLR;
+                                try
+                                {
+                                    match = returnType == null || (i.ReturnType != null && i.ReturnType.TypeForCLR == returnType.TypeForCLR);
+                                }
+                                catch
+                                {
+
+                                }
                             }
                             if (match)
                             {
@@ -646,33 +662,36 @@ namespace ILRuntime.CLR.TypeSystem
 
         public IType MakeGenericInstance(KeyValuePair<string, IType>[] genericArguments)
         {
-            if (genericInstances == null)
-                genericInstances = new List<CLRType>();
-            foreach (var i in genericInstances)
+            lock (this)
             {
-                bool match = true;
-                for (int j = 0; j < genericArguments.Length; j++)
+                if (genericInstances == null)
+                    genericInstances = new List<CLRType>();
+                foreach (var i in genericInstances)
                 {
-                    if (i.genericArguments[j].Value != genericArguments[j].Value)
+                    bool match = true;
+                    for (int j = 0; j < genericArguments.Length; j++)
                     {
-                        match = false;
-                        break;
+                        if (i.genericArguments[j].Value != genericArguments[j].Value)
+                        {
+                            match = false;
+                            break;
+                        }
                     }
+                    if (match)
+                        return i;
                 }
-                if (match)
-                    return i;
-            }
-            Type[] args = new Type[genericArguments.Length];
-            for (int i = 0; i < genericArguments.Length; i++)
-            {
-                args[i] = genericArguments[i].Value.TypeForCLR;
-            }
-            Type newType = clrType.MakeGenericType(args);
-            var res = new CLRType(newType, appdomain);
-            res.genericArguments = genericArguments;
+                Type[] args = new Type[genericArguments.Length];
+                for (int i = 0; i < genericArguments.Length; i++)
+                {
+                    args[i] = genericArguments[i].Value.TypeForCLR;
+                }
+                Type newType = clrType.MakeGenericType(args);
+                var res = new CLRType(newType, appdomain);
+                res.genericArguments = genericArguments;
 
-            genericInstances.Add(res);
-            return res;
+                genericInstances.Add(res);
+                return res;
+            }
         }
 
         public object CreateDefaultInstance()
@@ -710,16 +729,23 @@ namespace ILRuntime.CLR.TypeSystem
             }
             return byRefType;
         }
-        public IType MakeArrayType()
+        public IType MakeArrayType(int rank)
         {
-            if (arrayType == null)
+            if (arrayTypes == null)
+            {
+                arrayTypes = new Dictionary<int, IType>();
+            }
+            IType atype;
+            if (!arrayTypes.TryGetValue(rank, out atype))
             {
-                Type t = clrType.MakeArrayType();
-                arrayType = new CLRType(t, appdomain);
-                ((CLRType)arrayType).elementType = this;
-                ((CLRType)arrayType).IsArray = true;
+                Type t = rank > 1 ? clrType.MakeArrayType(rank) : clrType.MakeArrayType();
+                atype = new CLRType(t, appdomain);
+                ((CLRType)atype).elementType = this;
+                ((CLRType)atype).IsArray = true;
+                ((CLRType)atype).ArrayRank = rank;
+                arrayTypes[rank] = atype;
             }
-            return arrayType;
+            return atype;
         }
 
         public IType ResolveGenericType(IType contextType)

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/CLR/TypeSystem/CLRType.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 77e1f51e465e9e24ba3a42bb88b7ad34
-timeCreated: 1509525193
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 6 - 1
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/CLR/TypeSystem/ILGenericParameterType.cs

@@ -109,7 +109,7 @@ namespace ILRuntime.CLR.TypeSystem
             get { return arrayType; }
         }
 
-        public IType MakeArrayType()
+        public IType MakeArrayType(int rank)
         {
             if (arrayType == null)
                 arrayType = new ILGenericParameterType(name + "[]");
@@ -169,6 +169,11 @@ namespace ILRuntime.CLR.TypeSystem
             get { return false; }
         }
 
+        public int ArrayRank
+        {
+            get { return 1; }
+        }
+
         public IType[] Implements
         {
             get

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/CLR/TypeSystem/ILGenericParameterType.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: ea169e3908d84da4088fc6eae41d3c41
-timeCreated: 1509525195
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 21 - 11
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/CLR/TypeSystem/ILType.cs

@@ -30,7 +30,8 @@ namespace ILRuntime.CLR.TypeSystem
         int fieldStartIdx = -1;
         int totalFieldCnt = -1;
         KeyValuePair<string, IType>[] genericArguments;
-        IType baseType, byRefType, arrayType, enumType, elementType;
+        IType baseType, byRefType, enumType, elementType;
+        Dictionary<int, IType> arrayTypes;
         Type arrayCLRType, byRefCLRType;
         IType[] interfaces;
         bool baseTypeInitialized = false;
@@ -255,6 +256,11 @@ namespace ILRuntime.CLR.TypeSystem
             get; private set;
         }
 
+        public int ArrayRank
+        {
+            get; private set;
+        }
+
         private bool? isValueType;
 
         public bool IsValueType
@@ -337,7 +343,7 @@ namespace ILRuntime.CLR.TypeSystem
         {
             get
             {
-                return arrayType;
+                return arrayTypes != null ? arrayTypes[1] : null;
             }
         }
 
@@ -557,7 +563,7 @@ namespace ILRuntime.CLR.TypeSystem
                         methods[i.Name] = lst;
                     }
                     var m = new ILMethod(i, this, appdomain);
-                    lst.Add(new ILMethod(i, this, appdomain));
+                    lst.Add(m);
                 }
             }
 
@@ -969,17 +975,21 @@ namespace ILRuntime.CLR.TypeSystem
             return byRefType;
         }
 
-        public IType MakeArrayType()
+        public IType MakeArrayType(int rank)
         {
-            if (arrayType == null)
+            if (arrayTypes == null)
+                arrayTypes = new Dictionary<int, IType>();
+            IType atype;
+            if(!arrayTypes.TryGetValue(rank, out atype))
             {
-                var def = new ArrayType(typeRef);
-                arrayType = new ILType(def, appdomain);
-                ((ILType)arrayType).IsArray = true;
-                ((ILType)arrayType).elementType = this;
-                ((ILType)arrayType).arrayCLRType = this.TypeForCLR.MakeArrayType();
+                var def = new ArrayType(typeRef, rank);
+                atype = new ILType(def, appdomain);
+                ((ILType)atype).IsArray = true;
+                ((ILType)atype).elementType = this;
+                ((ILType)atype).arrayCLRType = rank > 1 ? this.TypeForCLR.MakeArrayType(rank) : this.TypeForCLR.MakeArrayType();
+                arrayTypes[rank] = atype;
             }
-            return arrayType;
+            return atype;
         }
 
         public IType ResolveGenericType(IType contextType)

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/CLR/TypeSystem/ILType.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: a657d8c53554fdb498c23061939379d5
-timeCreated: 1509525194
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 3 - 1
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/CLR/TypeSystem/IType.cs

@@ -28,6 +28,8 @@ namespace ILRuntime.CLR.TypeSystem
 
         bool IsArray { get; }
 
+        int ArrayRank { get; }
+
         bool IsValueType { get; }
 
         bool IsDelegate { get; }
@@ -70,7 +72,7 @@ namespace ILRuntime.CLR.TypeSystem
 
         IType MakeByRefType();
 
-        IType MakeArrayType();
+        IType MakeArrayType(int rank);
         IType FindGenericArgument(string key);
 
         IType ResolveGenericType(IType contextType);

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/CLR/TypeSystem/IType.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 2d59f9c8b6bc1b542a95502fa20ddea8
-timeCreated: 1509525192
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 8 - 4
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/CLR/Utils/Extensions.cs

@@ -43,13 +43,16 @@ namespace ILRuntime.CLR.Utils
                             }
                             else if (name.Contains(gp.Name))
                             {
+                                t = appdomain.GetType(ga, contextType, contextMethod);
+                                if (t == null && genericArguments != null)
+                                    t = genericArguments[j];
                                 if (name == gp.Name)
                                 {
-                                    name = ga.FullName;
+                                    name = t.FullName;
                                 }
                                 else if (name == gp.Name + "[]")
                                 {
-                                    name = ga.FullName + "[]";
+                                    name = t.FullName + "[]";
                                 }
                                 else
                                 {
@@ -62,6 +65,7 @@ namespace ILRuntime.CLR.Utils
                                     name = name.Replace("," + gp.Name + "[", "," + ga.FullName + "[");*/
                                     name = ReplaceGenericArgument(name, gp.Name, ga.FullName);
                                 }
+                                t = null;
                             }
                         }
                         if (t == null)
@@ -239,8 +243,8 @@ namespace ILRuntime.CLR.Utils
                 if (!(obj is ILEnumTypeInstance))
                 {
                     var ins = (ILTypeInstance)obj;
-                    if (ins.IsValueType)
-                        ins = ins.Clone();
+                    /*if (ins.IsValueType)
+                        ins = ins.Clone();*/
                     return ins.CLRInstance;
                 }
             }

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/CLR/Utils/Extensions.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: ed1e47ba193179f4b9f21caedbc1b605
-timeCreated: 1509525195
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Other/ByReferenceKeyComparer.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 85b57f58903421241b65cd2ffbcac7bf
-timeCreated: 1509525194
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Other/DelegateExportAttribute.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: eb007a85cca9ce54ea6e3b32ab7ddceb
-timeCreated: 1509525195
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Other/NeedAdaptorAttribute.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: fd1e000bd78872247b5ee948842785e9
-timeCreated: 1509525195
-licenseType: Free
+timeCreated: 1516154070
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Other/ThreadSafeDictionary.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: e45123ef096e7a446a6ccd805feaf05e
-timeCreated: 1509525195
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Other/UncheckedList.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: d923aa25f3f74d0489a9082f6a6c9942
-timeCreated: 1509525195
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Reflection/Extensions.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: ccb5490caeef4b7419ab1fc0690f19bd
-timeCreated: 1509525194
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Reflection/ILRuntimeConstructorInfo.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 205a4012c9bebf742b9ebdc7fcb24bff
-timeCreated: 1509525192
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 9 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Reflection/ILRuntimeFieldInfo.cs

@@ -153,11 +153,14 @@ namespace ILRuntime.Reflection
         {
             if (customAttributes == null)
                 InitializeCustomAttribute();
+
             List<object> res = new List<object>();
             for (int i = 0; i < customAttributes.Length; i++)
             {
-                if (attributeTypes[i] == attributeType)
+                if (attributeTypes[i].Equals(attributeType))
+                {
                     res.Add(customAttributes[i]);
+                }
             }
             return res.ToArray();
         }
@@ -187,10 +190,14 @@ namespace ILRuntime.Reflection
         {
             if (customAttributes == null)
                 InitializeCustomAttribute();
+
+
             for (int i = 0; i < customAttributes.Length; i++)
             {
-                if (attributeTypes[i] == attributeType)
+                if (attributeTypes[i].Equals(attributeType))
+                {
                     return true;
+                }
             }
             return false;
         }

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Reflection/ILRuntimeFieldInfo.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 05340a76bcd08e843b481e980988b984
-timeCreated: 1509525192
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 10 - 1
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Reflection/ILRuntimeMethodInfo.cs

@@ -6,6 +6,7 @@ using System.Reflection;
 using System.Globalization;
 
 using ILRuntime.CLR.Method;
+using ILRuntime.CLR.Utils;
 
 namespace ILRuntime.Reflection
 {
@@ -142,7 +143,7 @@ namespace ILRuntime.Reflection
             if (method.HasThis)
             {
                 var res = appdomain.Invoke(method, obj, parameters);
-                return res;
+                return ReturnType.CheckCLRTypes(res);
             }
             else
                 return appdomain.Invoke(method, null, parameters);
@@ -159,5 +160,13 @@ namespace ILRuntime.Reflection
             }
             return false;
         }
+
+        public override Type ReturnType
+        {
+            get
+            {
+                return method.ReturnType.ReflectionType;
+            }
+        }
     }
 }

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Reflection/ILRuntimeMethodInfo.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: e975e373cbb39824c9dbf99b5b834f76
-timeCreated: 1509525195
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Reflection/ILRuntimeParameterInfo.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: fb4bb43a033c2ee45b6957d7b7ae8b28
-timeCreated: 1509525195
-licenseType: Free
+timeCreated: 1516154070
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 9 - 3
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Reflection/ILRuntimePropertyInfo.cs

@@ -162,11 +162,14 @@ namespace ILRuntime.Reflection
         {
             if (customAttributes == null)
                 InitializeCustomAttribute();
+
             List<object> res = new List<object>();
             for (int i = 0; i < customAttributes.Length; i++)
             {
-                if (attributeTypes[i] == attributeType)
+                if (attributeTypes[i].Equals(attributeType))
+                {
                     res.Add(customAttributes[i]);
+                }
             }
             return res.ToArray();
         }
@@ -175,10 +178,13 @@ namespace ILRuntime.Reflection
         {
             if (customAttributes == null)
                 InitializeCustomAttribute();
+
             for (int i = 0; i < customAttributes.Length; i++)
             {
-                if (attributeTypes[i] == attributeType)
+                if (attributeTypes[i].Equals(attributeType))
+                {
                     return true;
+                }
             }
             return false;
         }
@@ -197,7 +203,7 @@ namespace ILRuntime.Reflection
 
         public override ParameterInfo[] GetIndexParameters()
         {
-            throw new NotImplementedException();
+            return new ParameterInfo[0];
         }
 
         public override MethodInfo GetSetMethod(bool nonPublic)

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Reflection/ILRuntimePropertyInfo.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 15c350fc8adaa6d43b32f054dacecead
-timeCreated: 1509525192
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 12 - 7
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Reflection/ILRuntimeType.cs

@@ -21,7 +21,7 @@ namespace ILRuntime.Reflection
         ILRuntimeMethodInfo[] methods;
 
         public ILType ILType { get { return type; } }
-        
+
         public ILRuntimeType(ILType t)
         {
             type = t;
@@ -46,7 +46,7 @@ namespace ILRuntime.Reflection
                 catch
                 {
                     attributeTypes[i] = typeof(Attribute);
-                }               
+                }
             }
 
         }
@@ -113,7 +113,12 @@ namespace ILRuntime.Reflection
         {
             get
             {
-                return type.BaseType != null ? type.BaseType.ReflectionType : null;
+                if (type.IsEnum)
+                    return typeof(Enum);
+                else
+                {
+                    return type.BaseType != null ? type.BaseType.ReflectionType : null;
+                }
             }
         }
 
@@ -153,7 +158,7 @@ namespace ILRuntime.Reflection
         {
             get
             {
-                throw new NotImplementedException();
+                return type.TypeDefinition.Namespace;
             }
         }
 
@@ -191,7 +196,7 @@ namespace ILRuntime.Reflection
             List<object> res = new List<object>();
             for(int i = 0; i < customAttributes.Length; i++)
             {
-                if (attributeTypes[i] == attributeType)
+                if (attributeTypes[i].Equals(attributeType))
                     res.Add(customAttributes[i]);
             }
             return res.ToArray();
@@ -289,7 +294,7 @@ namespace ILRuntime.Reflection
             }
             for (int i = methods.Length + fields.Length; i < res.Length; i++)
             {
-                res[i] = properties[i- methods.Length - fields.Length];
+                res[i] = properties[i - methods.Length - fields.Length];
             }
 
             return res;
@@ -343,7 +348,7 @@ namespace ILRuntime.Reflection
                 InitializeCustomAttribute();
             for (int i = 0; i < customAttributes.Length; i++)
             {
-                if (attributeTypes[i] == attributeType)
+                if (attributeTypes[i].Equals(attributeType))
                     return true;
             }
             return false;

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Reflection/ILRuntimeType.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: f3a1f2fbaeb2b8446a4001bf4537351d
-timeCreated: 1509525195
-licenseType: Free
+timeCreated: 1516154070
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Reflection/ILRuntimeWrapperType.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: eaefbb07ad715ce489ab00dd2080222f
-timeCreated: 1509525195
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Adaptors/CLRCrossBindingAdaptors.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 9c62df830a323ae4185db20e52d0a559
-timeCreated: 1509525194
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 17 - 3
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/CLRBinding/BindingCodeGenerator.cs

@@ -159,19 +159,32 @@ namespace ILRuntime.Runtime.Generated
 
             HashSet<MethodBase> excludeMethods = null;
             HashSet<FieldInfo> excludeFields = null;
+            HashSet<string> files = new HashSet<string>();
             List<string> clsNames = new List<string>();
             foreach (var info in infos)
             {
                 if (!info.Value.NeedGenerate)
                     continue;
                 Type i = info.Value.Type;
+                if (i.BaseType == typeof(MulticastDelegate))
+                    continue;
                 string clsName, realClsName;
                 bool isByRef;
                 if (i.GetCustomAttributes(typeof(ObsoleteAttribute), true).Length > 0)
                     continue;
                 i.GetClassName(out clsName, out realClsName, out isByRef);
+                if (clsNames.Contains(clsName))
+                    clsName = clsName + "_t";
                 clsNames.Add(clsName);
-                using (System.IO.StreamWriter sw = new System.IO.StreamWriter(outputPath + "/" + clsName + ".cs", false, Encoding.UTF8))
+                string oFileName = outputPath + "/" + clsName;
+                int len = Math.Min(oFileName.Length, 100);
+                if (len < oFileName.Length)
+                    oFileName = oFileName.Substring(0, len) + "_t";
+                while (files.Contains(oFileName))
+                    oFileName = oFileName + "_t";
+                files.Add(oFileName);
+                oFileName = oFileName + ".cs";
+                using (System.IO.StreamWriter sw = new System.IO.StreamWriter(oFileName, false, Encoding.UTF8))
                 {
                     sw.Write(@"using System;
 using System.Collections.Generic;
@@ -302,7 +315,7 @@ namespace ILRuntime.Runtime.Generated
             {
                 if (type is CLR.TypeSystem.ILType)
                 {
-                    if (type.HasGenericParameter)
+                    if (type.TypeForCLR.IsByRef || type.HasGenericParameter)
                         continue;
                     var methods = type.GetMethods().ToList();
                     foreach (var i in ((CLR.TypeSystem.ILType)type).GetConstructors())
@@ -449,7 +462,8 @@ namespace ILRuntime.Runtime.Generated
             info.Methods = new HashSet<MethodInfo>();
             info.Fields = new HashSet<FieldInfo>();
             info.Constructors = new HashSet<ConstructorInfo>();
-
+            if (t.IsValueType)
+                info.DefaultInstanceNeeded = true;
             return info;
         }
     }

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/CLRBinding/BindingCodeGenerator.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 4e7ba7f4b3e5e4843a17ebdf3ff249ef
-timeCreated: 1509525193
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 36 - 9
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/CLRBinding/BindingGeneratorExtensions.cs

@@ -27,7 +27,7 @@ namespace ILRuntime.Runtime.CLRBinding
         {
             if (i.IsPrivate)
                 return true;
-            if (i.IsGenericMethod)
+            if (i.IsGenericMethodDefinition)
                 return true;
             //EventHandler is currently not supported
             var param = i.GetParameters();
@@ -69,20 +69,27 @@ namespace ILRuntime.Runtime.CLRBinding
             return false;
         }
 
-        internal static void AppendParameters(this ParameterInfo[] param, StringBuilder sb)
+        internal static void AppendParameters(this ParameterInfo[] param, StringBuilder sb, bool isMultiArr = false, int skipLast = 0)
         {
             bool first = true;
-            foreach (var j in param)
+            for (int i = 0; i < param.Length - skipLast; i++)
             {
                 if (first)
                     first = false;
                 else
                     sb.Append(", ");
+                var j = param[i];
                 if (j.IsOut && j.ParameterType.IsByRef)
                     sb.Append("out ");
                 else if (j.ParameterType.IsByRef)
                     sb.Append("ref ");
-                sb.Append(j.Name);
+                if (isMultiArr)
+                {
+                    sb.Append("a");
+                    sb.Append(i + 1);
+                }
+                else
+                    sb.Append(j.Name);
             }
         }
 
@@ -230,7 +237,20 @@ namespace ILRuntime.Runtime.CLRBinding
             }
             else
             {
-                if (!type.IsValueType)
+                sb.Append(@"                        object ___obj = ");
+                sb.Append(paramName);
+                sb.AppendLine(";");
+                sb.AppendLine(@"                        if (___dst->ObjectType >= ObjectTypes.Object)
+                        {
+                            if (___obj is CrossBindingAdaptorType)
+                                ___obj = ((CrossBindingAdaptorType)___obj).ILInstance;
+                            __mStack[___dst->Value] = ___obj;
+                        }
+                        else
+                        {
+                            ILIntepreter.UnboxObject(___dst, ___obj, __mStack, __domain);
+                        }");
+                /*if (!type.IsValueType)
                 {
                     sb.Append(@"                        object ___obj = ");
                     sb.Append(paramName);
@@ -245,7 +265,7 @@ namespace ILRuntime.Runtime.CLRBinding
                     sb.Append("                        __mStack[___dst->Value] = ");
                     sb.Append(paramName);
                     sb.AppendLine(";");
-                }
+                }*/
             }
         }
 
@@ -320,15 +340,22 @@ namespace ILRuntime.Runtime.CLRBinding
             }
             else
             {
+                string isBox;
+                if (type == typeof(object))
+                    isBox = ", true";
+                else
+                    isBox = "";
                 if (!type.IsSealed && type != typeof(ILRuntime.Runtime.Intepreter.ILTypeInstance))
                 {
-                    sb.AppendLine(@"            object obj_result_of_this_method = result_of_this_method;
+                    sb.Append(@"            object obj_result_of_this_method = result_of_this_method;
             if(obj_result_of_this_method is CrossBindingAdaptorType)
             {    
-                return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance);
+                return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance");
+                    sb.Append(isBox);
+                    sb.AppendLine(@");
             }");
                 }
-                sb.AppendLine("            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);");
+                sb.AppendLine(string.Format("            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method{0});", isBox));
             }
         }
     }

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/CLRBinding/BindingGeneratorExtensions.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 3e91768ea7d0ed240bd26b8251c32ee8
-timeCreated: 1509525193
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 19 - 1
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/CLRBinding/CommonBindingGenerator.cs

@@ -28,7 +28,25 @@ namespace ILRuntime.Runtime.CLRBinding
             {
                 if (!type.IsAbstract || !type.IsSealed)
                 {
-                    sb.AppendLine(string.Format("            app.RegisterCLRCreateArrayInstance(type, s => new {0}[s]);", typeClsName));
+                    if (type.IsArray)
+                    {
+                        Type elementType = type;
+                        int arrCnt = 0;
+                        while (elementType.IsArray)
+                        {
+                            elementType = elementType.GetElementType();
+                            arrCnt++;
+                        }
+                        string elem, clsName;
+                        bool isByRef;
+                        elementType.GetClassName(out clsName, out elem, out isByRef);
+                        string trail = "";
+                        for (int i = 0; i < arrCnt; i++)
+                            trail += "[]";
+                        sb.AppendLine(string.Format("            app.RegisterCLRCreateArrayInstance(type, s => new {0}[s]{1});", elem, trail));
+                    }
+                    else
+                        sb.AppendLine(string.Format("            app.RegisterCLRCreateArrayInstance(type, s => new {0}[s]);", typeClsName));
                 }
             }
 

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/CLRBinding/CommonBindingGenerator.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: d2c990d8ba791ea41bdf7f8a58a4a713
-timeCreated: 1509525195
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 21 - 6
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/CLRBinding/ConstructorBindingGenerator.cs

@@ -53,6 +53,7 @@ namespace ILRuntime.Runtime.CLRBinding
             StringBuilder sb = new StringBuilder();
 
             int idx = 0;
+            bool isMultiArr = type.IsArray && type.GetArrayRank() > 1;
             foreach (var i in methods)
             {
                 if (excludes != null && excludes.Contains(i))
@@ -75,7 +76,12 @@ namespace ILRuntime.Runtime.CLRBinding
                     p.ParameterType.GetClassName(out tmp, out clsName, out isByRef);
                     if (isByRef)
                         sb.AppendLine("            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);");
-                    sb.AppendLine(string.Format("            {0} {1} = {2};", clsName, p.Name, p.ParameterType.GetRetrieveValueCode(clsName)));
+                    if (isMultiArr)
+                    {
+                        sb.AppendLine(string.Format("            {0} a{1} = {2};", clsName, j, p.ParameterType.GetRetrieveValueCode(clsName)));
+                    }
+                    else
+                        sb.AppendLine(string.Format("            {0} {1} = {2};", clsName, p.Name, p.ParameterType.GetRetrieveValueCode(clsName)));
                     if (!isByRef && !p.ParameterType.IsPrimitive)
                         sb.AppendLine("            __intp.Free(ptr_of_this_method);");
                 }
@@ -84,11 +90,20 @@ namespace ILRuntime.Runtime.CLRBinding
                 {
                     string tmp, clsName;
                     bool isByRef;
-                    type.GetClassName(out tmp, out clsName, out isByRef);
-                    sb.Append(string.Format("new {0}(", clsName));
-                    param.AppendParameters(sb);
-                    sb.AppendLine(");");
-
+                    if (isMultiArr)
+                    {
+                        type.GetElementType().GetClassName(out tmp, out clsName, out isByRef);
+                        sb.Append(string.Format("new {0}[", clsName));
+                        param.AppendParameters(sb, isMultiArr);
+                        sb.AppendLine("];");
+                    }
+                    else
+                    {
+                        type.GetClassName(out tmp, out clsName, out isByRef);
+                        sb.Append(string.Format("new {0}(", clsName));
+                        param.AppendParameters(sb, isMultiArr);
+                        sb.AppendLine(");");
+                    }
                 }
                 sb.AppendLine();
                 if (type.IsValueType)

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/CLRBinding/ConstructorBindingGenerator.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 531c09b4001f4574dbe7f989aef71c18
-timeCreated: 1509525193
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/CLRBinding/FieldBindingGenerator.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 9c0373a996c429f46ac5a2a2711f1793
-timeCreated: 1509525194
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 139 - 32
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/CLRBinding/MethodBindingGenerator.cs

@@ -13,36 +13,99 @@ namespace ILRuntime.Runtime.CLRBinding
         {
             StringBuilder sb = new StringBuilder();
             int idx = 0;
+            bool isMethodsGot = false;
             foreach (var i in methods)
             {
                 if (excludes != null && excludes.Contains(i))
                     continue;
                 if (type.ShouldSkipMethod(i))
                     continue;
-                bool isProperty = i.IsSpecialName;
-                var param = i.GetParameters();
-                StringBuilder sb2 = new StringBuilder();
-                sb2.Append("{");
-                bool first = true;
-                foreach (var j in param)
+                
+                if (i.IsGenericMethod)
                 {
-                    if (first)
-                        first = false;
-                    else
-                        sb2.Append(", ");
-                    sb2.Append("typeof(");
-                    string tmp, clsName;
-                    bool isByRef;
-                    j.ParameterType.GetClassName(out tmp, out clsName, out isByRef);
-                    sb2.Append(clsName);
-                    sb2.Append(")");
-                    if (isByRef)
-                        sb2.Append(".MakeByRefType()");
+                    if (!isMethodsGot)
+                    {
+                        sb.AppendLine(@"            Dictionary<string, List<MethodInfo>> genericMethods = new Dictionary<string, List<MethodInfo>>();
+            List<MethodInfo> lst = null;                    
+            foreach(var m in type.GetMethods())
+            {
+                if(m.IsGenericMethodDefinition)
+                {
+                    if (!genericMethods.TryGetValue(m.Name, out lst))
+                    {
+                        lst = new List<MethodInfo>();
+                        genericMethods[m.Name] = lst;
+                    }
+                    lst.Add(m);
+                }
+            }");
+                        isMethodsGot = true;
+                    }
+
+                    var param = i.GetGenericArguments();
+                    StringBuilder sb2 = new StringBuilder();
+                    sb2.Append("{");
+                    bool first = true;
+                    foreach (var j in param)
+                    {
+                        if (first)
+                            first = false;
+                        else
+                            sb2.Append(", ");
+                        sb2.Append("typeof(");
+                        string tmp, clsName;
+                        bool isByRef;
+                        j.GetClassName(out tmp, out clsName, out isByRef);
+                        sb2.Append(clsName);
+                        sb2.Append(")");
+                        if (isByRef)
+                            sb2.Append(".MakeByRefType()");
+                    }
+                    sb2.Append("}");
+                    sb.AppendLine(string.Format("            args = new Type[]{0};", sb2));
+                    sb.AppendLine(string.Format("            if (genericMethods.TryGetValue(\"{0}\", out lst))", i.Name));
+                    sb.Append(@"            {
+                foreach(var m in lst)
+                {
+                    if(m.GetParameters().Length == ");
+                    sb.Append(i.GetParameters().Length.ToString());
+                    sb.Append(@")
+                    {
+                        method = m.MakeGenericMethod(args);
+                        app.RegisterCLRMethodRedirection(method, ");
+                    sb.AppendLine(string.Format("{0}_{1});", i.Name, idx));
+                    sb.AppendLine(@"
+                        break;
+                    }
+                }
+            }");
+                }
+                else
+                {
+                    var param = i.GetParameters();
+                    StringBuilder sb2 = new StringBuilder();
+                    sb2.Append("{");
+                    bool first = true;
+                    foreach (var j in param)
+                    {
+                        if (first)
+                            first = false;
+                        else
+                            sb2.Append(", ");
+                        sb2.Append("typeof(");
+                        string tmp, clsName;
+                        bool isByRef;
+                        j.ParameterType.GetClassName(out tmp, out clsName, out isByRef);
+                        sb2.Append(clsName);
+                        sb2.Append(")");
+                        if (isByRef)
+                            sb2.Append(".MakeByRefType()");
+                    }
+                    sb2.Append("}");
+                    sb.AppendLine(string.Format("            args = new Type[]{0};", sb2));
+                    sb.AppendLine(string.Format("            method = type.GetMethod(\"{0}\", flag, null, args, null);", i.Name));
+                    sb.AppendLine(string.Format("            app.RegisterCLRMethodRedirection(method, {0}_{1});", i.Name, idx));
                 }
-                sb2.Append("}");
-                sb.AppendLine(string.Format("            args = new Type[]{0};", sb2));
-                sb.AppendLine(string.Format("            method = type.GetMethod(\"{0}\", flag, null, args, null);", i.Name));
-                sb.AppendLine(string.Format("            app.RegisterCLRMethodRedirection(method, {0}_{1});", i.Name, idx));
 
                 idx++;
             }
@@ -52,7 +115,7 @@ namespace ILRuntime.Runtime.CLRBinding
         internal static string GenerateMethodWraperCode(this Type type, MethodInfo[] methods, string typeClsName, HashSet<MethodBase> excludes)
         {
             StringBuilder sb = new StringBuilder();
-
+            bool isMultiArr = type.IsArray && type.GetArrayRank() > 1;
             int idx = 0;
             foreach (var i in methods)
             {
@@ -79,7 +142,12 @@ namespace ILRuntime.Runtime.CLRBinding
                     p.ParameterType.GetClassName(out tmp, out clsName, out isByRef);
                     if (isByRef)
                         sb.AppendLine("            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);");
-                    sb.AppendLine(string.Format("            {0} {1} = {2};", clsName, p.Name, p.ParameterType.GetRetrieveValueCode(clsName)));
+                    if (isMultiArr)
+                    {
+                        sb.AppendLine(string.Format("            {0} a{1} = {2};", clsName, j, p.ParameterType.GetRetrieveValueCode(clsName)));
+                    }
+                    else
+                        sb.AppendLine(string.Format("            {0} {1} = {2};", clsName, p.Name, p.ParameterType.GetRetrieveValueCode(clsName)));
                     if (!isByRef && !p.ParameterType.IsPrimitive)
                         sb.AppendLine("            __intp.Free(ptr_of_this_method);");
                 }
@@ -105,6 +173,27 @@ namespace ILRuntime.Runtime.CLRBinding
                 }
                 else
                     sb.Append("            ");
+                string genericArguments = "";
+                if (i.IsGenericMethod)
+                {
+                    var p = i.GetGenericArguments();
+                    StringBuilder sb2 = new StringBuilder();
+                    bool first = true;
+                    sb2.Append('<');
+                    foreach(var j in p)
+                    {
+                        if (first)
+                            first = false;
+                        else
+                            sb2.Append(", ");
+                        string tmp, clsName;
+                        bool isByRef;
+                        j.GetClassName(out tmp, out clsName, out isByRef);
+                        sb2.Append(clsName);
+                    }
+                    sb2.Append('>');
+                    genericArguments = sb2.ToString();
+                }
                 if (i.IsStatic)
                 {
                     if (isProperty)
@@ -187,7 +276,7 @@ namespace ILRuntime.Runtime.CLRBinding
                     }
                     else
                     {
-                        sb.Append(string.Format("{0}.{1}(", typeClsName, i.Name));
+                        sb.Append(string.Format("{0}.{1}{2}(", typeClsName, i.Name, genericArguments));
                         param.AppendParameters(sb);
                         sb.AppendLine(");");
                     }
@@ -222,9 +311,27 @@ namespace ILRuntime.Runtime.CLRBinding
                         else
                             throw new NotImplementedException();
                     }
+                    else if(isMultiArr)
+                    {
+                        if (i.Name == "Get")
+                        {
+                            sb.Append("instance_of_this_method[");
+                            param.AppendParameters(sb, true);
+                            sb.AppendLine("];");
+                        }
+                        else
+                        {
+                            sb.Append("instance_of_this_method[");
+                            param.AppendParameters(sb, true, 1);
+                            sb.Append("]");
+                            sb.Append(" = a");
+                            sb.Append(param.Length);
+                            sb.AppendLine(";");
+                        }
+                    }
                     else
                     {
-                        sb.Append(string.Format("instance_of_this_method.{0}(", i.Name));
+                        sb.Append(string.Format("instance_of_this_method.{0}{1}(", i.Name, genericArguments));
                         param.AppendParameters(sb);
                         sb.AppendLine(");");
                     }
@@ -266,8 +373,8 @@ namespace ILRuntime.Runtime.CLRBinding
                         }
                         else
                         {
-                            var t = __domain.GetType(___obj.GetType()) as CLRType;
-                            t.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, ");
+                            var ___type = __domain.GetType(___obj.GetType()) as CLRType;
+                            ___type.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, ");
                     sb.Append(p.Name);
                     sb.Append(@");
                         }
@@ -275,16 +382,16 @@ namespace ILRuntime.Runtime.CLRBinding
                     break;
                 case ObjectTypes.StaticFieldReference:
                     {
-                        var t = __domain.GetType(ptr_of_this_method->Value);
-                        if(t is ILType)
+                        var ___type = __domain.GetType(ptr_of_this_method->Value);
+                        if(___type is ILType)
                         {
-                            ((ILType)t).StaticInstance[ptr_of_this_method->ValueLow] = ");
+                            ((ILType)___type).StaticInstance[ptr_of_this_method->ValueLow] = ");
                     sb.Append(p.Name);
                     sb.Append(@";
                         }
                         else
                         {
-                            ((CLRType)t).SetStaticFieldValue(ptr_of_this_method->ValueLow, ");
+                            ((CLRType)___type).SetStaticFieldValue(ptr_of_this_method->ValueLow, ");
                     sb.Append(p.Name);
                     sb.Append(@");
                         }

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/CLRBinding/MethodBindingGenerator.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 3e7a4b0b251e3c24bbc7fbb93dc9d799
-timeCreated: 1509525193
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/CLRBinding/ValueTypeBindingGenerator.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 668af796108e80c408d8997b279d5728
-timeCreated: 1509525193
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/BreakPointContext.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: bfeefe6a2f833e2459c51dec09120b28
-timeCreated: 1509525194
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/BreakpointInfo.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: c1e1d9861d746594485e121a90ef9c38
-timeCreated: 1509525194
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 5 - 1
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/DebugMessageType.cs

@@ -20,6 +20,10 @@ namespace ILRuntime.Runtime.Debugger
         CSStep,
         SCStepComplete,
         CSResolveVariable,
-        SCResolveVariableResult
+        SCResolveVariableResult,
+        CSResolveIndexAccess,
+        SCResolveIndexAccessResult,
+        CSEnumChildren,
+        SCEnumChildrenResult,
     }
 }

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/DebugMessageType.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: a564f69cbf727c844bb66d4ef14055b8
-timeCreated: 1509525194
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 551 - 82
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/DebugService.cs

@@ -1,8 +1,10 @@
 using System;
 using System.Collections.Generic;
+using System.Collections;
 using System.Linq;
 using System.Text;
 using System.Threading;
+using System.Linq;
 
 using ILRuntime.CLR.Method;
 using ILRuntime.Runtime.Intepreter;
@@ -30,7 +32,7 @@ namespace ILRuntime.Runtime.Debugger
         {
             get
             {
-#if DEBUG
+#if DEBUG && !DISABLE_ILRUNTIME_DEBUG
                 return (server != null && server.IsAttached);
 #else
                 return false;
@@ -49,7 +51,7 @@ namespace ILRuntime.Runtime.Debugger
         /// <param name="port">Port to listen on</param>
         public void StartDebugService(int port)
         {
-#if DEBUG
+#if DEBUG && !DISABLE_ILRUNTIME_DEBUG
             server = new Debugger.DebuggerServer(this);
             server.Port = port;
             server.Start();
@@ -61,7 +63,7 @@ namespace ILRuntime.Runtime.Debugger
         /// </summary>
         public void StopDebugService()
         {
-#if DEBUG
+#if DEBUG && !DISABLE_ILRUNTIME_DEBUG
             server.Stop();
             server = null;
 #endif
@@ -138,20 +140,27 @@ namespace ILRuntime.Runtime.Debugger
             StringBuilder sb = new StringBuilder();
             for (int i = 0; i < fields.Count; i++)
             {
-                var f = fields[i];
-                if (f.IsStatic)
-                    continue;
-                var field = instance.Fields[idx];
-                var v = StackObject.ToObject(&field, intepreter.AppDomain, instance.ManagedObjects);
-                if (v == null)
-                    v = "null";
-                string name = f.Name;
-                sb.AppendFormat("{0} {1} = {2}", f.FieldType.Name, name, v);
-                if ((idx % 3 == 0 && idx != 0) || idx == instance.Fields.Length - 1)
-                    sb.AppendLine();
-                else
-                    sb.Append(", ");
-                idx++;
+                try
+                {
+                    var f = fields[i];
+                    if (f.IsStatic)
+                        continue;
+                    var field = instance.Fields[idx];
+                    var v = StackObject.ToObject(&field, intepreter.AppDomain, instance.ManagedObjects);
+                    if (v == null)
+                        v = "null";
+                    string name = f.Name;
+                    sb.AppendFormat("{0} {1} = {2}", f.FieldType.Name, name, v);
+                    if ((idx % 3 == 0 && idx != 0) || idx == instance.Fields.Length - 1)
+                        sb.AppendLine();
+                    else
+                        sb.Append(", ");
+                    idx++;
+                }
+                catch
+                {
+
+                }
             }
             return sb.ToString();
         }
@@ -163,17 +172,24 @@ namespace ILRuntime.Runtime.Debugger
             StringBuilder sb = new StringBuilder();
             for (int i = 0; i < m.LocalVariableCount; i++)
             {
-                var lv = m.Definition.Body.Variables[i];
-                var val = Add(topFrame.LocalVarPointer, i);
-                var v = StackObject.ToObject(val, intepreter.AppDomain, intepreter.Stack.ManagedStack);
-                if (v == null)
-                    v = "null";
-                string name = string.IsNullOrEmpty(lv.Name) ? "v" + lv.Index : lv.Name;
-                sb.AppendFormat("{0} {1} = {2}", lv.VariableType.Name, name, v);
-                if ((i % 3 == 0 && i != 0) || i == m.LocalVariableCount - 1)
-                    sb.AppendLine();
-                else
-                    sb.Append(", ");
+                try
+                {
+                    var lv = m.Definition.Body.Variables[i];
+                    var val = Add(topFrame.LocalVarPointer, i);
+                    var v = StackObject.ToObject(val, intepreter.AppDomain, intepreter.Stack.ManagedStack);
+                    if (v == null)
+                        v = "null";
+                    string name = string.IsNullOrEmpty(lv.Name) ? "v" + lv.Index : lv.Name;
+                    sb.AppendFormat("{0} {1} = {2}", lv.VariableType.Name, name, v);
+                    if ((i % 3 == 0 && i != 0) || i == m.LocalVariableCount - 1)
+                        sb.AppendLine();
+                    else
+                        sb.Append(", ");
+                }
+                catch
+                {
+
+                }
             }
             return sb.ToString();
         }
@@ -276,53 +292,57 @@ namespace ILRuntime.Runtime.Debugger
             if (server != null && server.IsAttached)
             {
                 int methodHash = method.GetHashCode();
+                BreakpointInfo[] lst = null;
+
                 lock (activeBreakpoints)
                 {
-                    LinkedList<BreakpointInfo> lst;
-                    bool bpHit = false;
+                    LinkedList<BreakpointInfo> bps;
+                    if (activeBreakpoints.TryGetValue(methodHash, out bps))
+                        lst = bps.ToArray();
+                }
+                bool bpHit = false;
 
-                    if (activeBreakpoints.TryGetValue(methodHash, out lst))
+                if (lst != null)
+                {
+                    var sp = method.Definition.Body.Instructions[ip].SequencePoint;
+                    if (sp != null)
                     {
-                        var sp = method.Definition.Body.Instructions[ip].SequencePoint;
-                        if (sp != null)
+                        foreach (var i in lst)
                         {
-                            foreach (var i in lst)
+                            if ((i.StartLine + 1) == sp.StartLine)
                             {
-                                if ((i.StartLine + 1) == sp.StartLine)
-                                {
-                                    DoBreak(intp, i.BreakpointHashCode, false);
-                                    bpHit = true;
-                                    break;
-                                }
+                                DoBreak(intp, i.BreakpointHashCode, false);
+                                bpHit = true;
+                                break;
                             }
                         }
                     }
+                }
 
-                    if (!bpHit)
+                if (!bpHit)
+                {
+                    var sp = method.Definition.Body.Instructions[ip].SequencePoint;
+                    if (sp != null && IsSequenceValid(sp))
                     {
-                        var sp = method.Definition.Body.Instructions[ip].SequencePoint;
-                        if (sp != null && IsSequenceValid(sp))
-                        {                            
-                            switch (intp.CurrentStepType)
-                            {
-                                case StepTypes.Into:
+                        switch (intp.CurrentStepType)
+                        {
+                            case StepTypes.Into:
+                                DoBreak(intp, 0, true);
+                                break;
+                            case StepTypes.Over:
+                                if (intp.Stack.Frames.Peek().BasePointer <= intp.LastStepFrameBase && ip != intp.LastStepInstructionIndex)
+                                {
                                     DoBreak(intp, 0, true);
-                                    break;
-                                case StepTypes.Over:
-                                    if (intp.Stack.Frames.Peek().BasePointer <= intp.LastStepFrameBase && ip != intp.LastStepInstructionIndex)
+                                }
+                                break;
+                            case StepTypes.Out:
+                                {
+                                    if (intp.Stack.Frames.Count > 0 && intp.Stack.Frames.Peek().BasePointer < intp.LastStepFrameBase)
                                     {
                                         DoBreak(intp, 0, true);
                                     }
-                                    break;
-                                case StepTypes.Out:
-                                    {
-                                        if (intp.Stack.Frames.Count > 0 && intp.Stack.Frames.Peek().BasePointer < intp.LastStepFrameBase)
-                                        {
-                                            DoBreak(intp, 0, true);
-                                        }
-                                    }
-                                    break;
-                            }
+                                }
+                                break;
                         }
                     }
                 }
@@ -344,7 +364,14 @@ namespace ILRuntime.Runtime.Debugger
                 if (j.Value != intp)
                 {
                     j.Value.ShouldBreak = true;
-                    frames[idx++] = new KeyValuePair<int, Debugger.StackFrameInfo[]>(j.Value.GetHashCode(), GetStackFrameInfo(j.Value));
+                    try
+                    {
+                        frames[idx++] = new KeyValuePair<int, Debugger.StackFrameInfo[]>(j.Value.GetHashCode(), GetStackFrameInfo(j.Value));
+                    }
+                    catch
+                    {
+                        frames[idx++] = new KeyValuePair<int, Debugger.StackFrameInfo[]>(j.Value.GetHashCode(), new StackFrameInfo[0]);
+                    }
                 }
             }
             if (!isStep)
@@ -397,15 +424,11 @@ namespace ILRuntime.Runtime.Debugger
                     string typeName = null;
                     var val = Add(arg, i);
                     v =  StackObject.ToObject(val, intp.AppDomain, intp.Stack.ManagedStack);
-                    if (v == null)
-                        v = "null";
                     if (argIdx >= 0)
                     {
                         var lv = m.Definition.Parameters[argIdx];
                         name = string.IsNullOrEmpty(lv.Name) ? "arg" + lv.Index : lv.Name;
                         typeName = lv.ParameterType.FullName;
-                        if (v != null)
-                            v = m.Parameters[argIdx].TypeForCLR.CheckCLRTypes(v);
                     }
                     else
                     {
@@ -413,10 +436,9 @@ namespace ILRuntime.Runtime.Debugger
                         typeName = m.DeclearingType.FullName;
                     }
 
-                    VariableInfo vinfo = new Debugger.VariableInfo();
+                    VariableInfo vinfo = VariableInfo.FromObject(v);
                     vinfo.Address = (long)val;
                     vinfo.Name = name;
-                    vinfo.Value = v.ToString();
                     vinfo.TypeName = typeName;
                     vinfo.Expandable = GetValueExpandable(val, intp.Stack.ManagedStack);
 
@@ -428,15 +450,11 @@ namespace ILRuntime.Runtime.Debugger
                     var lv = m.Definition.Body.Variables[locIdx];
                     var val = Add(topFrame.LocalVarPointer, locIdx);
                     var v = StackObject.ToObject(val, intp.AppDomain, intp.Stack.ManagedStack);
-                    if (v == null)
-                        v = "null";
-                    else
-                        v = intp.AppDomain.GetType(lv.VariableType, m.DeclearingType, m).TypeForCLR.CheckCLRTypes(v);
+                    var type = intp.AppDomain.GetType(lv.VariableType, m.DeclearingType, m);
                     string name = string.IsNullOrEmpty(lv.Name) ? "v" + lv.Index : lv.Name;
-                    VariableInfo vinfo = new Debugger.VariableInfo();
+                    VariableInfo vinfo = VariableInfo.FromObject(v);
                     vinfo.Address = (long)val;
                     vinfo.Name = name;
-                    vinfo.Value = v.ToString();
                     vinfo.TypeName = lv.VariableType.FullName;
                     vinfo.Expandable = GetValueExpandable(val, intp.Stack.ManagedStack);
                     info.LocalVariables[i] = vinfo;
@@ -446,9 +464,456 @@ namespace ILRuntime.Runtime.Debugger
             return frameInfos;
         }
 
-        internal VariableInfo ResolveVariable(VariableReference parent, string name)
+        internal unsafe VariableInfo[] EnumChildren(int threadHashCode, VariableReference parent)
+        {
+            ILIntepreter intepreter;
+            if (AppDomain.Intepreters.TryGetValue(threadHashCode, out intepreter))
+            {
+                object obj;
+                var info = ResolveVariable(threadHashCode, parent, out obj);
+                if (obj != null)
+                {
+                    if(obj is Array)
+                    {
+                        return EnumArray((Array)obj, intepreter);
+                    }
+                    else if(obj is IList)
+                    {
+                        return EnumList((IList)obj, intepreter);
+                    }
+                    else if(obj is IDictionary)
+                    {
+                        return EnumDictionary((IDictionary)obj, intepreter);
+                    }
+                    else if(obj is ILTypeInstance)
+                    {
+                        return EnumILTypeInstance((ILTypeInstance)obj, intepreter);
+                    }
+                    else if(obj is ILRuntime.Runtime.Enviorment.CrossBindingAdaptorType)
+                    {
+                        return EnumILTypeInstance(((Enviorment.CrossBindingAdaptorType)obj).ILInstance, intepreter);
+                    }
+                    else
+                    {
+                        return EnumCLRObject(obj, intepreter);
+                    }
+                }
+                else
+                    return new VariableInfo[] { VariableInfo.NullReferenceExeption };
+            }
+            else
+                return new VariableInfo[] { VariableInfo.NullReferenceExeption };
+        }
+
+        VariableInfo[] EnumArray(Array arr, ILIntepreter intepreter)
+        {
+            VariableInfo[] res = new VariableInfo[arr.Length];
+
+            for(int i = 0; i < arr.Length; i++)
+            {
+                try
+                {
+                    var obj = arr.GetValue(i);
+
+                    VariableInfo info = VariableInfo.FromObject(obj, true);
+                    info.Name = string.Format("[{0}]", i);
+                    info.Offset = i;
+                    info.Type = VariableTypes.IndexAccess;
+                    res[i] = info;
+                }
+                catch(Exception ex)
+                {
+                    var info = VariableInfo.GetException(ex);
+                    info.Name = string.Format("[{0}]", i);
+                    res[i] = info;
+                }
+            }
+
+            return res;
+        }
+
+        VariableInfo[] EnumList(IList lst, ILIntepreter intepreter)
+        {
+            VariableInfo[] res = new VariableInfo[lst.Count];
+
+            for (int i = 0; i < lst.Count; i++)
+            {
+                try
+                {
+                    var obj = lst[i];
+
+                    VariableInfo info = VariableInfo.FromObject(obj, true);
+                    info.Name = string.Format("[{0}]", i);
+                    info.Offset = i;
+                    info.Type = VariableTypes.IndexAccess;
+
+                    res[i] = info;
+                }
+                catch (Exception ex)
+                {
+                    var info = VariableInfo.GetException(ex);
+                    info.Name = string.Format("[{0}]", i);
+                    res[i] = info;
+                }
+            }
+
+            return res;
+        }
+
+        VariableInfo[] EnumDictionary(IDictionary lst, ILIntepreter intepreter)
+        {
+            VariableInfo[] res = new VariableInfo[lst.Count];
+
+            var keys = GetArray(lst.Keys);
+            var values = GetArray(lst.Values);
+            for (int i = 0; i < lst.Count; i++)
+            {
+                try
+                {
+                    var obj = values[i];
+                    VariableInfo info = VariableInfo.FromObject(obj, true);
+                    info.Name = string.Format("[{0}]", i);
+                    info.Type = VariableTypes.IndexAccess;
+                    info.Offset = i;
+                    info.Value = string.Format("{0},{1}", SafeToString(keys[i]), SafeToString(values[i]));
+                    info.Expandable = true;
+                    res[i] = info;
+                }
+                catch (Exception ex)
+                {
+                    var info = VariableInfo.GetException(ex);
+                    info.Name = string.Format("[{0}]", i);
+                    res[i] = info;
+                }
+            }
+            return res;
+        }
+
+        string SafeToString(object obj)
+        {
+            if (obj != null)
+                return obj.ToString();
+            else
+                return "null";
+        }
+        object[] GetArray(ICollection lst)
+        {
+            object[] res = new object[lst.Count];
+            int idx = 0;
+            foreach(var i in lst)
+            {
+                res[idx++] = i;
+            }
+            return res;
+        }
+
+        VariableInfo[] EnumILTypeInstance(ILTypeInstance obj, ILIntepreter intepreter)
+        {
+            return EnumObject(obj, obj.Type.ReflectionType);
+        }
+
+        VariableInfo[] EnumCLRObject(object obj, ILIntepreter intepreter)
+        {
+            return EnumObject(obj, obj.GetType());
+        }
+
+        VariableInfo[] EnumObject(object obj, Type t)
+        {
+            List<VariableInfo> lst = new List<VariableInfo>();
+            foreach (var i in t.GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance))
+            {
+                try
+                {
+                    if (i.GetCustomAttributes(typeof(System.Runtime.CompilerServices.CompilerGeneratedAttribute), false).Length > 0)
+                        continue;
+                    var val = i.GetValue(obj);
+                    VariableInfo info = VariableInfo.FromObject(val);
+                    info.Type = VariableTypes.FieldReference;
+                    info.TypeName = i.FieldType.FullName;
+                    info.Name = i.Name;
+                    info.Expandable = !i.FieldType.IsPrimitive && val != null;
+                    info.IsPrivate = i.IsPrivate;
+                    info.IsProtected = i.IsFamily;
+
+                    lst.Add(info);
+                }
+                catch (Exception ex)
+                {
+                    var info = VariableInfo.GetException(ex);
+                    info.Name = i.Name;
+                    lst.Add(info);
+                }
+            }
+
+            foreach (var i in t.GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance))
+            {
+                try
+                {
+                    if (i.GetIndexParameters().Length > 0)
+                        continue;
+                    var val = i.GetValue(obj, null);
+                    VariableInfo info = VariableInfo.FromObject(val);
+                    info.Type = VariableTypes.PropertyReference;
+                    info.TypeName = i.PropertyType.FullName;
+                    info.Name = i.Name;
+                    info.Expandable = !i.PropertyType.IsPrimitive && val != null;
+                    info.IsPrivate = i.GetGetMethod(true).IsPrivate;
+                    info.IsProtected = i.GetGetMethod(true).IsFamily;
+
+                    lst.Add(info);
+                }
+                catch (Exception ex)
+                {
+                    var info = VariableInfo.GetException(ex);
+                    info.Name = i.Name;
+                    lst.Add(info);
+                }
+            }
+
+            return lst.ToArray();
+        }
+
+        internal unsafe VariableInfo ResolveIndexAccess(int threadHashCode, VariableReference body, VariableReference idx, out object res)
+        {
+            ILIntepreter intepreter;
+            res = null;
+            if (AppDomain.Intepreters.TryGetValue(threadHashCode, out intepreter))
+            {
+                object obj;
+                var info = ResolveVariable(threadHashCode, body, out obj);
+                if (obj != null)
+                {
+                    object idxObj;
+                    info = ResolveVariable(threadHashCode, idx, out idxObj);
+                    if(obj is Array)
+                    {
+                        res = ((Array)obj).GetValue((int)idxObj);
+                        info = VariableInfo.FromObject(res);
+                        info.Type = VariableTypes.IndexAccess;
+                        info.TypeName = obj.GetType().GetElementType().FullName;
+                        info.Expandable = res != null && !obj.GetType().GetElementType().IsPrimitive;
+
+                        return info;
+                    }
+                    else
+                    {
+                        if(obj is ILTypeInstance)
+                        {
+                            var m = ((ILTypeInstance)obj).Type.GetMethod("get_Item");
+                            if (m != null)
+                            {
+                                res = intepreter.AppDomain.Invoke(m, obj, idxObj);
+                                info = VariableInfo.FromObject(res);
+                                info.Type = VariableTypes.IndexAccess;
+                                info.TypeName = m.ReturnType.FullName;
+                                info.Expandable = res != null && !m.ReturnType.IsPrimitive;
+
+                                return info;
+                            }
+                            else
+                                return VariableInfo.NullReferenceExeption;
+                        }
+                        else
+                        {
+                            if(obj is ILRuntime.Runtime.Enviorment.CrossBindingAdaptorType)
+                            {
+                                throw new NotImplementedException();
+                            }
+                            else
+                            {
+                                if(obj is IDictionary && idxObj is int)
+                                {
+                                    IDictionary dic = (IDictionary)obj;
+                                    var keys = GetArray(dic.Keys);                                    
+                                    if (keys[0].GetType() != typeof(int))
+                                    {
+                                        int index = (int)idxObj;
+                                        var values = GetArray(dic.Values);
+                                        var t = typeof(KeyValuePair<,>).MakeGenericType(keys[index].GetType(), values[index].GetType());
+                                        var ctor = t.GetConstructor(new Type[] { keys[index].GetType(), values[index].GetType() });
+                                        res = ctor.Invoke(new object[] { keys[index], values[index] });
+                                        info = VariableInfo.FromObject(res);
+                                        info.Type = VariableTypes.IndexAccess;
+                                        info.Offset = index;
+                                        info.TypeName = t.FullName;
+                                        info.Expandable = true;
+
+                                        return info;
+                                    }
+                                }
+                                var pi = obj.GetType().GetProperty("Item");
+                                if (pi != null)
+                                {
+                                    res = pi.GetValue(obj, new object[] { idxObj });
+                                    info = VariableInfo.FromObject(res);
+                                    info.Type = VariableTypes.IndexAccess;
+                                    info.TypeName = pi.PropertyType.FullName;
+                                    info.Expandable = res != null && !pi.PropertyType.IsPrimitive;
+
+                                    return info;
+                                }
+                                else
+                                    return VariableInfo.NullReferenceExeption;
+                            }
+                        }
+                    }
+                }
+                else
+                    return VariableInfo.NullReferenceExeption;
+            }
+            else
+                return VariableInfo.NullReferenceExeption;
+        }
+
+        internal unsafe VariableInfo ResolveVariable(int threadHashCode, VariableReference variable, out object res)
+        {
+            ILIntepreter intepreter;
+            res = null;
+            if (AppDomain.Intepreters.TryGetValue(threadHashCode, out intepreter))
+            {
+                if (variable != null)
+                {
+                    switch (variable.Type)
+                    {
+                        case VariableTypes.Normal:
+                            {
+                                StackObject* ptr = (StackObject*)variable.Address;
+                                object obj = StackObject.ToObject(ptr, AppDomain, intepreter.Stack.ManagedStack);
+                                if (obj != null)
+                                {
+                                    //return ResolveMember(obj, name, out res);   
+                                    res = obj;
+                                    return null;
+                                }
+                                else
+                                {
+                                    return VariableInfo.Null;
+                                }
+                            }
+                        case VariableTypes.FieldReference:
+                        case VariableTypes.PropertyReference:
+                            {
+                                object obj;
+                                if (variable.Parent != null)
+                                {
+                                    var info = ResolveVariable(threadHashCode, variable.Parent, out obj);
+                                    if (obj != null)
+                                    {
+                                        return ResolveMember(obj, variable.Name, out res);
+                                    }
+                                    else
+                                    {
+                                        return VariableInfo.NullReferenceExeption;
+                                    }
+                                }
+                                else
+                                {
+                                    var frame = intepreter.Stack.Frames.Peek();
+                                    var m = frame.Method;
+                                    if (m.HasThis)
+                                    {
+                                        var addr = Minus(frame.LocalVarPointer, m.ParameterCount + 1);
+                                        var v = StackObject.ToObject(addr, intepreter.AppDomain, intepreter.Stack.ManagedStack);
+                                        return ResolveMember(v, variable.Name, out res);
+                                    }
+                                    else
+                                    {
+                                        return VariableInfo.GetCannotFind(variable.Name);
+                                    }
+                                }
+                            }
+                        case VariableTypes.IndexAccess:
+                            {
+                                return ResolveIndexAccess(threadHashCode, variable.Parent, variable.Parameters[0], out res);
+                            }
+                        case VariableTypes.Integer:
+                            {
+                                res = variable.Offset;
+                                return VariableInfo.GetInteger(variable.Offset);
+                            }
+                        case VariableTypes.String:
+                            {
+                                res = variable.Name;
+                                return VariableInfo.GetString(variable.Name);
+                            }
+                        case VariableTypes.Boolean:
+                            {
+                                if(variable.Offset == 1)
+                                {
+                                    res = true;
+                                    return VariableInfo.True;
+                                }
+                                else
+                                {
+                                    res = false;
+                                    return VariableInfo.False;
+                                }
+                            }
+                        case VariableTypes.Null:
+                            {
+                                res = null;
+                                return VariableInfo.Null;
+                            }
+                        default:
+                            throw new NotImplementedException();
+                    }
+                }
+                else
+                {
+                    return VariableInfo.NullReferenceExeption;
+                }
+            }
+            else
+                return VariableInfo.NullReferenceExeption;
+        }
+
+        VariableInfo ResolveMember(object obj, string name, out object res)
         {
-            return null;
+            res = null;
+            Type type = null;
+            if (obj is ILTypeInstance)
+            {
+                type = ((ILTypeInstance)obj).Type.ReflectionType;
+            }
+            else if (obj is Enviorment.CrossBindingAdaptorType)
+                type = ((Enviorment.CrossBindingAdaptorType)obj).ILInstance.Type.ReflectionType;
+            else
+                type = obj.GetType();
+            var fi = type.GetField(name, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
+            if (fi != null)
+            {
+                res = fi.GetValue(obj);
+                VariableInfo info = VariableInfo.FromObject(res);
+
+                info.Address = 0;
+                info.Name = name;
+                info.Type = VariableTypes.FieldReference;
+                info.TypeName = fi.FieldType.FullName;
+                info.IsPrivate = fi.IsPrivate;
+                info.IsProtected = fi.IsFamily;
+                info.Expandable = res != null && !fi.FieldType.IsPrimitive;
+
+                return info;
+            }
+            else
+            {
+                var pi = type.GetProperty(name, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
+                if (pi != null)
+                {
+                    res = pi.GetValue(obj, null);
+                    VariableInfo info = VariableInfo.FromObject(res);
+
+                    info.Address = 0;
+                    info.Name = name;
+                    info.Type = VariableTypes.PropertyReference;
+                    info.TypeName = pi.PropertyType.FullName;
+                    info.IsPrivate = pi.GetGetMethod(true).IsPrivate;
+                    info.IsProtected = pi.GetGetMethod(true).IsFamily;
+                    info.Expandable = res != null && !pi.PropertyType.IsPrimitive;
+                    return info;
+                }
+            }
+            return VariableInfo.GetCannotFind(name);
         }
 
         unsafe bool GetValueExpandable(StackObject* esp, IList<object> mStack)
@@ -499,12 +964,12 @@ namespace ILRuntime.Runtime.Debugger
 
         internal unsafe void DumpStack(StackObject* esp, RuntimeStack stack)
         {
-#if !UNITY_5 && !UNITY_2017 && !UNITY_4
             var start = stack.StackBase;
             var end = esp + 10;
             var frames = stack.Frames;
             var mStack = stack.ManagedStack;
             var valuePointerEnd = stack.ValueTypeStackPointer;
+            StringBuilder final = new StringBuilder();
             HashSet<long> leakVObj = new HashSet<long>();
             for (var i = stack.ValueTypeStackBase; i > stack.ValueTypeStackPointer;)
             {
@@ -557,7 +1022,7 @@ namespace ILRuntime.Runtime.Debugger
                     sb.Append(baseMethod.ToString());
                 }
 
-                System.Diagnostics.Debug.Print(sb.ToString());
+                final.AppendLine(sb.ToString());
             }
 
             for (var i = stack.ValueTypeStackBase; i > stack.ValueTypeStackPointer;)
@@ -565,23 +1030,27 @@ namespace ILRuntime.Runtime.Debugger
                 var vt = domain.GetType(i->Value);
                 var cnt = i->ValueLow;
                 bool leak = leakVObj.Contains((long)i);
-                System.Diagnostics.Debug.Print("----------------------------------------------");
-                System.Diagnostics.Debug.Print(string.Format("{2}(0x{0:X8}){1}", (long)i, vt, leak ? "*" : ""));
+                final.AppendLine("----------------------------------------------");
+                final.AppendLine(string.Format("{2}(0x{0:X8}){1}", (long)i, vt, leak ? "*" : ""));
                 for (int j = 0; j < cnt; j++)
                 {
                     StringBuilder sb = new StringBuilder();
                     var ptr = Minus(i, j + 1);
                     sb.Append(string.Format("(0x{0:X8}) Type:{1} ", (long)ptr, ptr->ObjectType));
                     GetStackObjectText(sb, ptr, mStack, valuePointerEnd);
-                    System.Diagnostics.Debug.Print(sb.ToString());
+                    final.AppendLine(sb.ToString());
                 }
                 i = Minus(i, i->ValueLow + 1);
             }
-            System.Diagnostics.Debug.Print("Managed Objects:");
+            final.AppendLine("Managed Objects:");
             for (int i = 0; i < mStack.Count; i++)
             {
-                System.Diagnostics.Debug.Print(string.Format("({0}){1}", i, mStack[i]));
+                final.AppendLine(string.Format("({0}){1}", i, mStack[i]));
             }
+#if !UNITY_5 && !UNITY_2017 && !UNITY_4
+            System.Diagnostics.Debug.Print(final.ToString());
+#else
+            UnityEngine.Debug.LogWarning(final.ToString());
 #endif
         }
 

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/DebugService.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: bca0b6c7c373ab74b96df13b5517171c
-timeCreated: 1509525194
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 9 - 3
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/DebugSocket.cs

@@ -137,9 +137,15 @@ namespace ILRuntime.Runtime.Debugger
                 int type = br.ReadInt32();
                 msgBuff = br.ReadBytes(lastMsgLength - 4);
 
-                if (OnReciveMessage != null)
-                    OnReciveMessage((DebugMessageType)type, msgBuff);
-
+                try
+                {
+                    if (OnReciveMessage != null)
+                        OnReciveMessage((DebugMessageType)type, msgBuff);
+                }
+                catch(Exception ex)
+                {
+                    Console.WriteLine(ex.ToString());
+                }
                 lastMsgLength = -1;
                 remaining = (int)(recvBuffer.Length - recvBuffer.Position);
                 //保留剩余数据

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/DebugSocket.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: e514adc780b8fd94d94c8bedf0cdc91f
-timeCreated: 1509525195
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 161 - 22
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/DebuggerServer/DebuggerServer.cs

@@ -12,7 +12,7 @@ namespace ILRuntime.Runtime.Debugger
 {
     public class DebuggerServer
     {
-        public const int Version = 1;
+        public const int Version = 2;
         TcpListener listener;
         //HashSet<Session<T>> clients = new HashSet<Session<T>>();
         bool isUp = false;
@@ -61,6 +61,8 @@ namespace ILRuntime.Runtime.Debugger
                 this.listener.Stop();
             mainLoop.Abort();
             mainLoop = null;
+            if (clientSocket != null)
+                clientSocket.Close();
         }
 
         void NetworkLoop()
@@ -127,6 +129,7 @@ namespace ILRuntime.Runtime.Debugger
                     {
                         CSBindBreakpoint msg = new Protocol.CSBindBreakpoint();
                         msg.BreakpointHashCode = br.ReadInt32();
+                        msg.IsLambda = br.ReadBoolean();
                         msg.TypeName = br.ReadString();
                         msg.MethodName = br.ReadString();
                         msg.StartLine = br.ReadInt32();
@@ -159,9 +162,56 @@ namespace ILRuntime.Runtime.Debugger
                 case DebugMessageType.CSResolveVariable:
                     {
                         CSResolveVariable msg = new CSResolveVariable();
-                        msg.Name = br.ReadString();
-                        msg.Parent = ReadVariableReference(br);
-                        var info = ds.ResolveVariable(msg.Parent, msg.Name);
+                        msg.ThreadHashCode = br.ReadInt32();
+                        msg.Variable = ReadVariableReference(br);
+                        VariableInfo info;
+                        try
+                        {
+                            object res;
+                            info = ds.ResolveVariable(msg.ThreadHashCode, msg.Variable, out res);
+                        }
+                        catch (Exception ex)
+                        {
+                            info = VariableInfo.GetException(ex);
+                        }
+                        SendSCResolveVariableResult(info);
+                    }
+                    break;
+                case DebugMessageType.CSResolveIndexAccess:
+                    {
+                        CSResolveIndexer msg = new CSResolveIndexer();
+                        msg.ThreadHashCode = br.ReadInt32();
+                        msg.Body = ReadVariableReference(br);
+                        msg.Index = ReadVariableReference(br);
+
+                        VariableInfo info;
+                        try
+                        {
+                            object res;
+                            info = ds.ResolveIndexAccess(msg.ThreadHashCode, msg.Body, msg.Index, out res);
+                        }
+                        catch(Exception ex)
+                        {
+                            info = VariableInfo.GetException(ex);
+                        }
+                        SendSCResolveVariableResult(info);
+                    }
+                    break;
+                case DebugMessageType.CSEnumChildren:
+                    {
+                        int thId = br.ReadInt32();
+                        var parent = ReadVariableReference(br);
+
+                        VariableInfo[] info = null;
+                        try
+                        {
+                            info = ds.EnumChildren(thId, parent);
+                        }
+                        catch(Exception ex)
+                        {
+                            info = new VariableInfo[] { VariableInfo.GetException(ex) };
+                        }
+                        SendSCEnumChildrenResult(info);
                     }
                     break;
             }
@@ -177,7 +227,14 @@ namespace ILRuntime.Runtime.Debugger
                 res.Address = br.ReadInt64();
                 res.Type = (VariableTypes)br.ReadByte();
                 res.Offset = br.ReadInt32();
+                res.Name = br.ReadString();
                 res.Parent = ReadVariableReference(br);
+                int cnt = br.ReadInt32();
+                res.Parameters = new VariableReference[cnt];
+                for(int i = 0; i < cnt; i++)
+                {
+                    res.Parameters[i] = ReadVariableReference(br);
+                }
             }
             return res;
         }
@@ -209,32 +266,99 @@ namespace ILRuntime.Runtime.Debugger
             SCBindBreakpointResult res = new Protocol.SCBindBreakpointResult();
             res.BreakpointHashCode = msg.BreakpointHashCode;
             IType type;
-            if (domain.LoadedTypes.TryGetValue(msg.TypeName, out type))
+            if (msg.IsLambda)
             {
-                if(type is ILType)
+                ILMethod found = null;
+                foreach (var i in domain.LoadedTypes)
                 {
-                    ILType it = (ILType)type;
-                    ILMethod found = null;
-                    foreach(var i in it.GetMethods())
+                    var vt = i.Value as ILType;
+                    if (vt != null)
                     {
-                        if(i.Name == msg.MethodName)
+                        if (vt.FullName.Contains(msg.TypeName))
                         {
-                            ILMethod ilm = (ILMethod)i;
-                            if (ilm.StartLine <= (msg.StartLine + 1) && ilm.EndLine >= (msg.StartLine + 1))
+                            foreach (var j in vt.GetMethods())
                             {
-                                found = ilm;
-                                break;
+                                if (j.Name.Contains(string.Format("<{0}>", msg.MethodName)))
+                                {
+                                    ILMethod ilm = (ILMethod)j;
+                                    if (ilm.StartLine <= (msg.StartLine + 1) && ilm.EndLine >= (msg.StartLine + 1))
+                                    {
+                                        found = ilm;
+                                        break;
+                                    }
+                                }
                             }
                         }
                     }
-                    if(found != null)
+                    if (found != null)
+                        break;
+                }
+                if (found != null)
+                {
+                    ds.SetBreakPoint(found.GetHashCode(), msg.BreakpointHashCode, msg.StartLine);
+                    res.Result = BindBreakpointResults.OK;
+                }
+                else
+                {
+                    res.Result = BindBreakpointResults.CodeNotFound;
+                }
+            }
+            else
+            {
+                if (domain.LoadedTypes.TryGetValue(msg.TypeName, out type))
+                {
+                    if (type is ILType)
                     {
-                        ds.SetBreakPoint(found.GetHashCode(), msg.BreakpointHashCode, msg.StartLine);
-                        res.Result = BindBreakpointResults.OK;
+                        ILType it = (ILType)type;
+                        ILMethod found = null;
+                        if (msg.MethodName == ".ctor")
+                        {
+                            foreach (var i in it.GetConstructors())
+                            {
+                                ILMethod ilm = (ILMethod)i;
+                                if (ilm.StartLine <= (msg.StartLine + 1) && ilm.EndLine >= (msg.StartLine + 1))
+                                {
+                                    found = ilm;
+                                    break;
+                                }
+                            }
+                        }
+                        else if (msg.MethodName == ".cctor")
+                        {
+                            ILMethod ilm = it.GetStaticConstroctor() as ILMethod;
+                            if (ilm.StartLine <= (msg.StartLine + 1) && ilm.EndLine >= (msg.StartLine + 1))
+                            {
+                                found = ilm;
+                            }
+                        }
+                        else
+                        {
+                            foreach (var i in it.GetMethods())
+                            {
+                                if (i.Name == msg.MethodName)
+                                {
+                                    ILMethod ilm = (ILMethod)i;
+                                    if (ilm.StartLine <= (msg.StartLine + 1) && ilm.EndLine >= (msg.StartLine + 1))
+                                    {
+                                        found = ilm;
+                                        break;
+                                    }
+                                }
+                            }
+                        }
+                        if (found != null)
+                        {
+                            ds.SetBreakPoint(found.GetHashCode(), msg.BreakpointHashCode, msg.StartLine);
+                            res.Result = BindBreakpointResults.OK;
+                        }
+                        else
+                        {
+                            res.Result = BindBreakpointResults.CodeNotFound;
+                        }
                     }
                     else
                     {
-                        res.Result = BindBreakpointResults.CodeNotFound;
+                        res.Result = BindBreakpointResults.TypeNotFound;
                     }
                 }
                 else
@@ -242,10 +366,6 @@ namespace ILRuntime.Runtime.Debugger
                     res.Result = BindBreakpointResults.TypeNotFound;
                 }
             }
-            else
-            {
-                res.Result = BindBreakpointResults.TypeNotFound;
-            }
             SendSCBindBreakpointResult(res);
         }
 
@@ -281,6 +401,22 @@ namespace ILRuntime.Runtime.Debugger
             DoSend(DebugMessageType.SCResolveVariableResult);
         }
 
+        void SendSCEnumChildrenResult(VariableInfo[] info)
+        {
+            sendStream.Position = 0;
+            if (info != null)
+            {
+                bw.Write(info.Length);
+                for (int i = 0; i < info.Length; i++)
+                {
+                    WriteVariableInfo(info[i]);
+                }
+            }
+            else
+                bw.Write(0);
+            DoSend(DebugMessageType.SCEnumChildrenResult);
+        }
+
         void WriteStackFrames(KeyValuePair<int, StackFrameInfo[]>[] info)
         {
             bw.Write(info.Length);
@@ -312,8 +448,11 @@ namespace ILRuntime.Runtime.Debugger
             bw.Write(k.Offset);
             bw.Write(k.Name);
             bw.Write(k.Value);
+            bw.Write((byte)k.ValueType);
             bw.Write(k.TypeName);
             bw.Write(k.Expandable);
+            bw.Write(k.IsPrivate);
+            bw.Write(k.IsProtected);
         }
 
         internal void SendSCThreadStarted(int threadHash)

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/DebuggerServer/DebuggerServer.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 52306472508bb034f8fd1b68d450ce8e
-timeCreated: 1509525193
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 1 - 0
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/CSBindBreakpoint.cs

@@ -8,6 +8,7 @@ namespace ILRuntime.Runtime.Debugger.Protocol
     public class CSBindBreakpoint
     {
         public int BreakpointHashCode { get; set; }
+        public bool IsLambda { get; set; }
         public string TypeName { get; set; }
         public string MethodName { get; set; }
         public int StartLine { get; set; }

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/CSBindBreakpoint.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: aa0ea609114467a41941ebad10e2c081
-timeCreated: 1509525194
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/CSDeleteBreakpoint.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 58263d5697f506248a2a9fe66a69f3b1
-timeCreated: 1509525193
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 13 - 0
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/CSEnumChildren.cs

@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace ILRuntime.Runtime.Debugger.Protocol
+{
+    public class CSEnumChildren
+    {
+        public int ThreadHashCode { get; set; }
+        public VariableReference Parent { get; set; }
+    }
+}

+ 12 - 0
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/CSEnumChildren.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 212268b2a9e609d428bf6aa67411bf7c
+timeCreated: 1516154069
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/CSExecute.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 3a64e6abaa6367e4c86c71f47955ef15
-timeCreated: 1509525193
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 14 - 0
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/CSResolveIndexer.cs

@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace ILRuntime.Runtime.Debugger.Protocol
+{
+    public class CSResolveIndexer
+    {
+        public int ThreadHashCode { get; set; }
+        public VariableReference Index { get; set; }
+        public VariableReference Body { get; set; }
+    }
+}

+ 12 - 0
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/CSResolveIndexer.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 43a0e58b3a4ad774daf4a9e6bea7f529
+timeCreated: 1516154069
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/CSResolveVariable.cs

@@ -7,7 +7,7 @@ namespace ILRuntime.Runtime.Debugger.Protocol
 {
     public class CSResolveVariable
     {
-        public string Name { get; set; }
-        public VariableReference Parent { get; set; }
+        public int ThreadHashCode { get; set; }
+        public VariableReference Variable { get; set; }
     }
 }

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/CSResolveVariable.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 04bf766da67e49947812303010492217
-timeCreated: 1509525192
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/CSStep.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 58bb0ff22cedb204ba27ae8a3653c925
-timeCreated: 1509525193
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/SCAttachResult.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 4a95d12ad4b5f1e48b98c5dde9dcabf8
-timeCreated: 1509525193
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/SCBindBreakpointResult.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 1a7539c200fc96b439bf2ecc8e06cb98
-timeCreated: 1509525192
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/SCBreakpointHit.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 22bab0c3783302649afbacc7867f772a
-timeCreated: 1509525192
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 12 - 0
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/SCEnumChildrenResult.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace ILRuntime.Runtime.Debugger.Protocol
+{
+    public class SCEnumChildrenResult
+    {
+        public VariableInfo[] Children { get; set; }
+    }
+}

+ 12 - 0
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/SCEnumChildrenResult.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: d73532ae1dd88914c978bfc40307a3c8
+timeCreated: 1516154069
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/SCModuleLoaded.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 35a24baf8e5f2bd46a4a2a0352dc0bb8
-timeCreated: 1509525193
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/SCResolveVariableResult.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: fd3187a64b8594444922906ec3e35098
-timeCreated: 1509525195
-licenseType: Free
+timeCreated: 1516154070
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/SCStepComplete.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 0ed50f6dc3504124992baf704ff5bc3d
-timeCreated: 1509525192
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/SCThreadStarted.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 16dba5b2425526c41b18b579235f963a
-timeCreated: 1509525192
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/StackFrameInfo.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 1990fb3b0c78d1344b541383b5b4f514
-timeCreated: 1509525192
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/StepTypes.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: a9a918bf142c65744901f224ebcabd4d
-timeCreated: 1509525194
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 246 - 0
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/VariableInfo.cs

@@ -9,7 +9,26 @@ namespace ILRuntime.Runtime.Debugger
     {
         Normal,
         FieldReference,
+        PropertyReference,
+        TypeReference,
+        IndexAccess,
+        Invocation,
+        Integer,
+        Boolean,
+        String,
+        Null,
         Error,
+        NotFound,
+        Timeout,
+    }
+
+    public enum ValueTypes
+    {
+        Object,
+        Null,
+        Integer,
+        Boolean,
+        String,
     }
 
     public class VariableReference
@@ -17,7 +36,94 @@ namespace ILRuntime.Runtime.Debugger
         public long Address { get; set; }
         public VariableTypes Type { get; set; }
         public int Offset { get; set; }
+        public string Name { get; set; }
         public VariableReference Parent { get; set; }
+        public VariableReference[] Parameters { get; set; }
+
+        public string FullName
+        {
+            get
+            {
+                if (Parent != null)
+                {
+                    switch (Type)
+                    {
+                        case VariableTypes.FieldReference:
+                        case VariableTypes.PropertyReference:
+                            return string.Format("{0}.{1}", Parent.FullName, Name);
+                        case VariableTypes.IndexAccess:
+                            return string.Format("{0}[{1}]", Parent.FullName, Parameters[0].FullName);
+                        case VariableTypes.Error:
+                            return Name;
+                        default:
+                            throw new NotImplementedException();
+                    }
+                }
+                else
+                {
+                    switch (Type)
+                    {
+                        case VariableTypes.String:
+                            return string.Format("\"{0}\"", Name);
+                        case VariableTypes.Integer:
+                            return Offset.ToString();
+                        case VariableTypes.Boolean:
+                            return (Offset == 1).ToString();
+                        default:
+                            return Name;
+                    }
+                }
+            }
+        }
+
+        public static VariableReference Null = new VariableReference
+        {
+            Type = VariableTypes.Null,
+            Name = "null"
+        };
+
+        public static VariableReference True = new VariableReference
+        {
+            Type = VariableTypes.Boolean,
+            Name = "true",
+            Offset = 1,
+        };
+
+        public static VariableReference False = new VariableReference
+        {
+            Type = VariableTypes.Boolean,
+            Name = "false",
+            Offset = 0
+        };
+
+        public static VariableReference GetInteger(int val)
+        {
+            var res = new VariableReference();
+            res.Type = VariableTypes.Integer;
+            res.Name = "";
+            res.Offset = val;
+            
+            return res;
+        }
+
+        public static VariableReference GetString(string val)
+        {
+            var res = new VariableReference();
+            res.Type = VariableTypes.String;
+            res.Name = val;
+
+            return res;
+        }
+
+        public static VariableReference GetMember(string name, VariableReference parent)
+        {
+            var res = new VariableReference();
+            res.Type = VariableTypes.FieldReference;
+            res.Name = name;
+            res.Parent = parent;
+
+            return res;
+        }
     }
 
     public class VariableInfo
@@ -27,7 +133,147 @@ namespace ILRuntime.Runtime.Debugger
         public string Name { get; set; }
         public string TypeName { get; set; }
         public string Value { get; set; }
+        public ValueTypes ValueType { get; set; }
         public bool Expandable { get; set; }
+        public bool IsPrivate { get; set; }
+        public bool IsProtected { get; set; }
         public int Offset { get; set;}
+
+        public static VariableInfo FromObject(object obj, bool retriveType = false)
+        {
+            VariableInfo info = new VariableInfo();
+            info.Name = "";
+            if (obj != null)
+            {
+                info.Value = obj.ToString();
+                if(obj is int)
+                {
+                    info.ValueType = ValueTypes.Integer;
+                }
+                else if(obj is bool)
+                {
+                    info.ValueType = ValueTypes.Boolean;
+                }
+                else if(obj is string)
+                {
+                    info.ValueType = ValueTypes.String;
+                }
+                if (retriveType)
+                {
+                    if (obj is Runtime.Intepreter.ILTypeInstance)
+                    {
+                        info.TypeName = ((Intepreter.ILTypeInstance)obj).Type.FullName;                        
+                    }
+                    else if (obj is Enviorment.CrossBindingAdaptorType)
+                    {
+                        info.TypeName = ((Enviorment.CrossBindingAdaptorType)obj).ILInstance.Type.FullName;
+                    }
+                    else
+                    {
+                        info.TypeName = obj.GetType().FullName;
+                    }
+                }
+                info.Expandable = !obj.GetType().IsPrimitive && !(obj is string);
+            }
+            else
+            {
+                info.Value = "null";
+                info.ValueType = ValueTypes.Null;
+            }
+
+            return info;
+        }
+
+        public static VariableInfo NullReferenceExeption = new VariableInfo
+        {
+            Type = VariableTypes.Error,
+            Name = "",
+            TypeName = "",
+            Value = "NullReferenceException"
+        };
+
+        public static VariableInfo RequestTimeout = new VariableInfo
+        {
+            Type = VariableTypes.Timeout,
+            Name = "",
+            TypeName = "",
+            Value = "RequestTimeoutException"
+        };
+
+        public static VariableInfo Null = new VariableInfo
+        {
+            Type = VariableTypes.Null,
+            Name = "",
+            TypeName = "",
+            Value = "null",
+            ValueType = ValueTypes.Null
+        };
+
+        public static VariableInfo True = new VariableInfo
+        {
+            Type = VariableTypes.Boolean,
+            Name = "",
+            TypeName = "System.Boolean",
+            Value = "true",
+            ValueType = ValueTypes.Boolean
+        };
+
+        public static VariableInfo False = new VariableInfo
+        {
+            Type = VariableTypes.Boolean,
+            Name = "",
+            TypeName = "System.Boolean",
+            Value = "false",
+            ValueType = ValueTypes.Boolean
+        };
+
+        public static VariableInfo GetCannotFind(string name)
+        {
+            var res = new VariableInfo
+            {
+                Type = VariableTypes.NotFound,
+                TypeName = "",
+            };
+            res.Name = name;
+            res.Value = string.Format("Cannot find {0} in current scope.", name);
+
+            return res;
+        }
+
+        public static VariableInfo GetInteger(int val)
+        {
+            var res = new VariableInfo();
+            res.Type = VariableTypes.Integer;
+            res.Value = val.ToString();
+            res.TypeName = "System.Int32";
+            res.Name = "";
+            res.ValueType = ValueTypes.Integer;
+
+            return res;
+        }
+
+        public static VariableInfo GetString(string val)
+        {
+            var res = new VariableInfo();
+            res.Type = VariableTypes.String;
+            res.Value = val;
+            res.TypeName = "System.String";
+            res.Name = "";
+            res.ValueType = ValueTypes.String;
+
+            return res;
+        }
+
+        public static VariableInfo GetException(Exception ex)
+        {
+            var res = new VariableInfo();
+            res.Type = VariableTypes.Error;
+            res.Value = ex.ToString();
+            res.TypeName = ex.GetType().FullName;
+            res.Name = "";
+            res.ValueType = ValueTypes.String;
+
+            return res;
+        }
     }
 }

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Debugger/VariableInfo.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: ba46157c0b55fee46b03f075c5c7668e
-timeCreated: 1509525194
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 22 - 10
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Enviorment/AppDomain.cs

@@ -108,6 +108,13 @@ namespace ILRuntime.Runtime.Enviorment
                     RegisterCLRMethodRedirection(i, CLRRedirections.MethodInfoInvoke);
                 }
             }
+            foreach (var i in typeof(Enum).GetMethods())
+            {
+                if (i.Name == "Parse" && i.GetParameters().Length == 2)
+                {
+                    RegisterCLRMethodRedirection(i, CLRRedirections.EnumParse);
+                }
+            }
             mi = typeof(System.Type).GetMethod("GetTypeFromHandle");
             RegisterCLRMethodRedirection(mi, CLRRedirections.GetTypeFromHandle);
             mi = typeof(object).GetMethod("GetType");
@@ -340,13 +347,14 @@ namespace ILRuntime.Runtime.Enviorment
 
             if (module.HasAssemblyReferences) //如果此模块引用了其他模块
             {
-                foreach (var ar in module.AssemblyReferences)
+                /*foreach (var ar in module.AssemblyReferences)
                 {
-                    /*if (moduleref.Contains(ar.Name) == false)
+                    if (moduleref.Contains(ar.Name) == false)
                         moduleref.Add(ar.Name);
                     if (moduleref.Contains(ar.FullName) == false)
-                        moduleref.Add(ar.FullName);*/
+                        moduleref.Add(ar.FullName);
                 }
+                */
             }
 
             if (module.HasTypes)
@@ -374,7 +382,7 @@ namespace ILRuntime.Runtime.Enviorment
                 objectType = GetType("System.Object");
             }
             module.AssemblyResolver.ResolveFailure += AssemblyResolver_ResolveFailure;
-#if DEBUG
+#if DEBUG && !DISABLE_ILRUNTIME_DEBUG
             debugService.NotifyModuleLoaded(module.Name);
 #endif
         }
@@ -445,6 +453,9 @@ namespace ILRuntime.Runtime.Enviorment
             {
                 valueTypeBinders[t] = binder;
                 binder.RegisterCLRRedirection(this);
+
+                var ct = GetType(t) as CLRType;
+                binder.CLRType = ct;
             }
         }
 
@@ -519,7 +530,7 @@ namespace ILRuntime.Runtime.Enviorment
 
                 if (isArray)
                 {
-                    bt = bt.MakeArrayType();
+                    bt = bt.MakeArrayType(1);
                     mapType[bt.FullName] = bt;
                     mapTypeToken[bt.GetHashCode()] = bt;
                     if (!isByRef)
@@ -701,10 +712,11 @@ namespace ILRuntime.Runtime.Enviorment
                 }
                 if (_ref.IsArray)
                 {
+                    ArrayType at = (ArrayType)_ref;
                     var t = GetType(_ref.GetElementType(), contextType, contextMethod);
                     if (t != null)
                     {
-                        res = t.MakeArrayType();
+                        res = t.MakeArrayType(at.Rank);
                         if (res is ILType)
                         {
                             ///Unify the TypeReference
@@ -965,7 +977,7 @@ namespace ILRuntime.Runtime.Enviorment
                     else
                     {
                         inteptreter = new ILIntepreter(this);
-#if DEBUG
+#if DEBUG && !DISABLE_ILRUNTIME_DEBUG
                         intepreters[inteptreter.GetHashCode()] = inteptreter;
                         debugService.ThreadStarted(inteptreter);
 #endif
@@ -979,8 +991,8 @@ namespace ILRuntime.Runtime.Enviorment
                 {
                     lock (freeIntepreters)
                     {
-#if DEBUG
-                        if(inteptreter.CurrentStepType!= StepTypes.None)
+#if DEBUG && !DISABLE_ILRUNTIME_DEBUG
+                        if (inteptreter.CurrentStepType!= StepTypes.None)
                         {
                             //We should resume all other threads if we are currently doing stepping operation
                             foreach(var i in intepreters)
@@ -997,7 +1009,7 @@ namespace ILRuntime.Runtime.Enviorment
                         inteptreter.Stack.ManagedStack.Clear();
                         inteptreter.Stack.Frames.Clear();
                         freeIntepreters.Enqueue(inteptreter);
-#if DEBUG
+#if DEBUG && !DISABLE_ILRUNTIME_DEBUG
                         //debugService.ThreadEnded(inteptreter);
 #endif
 

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Enviorment/AppDomain.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 7e82484243e934c46b52e732ea60be5a
-timeCreated: 1509525194
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 62 - 1
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Enviorment/CLRRedirections.cs

@@ -791,7 +791,23 @@ namespace ILRuntime.Runtime.Enviorment
                 }
                 bool unhandled;
                 var ilmethod = ((ILRuntimeMethodInfo)instance).ILMethod;
-                return intp.Execute(ilmethod, esp, out unhandled);
+                ret = intp.Execute(ilmethod, esp, out unhandled);
+                ILRuntimeMethodInfo imi = (ILRuntimeMethodInfo)instance;
+                var rt = imi.ReturnType;
+                if (rt != domain.VoidType)
+                {
+                    var res = ret - 1;
+                    if (res->ObjectType < ObjectTypes.Object)
+                    {
+                        if (rt is ILRuntimeWrapperType)
+                            rt = ((ILRuntimeWrapperType)rt).CLRType.TypeForCLR;
+                        return ILIntepreter.PushObject(res, mStack, rt.CheckCLRTypes(StackObject.ToObject(res, domain, mStack)), true);
+                    }
+                    else
+                        return ret;
+                }
+                else
+                    return ret;                
             }
             else
                 return ILIntepreter.PushObject(ret, mStack, ((MethodInfo)instance).Invoke(obj, (object[])p));
@@ -861,5 +877,50 @@ namespace ILRuntime.Runtime.Enviorment
             else
                 return type;
         }*/
+        public static StackObject* EnumParse(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj)
+        {
+            var ret = esp - 1 - 1;
+            AppDomain domain = intp.AppDomain;
+
+            var p = esp - 1;
+            string name = (string)StackObject.ToObject(p, domain, mStack); 
+            intp.Free(p);
+
+            p = esp - 1 - 1;
+            Type t = (Type)StackObject.ToObject(p, domain, mStack);
+            intp.Free(p);
+            if (t is ILRuntimeType)
+            {
+                ILType it = ((ILRuntimeType)t).ILType;
+                if (it.IsEnum)
+                {
+                    var fields = it.TypeDefinition.Fields;
+                    for (int i = 0; i < fields.Count; i++)
+                    {
+                        var f = fields[i];
+                        if (f.IsStatic)
+                        {
+                            if(f.Name == name)
+                            {
+                                ILEnumTypeInstance ins = new ILEnumTypeInstance(it);
+                                ins[0] = f.Constant;
+                                ins.Boxed = true;
+
+                                return ILIntepreter.PushObject(ret, mStack, ins, true);
+                            }
+                        }
+                    }
+                    return ILIntepreter.PushNull(ret);
+                }
+                else
+                    throw new Exception(string.Format("{0} is not Enum", t.FullName));
+            }
+            else if (t is ILRuntimeWrapperType)
+            {
+                return ILIntepreter.PushObject(ret, mStack, Enum.Parse(((ILRuntimeWrapperType)t).RealType, name), true);
+            }
+            else
+                return ILIntepreter.PushObject(ret, mStack, Enum.Parse(t, name), true);
+        }
     }
 }

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Enviorment/CLRRedirections.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: f69628ad8b7de48438cc264443cb5c7c
-timeCreated: 1509525195
-licenseType: Free
+timeCreated: 1516154070
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 7 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Enviorment/CrossBindingAdaptor.cs

@@ -96,9 +96,9 @@ namespace ILRuntime.Runtime.Enviorment
             return type.MakeByRefType();
         }
 
-        public IType MakeArrayType()
+        public IType MakeArrayType(int rank)
         {
-            return type.MakeArrayType();
+            return type.MakeArrayType(rank);
         }
 
         public IType FindGenericArgument(string key)
@@ -239,6 +239,11 @@ namespace ILRuntime.Runtime.Enviorment
         {
             get { return false; }
         }
+
+        public int ArrayRank
+        {
+            get { return type.ArrayRank; }
+        }
         #endregion
     }
 }

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Enviorment/CrossBindingAdaptor.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 89b5db64481707c44b294daa538d54df
-timeCreated: 1509525194
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Enviorment/DelegateManager.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: ea8e4e6294992d0489b4f3671c3a7b5e
-timeCreated: 1509525195
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Enviorment/ValueTypeBinder.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: da1fec14f676a0444b5f6b09e4bf0bfd
-timeCreated: 1509525195
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 55 - 4
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Extensions.cs

@@ -12,11 +12,43 @@ namespace ILRuntime.Runtime
         public static void GetClassName(this Type type, out string clsName, out string realClsName, out bool isByRef, bool simpleClassName = false)
         {
             isByRef = type.IsByRef;
+            int arrayRank = 1;
             bool isArray = type.IsArray;
             if (isByRef)
+            {
                 type = type.GetElementType();
+            }
             if (isArray)
+            {
+                arrayRank = type.GetArrayRank();
                 type = type.GetElementType();
+                if (type.IsArray)
+                {
+                    type.GetClassName(out clsName, out realClsName, out isByRef, simpleClassName);
+
+                    clsName += "_Array";
+                    if (!simpleClassName)
+                        clsName += "_Binding";
+                    if (arrayRank > 1)
+                        clsName += arrayRank;
+                    if (arrayRank <= 1)
+                        realClsName += "[]";
+                    else
+                    {
+                        StringBuilder sb = new StringBuilder();
+                        sb.Append(realClsName);
+                        sb.Append('[');
+                        for (int i = 0; i < arrayRank - 1; i++)
+                        {
+                            sb.Append(',');
+                        }
+                        sb.Append(']');
+                        realClsName = sb.ToString();
+                    }
+
+                    return;
+                }
+            }
             string realNamespace = null;
             bool isNestedGeneric = false;
             if (type.IsNested)
@@ -33,7 +65,7 @@ namespace ILRuntime.Runtime
                     }
                 }
                 GetClassName(rt, out bClsName, out bRealClsName, out tmp);
-                clsName = simpleClassName ? "" : bClsName + "_";
+                clsName = bClsName + "_";
                 realNamespace = bRealClsName + ".";
             }
             else
@@ -68,10 +100,14 @@ namespace ILRuntime.Runtime
                 }
                 ga += ">";
             }
-            if (!simpleClassName)
-                clsName += "_Binding";
             if (isArray)
+            {
                 clsName += "_Array";
+                if (arrayRank > 1)
+                    clsName += arrayRank;
+            }
+            if (!simpleClassName)
+                clsName += "_Binding";
 
             realClsName = realNamespace;
             if (isGeneric)
@@ -89,7 +125,22 @@ namespace ILRuntime.Runtime
                 realClsName += type.Name;
 
             if (isArray)
-                realClsName += "[]";
+            {
+                if (arrayRank <= 1)
+                    realClsName += "[]";
+                else
+                {
+                    StringBuilder sb = new StringBuilder();
+                    sb.Append(realClsName);
+                    sb.Append('[');
+                    for(int i=0;i<arrayRank - 1; i++)
+                    {
+                        sb.Append(',');
+                    }
+                    sb.Append(']');
+                    realClsName = sb.ToString();
+                }
+            }
 
         }
         public static int ToInt32(this object obj)

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Extensions.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: cd8de1ae799f1ca47a32ba07ea2a5bf8
-timeCreated: 1509525195
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 6 - 0
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Intepreter/DelegateAdapter.cs

@@ -687,6 +687,12 @@ namespace ILRuntime.Runtime.Intepreter
                 if(ret->ObjectType>= ObjectTypes.Object)
                 {
                     retObj = mStack[ret->Value];
+                    if(retObj == null)
+                    {
+                        retSObj.ObjectType = ObjectTypes.Null;
+                        retSObj.Value = -1;
+                        retSObj.ValueLow = 0;
+                    }
                 }
                 intp.Free(ret);
             }

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Intepreter/DelegateAdapter.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: a6dd5ad6790a01b468a803875deb4a3f
-timeCreated: 1509525194
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 197 - 63
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Intepreter/ILIntepreter.cs

@@ -33,7 +33,7 @@ namespace ILRuntime.Runtime.Intepreter
             this.domain = domain;
             stack = new RuntimeStack(this);
             allowUnboundCLRMethod = domain.AllowUnboundCLRMethod;
-#if DEBUG
+#if DEBUG && !DISABLE_ILRUNTIME_DEBUG
             _lockObj = new object();
 #endif
         }
@@ -45,7 +45,9 @@ namespace ILRuntime.Runtime.Intepreter
             //Clear old debug state
             ClearDebugState();
             lock (_lockObj)
+            {
                 Monitor.Wait(_lockObj);
+            }
         }
 
         public void Resume()
@@ -80,7 +82,7 @@ namespace ILRuntime.Runtime.Intepreter
             esp = Execute(method, esp, out unhandledException);
             object result = method.ReturnType != domain.VoidType ? method.ReturnType.TypeForCLR.CheckCLRTypes(StackObject.ToObject((esp - 1), domain, mStack)) : null;
             //ClearStack
-#if DEBUG
+#if DEBUG && !DISABLE_ILRUNTIME_DEBUG
             ((List<object>)mStack).RemoveRange(mStackBase, mStack.Count - mStackBase);
 #else
             ((UncheckedList<object>)mStack).RemoveRange(mStackBase, mStack.Count - mStackBase);
@@ -214,7 +216,7 @@ namespace ILRuntime.Runtime.Intepreter
                 {
                     try
                     {
-#if DEBUG
+#if DEBUG && !DISABLE_ILRUNTIME_DEBUG
                         if (ShouldBreak)
                             Break();
                         var insOffset = (int)(ip - ptr);
@@ -762,6 +764,34 @@ namespace ILRuntime.Runtime.Intepreter
                                 }
                                 break;
                             case OpCodeEnum.Stind_I8:
+                                {
+                                    var dst = GetObjectAndResolveReference(esp - 1 - 1);
+                                    var val = esp - 1;
+                                    switch (dst->ObjectType)
+                                    {
+                                        case ObjectTypes.FieldReference:
+                                            {
+                                                StoreValueToFieldReference(mStack[dst->Value], dst->ValueLow, val, mStack);
+                                            }
+                                            break;
+                                        case ObjectTypes.ArrayReference:
+                                            {
+                                                StoreValueToArrayReference(dst, val, typeof(long), mStack);
+                                            }
+                                            break;
+                                        default:
+                                            {
+                                                dst->Value = val->Value;
+                                                dst->ValueLow = val->ValueLow;
+                                            }
+                                            break;
+                                    }
+
+                                    Free(esp - 1);
+                                    Free(esp - 1 - 1);
+                                    esp = esp - 1 - 1;
+                                }
+                                break;
                             case OpCodeEnum.Stind_R8:
                                 {
                                     var dst = GetObjectAndResolveReference(esp - 1 - 1);
@@ -773,6 +803,11 @@ namespace ILRuntime.Runtime.Intepreter
                                                 StoreValueToFieldReference(mStack[dst->Value], dst->ValueLow, val, mStack);
                                             }
                                             break;
+                                        case ObjectTypes.ArrayReference:
+                                            {
+                                                StoreValueToArrayReference(dst, val, typeof(double), mStack);
+                                            }
+                                            break;
                                         default:
                                             {
                                                 dst->Value = val->Value;
@@ -797,6 +832,11 @@ namespace ILRuntime.Runtime.Intepreter
                                                 StoreValueToFieldReference(mStack[dst->Value], dst->ValueLow, val, mStack);
                                             }
                                             break;
+                                        case ObjectTypes.ArrayReference:
+                                            {
+                                                StoreValueToArrayReference(dst, val, typeof(object), mStack);
+                                            }
+                                            break;
                                         default:
                                             {
                                                 switch (val->ObjectType)
@@ -1642,10 +1682,19 @@ namespace ILRuntime.Runtime.Intepreter
                                                     var objRef = GetObjectAndResolveReference(Minus(esp, ilm.ParameterCount + 1));
                                                     if (objRef->ObjectType == ObjectTypes.Null)
                                                         throw new NullReferenceException();
-                                                    var obj = mStack[objRef->Value];
-                                                    if (obj == null)
-                                                        throw new NullReferenceException();
-                                                    ilm = ((ILTypeInstance)obj).Type.GetVirtualMethod(ilm) as ILMethod;
+                                                    if (objRef->ObjectType == ObjectTypes.ValueTypeObjectReference)
+                                                    {
+                                                        StackObject* dst = *(StackObject**)&objRef->Value;
+                                                        var ft = domain.GetType(dst->Value) as ILType;
+                                                        ilm = ft.GetVirtualMethod(ilm) as ILMethod;
+                                                    }
+                                                    else
+                                                    {
+                                                        var obj = mStack[objRef->Value];
+                                                        if (obj == null)
+                                                            throw new NullReferenceException();
+                                                        ilm = ((ILTypeInstance)obj).Type.GetVirtualMethod(ilm) as ILMethod;
+                                                    }                                                    
                                                 }
                                                 esp = Execute(ilm, esp, out unhandledException);
                                                 ValueTypeBasePointer = bp;
@@ -1674,7 +1723,7 @@ namespace ILRuntime.Runtime.Intepreter
                                                     esp = redirect(this, esp, mStack, cm, false);
                                                 else
                                                 {
-#if DEBUG
+#if DEBUG && !DISABLE_ILRUNTIME_DEBUG
                                                     if (!allowUnboundCLRMethod)
                                                         throw new NotSupportedException(cm.ToString() + " is not bound!");
 #endif
@@ -1794,6 +1843,14 @@ namespace ILRuntime.Runtime.Intepreter
                                                                     }
                                                                 }
                                                                 break;
+                                                            case ObjectTypes.ValueTypeObjectReference:
+                                                                {
+                                                                    var dst = *(StackObject**)&objRef->Value;
+                                                                    var ct = domain.GetType(dst->Value) as CLRType;
+                                                                    var binder = ct.ValueTypeBinder;
+                                                                    binder.CopyValueTypeToStack(obj, dst, mStack);
+                                                                }
+                                                                break;
                                                             default:
                                                                 throw new NotImplementedException();
                                                         }
@@ -1813,7 +1870,8 @@ namespace ILRuntime.Runtime.Intepreter
                                 break;
                             case OpCodeEnum.Ldfld:
                                 {
-                                    StackObject* objRef = GetObjectAndResolveReference(esp - 1);
+                                    var ret = esp - 1;
+                                    StackObject* objRef = GetObjectAndResolveReference(ret);
                                     if (objRef->ObjectType == ObjectTypes.ValueTypeObjectReference)
                                     {
                                         var dst = *(StackObject**)&objRef->Value;
@@ -1822,18 +1880,18 @@ namespace ILRuntime.Runtime.Intepreter
                                             dst = Minus(dst, (int)ip->TokenLong + 1);
                                         else
                                             dst = Minus(dst, ((CLRType)ft).FieldIndexMapping[(int)ip->TokenLong] + 1);
-                                        CopyToStack(objRef, dst, mStack);
+                                        CopyToStack(ret, dst, mStack);
                                     }
                                     else
                                     {
                                         object obj = RetriveObject(objRef, mStack);
-                                        Free(esp - 1);
+                                        Free(ret);
                                         if (obj != null)
                                         {
                                             if (obj is ILTypeInstance)
                                             {
                                                 ILTypeInstance instance = obj as ILTypeInstance;
-                                                instance.PushToStack((int)ip->TokenLong, esp - 1, AppDomain, mStack);
+                                                instance.PushToStack((int)ip->TokenLong, ret, AppDomain, mStack);
                                             }
                                             else
                                             {
@@ -1846,7 +1904,7 @@ namespace ILRuntime.Runtime.Intepreter
                                                     var val = ((CLRType)type).GetFieldValue(token, obj);
                                                     if (val is CrossBindingAdaptorType)
                                                         val = ((CrossBindingAdaptorType)val).ILInstance;
-                                                    PushObject(esp - 1, mStack, val, ft.FieldType == typeof(object));
+                                                    PushObject(ret, mStack, val, ft.FieldType == typeof(object));
                                                 }
                                                 else
                                                     throw new TypeLoadException();
@@ -2408,7 +2466,9 @@ namespace ILRuntime.Runtime.Intepreter
                                             }
                                             else
                                             {
-                                                //Nothing to do for normal IL Types
+                                                object res = RetriveObject(obj, mStack);
+                                                Free(objRef);
+                                                esp = PushObject(objRef, mStack, res, true);
                                             }
                                         }
                                         else
@@ -2424,7 +2484,9 @@ namespace ILRuntime.Runtime.Intepreter
                                             }
                                             else
                                             {
-                                                //Nothing to do for other CLR types
+                                                object res = RetriveObject(obj, mStack);
+                                                Free(objRef);
+                                                esp = PushObject(objRef, mStack, res, true);
                                             }
                                         }
                                     }
@@ -2465,18 +2527,25 @@ namespace ILRuntime.Runtime.Intepreter
                                                         {
                                                             var val = mStack[obj->Value];
                                                             Free(obj);
-                                                            ILTypeInstance ins = (ILTypeInstance)val;
-                                                            if (ins != null)
+                                                            if (type.IsArray)
                                                             {
-                                                                if (ins.IsValueType)
-                                                                {
-                                                                    ins.Boxed = true;
-                                                                }
-                                                                esp = PushObject(obj, mStack, ins, true);
+                                                                esp = PushObject(obj, mStack, val, true);
                                                             }
                                                             else
                                                             {
-                                                                esp = PushNull(obj);
+                                                                ILTypeInstance ins = (ILTypeInstance)val;
+                                                                if (ins != null)
+                                                                {
+                                                                    if (ins.IsValueType)
+                                                                    {
+                                                                        ins.Boxed = true;
+                                                                    }
+                                                                    esp = PushObject(obj, mStack, ins, true);
+                                                                }
+                                                                else
+                                                                {
+                                                                    esp = PushNull(obj);
+                                                                }
                                                             }
                                                         }
                                                         break;
@@ -2847,6 +2916,25 @@ namespace ILRuntime.Runtime.Intepreter
                                                             throw new NullReferenceException();
                                                     }
                                                     break;
+                                                case ObjectTypes.ArrayReference:
+                                                    {
+                                                        var arr = mStack[objRef->Value] as Array;
+                                                        var idx = objRef->ValueLow;
+                                                        var obj = arr.GetValue(idx);
+                                                        if (obj == null)
+                                                            arr.SetValue(it.Instantiate(), idx);
+                                                        else
+                                                        {
+                                                            if (obj is ILTypeInstance)
+                                                            {
+                                                                ILTypeInstance instance = obj as ILTypeInstance;
+                                                                instance.Clear();
+                                                            }
+                                                            else
+                                                                throw new NotImplementedException();
+                                                        }
+                                                    }
+                                                    break;
                                                 default:
                                                     throw new NotImplementedException();
                                             }
@@ -2898,6 +2986,7 @@ namespace ILRuntime.Runtime.Intepreter
                             case OpCodeEnum.Isinst:
                                 {
                                     var objRef = esp - 1;
+                                    var oriRef = objRef;
                                     var type = domain.GetType(ip->TokenInteger);
                                     if (type != null)
                                     {
@@ -2911,9 +3000,9 @@ namespace ILRuntime.Runtime.Intepreter
                                                     {
                                                         if (tclr != typeof(int) && tclr != typeof(bool) && tclr != typeof(short) && tclr != typeof(byte) && tclr != typeof(ushort) && tclr !=typeof(uint))
                                                         {
-                                                            objRef->ObjectType = ObjectTypes.Null;
-                                                            objRef->Value = -1;
-                                                            objRef->ValueLow = 0;
+                                                            oriRef->ObjectType = ObjectTypes.Null;
+                                                            oriRef->Value = -1;
+                                                            oriRef->ValueLow = 0;
                                                         }
                                                     }
                                                     break;
@@ -2921,9 +3010,9 @@ namespace ILRuntime.Runtime.Intepreter
                                                     {
                                                         if (tclr != typeof(long) && tclr != typeof(ulong))
                                                         {
-                                                            objRef->ObjectType = ObjectTypes.Null;
-                                                            objRef->Value = -1;
-                                                            objRef->ValueLow = 0;
+                                                            oriRef->ObjectType = ObjectTypes.Null;
+                                                            oriRef->Value = -1;
+                                                            oriRef->ValueLow = 0;
                                                         }
                                                     }
                                                     break;
@@ -2931,9 +3020,9 @@ namespace ILRuntime.Runtime.Intepreter
                                                     {
                                                         if (tclr != typeof(float))
                                                         {
-                                                            objRef->ObjectType = ObjectTypes.Null;
-                                                            objRef->Value = -1;
-                                                            objRef->ValueLow = 0;
+                                                            oriRef->ObjectType = ObjectTypes.Null;
+                                                            oriRef->Value = -1;
+                                                            oriRef->ValueLow = 0;
                                                         }
                                                     }
                                                     break;
@@ -2941,23 +3030,23 @@ namespace ILRuntime.Runtime.Intepreter
                                                     {
                                                         if (tclr != typeof(double))
                                                         {
-                                                            objRef->ObjectType = ObjectTypes.Null;
-                                                            objRef->Value = -1;
-                                                            objRef->ValueLow = 0;
+                                                            oriRef->ObjectType = ObjectTypes.Null;
+                                                            oriRef->Value = -1;
+                                                            oriRef->ValueLow = 0;
                                                         }
                                                     }
                                                     break;
                                                 case ObjectTypes.Null:
-                                                    objRef->ObjectType = ObjectTypes.Null;
-                                                    objRef->Value = -1;
-                                                    objRef->ValueLow = 0;
+                                                    oriRef->ObjectType = ObjectTypes.Null;
+                                                    oriRef->Value = -1;
+                                                    oriRef->ValueLow = 0;
                                                     break;
                                             }
                                         }
                                         else
                                         {
                                             var obj = RetriveObject(objRef, mStack);
-                                            Free(objRef);
+                                            Free(oriRef);
 
                                             if (obj != null)
                                             {
@@ -2965,14 +3054,14 @@ namespace ILRuntime.Runtime.Intepreter
                                                 {
                                                     if (((ILTypeInstance)obj).CanAssignTo(type))
                                                     {
-                                                        esp = PushObject(objRef, mStack, obj);
+                                                        esp = PushObject(oriRef, mStack, obj);
                                                     }
                                                     else
                                                     {
-#if !DEBUG
-                                                        objRef->ObjectType = ObjectTypes.Null;
-                                                        objRef->Value = -1;
-                                                        objRef->ValueLow = 0;
+#if !DEBUG || DISABLE_ILRUNTIME_DEBUG
+                                                        oriRef->ObjectType = ObjectTypes.Null;
+                                                        oriRef->Value = -1;
+                                                        oriRef->ValueLow = 0;
 #endif
                                                     }
                                                 }
@@ -2980,24 +3069,24 @@ namespace ILRuntime.Runtime.Intepreter
                                                 {
                                                     if (type.TypeForCLR.IsAssignableFrom(obj.GetType()))
                                                     {
-                                                        esp = PushObject(objRef, mStack, obj, true);
+                                                        esp = PushObject(oriRef, mStack, obj, true);
                                                     }
                                                     else
                                                     {
-#if !DEBUG
-                                                        objRef->ObjectType = ObjectTypes.Null;
-                                                        objRef->Value = -1;
-                                                        objRef->ValueLow = 0;
+#if !DEBUG || DISABLE_ILRUNTIME_DEBUG
+                                                        oriRef->ObjectType = ObjectTypes.Null;
+                                                        oriRef->Value = -1;
+                                                        oriRef->ValueLow = 0;
 #endif
                                                     }
                                                 }
                                             }
                                             else
                                             {
-#if !DEBUG
-                                                    objRef->ObjectType = ObjectTypes.Null;
-                                                    objRef->Value = -1;
-                                                    objRef->ValueLow = 0;
+#if !DEBUG || DISABLE_ILRUNTIME_DEBUG
+                                                    oriRef->ObjectType = ObjectTypes.Null;
+                                                    oriRef->Value = -1;
+                                                    oriRef->ValueLow = 0;
 #endif
                                             }
                                         }
@@ -3069,6 +3158,10 @@ namespace ILRuntime.Runtime.Intepreter
                                             case ObjectTypes.Double:
                                                 arr.SetValue(*(double*)&val->Value, idx->Value);
                                                 break;
+                                            case ObjectTypes.ValueTypeObjectReference:
+                                                ArraySetValue(arr, StackObject.ToObject(val, domain, mStack), idx->Value);
+                                                FreeStackValueType(esp - 1);
+                                                break;
                                             default:
                                                 throw new NotImplementedException();
                                         }
@@ -3107,6 +3200,10 @@ namespace ILRuntime.Runtime.Intepreter
                                                     ((double[])arr)[idx->Value] = *(double*)&val->Value;
                                                 }
                                                 break;
+                                            case ObjectTypes.ValueTypeObjectReference:
+                                                ArraySetValue(arr, StackObject.ToObject(val, domain, mStack), idx->Value);
+                                                FreeStackValueType(esp - 1);
+                                                break;
                                             default:
                                                 throw new NotImplementedException();
                                         }
@@ -3559,6 +3656,7 @@ namespace ILRuntime.Runtime.Intepreter
                                 }
                                 break;
                             case OpCodeEnum.Conv_U4:
+                            case OpCodeEnum.Conv_U:
                             case OpCodeEnum.Conv_Ovf_U4:
                             case OpCodeEnum.Conv_Ovf_U4_Un:
                                 {
@@ -3587,6 +3685,7 @@ namespace ILRuntime.Runtime.Intepreter
                                 }
                                 break;
                             case OpCodeEnum.Conv_I4:
+                            case OpCodeEnum.Conv_I:
                             case OpCodeEnum.Conv_Ovf_I:
                             case OpCodeEnum.Conv_Ovf_I_Un:
                             case OpCodeEnum.Conv_Ovf_I4:
@@ -3765,6 +3864,7 @@ namespace ILRuntime.Runtime.Intepreter
                             case OpCodeEnum.Nop:
                             case OpCodeEnum.Volatile:
                             case OpCodeEnum.Castclass:
+                            case OpCodeEnum.Readonly:
                                 break;
                             default:
                                 throw new NotSupportedException("Not supported opcode " + code);
@@ -3827,7 +3927,7 @@ namespace ILRuntime.Runtime.Intepreter
 
                         unhandledException = true;
                         returned = true;
-#if DEBUG
+#if DEBUG && !DISABLE_ILRUNTIME_DEBUG
                         if (!AppDomain.DebugService.Break(this, ex))
 #endif
                         {
@@ -3922,8 +4022,15 @@ namespace ILRuntime.Runtime.Intepreter
                             }
                             else
                             {
-                                var vb = ((CLRType)domain.GetType(dst->Value)).ValueTypeBinder;
-                                vb.CopyValueTypeToStack(ins, dst, mStack);
+                                if (ins is CrossBindingAdaptorType)
+                                {
+                                    ((CrossBindingAdaptorType)ins).ILInstance.CopyValueTypeToStack(dst, mStack);
+                                }
+                                else
+                                {
+                                    var vb = ((CLRType)domain.GetType(dst->Value)).ValueTypeBinder;
+                                    vb.CopyValueTypeToStack(ins, dst, mStack);
+                                }
                             }
                         }
                         else
@@ -4048,6 +4155,9 @@ namespace ILRuntime.Runtime.Intepreter
                         }
                     }
                     break;
+                case ObjectTypes.ValueTypeObjectReference:
+                    obj = StackObject.ToObject(objRef, domain, mStack);
+                    break;
                 default:
                     throw new NotImplementedException();
             }
@@ -4213,7 +4323,6 @@ namespace ILRuntime.Runtime.Intepreter
                     long[] arr = obj as long[];
                     objRef->ObjectType = ObjectTypes.Long;
                     *(long*)&objRef->Value = arr[idx];
-                    objRef->ValueLow = 0;
                 }
                 else if (nT == typeof(float))
                 {
@@ -4227,7 +4336,6 @@ namespace ILRuntime.Runtime.Intepreter
                     double[] arr = obj as double[];
                     objRef->ObjectType = ObjectTypes.Double;
                     *(double*)&objRef->Value = arr[idx];
-                    objRef->ValueLow = 0;
                 }
                 else if (nT == typeof(byte))
                 {
@@ -4257,6 +4365,12 @@ namespace ILRuntime.Runtime.Intepreter
                     objRef->Value = arr[idx];
                     objRef->ValueLow = 0;
                 }
+                else if (nT == typeof(ulong))
+                {
+                    ulong[] arr = obj as ulong[];
+                    objRef->ObjectType = ObjectTypes.Long;
+                    *(ulong*)&objRef->Value = arr[idx];
+                }
                 else
                     throw new NotImplementedException();
             }
@@ -4444,9 +4558,29 @@ namespace ILRuntime.Runtime.Intepreter
             return esp + 1;
         }
 
-        public static void UnboxObject(StackObject* esp, object obj)
+        public static void UnboxObject(StackObject* esp, object obj, IList<object> mStack = null, Enviorment.AppDomain domain = null)
         {
-            if (obj is int)
+            if (esp->ObjectType == ObjectTypes.ValueTypeObjectReference && domain != null)
+            {
+                var dst = *(StackObject**)&esp->Value;
+                var vt = domain.GetType(dst->Value);
+
+                if (obj is ILTypeInstance)
+                {
+                    var ins = (ILTypeInstance)obj;
+                    ins.CopyValueTypeToStack(dst, mStack);
+                }
+                else if (obj is CrossBindingAdaptorType)
+                {
+                    var ins = ((CrossBindingAdaptorType)obj).ILInstance;
+                    ins.CopyValueTypeToStack(dst, mStack);
+                }
+                else
+                {
+                    ((CLRType)vt).ValueTypeBinder.CopyValueTypeToStack(obj, dst, mStack);
+                }
+            }
+            else if (obj is int)
             {
                 esp->ObjectType = ObjectTypes.Integer;
                 esp->Value = (int)obj;
@@ -4505,7 +4639,7 @@ namespace ILRuntime.Runtime.Intepreter
             {
                 esp->ObjectType = ObjectTypes.Integer;
                 esp->Value = (sbyte)obj;
-            }
+            }            
             else
                 throw new NotImplementedException();
         }
@@ -4520,7 +4654,7 @@ namespace ILRuntime.Runtime.Intepreter
 
                     if ((typeFlags & CLR.Utils.Extensions.TypeFlags.IsPrimitive) != 0)
                     {
-                        UnboxObject(esp, obj);
+                        UnboxObject(esp, obj, mStack);
                     }
                     else if ((typeFlags & CLR.Utils.Extensions.TypeFlags.IsEnum) != 0)
                     {
@@ -4566,7 +4700,7 @@ namespace ILRuntime.Runtime.Intepreter
                 if (esp->Value == stack.ManagedStack.Count - 1)
                     stack.ManagedStack.RemoveAt(esp->Value);
             }
-#if DEBUG
+#if DEBUG && !DISABLE_ILRUNTIME_DEBUG
             esp->ObjectType = ObjectTypes.Null;
             esp->Value = -1;
             esp->ValueLow = 0;

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Intepreter/ILIntepreter.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: a0bb99f039f2a6f418e5af5bef359bf5
-timeCreated: 1509525194
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ThirdParty/ILRuntime/ILRuntime/Runtime/Intepreter/ILRuntimeException.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: ebae8830490e95743a6bf3332b2ee263
-timeCreated: 1509525195
-licenseType: Free
+timeCreated: 1516154069
+licenseType: Pro
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

Некоторые файлы не были показаны из-за большого количества измененных файлов