Procházet zdrojové kódy

1.重构使用了新的disposer事件机制。
2.更新ilruntime修复了as操作的bug
3.增加Log.Debug重定向,能够显示正确的堆栈

tanghai před 8 roky
rodič
revize
3c8681954d
100 změnil soubory, kde provedl 2269 přidání a 696 odebrání
  1. 13 4
      Unity/Assets/ILRuntime/ILRuntime/CLR/Method/CLRMethod.cs
  2. 2 2
      Unity/Assets/ILRuntime/ILRuntime/CLR/Method/CLRMethod.cs.meta
  3. 2 2
      Unity/Assets/ILRuntime/ILRuntime/CLR/Method/ExceptionHandler.cs.meta
  4. 74 4
      Unity/Assets/ILRuntime/ILRuntime/CLR/Method/ILMethod.cs
  5. 2 2
      Unity/Assets/ILRuntime/ILRuntime/CLR/Method/ILMethod.cs.meta
  6. 2 2
      Unity/Assets/ILRuntime/ILRuntime/CLR/Method/IMethod.cs.meta
  7. 70 13
      Unity/Assets/ILRuntime/ILRuntime/CLR/TypeSystem/CLRType.cs
  8. 2 2
      Unity/Assets/ILRuntime/ILRuntime/CLR/TypeSystem/CLRType.cs.meta
  9. 13 0
      Unity/Assets/ILRuntime/ILRuntime/CLR/TypeSystem/ILGenericParameterType.cs
  10. 2 2
      Unity/Assets/ILRuntime/ILRuntime/CLR/TypeSystem/ILGenericParameterType.cs.meta
  11. 194 76
      Unity/Assets/ILRuntime/ILRuntime/CLR/TypeSystem/ILType.cs
  12. 2 2
      Unity/Assets/ILRuntime/ILRuntime/CLR/TypeSystem/ILType.cs.meta
  13. 4 0
      Unity/Assets/ILRuntime/ILRuntime/CLR/TypeSystem/IType.cs
  14. 2 2
      Unity/Assets/ILRuntime/ILRuntime/CLR/TypeSystem/IType.cs.meta
  15. 10 2
      Unity/Assets/ILRuntime/ILRuntime/CLR/Utils/Extensions.cs
  16. 2 2
      Unity/Assets/ILRuntime/ILRuntime/CLR/Utils/Extensions.cs.meta
  17. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Other/DelegateExportAttribute.cs.meta
  18. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Other/NeedAdaptorAttribute.cs.meta
  19. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Reflection/Extensions.cs.meta
  20. 107 0
      Unity/Assets/ILRuntime/ILRuntime/Reflection/ILRuntimeConstructorInfo.cs
  21. 12 0
      Unity/Assets/ILRuntime/ILRuntime/Reflection/ILRuntimeConstructorInfo.cs.meta
  22. 23 3
      Unity/Assets/ILRuntime/ILRuntime/Reflection/ILRuntimeFieldInfo.cs
  23. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Reflection/ILRuntimeFieldInfo.cs.meta
  24. 58 5
      Unity/Assets/ILRuntime/ILRuntime/Reflection/ILRuntimeMethodInfo.cs
  25. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Reflection/ILRuntimeMethodInfo.cs.meta
  26. 28 0
      Unity/Assets/ILRuntime/ILRuntime/Reflection/ILRuntimeParameterInfo.cs
  27. 12 0
      Unity/Assets/ILRuntime/ILRuntime/Reflection/ILRuntimeParameterInfo.cs.meta
  28. 221 0
      Unity/Assets/ILRuntime/ILRuntime/Reflection/ILRuntimePropertyInfo.cs
  29. 12 0
      Unity/Assets/ILRuntime/ILRuntime/Reflection/ILRuntimePropertyInfo.cs.meta
  30. 176 14
      Unity/Assets/ILRuntime/ILRuntime/Reflection/ILRuntimeType.cs
  31. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Reflection/ILRuntimeType.cs.meta
  32. 240 0
      Unity/Assets/ILRuntime/ILRuntime/Reflection/ILRuntimeWrapperType.cs
  33. 12 0
      Unity/Assets/ILRuntime/ILRuntime/Reflection/ILRuntimeWrapperType.cs.meta
  34. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Adaptors/CLRCrossBindingAdaptors.cs.meta
  35. 38 115
      Unity/Assets/ILRuntime/ILRuntime/Runtime/CLRBinding/BindingCodeGenerator.cs
  36. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/CLRBinding/BindingCodeGenerator.cs.meta
  37. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Debugger/BreakPointContext.cs.meta
  38. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Debugger/BreakpointInfo.cs.meta
  39. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Debugger/DebugMessageType.cs.meta
  40. 7 5
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Debugger/DebugService.cs
  41. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Debugger/DebugService.cs.meta
  42. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Debugger/DebugSocket.cs.meta
  43. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Debugger/DebuggerServer/DebuggerServer.cs.meta
  44. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/CSBindBreakpoint.cs.meta
  45. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/CSDeleteBreakpoint.cs.meta
  46. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/CSExecute.cs.meta
  47. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/CSResolveVariable.cs.meta
  48. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/CSStep.cs.meta
  49. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/SCAttachResult.cs.meta
  50. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/SCBindBreakpointResult.cs.meta
  51. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/SCBreakpointHit.cs.meta
  52. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/SCModuleLoaded.cs.meta
  53. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/SCResolveVariableResult.cs.meta
  54. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/SCStepComplete.cs.meta
  55. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Debugger/Protocol/SCThreadStarted.cs.meta
  56. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Debugger/StackFrameInfo.cs.meta
  57. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Debugger/StepTypes.cs.meta
  58. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Debugger/VariableInfo.cs.meta
  59. 107 28
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Enviorment/AppDomain.cs
  60. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Enviorment/AppDomain.cs.meta
  61. 43 3
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Enviorment/CLRRedirections.cs
  62. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Enviorment/CLRRedirections.cs.meta
  63. 38 1
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Enviorment/CrossBindingAdaptor.cs
  64. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Enviorment/CrossBindingAdaptor.cs.meta
  65. 93 10
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Enviorment/DelegateManager.cs
  66. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Enviorment/DelegateManager.cs.meta
  67. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Enviorment/ILContext.cs.meta
  68. 93 0
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Extensions.cs
  69. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Extensions.cs.meta
  70. 91 4
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Intepreter/DelegateAdapter.cs
  71. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Intepreter/DelegateAdapter.cs.meta
  72. 317 245
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Intepreter/ILIntepreter.cs
  73. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Intepreter/ILIntepreter.cs.meta
  74. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Intepreter/ILRuntimeException.cs.meta
  75. 20 21
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Intepreter/ILTypeInstance.cs
  76. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Intepreter/ILTypeInstance.cs.meta
  77. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Intepreter/OpCodes/OpCode.cs.meta
  78. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Intepreter/OpCodes/OpCodeEnum.cs.meta
  79. 1 1
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Stack/RuntimeStack.cs
  80. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Stack/RuntimeStack.cs.meta
  81. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Stack/StackFrame.cs.meta
  82. 2 2
      Unity/Assets/ILRuntime/ILRuntime/Runtime/Stack/StackObject.cs.meta
  83. 2 2
      Unity/Assets/ILRuntime/Mono.Cecil.20/MonoCecil/Mono.Cecil.Cil/Code.cs.meta
  84. 2 2
      Unity/Assets/ILRuntime/Mono.Cecil.20/MonoCecil/Mono.Cecil.Cil/CodeReader.cs.meta
  85. 2 2
      Unity/Assets/ILRuntime/Mono.Cecil.20/MonoCecil/Mono.Cecil.Cil/CodeWriter.cs.meta
  86. 2 2
      Unity/Assets/ILRuntime/Mono.Cecil.20/MonoCecil/Mono.Cecil.Cil/Document.cs.meta
  87. 2 2
      Unity/Assets/ILRuntime/Mono.Cecil.20/MonoCecil/Mono.Cecil.Cil/ExceptionHandler.cs.meta
  88. 2 2
      Unity/Assets/ILRuntime/Mono.Cecil.20/MonoCecil/Mono.Cecil.Cil/ILProcessor.cs.meta
  89. 2 2
      Unity/Assets/ILRuntime/Mono.Cecil.20/MonoCecil/Mono.Cecil.Cil/Instruction.cs.meta
  90. 2 2
      Unity/Assets/ILRuntime/Mono.Cecil.20/MonoCecil/Mono.Cecil.Cil/MethodBody.cs.meta
  91. 2 2
      Unity/Assets/ILRuntime/Mono.Cecil.20/MonoCecil/Mono.Cecil.Cil/OpCode.cs.meta
  92. 2 2
      Unity/Assets/ILRuntime/Mono.Cecil.20/MonoCecil/Mono.Cecil.Cil/OpCodes.cs.meta
  93. 2 2
      Unity/Assets/ILRuntime/Mono.Cecil.20/MonoCecil/Mono.Cecil.Cil/SequencePoint.cs.meta
  94. 2 2
      Unity/Assets/ILRuntime/Mono.Cecil.20/MonoCecil/Mono.Cecil.Cil/Symbols.cs.meta
  95. 2 2
      Unity/Assets/ILRuntime/Mono.Cecil.20/MonoCecil/Mono.Cecil.Cil/VariableDefinition.cs.meta
  96. 2 2
      Unity/Assets/ILRuntime/Mono.Cecil.20/MonoCecil/Mono.Cecil.Cil/VariableReference.cs.meta
  97. 2 2
      Unity/Assets/ILRuntime/Mono.Cecil.20/MonoCecil/Mono.Cecil.Metadata/BlobHeap.cs.meta
  98. 2 2
      Unity/Assets/ILRuntime/Mono.Cecil.20/MonoCecil/Mono.Cecil.Metadata/Buffers.cs.meta
  99. 2 2
      Unity/Assets/ILRuntime/Mono.Cecil.20/MonoCecil/Mono.Cecil.Metadata/CodedIndex.cs.meta
  100. 2 2
      Unity/Assets/ILRuntime/Mono.Cecil.20/MonoCecil/Mono.Cecil.Metadata/ElementType.cs.meta

+ 13 - 4
Unity/Assets/ILRuntime/ILRuntime/CLR/Method/CLRMethod.cs

@@ -25,6 +25,8 @@ namespace ILRuntime.CLR.Method
         IType[] genericArguments;
         object[] invocationParam;
         bool isDelegateInvoke;
+        int hashCode = -1;
+        static int instance_id = 0x20000000;
 
         public IType DeclearingType
         {
@@ -218,7 +220,7 @@ namespace ILRuntime.CLR.Method
             for (int i = paramCount; i >= 1; i--)
             {
                 var p = Minus(esp, i);
-                var obj = this.param[paramCount - i].ParameterType.CheckCLRTypes(appdomain, StackObject.ToObject(p, appdomain, mStack));
+                var obj = this.param[paramCount - i].ParameterType.CheckCLRTypes(StackObject.ToObject(p, appdomain, mStack));
                 obj = ILIntepreter.CheckAndCloneValueType(obj, appdomain);
                 param[paramCount - i] = obj;
             }
@@ -229,10 +231,10 @@ namespace ILRuntime.CLR.Method
                 {
                     if (!cDef.IsStatic)
                     {
-                        object instance = declaringType.TypeForCLR.CheckCLRTypes(appdomain, StackObject.ToObject((Minus(esp, paramCount + 1)), appdomain, mStack));
+                        object instance = declaringType.TypeForCLR.CheckCLRTypes(StackObject.ToObject((Minus(esp, paramCount + 1)), appdomain, mStack));
                         if (instance == null)
                             throw new NullReferenceException();
-                        if (instance is CrossBindingAdaptorType)//It makes no sense to call the Adaptor's constructor
+                        if (instance is CrossBindingAdaptorType && paramCount == 0)//It makes no sense to call the Adaptor's default constructor
                             return null;
                         cDef.Invoke(instance, param);
                         return null;
@@ -257,7 +259,7 @@ namespace ILRuntime.CLR.Method
 
                 if (!def.IsStatic)
                 {
-                    instance = declaringType.TypeForCLR.CheckCLRTypes(appdomain, StackObject.ToObject((Minus(esp, paramCount + 1)), appdomain, mStack));
+                    instance = declaringType.TypeForCLR.CheckCLRTypes(StackObject.ToObject((Minus(esp, paramCount + 1)), appdomain, mStack));
                     if (instance == null)
                         throw new NullReferenceException();
                 }
@@ -349,5 +351,12 @@ namespace ILRuntime.CLR.Method
             else
                 return cDef.ToString();
         }
+
+        public override int GetHashCode()
+        {
+            if (hashCode == -1)
+                hashCode = System.Threading.Interlocked.Add(ref instance_id, 1);
+            return hashCode;
+        }
     }
 }

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

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

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

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

+ 74 - 4
Unity/Assets/ILRuntime/ILRuntime/CLR/Method/ILMethod.cs

@@ -21,10 +21,15 @@ namespace ILRuntime.CLR.Method
         ILType declaringType;
         ExceptionHandler[] exceptionHandler;
         KeyValuePair<string, IType>[] genericParameters;
+        IType[] genericArguments;
         Dictionary<int, int[]> jumptables;
         bool isDelegateInvoke;
         ILRuntimeMethodInfo refletionMethodInfo;
+        ILRuntimeConstructorInfo reflectionCtorInfo;
         int paramCnt, localVarCnt;
+        Mono.Collections.Generic.Collection<Mono.Cecil.Cil.VariableDefinition> variables;
+        int hashCode = -1;
+        static int instance_id = 0x10000000;
 
         public MethodDefinition Definition { get { return def; } }
 
@@ -40,12 +45,26 @@ namespace ILRuntime.CLR.Method
         {
             get
             {
+                if (IsConstructor)
+                    throw new NotSupportedException();
                 if (refletionMethodInfo == null)
                     refletionMethodInfo = new ILRuntimeMethodInfo(this);
                 return refletionMethodInfo;
             }
         }
 
+        public ConstructorInfo ReflectionConstructorInfo
+        {
+            get
+            {
+                if (!IsConstructor)
+                    throw new NotSupportedException();
+                if (reflectionCtorInfo == null)
+                    reflectionCtorInfo = new ILRuntimeConstructorInfo(this);
+                return reflectionCtorInfo;
+            }
+        }
+
         internal ExceptionHandler[] ExceptionHandler
         {
             get
@@ -83,6 +102,8 @@ namespace ILRuntime.CLR.Method
         {
             get
             {
+                if (IsGenericInstance)
+                    return 0;
                 return def.GenericParameters.Count;
             }
         }
@@ -93,6 +114,17 @@ namespace ILRuntime.CLR.Method
                 return genericParameters != null;
             }
         }
+        public Mono.Collections.Generic.Collection<Mono.Cecil.Cil.VariableDefinition> Variables
+        {
+            get
+            {
+                return variables;
+            }
+        }
+
+        public KeyValuePair<string, IType>[] GenericArguments { get { return genericParameters; } }
+
+        public IType[] GenericArugmentsArray { get { return genericArguments; } }
         public ILMethod(MethodDefinition def, ILType type, ILRuntime.Runtime.Enviorment.AppDomain domain)
         {
             this.def = def;
@@ -107,7 +139,6 @@ namespace ILRuntime.CLR.Method
                 isDelegateInvoke = true;
             this.appdomain = domain;
             paramCnt = def.HasParameters ? def.Parameters.Count : 0;
-            localVarCnt = def.HasBody ? def.Body.Variables.Count : 0;
 #if DEBUG
             if (def.HasBody)
             {
@@ -210,6 +241,7 @@ namespace ILRuntime.CLR.Method
         {
             if (def.HasBody)
             {
+                localVarCnt = def.Body.Variables.Count;
                 body = new OpCode[def.Body.Instructions.Count];
                 Dictionary<Mono.Cecil.Cil.Instruction, int> addr = new Dictionary<Mono.Cecil.Cil.Instruction, int>();
                 for (int i = 0; i < body.Length; i++)
@@ -254,6 +286,9 @@ namespace ILRuntime.CLR.Method
                     exceptionHandler[i] = e;
                     //Mono.Cecil.Cil.ExceptionHandlerType.
                 }
+                //Release Method body to save memory
+                variables = def.Body.Variables;
+                def.Body = null;
             }
             else
                 body = new OpCode[0];
@@ -418,7 +453,7 @@ namespace ILRuntime.CLR.Method
         int GetTypeTokenHashCode(object token)
         {
             var t = appdomain.GetType(token, declaringType, this);
-            bool isGenericParameter = token is TypeReference && ((TypeReference)token).IsGenericParameter;
+            bool isGenericParameter = CheckHasGenericParamter(token);
             if (t == null && isGenericParameter)
             {
                 t = FindGenericArgument(((TypeReference)token).Name);
@@ -427,11 +462,14 @@ namespace ILRuntime.CLR.Method
             {
                 if (t is ILType)
                 {
-                    return ((ILType)t).TypeReference.GetHashCode();
+                    if (((ILType)t).TypeReference.HasGenericParameters)
+                        return t.GetHashCode();
+                    else
+                        return ((ILType)t).TypeReference.GetHashCode();
                 }
                 else if (isGenericParameter)
                 {
-                    return t.TypeForCLR.GetHashCode();
+                    return t.GetHashCode();
                 }
                 else
                     return token.GetHashCode();
@@ -439,6 +477,30 @@ namespace ILRuntime.CLR.Method
             return 0;
         }
 
+        bool CheckHasGenericParamter(object token)
+        {
+            if (token is TypeReference)
+            {
+                TypeReference _ref = ((TypeReference)token);
+                if (_ref.IsGenericParameter)
+                    return true;
+                if (_ref.IsGenericInstance)
+                {
+                    GenericInstanceType gi = (GenericInstanceType)_ref;
+                    foreach(var i in gi.GenericArguments)
+                    {
+                        if (CheckHasGenericParamter(i))
+                            return true;
+                    }
+                    return false;
+                }
+                else
+                    return false;
+            }
+            else
+                return false;
+        }
+
         void PrepareJumpTable(object token, Dictionary<Mono.Cecil.Cil.Instruction, int> addr)
         {
             int hashCode = token.GetHashCode();
@@ -521,6 +583,7 @@ namespace ILRuntime.CLR.Method
 
             ILMethod m = new ILMethod(def, declaringType, appdomain);
             m.genericParameters = genericParameters;
+            m.genericArguments = genericArguments;
             if (m.def.ReturnType.IsGenericParameter)
             {
                 m.ReturnType = m.FindGenericArgument(m.def.ReturnType.Name);
@@ -551,5 +614,12 @@ namespace ILRuntime.CLR.Method
             sb.Append(')');
             return sb.ToString();
         }
+
+        public override int GetHashCode()
+        {
+            if (hashCode == -1)
+                hashCode = System.Threading.Interlocked.Add(ref instance_id, 1);
+            return hashCode;
+        }
     }
 }

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

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

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

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

+ 70 - 13
Unity/Assets/ILRuntime/ILRuntime/CLR/TypeSystem/CLRType.cs

@@ -6,6 +6,7 @@ using System.Reflection;
 
 using Mono.Cecil;
 using ILRuntime.CLR.Method;
+using ILRuntime.Reflection;
 namespace ILRuntime.CLR.TypeSystem
 {
     public class CLRType : IType
@@ -14,16 +15,21 @@ namespace ILRuntime.CLR.TypeSystem
         Dictionary<string, List<CLRMethod>> methods;
         ILRuntime.Runtime.Enviorment.AppDomain appdomain;
         List<CLRMethod> constructors;
-        KeyValuePair<string,IType>[] genericArguments;
+        KeyValuePair<string, IType>[] genericArguments;
         List<CLRType> genericInstances;
         Dictionary<string, int> fieldMapping;
         Dictionary<int, FieldInfo> fieldInfoCache;
         Dictionary<int, int> fieldTokenMapping;
-        IType byRefType, arrayType;
+        IType byRefType, arrayType, elementType;
+        IType[] interfaces;
         bool isDelegate;
         IType baseType;
-        bool isBaseTypeInitialized = false;
+        bool isBaseTypeInitialized = false, interfaceInitialized = false;
         MethodInfo memberwiseClone;
+        ILRuntimeWrapperType wraperType;
+
+        int hashCode = -1;
+        static int instance_id = 0x20000000;
 
         public Dictionary<int, FieldInfo> Fields
         {
@@ -48,7 +54,7 @@ namespace ILRuntime.CLR.TypeSystem
             this.appdomain = appdomain;
             isDelegate = clrType.BaseType == typeof(MulticastDelegate);
         }
-        
+
         public bool IsGenericInstance
         {
             get
@@ -64,6 +70,9 @@ namespace ILRuntime.CLR.TypeSystem
                 return genericArguments;
             }
         }
+
+        public IType ElementType { get { return elementType; } }
+
         public bool HasGenericParameter
         {
             get
@@ -84,7 +93,9 @@ namespace ILRuntime.CLR.TypeSystem
         {
             get
             {
-                return clrType;
+                if (wraperType == null)
+                    wraperType = new ILRuntimeWrapperType(this);
+                return wraperType;
             }
         }
         public IType ByRefType
@@ -101,6 +112,12 @@ namespace ILRuntime.CLR.TypeSystem
                 return arrayType;
             }
         }
+
+        public bool IsArray
+        {
+            get;private set;
+        }
+
         public bool IsValueType
         {
             get
@@ -140,11 +157,21 @@ namespace ILRuntime.CLR.TypeSystem
             }
         }
 
+        public IType[] Implements
+        {
+            get
+            {
+                if (!interfaceInitialized)
+                    InitializeInterfaces();
+                return interfaces;
+            }
+        }
+
         public new MethodInfo MemberwiseClone
         {
             get
             {
-                if(clrType.IsValueType && memberwiseClone == null)
+                if (clrType.IsValueType && memberwiseClone == null)
                 {
                     memberwiseClone = clrType.GetMethod("MemberwiseClone", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
                 }
@@ -162,6 +189,20 @@ namespace ILRuntime.CLR.TypeSystem
             isBaseTypeInitialized = true;
         }
 
+        void InitializeInterfaces()
+        {
+            interfaceInitialized = true;
+            var arr = clrType.GetInterfaces();
+            if (arr.Length >0)
+            {
+                interfaces = new IType[arr.Length];
+                for (int i = 0; i < interfaces.Length; i++)
+                {
+                    interfaces[i] = appdomain.GetType(arr[i]);
+                }
+            }
+        }
+
         public FieldInfo GetField(int hash)
         {
             var dic = Fields;
@@ -314,15 +355,22 @@ namespace ILRuntime.CLR.TypeSystem
                                     break;
                                 }
                             }
-                            if (match)
+                            if (match && genericMethod == null)
                             {
                                 genericMethod = i;
-                                break;
-                            }                            
+                            }
                         }
                         else
                         {
-                            match = genericArguments == null;
+                            if (genericArguments == null)
+                                match = i.GenericArguments == null;
+                            else
+                            {
+                                if (i.GenericArguments == null)
+                                    match = false;
+                                else
+                                    match = i.GenericArguments.Length == genericArguments.Length;
+                            }
                             for (int j = 0; j < param.Count; j++)
                             {
                                 var typeA = param[j].TypeForCLR.IsByRef ? param[j].TypeForCLR.GetElementType() : param[j].TypeForCLR;
@@ -340,14 +388,14 @@ namespace ILRuntime.CLR.TypeSystem
                             }
                             if (match)
                             {
-                                
+
                                 if (i.IsGenericInstance)
                                 {
                                     if (i.GenericArguments.Length == genericArguments.Length)
                                     {
                                         for (int j = 0; j < genericArguments.Length; j++)
                                         {
-                                            if(i.GenericArguments[j] != genericArguments[j])
+                                            if (i.GenericArguments[j] != genericArguments[j])
                                             {
                                                 match = false;
                                                 break;
@@ -406,7 +454,7 @@ namespace ILRuntime.CLR.TypeSystem
                     }
                 }
             }
-            
+
             return null;
         }
 
@@ -456,6 +504,8 @@ namespace ILRuntime.CLR.TypeSystem
             {
                 Type t = clrType.MakeArrayType();
                 arrayType = new CLRType(t, appdomain);
+                ((CLRType)arrayType).elementType = this;
+                ((CLRType)arrayType).IsArray = true;
             }
             return arrayType;
         }
@@ -464,5 +514,12 @@ namespace ILRuntime.CLR.TypeSystem
         {
             throw new NotImplementedException();
         }
+
+        public override int GetHashCode()
+        {
+            if (hashCode == -1)
+                hashCode = System.Threading.Interlocked.Add(ref instance_id, 1);
+            return hashCode;
+        }
     }
 }

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

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

+ 13 - 0
Unity/Assets/ILRuntime/ILRuntime/CLR/TypeSystem/ILGenericParameterType.cs

@@ -158,5 +158,18 @@ namespace ILRuntime.CLR.TypeSystem
         {
             return method;
         }
+
+        public bool IsArray
+        {
+            get { return false; }
+        }
+
+        public IType[] Implements
+        {
+            get
+            {
+                return null;
+            }
+        }
     }
 }

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

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

+ 194 - 76
Unity/Assets/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;
+        IType baseType, byRefType, arrayType, enumType, elementType;
+        Type arrayCLRType, byRefCLRType;
         IType[] interfaces;
         bool baseTypeInitialized = false;
         bool interfaceInitialized = false;
@@ -38,6 +39,8 @@ namespace ILRuntime.CLR.TypeSystem
         bool isDelegate;
         ILRuntimeType reflectionType;
         IType firstCLRBaseType, firstCLRInterface;
+        int hashCode = -1;
+        static int instance_id = 0x10000000;
         public TypeDefinition TypeDefinition { get { return definition; } }
 
         public TypeReference TypeReference
@@ -131,7 +134,7 @@ namespace ILRuntime.CLR.TypeSystem
             }
         }
 
-        IType FirstCLRInterface
+        public IType FirstCLRInterface
         {
             get
             {
@@ -221,28 +224,13 @@ namespace ILRuntime.CLR.TypeSystem
         /// <param name="def"></param>
         void RetriveDefinitino(TypeReference def)
         {
-            TypeReference res;
-            if (def is GenericInstanceType)
+            if (!def.IsGenericParameter)
             {
-                res = ((GenericInstanceType)def).ElementType;
-            }
-            else if (def is ByReferenceType)
-            {
-                res = ((ByReferenceType)def).ElementType;
-            }
-            else if (def.IsArray)
-            {
-                res = (TypeDefinition)def.GetElementType();
-            }
-            else
-                res = (TypeDefinition)def;
-
-
-            if (!res.IsGenericParameter)
-            {
-                definition = res as TypeDefinition;
+                if (def is TypeSpecification)
+                    RetriveDefinitino(def.GetElementType());
+                else
+                    definition = def as TypeDefinition;
             }
-
         }
 
         public bool IsGenericInstance
@@ -260,6 +248,13 @@ namespace ILRuntime.CLR.TypeSystem
             }
         }
 
+        public IType ElementType { get { return elementType; } }
+
+        public bool IsArray
+        {
+            get; private set;
+        }
+
         public bool IsValueType
         {
             get
@@ -288,12 +283,16 @@ namespace ILRuntime.CLR.TypeSystem
                 {
                     if (enumType == null)
                         InitializeFields();
-                    if (enumType == null)
-                    {
-
-                    }
                     return enumType.TypeForCLR;
                 }
+                else if (typeRef is ArrayType)
+                {
+                    return arrayCLRType;
+                }
+                else if (typeRef is ByReferenceType)
+                {
+                    return byRefCLRType;
+                }
                 else if (FirstCLRBaseType != null && FirstCLRBaseType is CrossBindingAdaptor)
                 {
                     return ((CrossBindingAdaptor)FirstCLRBaseType).RuntimeType.TypeForCLR;
@@ -375,7 +374,8 @@ namespace ILRuntime.CLR.TypeSystem
                 for (int i = 0; i < interfaces.Length; i++)
                 {
                     interfaces[i] = appdomain.GetType(definition.Interfaces[i], this, null);
-                    if (interfaces[i] is CLRType)
+                    //only one clrInterface is valid
+                    if (interfaces[i] is CLRType && firstCLRInterface == null)
                     {
                         CrossBindingAdaptor adaptor;
                         if (appdomain.CrossBindingAdaptors.TryGetValue(interfaces[i].TypeForCLR, out adaptor))
@@ -391,34 +391,89 @@ namespace ILRuntime.CLR.TypeSystem
         }
         void InitializeBaseType()
         {
-            baseTypeInitialized = true;
             if (definition.BaseType != null)
             {
-                baseType = appdomain.GetType(definition.BaseType, this, null);
-                if (baseType is CLRType)
+                bool specialProcess = false;
+                List<int> spIdx = null;
+                if (definition.BaseType.IsGenericInstance)
                 {
-                    if (baseType.TypeForCLR == typeof(Enum) || baseType.TypeForCLR == typeof(object) || baseType.TypeForCLR == typeof(ValueType) || baseType.TypeForCLR == typeof(System.Enum))
-                    {//都是这样,无所谓
-                        baseType = null;
+                    GenericInstanceType git = definition.BaseType as GenericInstanceType;
+                    var elementType = appdomain.GetType(definition.BaseType.GetElementType(), this, null);
+                    if (elementType is CLRType)
+                    {
+                        for (int i = 0; i < git.GenericArguments.Count; i++)
+                        {
+                            var ga = git.GenericArguments[i];
+                            if (ga == typeRef)
+                            {
+                                specialProcess = true;
+                                if (spIdx == null)
+                                    spIdx = new List<int>();
+                                spIdx.Add(i);
+                            }
+                        }
                     }
-                    else if (baseType.TypeForCLR == typeof(MulticastDelegate))
+                }
+                if (specialProcess)
+                {
+                    //如果泛型参数是自身,则必须要特殊处理,否则会StackOverflow
+                    var elementType = appdomain.GetType(definition.BaseType.GetElementType(), this, null);
+                    foreach (var i in appdomain.CrossBindingAdaptors)
                     {
-                        baseType = null;
-                        isDelegate = true;
+                        if (i.Key.IsGenericType && !i.Key.IsGenericTypeDefinition)
+                        {
+                            var gd = i.Key.GetGenericTypeDefinition();
+                            if (gd == elementType.TypeForCLR)
+                            {
+                                var ga = i.Key.GetGenericArguments();
+                                bool match = true;
+                                foreach (var j in spIdx)
+                                {
+                                    if (ga[j] != i.Value.AdaptorType)
+                                    {
+                                        match = false;
+                                        break;
+                                    }
+                                }
+                                if (match)
+                                {
+                                    baseType = i.Value;
+                                    break;
+                                }
+                            }
+                        }
                     }
-                    else
+                    if (baseType == null)
+                        throw new TypeLoadException("Cannot find Adaptor for:" + definition.BaseType.FullName);
+                }
+                else
+                {
+                    baseType = appdomain.GetType(definition.BaseType, this, null);
+                    if (baseType is CLRType)
                     {
-                        CrossBindingAdaptor adaptor;
-                        if (appdomain.CrossBindingAdaptors.TryGetValue(baseType.TypeForCLR, out adaptor))
+                        if (baseType.TypeForCLR == typeof(Enum) || baseType.TypeForCLR == typeof(object) || baseType.TypeForCLR == typeof(ValueType) || baseType.TypeForCLR == typeof(System.Enum))
+                        {//都是这样,无所谓
+                            baseType = null;
+                        }
+                        else if (baseType.TypeForCLR == typeof(MulticastDelegate))
                         {
-                            baseType = adaptor;
+                            baseType = null;
+                            isDelegate = true;
                         }
                         else
-                            throw new TypeLoadException("Cannot find Adaptor for:" + baseType.TypeForCLR.ToString());
-                        //继承了其他系统类型
-                        //env.logger.Log_Error("ScriptType:" + Name + " Based On a SystemType:" + BaseType.Name);
-                        //HasSysBase = true;
-                        //throw new Exception("不得继承系统类型,脚本类型系统和脚本类型系统是隔离的");
+                        {
+                            CrossBindingAdaptor adaptor;
+                            if (appdomain.CrossBindingAdaptors.TryGetValue(baseType.TypeForCLR, out adaptor))
+                            {
+                                baseType = adaptor;
+                            }
+                            else
+                                throw new TypeLoadException("Cannot find Adaptor for:" + baseType.TypeForCLR.ToString());
+                            //继承了其他系统类型
+                            //env.logger.Log_Error("ScriptType:" + Name + " Based On a SystemType:" + BaseType.Name);
+                            //HasSysBase = true;
+                            //throw new Exception("不得继承系统类型,脚本类型系统和脚本类型系统是隔离的");
+                        }
                     }
                 }
             }
@@ -428,6 +483,7 @@ namespace ILRuntime.CLR.TypeSystem
                 curBase = curBase.BaseType;
             }
             firstCLRBaseType = curBase;
+            baseTypeInitialized = true;
         }
 
         public IMethod GetMethod(string name)
@@ -484,7 +540,7 @@ namespace ILRuntime.CLR.TypeSystem
                 }
             }
 
-            if (staticConstructor != null)
+            if (staticConstructor != null && (!TypeReference.HasGenericParameters || IsGenericInstance))
             {
                 appdomain.Invoke(staticConstructor, null, null);
             }
@@ -492,7 +548,16 @@ namespace ILRuntime.CLR.TypeSystem
 
         public IMethod GetVirtualMethod(IMethod method)
         {
-            var m = GetMethod(method.Name, method.Parameters, null, method.ReturnType);
+            IType[] genericArguments = null;
+            if (method is ILMethod)
+            {
+                genericArguments = ((ILMethod)method).GenericArugmentsArray;
+            }
+            else
+            {
+                genericArguments = ((CLRMethod)method).GenericArguments;
+            }
+            var m = GetMethod(method.Name, method.Parameters, genericArguments, method.ReturnType);
             if (m == null)
             {
                 if (BaseType != null)
@@ -525,12 +590,12 @@ namespace ILRuntime.CLR.TypeSystem
                         if (genericArguments != null && i.GenericParameterCount == genericArguments.Length)
                         {
                             genericMethod = CheckGenericParams(i, param, ref match);
-                            if (genericMethod != null)
-                                break;
                         }
                         else
                         {
-                            match = genericArguments == null;
+                            match = CheckGenericArguments(i, genericArguments);
+                            if (!match)
+                                continue;
                             for (int j = 0; j < pCnt; j++)
                             {
                                 if (param[j] != i.Parameters[j])
@@ -558,22 +623,51 @@ namespace ILRuntime.CLR.TypeSystem
             return null;
         }
 
-        ILMethod CheckGenericParams(ILMethod i, List<IType> param, ref bool match)
+        bool CheckGenericArguments(ILMethod i, IType[] genericArguments)
         {
-            ILMethod genericMethod = null;
-            for (int j = 0; j < param.Count; j++)
+            if (genericArguments == null)
+            {
+                return i.GenericArguments == null;
+            }
+            else
             {
-                var p = i.Parameters[j];
-                if (p.HasGenericParameter)
+                if (i.GenericArguments == null)
+                    return false;
+                else if (i.GenericArguments.Length != genericArguments.Length)
+                    return false;
+                if (i.GenericArguments.Length == genericArguments.Length)
                 {
-                    //TODO should match the generic parameters;
-                    continue;
+                    for (int j = 0; j < genericArguments.Length; j++)
+                    {
+                        if (i.GenericArguments[j].Value != genericArguments[j])
+                            return false;
+                    }
+                    return true;
                 }
+                else
+                    return false;
+            }
+        }
 
-                if (param[j] != p)
+        ILMethod CheckGenericParams(ILMethod i, List<IType> param, ref bool match)
+        {
+            ILMethod genericMethod = null;
+            if (param != null)
+            {
+                for (int j = 0; j < param.Count; j++)
                 {
-                    match = false;
-                    break;
+                    var p = i.Parameters[j];
+                    if (p.HasGenericParameter)
+                    {
+                        //TODO should match the generic parameters;
+                        continue;
+                    }
+
+                    if (param[j] != p)
+                    {
+                        match = false;
+                        break;
+                    }
                 }
             }
             if (match)
@@ -583,6 +677,13 @@ namespace ILRuntime.CLR.TypeSystem
             return genericMethod;
         }
 
+        public List<ILMethod> GetConstructors()
+        {
+            if (constructors == null)
+                InitializeMethods();
+            return constructors;
+        }
+
         public IMethod GetConstructor(int paramCnt)
         {
             if (constructors == null)
@@ -688,21 +789,25 @@ namespace ILRuntime.CLR.TypeSystem
                 var field = fields[i];
                 if (field.IsStatic)
                 {
-                    if (staticFieldTypes == null)
+                    //It makes no sence to initialize
+                    if (!TypeReference.HasGenericParameters || IsGenericInstance)
                     {
-                        staticFieldTypes = new IType[definition.Fields.Count];
-                        staticFieldDefinitions = new FieldDefinition[definition.Fields.Count];
-                        staticFieldMapping = new Dictionary<string, int>();
-                    }
-                    staticFieldMapping[field.Name] = idxStatic;
-                    staticFieldDefinitions[idxStatic] = field;
-                    if (field.FieldType.IsGenericParameter)
-                    {
-                        staticFieldTypes[idxStatic] = FindGenericArgument(field.FieldType.Name);
+                        if (staticFieldTypes == null)
+                        {
+                            staticFieldTypes = new IType[definition.Fields.Count];
+                            staticFieldDefinitions = new FieldDefinition[definition.Fields.Count];
+                            staticFieldMapping = new Dictionary<string, int>();
+                        }
+                        staticFieldMapping[field.Name] = idxStatic;
+                        staticFieldDefinitions[idxStatic] = field;
+                        if (field.FieldType.IsGenericParameter)
+                        {
+                            staticFieldTypes[idxStatic] = FindGenericArgument(field.FieldType.Name);
+                        }
+                        else
+                            staticFieldTypes[idxStatic] = appdomain.GetType(field.FieldType, this, null);
+                        idxStatic++;
                     }
-                    else
-                        staticFieldTypes[idxStatic] = appdomain.GetType(field.FieldType, this, null);
-                    idxStatic++;
                 }
                 else
                 {
@@ -747,18 +852,19 @@ namespace ILRuntime.CLR.TypeSystem
 
         public bool CanAssignTo(IType type)
         {
+            bool res = false;
             if (this == type)
             {
                 return true;
             }
             else if (BaseType != null)
-                return BaseType.CanAssignTo(type);
-            else if (Implements != null)
+                res = BaseType.CanAssignTo(type);
+            if (!res && Implements != null)
             {
                 for (int i = 0; i < interfaces.Length; i++)
                 {
                     var im = interfaces[i];
-                    bool res = im.CanAssignTo(type);
+                    res = im.CanAssignTo(type);
                     if (res)
                         return true;
                 }
@@ -810,6 +916,8 @@ namespace ILRuntime.CLR.TypeSystem
             {
                 var def = new ByReferenceType(typeRef);
                 byRefType = new ILType(def, appdomain);
+                ((ILType)byRefType).elementType = this;
+                ((ILType)byRefType).byRefCLRType = this.TypeForCLR.MakeByRefType();
             }
             return byRefType;
         }
@@ -820,6 +928,9 @@ namespace ILRuntime.CLR.TypeSystem
             {
                 var def = new ArrayType(typeRef);
                 arrayType = new ILType(def, appdomain);
+                ((ILType)arrayType).IsArray = true;
+                ((ILType)arrayType).elementType = this;
+                ((ILType)arrayType).arrayCLRType = this.TypeForCLR.MakeArrayType();
             }
             return arrayType;
         }
@@ -859,5 +970,12 @@ namespace ILRuntime.CLR.TypeSystem
 
             return null;
         }
+
+        public override int GetHashCode()
+        {
+            if (hashCode == -1)
+                hashCode = System.Threading.Interlocked.Add(ref instance_id, 1);
+            return hashCode;
+        }
     }
 }

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

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

+ 4 - 0
Unity/Assets/ILRuntime/ILRuntime/CLR/TypeSystem/IType.cs

@@ -16,6 +16,8 @@ namespace ILRuntime.CLR.TypeSystem
 
         IType BaseType { get; }
 
+        IType[] Implements { get; }
+
         IType ByRefType { get; }
 
         IType ArrayType { get; }
@@ -24,6 +26,8 @@ namespace ILRuntime.CLR.TypeSystem
 
         string Name { get; }
 
+        bool IsArray { get; }
+
         bool IsValueType { get; }
 
         bool IsDelegate { get; }

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

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

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

@@ -106,7 +106,7 @@ namespace ILRuntime.CLR.Utils
             return sb.ToString();
         }
 
-        public static object CheckCLRTypes(this Type pt, Runtime.Enviorment.AppDomain domain, object obj)
+        public static object CheckCLRTypes(this Type pt, object obj)
         {
             if (obj == null)
                 return null;
@@ -133,6 +133,10 @@ namespace ILRuntime.CLR.Utils
                     obj = (ulong)(long)obj;
                 }
             }
+            else if (obj is ILRuntime.Reflection.ILRuntimeWrapperType)
+            {
+                obj = ((ILRuntime.Reflection.ILRuntimeWrapperType)obj).RealType;
+            }
             else if (pt == typeof(Delegate) || pt.IsSubclassOf(typeof(Delegate)))
             {
                 if (obj is Delegate)
@@ -143,7 +147,7 @@ namespace ILRuntime.CLR.Utils
             }
             else if (pt.IsByRef)
             {
-                return CheckCLRTypes(pt.GetElementType(), domain, obj);
+                return CheckCLRTypes(pt.GetElementType(), obj);
             }
             else if (pt.IsEnum)
             {
@@ -151,6 +155,10 @@ namespace ILRuntime.CLR.Utils
             }
             else if (obj is ILTypeInstance)
             {
+                if (obj is IDelegateAdapter && pt != typeof(ILTypeInstance))
+                {
+                    return ((IDelegateAdapter)obj).Delegate;
+                }
                 if (!(obj is ILEnumTypeInstance))
                 {
                     var ins = (ILTypeInstance)obj;

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

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

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

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

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

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

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

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

+ 107 - 0
Unity/Assets/ILRuntime/ILRuntime/Reflection/ILRuntimeConstructorInfo.cs

@@ -0,0 +1,107 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+using System.Globalization;
+
+using ILRuntime.CLR.Method;
+using ILRuntime.CLR.TypeSystem;
+
+namespace ILRuntime.Reflection
+{
+    public class ILRuntimeConstructorInfo : ConstructorInfo
+    {
+        ILMethod method;
+        ILRuntimeParameterInfo[] parameters;
+        public ILRuntimeConstructorInfo(ILMethod m)
+        {
+            method = m;
+            parameters = new ILRuntimeParameterInfo[m.ParameterCount];
+            for(int i = 0; i < m.ParameterCount; i++)
+            {
+                parameters[i] = new ILRuntimeParameterInfo(m.Parameters[i]);
+            }
+        }
+
+        internal ILMethod ILMethod { get { return method; } }
+        public override MethodAttributes Attributes
+        {
+            get
+            {
+                return MethodAttributes.Public;
+            }
+        }
+
+        public override Type DeclaringType
+        {
+            get
+            {
+                return method.DeclearingType.ReflectionType;
+            }
+        }
+
+        public override RuntimeMethodHandle MethodHandle
+        {
+            get
+            {
+                throw new NotImplementedException();
+            }
+        }
+
+        public override string Name
+        {
+            get
+            {
+                return method.Name;
+            }
+        }
+
+        public override Type ReflectedType
+        {
+            get
+            {
+                return method.DeclearingType.ReflectionType;
+            }
+        }
+
+        public override object[] GetCustomAttributes(bool inherit)
+        {
+            throw new NotImplementedException();
+        }
+
+        public override object[] GetCustomAttributes(Type attributeType, bool inherit)
+        {
+            throw new NotImplementedException();
+        }
+
+        public override MethodImplAttributes GetMethodImplementationFlags()
+        {
+            throw new NotImplementedException();
+        }
+
+        public override ParameterInfo[] GetParameters()
+        {
+            return parameters;
+        }
+
+        public override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
+        {
+            var res = ((ILType)method.DeclearingType).Instantiate(false);
+            method.DeclearingType.AppDomain.Invoke(method, res, parameters);
+            return res;
+        }
+
+        public override bool IsDefined(Type attributeType, bool inherit)
+        {
+            throw new NotImplementedException();
+        }
+
+        public override object Invoke(BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
+        {
+            var res = ((ILType)method.DeclearingType).Instantiate(false);
+            method.DeclearingType.AppDomain.Invoke(method, res, parameters);
+            return res;
+        }
+    }
+}

+ 12 - 0
Unity/Assets/ILRuntime/ILRuntime/Reflection/ILRuntimeConstructorInfo.cs.meta

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

+ 23 - 3
Unity/Assets/ILRuntime/ILRuntime/Reflection/ILRuntimeFieldInfo.cs

@@ -17,7 +17,7 @@ namespace ILRuntime.Reflection
 {
     public class ILRuntimeFieldInfo : FieldInfo
     {
-        System.Reflection.FieldAttributes attr = System.Reflection.FieldAttributes.Public;
+        System.Reflection.FieldAttributes attr;
         ILRuntimeType dType;
         ILType ilType;
         IType fieldType;
@@ -42,6 +42,12 @@ namespace ILRuntime.Reflection
             this.fieldIdx = fieldIdx; 
             if (isStatic)
                 attr |= System.Reflection.FieldAttributes.Static;
+            if (def.IsPublic)
+            {
+                attr |= System.Reflection.FieldAttributes.Public;
+            }
+            else
+                attr |= System.Reflection.FieldAttributes.Private;
             fieldType = isStatic ? ilType.StaticFieldTypes[fieldIdx] : ilType.FieldTypes[fieldIdx];
         }
 
@@ -56,6 +62,12 @@ namespace ILRuntime.Reflection
             this.fieldIdx = fieldIdx;
             if (isStatic)
                 attr |= System.Reflection.FieldAttributes.Static;
+            if (def.IsPublic)
+            {
+                attr |= System.Reflection.FieldAttributes.Public;
+            }
+            else
+                attr |= System.Reflection.FieldAttributes.Private;
             this.fieldType = fieldType;
         }
 
@@ -80,6 +92,7 @@ namespace ILRuntime.Reflection
                 }
             }
         }
+
         public override System.Reflection.FieldAttributes Attributes
         {
             get
@@ -166,13 +179,20 @@ namespace ILRuntime.Reflection
                     else
                         ins = ((CrossBindingAdaptorType)obj).ILInstance;
                 }
-                return ins[fieldIdx];
+                return fieldType.TypeForCLR.CheckCLRTypes(ins[fieldIdx]);
             }
         }
 
         public override bool IsDefined(Type attributeType, bool inherit)
         {
-            throw new NotImplementedException();
+            if (customAttributes == null)
+                InitializeCustomAttribute();
+            for (int i = 0; i < customAttributes.Length; i++)
+            {
+                if (attributeTypes[i] == attributeType)
+                    return true;
+            }
+            return false;
         }
 
         public override void SetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture)

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

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

+ 58 - 5
Unity/Assets/ILRuntime/ILRuntime/Reflection/ILRuntimeMethodInfo.cs

@@ -12,9 +12,44 @@ namespace ILRuntime.Reflection
     public class ILRuntimeMethodInfo : MethodInfo
     {
         ILMethod method;
+        ILRuntimeParameterInfo[] parameters;
+        Mono.Cecil.MethodDefinition definition;
+        ILRuntime.Runtime.Enviorment.AppDomain appdomain;
+
+        object[] customAttributes;
+        Type[] attributeTypes;
         public ILRuntimeMethodInfo(ILMethod m)
         {
             method = m;
+            definition = m.Definition;
+            appdomain = m.DeclearingType.AppDomain;
+            parameters = new ILRuntimeParameterInfo[m.ParameterCount];
+            for (int i = 0; i < m.ParameterCount; i++)
+            {
+                parameters[i] = new ILRuntimeParameterInfo(m.Parameters[i]);
+            }
+        }
+
+        void InitializeCustomAttribute()
+        {
+            customAttributes = new object[definition.CustomAttributes.Count];
+            attributeTypes = new Type[customAttributes.Length];
+            for (int i = 0; i < definition.CustomAttributes.Count; i++)
+            {
+                var attribute = definition.CustomAttributes[i];
+                var at = appdomain.GetType(attribute.AttributeType, null, null);
+                try
+                {
+                    object ins = attribute.CreateInstance(at, appdomain);
+
+                    attributeTypes[i] = at.ReflectionType;
+                    customAttributes[i] = ins;
+                }
+                catch
+                {
+                    attributeTypes[i] = typeof(Attribute);
+                }
+            }
         }
 
         internal ILMethod ILMethod { get { return method; } }
@@ -73,12 +108,23 @@ namespace ILRuntime.Reflection
 
         public override object[] GetCustomAttributes(bool inherit)
         {
-            throw new NotImplementedException();
+            if (customAttributes == null)
+                InitializeCustomAttribute();
+
+            return customAttributes;
         }
 
         public override object[] GetCustomAttributes(Type attributeType, bool inherit)
         {
-            throw new NotImplementedException();
+            if (customAttributes == null)
+                InitializeCustomAttribute();
+            List<object> res = new List<object>();
+            for (int i = 0; i < customAttributes.Length; i++)
+            {
+                if (attributeTypes[i] == attributeType)
+                    res.Add(customAttributes[i]);
+            }
+            return res.ToArray();
         }
 
         public override MethodImplAttributes GetMethodImplementationFlags()
@@ -95,16 +141,23 @@ namespace ILRuntime.Reflection
         {
             if (method.HasThis)
             {
-                var res = method.DeclearingType.AppDomain.Invoke(method, obj, parameters);
+                var res = appdomain.Invoke(method, obj, parameters);
                 return res;
             }
             else
-                return method.DeclearingType.AppDomain.Invoke(method, null, parameters);
+                return appdomain.Invoke(method, null, parameters);
         }
 
         public override bool IsDefined(Type attributeType, bool inherit)
         {
-            throw new NotImplementedException();
+            if (customAttributes == null)
+                InitializeCustomAttribute();
+            for (int i = 0; i < customAttributes.Length; i++)
+            {
+                if (attributeTypes[i] == attributeType)
+                    return true;
+            }
+            return false;
         }
     }
 }

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

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

+ 28 - 0
Unity/Assets/ILRuntime/ILRuntime/Reflection/ILRuntimeParameterInfo.cs

@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+using System.Globalization;
+
+using ILRuntime.CLR.TypeSystem;
+
+namespace ILRuntime.Reflection
+{
+    public class ILRuntimeParameterInfo : ParameterInfo
+    {
+        IType type;
+
+        public ILRuntimeParameterInfo(IType type)
+        {
+            this.type = type;
+        }
+        public override Type ParameterType
+        {
+            get
+            {
+                return type.ReflectionType;
+            }
+        }
+    }
+}

+ 12 - 0
Unity/Assets/ILRuntime/ILRuntime/Reflection/ILRuntimeParameterInfo.cs.meta

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

+ 221 - 0
Unity/Assets/ILRuntime/ILRuntime/Reflection/ILRuntimePropertyInfo.cs

@@ -0,0 +1,221 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+using System.Globalization;
+
+using ILRuntime.CLR.Method;
+using ILRuntime.CLR.TypeSystem;
+
+namespace ILRuntime.Reflection
+{
+    public class ILRuntimePropertyInfo : PropertyInfo
+    {
+        ILMethod getter, setter;
+        ILType dType;
+        Mono.Cecil.PropertyDefinition definition;
+        ILRuntime.Runtime.Enviorment.AppDomain appdomain;
+
+        object[] customAttributes;
+        Type[] attributeTypes;
+        static object[] param = new object[1];
+
+        public ILMethod Getter
+        {
+            get { return getter; }
+            set
+            {
+                getter = value;
+            }
+        }
+
+        public ILMethod Setter
+        {
+            get { return setter; }
+            set
+            {
+                setter = value;
+            }
+        }
+
+        public bool IsPublic
+        {
+            get
+            {
+                if (getter != null)
+                    return getter.Definition.IsPublic;
+                else
+                    return setter.Definition.IsPublic;
+            }
+        }
+
+        public bool IsStatic
+        {
+            get
+            {
+                if (getter != null)
+                    return getter.IsStatic;
+                else
+                    return setter.IsStatic;
+            }
+        }
+        public ILRuntimePropertyInfo(Mono.Cecil.PropertyDefinition definition, ILType dType)
+        {
+            this.definition = definition;
+            this.dType = dType;
+            appdomain = dType.AppDomain;
+        }
+
+        void InitializeCustomAttribute()
+        {
+            customAttributes = new object[definition.CustomAttributes.Count];
+            attributeTypes = new Type[customAttributes.Length];
+            for (int i = 0; i < definition.CustomAttributes.Count; i++)
+            {
+                var attribute = definition.CustomAttributes[i];
+                var at = appdomain.GetType(attribute.AttributeType, null, null);
+                try
+                {
+                    object ins = attribute.CreateInstance(at, appdomain);
+
+                    attributeTypes[i] = at.ReflectionType;
+                    customAttributes[i] = ins;
+                }
+                catch
+                {
+                    attributeTypes[i] = typeof(Attribute);
+                }
+            }
+        }
+
+        public override string Name
+        {
+            get
+            {
+                return definition.Name;
+            }
+        }
+
+        public override Type ReflectedType
+        {
+            get
+            {
+                return dType.ReflectionType;
+            }
+        }
+
+        public override PropertyAttributes Attributes
+        {
+            get
+            {
+                return PropertyAttributes.None;
+            }
+        }
+
+        public override bool CanRead
+        {
+            get
+            {
+                return getter != null;
+            }
+        }
+
+        public override bool CanWrite
+        {
+            get
+            {
+                return setter != null;
+            }
+        }
+
+        public override Type PropertyType
+        {
+            get
+            {
+                if (getter != null)
+                    return getter.ReturnType.ReflectionType;
+                else
+                {
+                    return setter.Parameters[0].ReflectionType;
+                }
+            }
+        }
+
+        public override Type DeclaringType
+        {
+            get
+            {
+                return dType.ReflectionType;
+            }
+        }
+
+        public override object[] GetCustomAttributes(bool inherit)
+        {
+            if (customAttributes == null)
+                InitializeCustomAttribute();
+
+            return customAttributes;
+        }
+
+        public override object[] GetCustomAttributes(Type attributeType, bool inherit)
+        {
+            if (customAttributes == null)
+                InitializeCustomAttribute();
+            List<object> res = new List<object>();
+            for (int i = 0; i < customAttributes.Length; i++)
+            {
+                if (attributeTypes[i] == attributeType)
+                    res.Add(customAttributes[i]);
+            }
+            return res.ToArray();
+        }
+
+        public override bool IsDefined(Type attributeType, bool inherit)
+        {
+            if (customAttributes == null)
+                InitializeCustomAttribute();
+            for (int i = 0; i < customAttributes.Length; i++)
+            {
+                if (attributeTypes[i] == attributeType)
+                    return true;
+            }
+            return false;
+        }
+
+        public override MethodInfo[] GetAccessors(bool nonPublic)
+        {
+            throw new NotImplementedException();
+        }
+
+        public override MethodInfo GetGetMethod(bool nonPublic)
+        {
+            if (getter != null)
+                return getter.ReflectionMethodInfo;
+            return null;
+        }
+
+        public override ParameterInfo[] GetIndexParameters()
+        {
+            throw new NotImplementedException();
+        }
+
+        public override MethodInfo GetSetMethod(bool nonPublic)
+        {
+            if (setter != null)
+                return setter.ReflectionMethodInfo;
+            return null;
+        }
+
+        public override object GetValue(object obj, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture)
+        {
+            return appdomain.Invoke(getter, obj, null);
+        }
+
+        public override void SetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture)
+        {
+            param[0] = value;
+            appdomain.Invoke(setter, obj, param);
+        }
+    }
+}

+ 12 - 0
Unity/Assets/ILRuntime/ILRuntime/Reflection/ILRuntimePropertyInfo.cs.meta

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

+ 176 - 14
Unity/Assets/ILRuntime/ILRuntime/Reflection/ILRuntimeType.cs

@@ -17,6 +17,8 @@ namespace ILRuntime.Reflection
         object[] customAttributes;
         Type[] attributeTypes;
         ILRuntimeFieldInfo[] fields;
+        ILRuntimePropertyInfo[] properties;
+        ILRuntimeMethodInfo[] methods;
 
         public ILType ILType { get { return type; } }
         
@@ -38,7 +40,7 @@ namespace ILRuntime.Reflection
                 {
                     object ins = attribute.CreateInstance(at, appdomain);
 
-                    attributeTypes[i] = at.ReflectionType;
+                    attributeTypes[i] = at.ReflectionType is ILRuntimeWrapperType ? at.TypeForCLR : at.ReflectionType;
                     customAttributes[i] = ins;
                 }
                 catch
@@ -49,6 +51,32 @@ namespace ILRuntime.Reflection
 
         }
 
+        void InitializeProperties()
+        {
+            int cnt = type.TypeDefinition.HasProperties ? type.TypeDefinition.Properties.Count : 0;
+            properties = new ILRuntimePropertyInfo[cnt];
+            for (int i = 0; i < cnt; i++)
+            {
+                Mono.Cecil.PropertyDefinition pd = type.TypeDefinition.Properties[i];
+                ILRuntimePropertyInfo pi = new ILRuntimePropertyInfo(pd, type);
+                properties[i] = pi;
+                if (pd.GetMethod != null)
+                    pi.Getter = type.GetMethod(pd.GetMethod.Name, 0) as ILMethod;
+                if (pd.SetMethod != null)
+                    pi.Setter = type.GetMethod(pd.SetMethod.Name, 1) as ILMethod;
+            }
+        }
+
+        void InitializeMethods()
+        {
+            var methods = type.GetMethods();
+            this.methods = new ILRuntimeMethodInfo[methods.Count];
+            for(int i = 0; i < methods.Count; i++)
+            {
+                this.methods[i] = (ILRuntimeMethodInfo)((ILMethod)methods[i]).ReflectionMethodInfo;
+            }
+        }
+
         void InitializeFields()
         {
             int staticCnt = type.StaticFieldTypes != null ? type.StaticFieldTypes.Length : 0;
@@ -139,7 +167,13 @@ namespace ILRuntime.Reflection
 
         public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr)
         {
-            throw new NotImplementedException();
+            var ctors = type.GetConstructors();
+            ConstructorInfo[] res = new ConstructorInfo[ctors.Count];
+            for(int i = 0; i < res.Length; i++)
+            {
+                res[i] = ctors[i].ReflectionConstructorInfo;
+            }
+            return res;
         }
 
         public override object[] GetCustomAttributes(bool inherit)
@@ -165,7 +199,12 @@ namespace ILRuntime.Reflection
 
         public override Type GetElementType()
         {
-            throw new NotImplementedException();
+            if (type.IsArray)
+            {
+                return type.ElementType.ReflectionType;
+            }
+            else
+                throw new NotImplementedException();
         }
 
         public override EventInfo GetEvent(string name, BindingFlags bindingAttr)
@@ -194,27 +233,73 @@ namespace ILRuntime.Reflection
         {
             if (fields == null)
                 InitializeFields();
-            return fields;
+            bool isPublic = (bindingAttr & BindingFlags.Public) == BindingFlags.Public;
+            bool isPrivate = (bindingAttr & BindingFlags.NonPublic) == BindingFlags.NonPublic;
+            bool isStatic = (bindingAttr & BindingFlags.Static) == BindingFlags.Static;
+            bool isInstance = (bindingAttr & BindingFlags.Instance) == BindingFlags.Instance;
+            List<FieldInfo> res = new List<FieldInfo>();
+            foreach(var i in fields)
+            {
+                if (isPublic != i.IsPublic && isPrivate != !i.IsPublic)
+                    continue;
+                if ((isStatic != i.IsStatic) && (isInstance != !i.IsStatic))
+                    continue;
+                res.Add(i);
+            }
+            return res.ToArray();
         }
 
         public override Type GetInterface(string name, bool ignoreCase)
         {
-            throw new NotImplementedException();
+            if (type.FirstCLRInterface != null)
+            {
+                if (type.FirstCLRInterface.Name == name)
+                    return type.FirstCLRInterface.TypeForCLR;
+                else
+                    return null;
+            }
+            else
+                return null;
         }
 
         public override Type[] GetInterfaces()
         {
-            throw new NotImplementedException();
+            if (type.FirstCLRInterface != null)
+                return new Type[] { type.FirstCLRInterface.TypeForCLR };
+            else
+                return new Type[0];
         }
 
         public override MemberInfo[] GetMembers(BindingFlags bindingAttr)
         {
-            throw new NotImplementedException();
+            if (methods == null)
+                InitializeMethods();
+            if (fields == null)
+                InitializeFields();
+            if (properties == null)
+                InitializeProperties();
+            MemberInfo[] res = new MemberInfo[methods.Length + fields.Length + properties.Length];
+            for (int i = 0; i < methods.Length; i++)
+            {
+                res[i] = methods[i];
+            }
+            for (int i = methods.Length; i < methods.Length + fields.Length; i++)
+            {
+                res[i] = fields[i - methods.Length];
+            }
+            for (int i = methods.Length + fields.Length; i < res.Length; i++)
+            {
+                res[i] = properties[i- methods.Length - fields.Length];
+            }
+
+            return res;
         }
 
         public override MethodInfo[] GetMethods(BindingFlags bindingAttr)
         {
-            throw new NotImplementedException();
+            if (methods == null)
+                InitializeMethods();
+            return methods;
         }
 
         public override Type GetNestedType(string name, BindingFlags bindingAttr)
@@ -229,7 +314,22 @@ namespace ILRuntime.Reflection
 
         public override PropertyInfo[] GetProperties(BindingFlags bindingAttr)
         {
-            throw new NotImplementedException();
+            if (properties == null)
+                InitializeProperties();
+            bool isPublic = (bindingAttr & BindingFlags.Public) == BindingFlags.Public;
+            bool isPrivate = (bindingAttr & BindingFlags.NonPublic) == BindingFlags.NonPublic;
+            bool isStatic = (bindingAttr & BindingFlags.Static) == BindingFlags.Static;
+            bool isInstance = (bindingAttr & BindingFlags.Instance) == BindingFlags.Instance;
+            List<PropertyInfo> res = new List<PropertyInfo>();
+            foreach (var i in properties)
+            {
+                if (isPublic != i.IsPublic && isPrivate != !i.IsPublic)
+                    continue;
+                if ((isStatic != i.IsStatic) && (isInstance != !i.IsStatic))
+                    continue;
+                res.Add(i);
+            }
+            return res.ToArray();
         }
 
         public override object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target, object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters)
@@ -239,17 +339,52 @@ namespace ILRuntime.Reflection
 
         public override bool IsDefined(Type attributeType, bool inherit)
         {
-            throw new NotImplementedException();
+            if (customAttributes == null)
+                InitializeCustomAttribute();
+            for (int i = 0; i < customAttributes.Length; i++)
+            {
+                if (attributeTypes[i] == attributeType)
+                    return true;
+            }
+            return false;
         }
 
         protected override TypeAttributes GetAttributeFlagsImpl()
         {
-            throw new NotImplementedException();
+            TypeAttributes res = TypeAttributes.Public;
+            if (type.TypeDefinition.IsAbstract)
+                res |= TypeAttributes.Abstract;
+            if (!type.IsValueType)
+                res |= TypeAttributes.Class;
+            if (type.TypeDefinition.IsSealed)
+                res |= TypeAttributes.Sealed;
+            return res;
         }
 
         protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
         {
-            throw new NotImplementedException();
+            List<IType> param = new List<IType>();
+            for (int i = 0; i < types.Length; i++)
+            {
+                if (types[i] is ILRuntimeType)
+                    param.Add(((ILRuntimeType)types[i]).type);
+                else
+                {
+                    var t = appdomain.GetType(types[i]);
+                    if (t == null)
+                        t = appdomain.GetType(types[i].AssemblyQualifiedName);
+                    if (t == null)
+                        throw new TypeLoadException();
+                    param.Add(t);
+                }
+            }
+
+            var res = type.GetConstructor(param);
+
+            if (res != null)
+                return ((ILMethod)res).ReflectionConstructorInfo;
+            else
+                return null;
         }
 
         protected override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
@@ -285,7 +420,15 @@ namespace ILRuntime.Reflection
 
         protected override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers)
         {
-            throw new NotImplementedException();
+            if (properties == null)
+                InitializeProperties();
+
+            foreach(var i in properties)
+            {
+                if (i.Name == name)
+                    return i;
+            }
+            return null;
         }
 
         protected override bool HasElementTypeImpl()
@@ -295,7 +438,7 @@ namespace ILRuntime.Reflection
 
         protected override bool IsArrayImpl()
         {
-            return false;
+            return type.IsArray;
         }
 
         protected override bool IsByRefImpl()
@@ -321,5 +464,24 @@ namespace ILRuntime.Reflection
         {
             return type.GetHashCode();
         }
+        public override bool Equals(object o)
+        {
+            return o is ILRuntimeType ? ((ILRuntimeType)o).type == type : false;
+        }
+        public override bool IsGenericType
+        {
+            get
+            {
+                return type.HasGenericParameter;
+            }
+        }
+
+        public override bool IsGenericTypeDefinition
+        {
+            get
+            {
+                return type.HasGenericParameter;
+            }
+        }
     }
 }

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

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

+ 240 - 0
Unity/Assets/ILRuntime/ILRuntime/Reflection/ILRuntimeWrapperType.cs

@@ -0,0 +1,240 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using ILRuntime.CLR.TypeSystem;
+using ILRuntime.CLR.Method;
+using ILRuntime.Runtime.Intepreter;
+
+namespace ILRuntime.Reflection
+{
+    public class ILRuntimeWrapperType : Type
+    {
+        CLRType type;
+        Type et;
+
+        public CLRType CLRType { get { return type; } }
+
+        public Type RealType { get { return et; } }
+
+        public override Guid GUID
+        {
+            get
+            {
+                return et.GUID;
+            }
+        }
+
+        public override Module Module
+        {
+            get
+            {
+                return et.Module;
+            }
+        }
+
+        public override Assembly Assembly
+        {
+            get
+            {
+                return et.Assembly;
+            }
+        }
+
+        public override string FullName
+        {
+            get
+            {
+                return et.FullName;
+            }
+        }
+
+        public override string Namespace
+        {
+            get
+            {
+                return et.Namespace;
+            }
+        }
+
+        public override string AssemblyQualifiedName
+        {
+            get
+            {
+                return et.AssemblyQualifiedName;
+            }
+        }
+
+        public override Type BaseType
+        {
+            get
+            {
+                return et.BaseType;
+            }
+        }
+
+        public override Type UnderlyingSystemType
+        {
+            get
+            {
+                return et.UnderlyingSystemType;
+            }
+        }
+
+        public override string Name
+        {
+            get
+            {
+                return et.Name;
+            }
+        }
+
+        public ILRuntimeWrapperType(CLRType t)
+        {
+            type = t;
+            et = t.TypeForCLR;
+        }
+
+        public override object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target, object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters)
+        {
+            return et.InvokeMember(name, invokeAttr, binder, target, args, modifiers, culture, namedParameters);
+        }
+
+        protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
+        {
+            return et.GetConstructor(bindingAttr, binder, callConvention, types, modifiers);
+        }
+
+        public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr)
+        {
+            return et.GetConstructors(bindingAttr);
+        }
+
+        protected override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
+        {
+            return et.GetMethod(name, bindingAttr, binder, callConvention, types, modifiers);
+        }
+
+        public override MethodInfo[] GetMethods(BindingFlags bindingAttr)
+        {
+            return et.GetMethods(bindingAttr);
+        }
+
+        public override FieldInfo GetField(string name, BindingFlags bindingAttr)
+        {
+            return et.GetField(name, bindingAttr);
+        }
+
+        public override FieldInfo[] GetFields(BindingFlags bindingAttr)
+        {
+            return et.GetFields(bindingAttr);
+        }
+
+        public override Type GetInterface(string name, bool ignoreCase)
+        {
+            return et.GetInterface(name, ignoreCase);
+        }
+
+        public override Type[] GetInterfaces()
+        {
+            return et.GetInterfaces();
+        }
+
+        public override EventInfo GetEvent(string name, BindingFlags bindingAttr)
+        {
+            return et.GetEvent(name, bindingAttr);
+        }
+
+        public override EventInfo[] GetEvents(BindingFlags bindingAttr)
+        {
+            return et.GetEvents(bindingAttr);
+        }
+
+        protected override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers)
+        {
+            return et.GetProperty(name, bindingAttr, binder, returnType, types, modifiers);
+        }
+
+        public override PropertyInfo[] GetProperties(BindingFlags bindingAttr)
+        {
+            return et.GetProperties(bindingAttr);
+        }
+
+        public override Type[] GetNestedTypes(BindingFlags bindingAttr)
+        {
+            return et.GetNestedTypes(bindingAttr);
+        }
+
+        public override int GetHashCode()
+        {
+            return type.GetHashCode();
+        }
+
+        public override Type GetNestedType(string name, BindingFlags bindingAttr)
+        {
+            return et.GetNestedType(name, bindingAttr);
+        }
+
+        public override MemberInfo[] GetMembers(BindingFlags bindingAttr)
+        {
+            return et.GetMembers(bindingAttr);
+        }
+
+        protected override TypeAttributes GetAttributeFlagsImpl()
+        {
+            return et.Attributes;
+        }
+
+        protected override bool IsArrayImpl()
+        {
+            return et.IsArray;
+        }
+
+        protected override bool IsByRefImpl()
+        {
+            return et.IsByRef;
+        }
+
+        protected override bool IsPointerImpl()
+        {
+            return et.IsPointer;
+        }
+
+        protected override bool IsPrimitiveImpl()
+        {
+            return et.IsPrimitive;
+        }
+
+        protected override bool IsCOMObjectImpl()
+        {
+            return et.IsCOMObject;
+        }
+
+        public override Type GetElementType()
+        {
+            return et.GetElementType();
+        }
+
+        protected override bool HasElementTypeImpl()
+        {
+            return et.HasElementType;
+        }
+
+        public override object[] GetCustomAttributes(bool inherit)
+        {
+            return et.GetCustomAttributes(inherit);
+        }
+
+        public override object[] GetCustomAttributes(Type attributeType, bool inherit)
+        {
+            return et.GetCustomAttributes(attributeType, inherit);
+        }
+
+        public override bool IsDefined(Type attributeType, bool inherit)
+        {
+            return et.IsDefined(attributeType, inherit);
+        }
+    }
+}

+ 12 - 0
Unity/Assets/ILRuntime/ILRuntime/Reflection/ILRuntimeWrapperType.cs.meta

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

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

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

+ 38 - 115
Unity/Assets/ILRuntime/ILRuntime/Runtime/CLRBinding/BindingCodeGenerator.cs

@@ -3,7 +3,6 @@ using System.Collections.Generic;
 using System.Reflection;
 using System.Linq;
 using System.Text;
-using Model;
 using ILRuntime.Runtime.Enviorment;
 
 namespace ILRuntime.Runtime.CLRBinding
@@ -26,9 +25,8 @@ namespace ILRuntime.Runtime.CLRBinding
                 bool isByRef;
                 if (i.GetCustomAttributes(typeof(ObsoleteAttribute), true).Length > 0)
                     continue;
-                GetClassName(i, out clsName, out realClsName, out isByRef);
+                i.GetClassName(out clsName, out realClsName, out isByRef);
                 clsNames.Add(clsName);
-				Log.Debug("class " + clsName);
                 using (System.IO.StreamWriter sw = new System.IO.StreamWriter(outputPath + "/" + clsName + ".cs", false, Encoding.UTF8))
                 {
                     sw.Write(@"using System;
@@ -160,7 +158,7 @@ namespace ILRuntime.Runtime.Generated
                     sb2.Append("typeof(");
                     string tmp, clsName;
                     bool isByRef;
-                    GetClassName(j.ParameterType, out tmp, out clsName, out isByRef);
+                    j.ParameterType.GetClassName(out tmp, out clsName, out isByRef);
                     sb2.Append(clsName);
                     sb2.Append(")");
                     if (isByRef)
@@ -199,7 +197,7 @@ namespace ILRuntime.Runtime.Generated
                     sb2.Append("typeof(");
                     string tmp, clsName;
                     bool isByRef;
-                    GetClassName(j.ParameterType, out tmp, out clsName, out isByRef);
+                    j.ParameterType.GetClassName(out tmp, out clsName, out isByRef);
                     sb2.Append(clsName);
                     sb2.Append(")");
                     if (isByRef)
@@ -362,7 +360,7 @@ namespace ILRuntime.Runtime.Generated
                     sb.AppendLine(string.Format("            ptr_of_this_method = ILIntepreter.Minus(__esp, {0});", param.Length - j + 1));
                     string tmp, clsName;
                     bool isByRef;
-                    GetClassName(p.ParameterType, out tmp, out clsName, out isByRef);
+                    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, GetRetrieveValueCode(p.ParameterType, clsName)));
@@ -374,7 +372,7 @@ namespace ILRuntime.Runtime.Generated
                 {
                     string tmp, clsName;
                     bool isByRef;
-                    GetClassName(type, out tmp, out clsName, out isByRef);
+                    type.GetClassName(out tmp, out clsName, out isByRef);
                     sb.Append(string.Format("new {0}(", clsName));
                     AppendParameters(param, sb);
                     sb.AppendLine(");");
@@ -399,13 +397,13 @@ namespace ILRuntime.Runtime.Generated
                         continue;
                     string tmp, clsName;
                     bool isByRef;
-                    GetClassName(p.ParameterType.GetElementType(), out tmp, out clsName, out isByRef);
+                    p.ParameterType.GetElementType().GetClassName(out tmp, out clsName, out isByRef);
                     sb.AppendLine(string.Format("            ptr_of_this_method = ILIntepreter.Minus(__esp, {0});", param.Length - j + 1));
                     sb.AppendLine(@"            switch(ptr_of_this_method->ObjectType)
             {
                 case ObjectTypes.StackObjectReference:
                     {
-                        var dst = *(StackObject**)&ptr_of_this_method->Value;");
+                        var ___dst = *(StackObject**)&ptr_of_this_method->Value;");
                     GetRefWriteBackValueCode(p.ParameterType.GetElementType(), sb, p.Name);
                     sb.Append(@"                    }
                     break;
@@ -494,7 +492,7 @@ namespace ILRuntime.Runtime.Generated
                     sb.AppendLine(string.Format("            ptr_of_this_method = ILIntepreter.Minus(__esp, {0});", param.Length - j + 1));
                     string tmp, clsName;
                     bool isByRef;
-                    GetClassName(p.ParameterType, out tmp, out clsName, out isByRef);
+                    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, GetRetrieveValueCode(p.ParameterType, clsName)));
@@ -592,7 +590,7 @@ namespace ILRuntime.Runtime.Generated
                                     {
                                         string tmp, clsName;
                                         bool isByRef;
-                                        GetClassName(i.ReturnType, out tmp, out clsName, out isByRef);
+                                        i.ReturnType.GetClassName(out tmp, out clsName, out isByRef);
                                         sb.AppendLine(string.Format("({1}){0};", param[0].Name, clsName));
                                     }
                                     break;
@@ -663,13 +661,13 @@ namespace ILRuntime.Runtime.Generated
                         continue;
                     string tmp, clsName;
                     bool isByRef;
-                    GetClassName(p.ParameterType.GetElementType(), out tmp, out clsName, out isByRef);
+                    p.ParameterType.GetElementType().GetClassName(out tmp, out clsName, out isByRef);
                     sb.AppendLine(string.Format("            ptr_of_this_method = ILIntepreter.Minus(__esp, {0});", param.Length - j + 1));
                     sb.AppendLine(@"            switch(ptr_of_this_method->ObjectType)
             {
                 case ObjectTypes.StackObjectReference:
                     {
-                        var dst = *(StackObject**)&ptr_of_this_method->Value;");
+                        var ___dst = *(StackObject**)&ptr_of_this_method->Value;");
                     GetRefWriteBackValueCode(p.ParameterType.GetElementType(), sb, p.Name);
                     sb.Append(@"                    }
                     break;
@@ -758,74 +756,74 @@ namespace ILRuntime.Runtime.Generated
             {
                 if (type == typeof(int))
                 {
-                    sb.AppendLine("                        dst->ObjectType = ObjectTypes.Integer;");
-                    sb.Append("                        dst->Value = " + paramName);
+                    sb.AppendLine("                        ___dst->ObjectType = ObjectTypes.Integer;");
+                    sb.Append("                        ___dst->Value = " + paramName);
                     sb.AppendLine(";");
                 }
                 else if (type == typeof(long))
                 {
-                    sb.AppendLine("                        dst->ObjectType = ObjectTypes.Long;");
-                    sb.Append("                        *(long*)&dst->Value = " + paramName);
+                    sb.AppendLine("                        ___dst->ObjectType = ObjectTypes.Long;");
+                    sb.Append("                        *(long*)&___dst->Value = " + paramName);
                     sb.AppendLine(";");
                 }
                 else if (type == typeof(short))
                 {
-                    sb.AppendLine("                        dst->ObjectType = ObjectTypes.Integer;");
-                    sb.Append("                        dst->Value = " + paramName);
+                    sb.AppendLine("                        ___dst->ObjectType = ObjectTypes.Integer;");
+                    sb.Append("                        ___dst->Value = " + paramName);
                     sb.AppendLine(";");
                 }
                 else if (type == typeof(bool))
                 {
-                    sb.AppendLine("                        dst->ObjectType = ObjectTypes.Integer;");
-                    sb.Append("                        dst->Value = " + paramName + " ? 1 : 0;");
+                    sb.AppendLine("                        ___dst->ObjectType = ObjectTypes.Integer;");
+                    sb.Append("                        ___dst->Value = " + paramName + " ? 1 : 0;");
                     sb.AppendLine(";");
                 }
                 else if (type == typeof(ushort))
                 {
-                    sb.AppendLine("                        dst->ObjectType = ObjectTypes.Integer;");
-                    sb.Append("                        dst->Value = " + paramName);
+                    sb.AppendLine("                        ___dst->ObjectType = ObjectTypes.Integer;");
+                    sb.Append("                        ___dst->Value = " + paramName);
                     sb.AppendLine(";");
                 }
                 else if (type == typeof(float))
                 {
-                    sb.AppendLine("                        dst->ObjectType = ObjectTypes.Float;");
-                    sb.Append("                        *(float*)&dst->Value = " + paramName);
+                    sb.AppendLine("                        ___dst->ObjectType = ObjectTypes.Float;");
+                    sb.Append("                        *(float*)&___dst->Value = " + paramName);
                     sb.AppendLine(";");
                 }
                 else if (type == typeof(double))
                 {
-                    sb.AppendLine("                        dst->ObjectType = ObjectTypes.Double;");
-                    sb.Append("                        *(double*)&dst->Value = " + paramName);
+                    sb.AppendLine("                        ___dst->ObjectType = ObjectTypes.Double;");
+                    sb.Append("                        *(double*)&___dst->Value = " + paramName);
                     sb.AppendLine(";");
                 }
                 else if (type == typeof(byte))
                 {
-                    sb.AppendLine("                        dst->ObjectType = ObjectTypes.Integer;");
-                    sb.Append("                        dst->Value = " + paramName);
+                    sb.AppendLine("                        ___dst->ObjectType = ObjectTypes.Integer;");
+                    sb.Append("                        ___dst->Value = " + paramName);
                     sb.AppendLine(";");
                 }
                 else if (type == typeof(sbyte))
                 {
-                    sb.AppendLine("                        dst->ObjectType = ObjectTypes.Integer;");
-                    sb.Append("                        dst->Value = " + paramName);
+                    sb.AppendLine("                        ___dst->ObjectType = ObjectTypes.Integer;");
+                    sb.Append("                        ___dst->Value = " + paramName);
                     sb.AppendLine(";");
                 }
                 else if (type == typeof(uint))
                 {
-                    sb.AppendLine("                        dst->ObjectType = ObjectTypes.Integer;");
-                    sb.Append("                        dst->Value = (int)" + paramName);
+                    sb.AppendLine("                        ___dst->ObjectType = ObjectTypes.Integer;");
+                    sb.Append("                        ___dst->Value = (int)" + paramName);
                     sb.AppendLine(";");
                 }
                 else if (type == typeof(char))
                 {
-                    sb.AppendLine("                        dst->ObjectType = ObjectTypes.Integer;");
-                    sb.Append("                        dst->Value = (int)" + paramName);
+                    sb.AppendLine("                        ___dst->ObjectType = ObjectTypes.Integer;");
+                    sb.Append("                        ___dst->Value = (int)" + paramName);
                     sb.AppendLine(";");
                 }
                 else if (type == typeof(ulong))
                 {
-                    sb.AppendLine("                        dst->ObjectType = ObjectTypes.Long;");
-                    sb.Append("                        *(ulong*)&dst->Value = " + paramName);
+                    sb.AppendLine("                        ___dst->ObjectType = ObjectTypes.Long;");
+                    sb.Append("                        *(ulong*)&___dst->Value = " + paramName);
                     sb.AppendLine(";");
                 }
                 else
@@ -841,11 +839,11 @@ namespace ILRuntime.Runtime.Generated
 
                     sb.AppendLine(@"                        if (___obj is CrossBindingAdaptorType)
                             ___obj = ((CrossBindingAdaptorType)___obj).ILInstance;
-                        __mStack[dst->Value] = ___obj; ");
+                        __mStack[___dst->Value] = ___obj; ");
                 }
                 else
                 {
-                    sb.Append("                        __mStack[dst->Value] = ");
+                    sb.Append("                        __mStack[___dst->Value] = ");
                     sb.Append(paramName);
                     sb.AppendLine(";");
                 }
@@ -994,83 +992,8 @@ namespace ILRuntime.Runtime.Generated
             }
             else
             {
-                return string.Format("({0})typeof({0}).CheckCLRTypes(__domain, StackObject.ToObject(ptr_of_this_method, __domain, __mStack))", realClsName);
+                return string.Format("({0})typeof({0}).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack))", realClsName);
             }
         }
-
-        static void GetClassName(Type type, out string clsName, out string realClsName, out bool isByRef, bool simpleClassName = false)
-        {
-            isByRef = type.IsByRef;
-            bool isArray = type.IsArray;
-            if (isByRef)
-                type = type.GetElementType();
-            if (isArray)
-                type = type.GetElementType();
-            string realNamespace = null;
-            if (type.IsNested)
-            {
-                string bClsName, bRealClsName;
-                bool tmp;
-                GetClassName(type.ReflectedType, out bClsName, out bRealClsName, out tmp);
-                clsName = simpleClassName ? "" : bClsName + "_";
-                realNamespace = bRealClsName + ".";
-            }
-            else
-            {
-                clsName = simpleClassName ? "" : (!string.IsNullOrEmpty(type.Namespace) ? type.Namespace.Replace(".", "_") + "_" : "");
-                realNamespace = !string.IsNullOrEmpty(type.Namespace) ? type.Namespace + "." : null;
-            }
-            clsName = clsName + type.Name.Replace(".", "_").Replace("`", "_").Replace("<", "_").Replace(">", "_");
-            bool isGeneric = false;
-            string ga = null;
-            if (type.IsGenericType)
-            {
-                isGeneric = true;
-                clsName += "_";
-                ga = "<";
-                var args = type.GetGenericArguments();
-                bool first = true;
-                foreach (var j in args)
-                {
-                    if (first)
-                        first = false;
-                    else
-                    {
-                        clsName += "_";
-                        ga += ", ";
-                    }
-                    string a, b;
-                    bool tmp;
-                    GetClassName(j, out a, out b, out tmp, true);
-                    clsName += a;
-                    ga += b;
-                }
-                ga += ">";
-            }
-            if (!simpleClassName)
-                clsName += "_Binding";
-            if (!simpleClassName && isArray)
-                clsName += "_Array";
-
-            realClsName = realNamespace;
-            if (isGeneric)
-            {
-                int idx = type.Name.IndexOf("`");
-                if (idx > 0)
-                {
-                    realClsName += type.Name.Substring(0, idx);
-                    realClsName += ga;
-                }
-                else
-                    realClsName += type.Name;
-            }
-            else
-                realClsName += type.Name;
-
-            if (isArray)
-                realClsName += "[]";
-
-        }
-
     }
 }

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

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

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

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

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

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

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

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

+ 7 - 5
Unity/Assets/ILRuntime/ILRuntime/Runtime/Debugger/DebugService.cs

@@ -89,7 +89,7 @@ namespace ILRuntime.Runtime.Debugger
             return false;
         }
 
-        internal string GetStackTrance(ILIntepreter intepreper)
+        public string GetStackTrance(ILIntepreter intepreper)
         {
             StringBuilder sb = new StringBuilder();
             ILRuntime.CLR.Method.ILMethod m;
@@ -120,14 +120,16 @@ namespace ILRuntime.Runtime.Debugger
             return sb.ToString();
         }
 
-        internal unsafe string GetThisInfo(ILIntepreter intepreter)
+        public unsafe string GetThisInfo(ILIntepreter intepreter)
         {
             var topFrame = intepreter.Stack.Frames.Peek();
             var arg = Minus(topFrame.LocalVarPointer, topFrame.Method.ParameterCount);
             if (topFrame.Method.HasThis)
                 arg--;
             if (arg->ObjectType == ObjectTypes.StackObjectReference)
+            {
                 arg = *(StackObject**)&arg->Value;
+            }
             ILTypeInstance instance = arg->ObjectType != ObjectTypes.Null ? intepreter.Stack.ManagedStack[arg->Value] as ILTypeInstance : null;
             if (instance == null)
                 return "null";
@@ -154,7 +156,7 @@ namespace ILRuntime.Runtime.Debugger
             return sb.ToString();
         }
 
-        internal unsafe string GetLocalVariableInfo(ILIntepreter intepreter)
+        public unsafe string GetLocalVariableInfo(ILIntepreter intepreter)
         {
             StackFrame topFrame = intepreter.Stack.Frames.Peek();
             var m = topFrame.Method;
@@ -403,7 +405,7 @@ namespace ILRuntime.Runtime.Debugger
                         name = string.IsNullOrEmpty(lv.Name) ? "arg" + lv.Index : lv.Name;
                         typeName = lv.ParameterType.FullName;
                         if (v != null)
-                            v = m.Parameters[argIdx].TypeForCLR.CheckCLRTypes(intp.AppDomain, v);
+                            v = m.Parameters[argIdx].TypeForCLR.CheckCLRTypes(v);
                     }
                     else
                     {
@@ -429,7 +431,7 @@ namespace ILRuntime.Runtime.Debugger
                     if (v == null)
                         v = "null";
                     else
-                        v = intp.AppDomain.GetType(lv.VariableType, m.DeclearingType, m).TypeForCLR.CheckCLRTypes(intp.AppDomain, v);
+                        v = intp.AppDomain.GetType(lv.VariableType, m.DeclearingType, m).TypeForCLR.CheckCLRTypes(v);
                     string name = string.IsNullOrEmpty(lv.Name) ? "v" + lv.Index : lv.Name;
                     VariableInfo vinfo = new Debugger.VariableInfo();
                     vinfo.Address = (long)val;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

+ 107 - 28
Unity/Assets/ILRuntime/ILRuntime/Runtime/Enviorment/AppDomain.cs

@@ -64,6 +64,10 @@ namespace ILRuntime.Runtime.Enviorment
                 {
                     RegisterCLRMethodRedirection(i, CLRRedirections.GetType);
                 }
+                if(i.Name=="Equals" && i.GetParameters()[0].ParameterType == typeof(Type))
+                {
+                    RegisterCLRMethodRedirection(i, CLRRedirections.TypeEquals);
+                }
             }
             foreach (var i in typeof(System.Delegate).GetMethods())
             {
@@ -433,6 +437,7 @@ namespace ILRuntime.Runtime.Enviorment
                     }
                     bt = bt.MakeGenericInstance(genericArguments);
                     mapType[bt.FullName] = bt;
+                    mapTypeToken[bt.GetHashCode()] = bt;
                     StringBuilder sb = new StringBuilder();
                     sb.Append(baseType);
                     sb.Append('<');
@@ -451,22 +456,23 @@ namespace ILRuntime.Runtime.Enviorment
                         mapType[asmName] = bt;
                 }
 
-                if (isByRef)
+                if (isArray)
                 {
-                    bt = bt.MakeByRefType();
+                    bt = bt.MakeArrayType();
                     mapType[bt.FullName] = bt;
-                    if (!isArray)
+                    mapTypeToken[bt.GetHashCode()] = bt;
+                    if (!isByRef)
                     {
-                        mapType[fullname] = bt;
                         return bt;
                     }
                 }
 
-                if (isArray)
+                if (isByRef)
                 {
-                    res = bt.MakeArrayType();
+                    res = bt.MakeByRefType();
                     mapType[fullname] = res;
                     mapType[res.FullName] = res;
+                    mapTypeToken[res.GetHashCode()] = res;
                     return res;
                 }
                 else
@@ -477,12 +483,15 @@ namespace ILRuntime.Runtime.Enviorment
                 Type t = Type.GetType(fullname);
                 if (t != null)
                 {
-                    res = new CLRType(t, this);
+                    if (!clrTypeMapping.TryGetValue(t, out res))
+                    {
+                        res = new CLRType(t, this);
+                        clrTypeMapping[t] = res;
+                    }
                     mapType[fullname] = res;
                     mapType[res.FullName] = res;
                     mapType[t.AssemblyQualifiedName] = res;
-                    clrTypeMapping[t] = res;
-                    mapTypeToken[t.GetHashCode()] = res;
+                    mapTypeToken[res.GetHashCode()] = res;
                     return res;
                 }
             }
@@ -606,16 +615,19 @@ namespace ILRuntime.Runtime.Enviorment
                 }
                 if (_ref.IsByReference)
                 {
-                    var t = GetType(_ref.GetElementType(), contextType, contextMethod);
+                    var et = _ref.GetElementType();
+                    bool valid = !et.IsGenericParameter;
+                    var t = GetType(et, contextType, contextMethod);
                     if (t != null)
                     {
                         res = t.MakeByRefType();
-                        if (res is ILType)
+                        if (res is ILType && valid)
                         {
                             ///Unify the TypeReference
                             ((ILType)res).TypeReference = _ref;
                         }
-                        mapTypeToken[hash] = res;
+                        if (valid)
+                            mapTypeToken[hash] = res;
                         if (!string.IsNullOrEmpty(res.FullName))
                             mapType[res.FullName] = res;
                         return res;
@@ -668,6 +680,8 @@ namespace ILRuntime.Runtime.Enviorment
                         }
                         else
                             val = GetType(gType.GenericArguments[i], contextType, contextMethod);
+                        if (val != null && val.HasGenericParameter)
+                            dummyGenericInstance = true;
                         if (val != null)
                             genericArguments[i] = new KeyValuePair<string, IType>(key, val);
                         else
@@ -734,8 +748,12 @@ namespace ILRuntime.Runtime.Enviorment
                     ((ILType)res).TypeReference = (TypeReference)token;
                 }
                 if (!string.IsNullOrEmpty(res.FullName))
-                    mapType[res.FullName] = res;
+                {
+                    if (res is CLRType || !((ILType)res).TypeReference.HasGenericParameters)
+                        mapType[res.FullName] = res;
+                }
             }
+            mapTypeToken[res.GetHashCode()] = res;
             if (!dummyGenericInstance)
                 mapTypeToken[hash] = res;
             return res;
@@ -817,10 +835,18 @@ namespace ILRuntime.Runtime.Enviorment
             IType t = GetType(type);
             if (t == null)
                 return null;
-            var m = t.GetMethod(method, p != null ? p.Length : 0);
-
+            var m = t.GetMethod(method, p != null ? p.Length : 0);            
             if (m != null)
             {
+                for(int i = 0; i < m.ParameterCount; i++)
+                {
+                    if (p[i] == null)
+                        continue;
+                    if (!m.Parameters[i].TypeForCLR.IsAssignableFrom(p[i].GetType()))
+                    {
+                        throw new ArgumentException("Parameter type mismatch");
+                    }
+                }
                 return Invoke(m, instance, p);
             }
             return null;
@@ -946,6 +972,7 @@ namespace ILRuntime.Runtime.Enviorment
                 }
                 methodname = _ref.Name;
                 var typeDef = _ref.DeclaringType;
+
                 type = GetType(typeDef, contextType, contextMethod);
                 if (type == null)
                     throw new KeyNotFoundException("Cannot find type:" + typename);
@@ -957,7 +984,7 @@ namespace ILRuntime.Runtime.Enviorment
                 }
                 else
                     isConstructor = methodname == ".ctor";
-                
+
                 if (_ref.IsGenericInstance)
                 {
                     GenericInstanceMethod gim = (GenericInstanceMethod)_ref;
@@ -982,9 +1009,22 @@ namespace ILRuntime.Runtime.Enviorment
                             genericArguments[i] = gt;
                     }
                 }
-
+                if (!invalidToken && typeDef.IsGenericInstance)
+                {
+                    GenericInstanceType gim = (GenericInstanceType)typeDef;
+                    for (int i = 0; i < gim.GenericArguments.Count; i++)
+                    {
+                        if (gim.GenericArguments[0].IsGenericParameter)
+                        {
+                            invalidToken = true;
+                            break;
+                        }
+                    }
+                }
                 paramList = _ref.GetParamList(this, contextType, contextMethod, genericArguments);
-                returnType = GetType(_ref.ReturnType, contextType, null);
+                returnType = GetType(_ref.ReturnType, type, null);
+                if (returnType == null)
+                    returnType = GetType(_ref.ReturnType, contextType, null);
             }
             else
             {
@@ -998,8 +1038,6 @@ namespace ILRuntime.Runtime.Enviorment
             else
             {
                 method = type.GetMethod(methodname, paramList, genericArguments, returnType);
-                if (method != null && method.IsGenericInstance)
-                    mapMethod[method.GetHashCode()] = method;
             }
 
             if (method == null)
@@ -1007,16 +1045,18 @@ namespace ILRuntime.Runtime.Enviorment
                 if (isConstructor && contextType.FirstCLRBaseType != null && contextType.FirstCLRBaseType is CrossBindingAdaptor && type.TypeForCLR == ((CrossBindingAdaptor)contextType.FirstCLRBaseType).BaseCLRType)
                 {
                     method = contextType.BaseType.GetConstructor(paramList);
-                    if(method == null)
-                        throw new KeyNotFoundException("Cannot find method:" + methodname);
+                    if (method == null)
+                        throw new KeyNotFoundException(string.Format("Cannot find method:{0} in type:{1}, token={2}", methodname, type.FullName, token));
                     invalidToken = true;
                     mapMethod[method.GetHashCode()] = method;
                 }
                 else
-                    throw new KeyNotFoundException("Cannot find method:" + methodname);
+                    throw new KeyNotFoundException(string.Format("Cannot find method:{0} in type:{1}, token={2}", methodname, type.FullName, token));
             }
             if (!invalidToken)
                 mapMethod[hashCode] = method;
+            else
+                mapMethod[method.GetHashCode()] = method;
             return method;
         }
 
@@ -1049,14 +1089,23 @@ namespace ILRuntime.Runtime.Enviorment
             {
                 var it = type as ILType;
                 int idx = it.GetFieldIndex(token);
-                long res = ((long)it.TypeReference.GetHashCode() << 32) | (uint)idx;
+                long res = 0;
+                if (it.TypeReference.HasGenericParameters)
+                {
+                    mapTypeToken[type.GetHashCode()] = it;
+                    res = ((long)type.GetHashCode() << 32) | (uint)idx;
+                }
+                else
+                {
+                    res = ((long)it.TypeReference.GetHashCode() << 32) | (uint)idx;
+                }
 
                 return res;
             }
             else
             {
                 int idx = type.GetFieldIndex(token);
-                long res = ((long)f.DeclaringType.GetHashCode() << 32) | (uint)idx;
+                long res = ((long)type.GetHashCode() << 32) | (uint)idx;
 
                 return res;
             }
@@ -1100,8 +1149,29 @@ namespace ILRuntime.Runtime.Enviorment
 
         public void RegisterCrossBindingAdaptor(CrossBindingAdaptor adaptor)
         {
-            if (!crossAdaptors.ContainsKey(adaptor.BaseCLRType))
+            var bType = adaptor.BaseCLRType;
+            if (bType != null)
+            {
+                if (!crossAdaptors.ContainsKey(bType))
+                {
+                    var t = adaptor.AdaptorType;
+                    var res = GetType(t);
+                    if (res == null)
+                    {
+                        res = new CLRType(t, this);
+                        mapType[res.FullName] = res;
+                        mapType[t.AssemblyQualifiedName] = res;
+                        clrTypeMapping[t] = res;
+                    }
+                    adaptor.RuntimeType = res;
+                    crossAdaptors[bType] = adaptor;
+                }
+                else
+                    throw new Exception("Crossbinding Adapter for " + bType.FullName + " is already added.");
+            }
+            else
             {
+                var bTypes = adaptor.BaseCLRTypes;
                 var t = adaptor.AdaptorType;
                 var res = GetType(t);
                 if (res == null)
@@ -1112,8 +1182,17 @@ namespace ILRuntime.Runtime.Enviorment
                     clrTypeMapping[t] = res;
                 }
                 adaptor.RuntimeType = res;
-                crossAdaptors[adaptor.BaseCLRType] = adaptor;
-            }
+
+                foreach (var i in bTypes)
+                {
+                    if (!crossAdaptors.ContainsKey(i))
+                    {
+                        crossAdaptors[i] = adaptor;
+                    }
+                    else
+                        throw new Exception("Crossbinding Adapter for " + i.FullName + " is already added.");
+                }
+            } 
         }
     }
 }

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

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

+ 43 - 3
Unity/Assets/ILRuntime/ILRuntime/Runtime/Enviorment/CLRRedirections.cs

@@ -6,6 +6,7 @@ using System.Reflection;
 
 using ILRuntime.CLR.TypeSystem;
 using ILRuntime.CLR.Method;
+using ILRuntime.CLR.Utils;
 using ILRuntime.Runtime.Intepreter;
 using ILRuntime.Runtime.Stack;
 using ILRuntime.Reflection;
@@ -93,6 +94,37 @@ namespace ILRuntime.Runtime.Enviorment
                 return ILIntepreter.PushNull(p);
         }
 
+        public static StackObject* TypeEquals(ILIntepreter intp, StackObject* esp, List<object> mStack, CLRMethod method, bool isNewObj)
+        {
+            var ret = ILIntepreter.Minus(esp, 2);
+            var p = esp - 1;
+            AppDomain dommain = intp.AppDomain;
+            var other = StackObject.ToObject(p, dommain, mStack);
+            intp.Free(p);
+            p = ILIntepreter.Minus(esp, 2);
+            var instance = StackObject.ToObject(p, dommain, mStack);
+            intp.Free(p);
+            if(instance is ILRuntimeType)
+            {
+                if (other is ILRuntimeType)
+                {
+                    if(((ILRuntimeType)instance).ILType == ((ILRuntimeType)other).ILType)
+                        return ILIntepreter.PushOne(ret);
+                    else
+                        return ILIntepreter.PushZero(ret);
+                }
+                else
+                    return ILIntepreter.PushZero(ret);
+            }
+            else
+            {
+                if(((Type)typeof(Type).CheckCLRTypes(instance)).Equals(((Type)typeof(Type).CheckCLRTypes(other))))
+                    return ILIntepreter.PushOne(ret);
+                else
+                    return ILIntepreter.PushZero(ret);
+            }
+        }
+
         /*public static object GetType(ILContext ctx, object instance, object[] param, IType[] genericArguments)
         {
             var t = ctx.AppDomain.GetType((string)param[0]);
@@ -379,16 +411,24 @@ namespace ILRuntime.Runtime.Enviorment
                         if (dele2 is IDelegateAdapter)
                         {
                             var dele = ((IDelegateAdapter)dele1);
-                            //This means it's the default delegate which should be singleton to support == operator
-                            if (dele.Next == null)
+                            //This means it's the original delegate which should be untouch
+                            if (!dele.IsClone)
                             {
-                                dele = dele.Instantiate(domain, dele.Instance, dele.Method);
+                                dele = dele.Clone();
+                            }
+                            if(!((IDelegateAdapter)dele2).IsClone)
+                            {
+                                dele2 = ((IDelegateAdapter)dele2).Clone();
                             }
                             dele.Combine((IDelegateAdapter)dele2);
                             return ILIntepreter.PushObject(ret, mStack, dele);
                         }
                         else
                         {
+                            if (!((IDelegateAdapter)dele1).IsClone)
+                            {
+                                dele1 = ((IDelegateAdapter)dele1).Clone();
+                            }
                             ((IDelegateAdapter)dele1).Combine((Delegate)dele2);
                             return ILIntepreter.PushObject(ret, mStack, dele1);
                         }

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

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

+ 38 - 1
Unity/Assets/ILRuntime/ILRuntime/Runtime/Enviorment/CrossBindingAdaptor.cs

@@ -23,6 +23,17 @@ namespace ILRuntime.Runtime.Enviorment
         /// </summary>
         public abstract Type BaseCLRType { get; }
 
+        /// <summary>
+        /// If this Adaptor is capable to impelement multuple interfaces, use this Property, AND BaseCLRType should return null
+        /// </summary>
+        public virtual Type[] BaseCLRTypes
+        {
+            get
+            {
+                return null;
+            }
+        }
+
         public abstract Type AdaptorType { get; }
 
         public abstract object CreateCLRInstance(Enviorment.AppDomain appdomain, ILTypeInstance instance);
@@ -58,7 +69,21 @@ namespace ILRuntime.Runtime.Enviorment
 
         public bool CanAssignTo(IType type)
         {
-            return type.CanAssignTo(type);
+            bool res = false;
+            if (BaseType != null)
+                res = BaseType.CanAssignTo(type);
+            var interfaces = Implements;
+            if (!res && interfaces != null)
+            {
+                for (int i = 0; i < interfaces.Length; i++)
+                {
+                    var im = interfaces[i];
+                    res = im.CanAssignTo(type);
+                    if (res)
+                        return true;
+                }
+            }
+            return false;
         }
 
         public IType MakeGenericInstance(KeyValuePair<string, IType>[] genericArguments)
@@ -187,6 +212,14 @@ namespace ILRuntime.Runtime.Enviorment
             }
         }
 
+        public IType[] Implements
+        {
+            get
+            {
+                return type.Implements;
+            }
+        }
+
         public bool HasGenericParameter
         {
             get
@@ -194,6 +227,10 @@ namespace ILRuntime.Runtime.Enviorment
                 return type.HasGenericParameter;
             }
         }
+        public bool IsArray
+        {
+            get { return false; }
+        }
         #endregion
     }
 }

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

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

+ 93 - 10
Unity/Assets/ILRuntime/ILRuntime/Runtime/Enviorment/DelegateManager.cs

@@ -16,10 +16,17 @@ namespace ILRuntime.Runtime.Enviorment
         IDelegateAdapter zeroParamMethodAdapter = new MethodDelegateAdapter();
         IDelegateAdapter dummyAdapter = new DummyDelegateAdapter();
         Dictionary<Type, Func<Delegate, Delegate>> clrDelegates = new Dictionary<Type, Func<Delegate, Delegate>>();
+        Func<Delegate, Delegate> defaultConverter;
         Enviorment.AppDomain appdomain;
         public DelegateManager(Enviorment.AppDomain appdomain)
         {
             this.appdomain = appdomain;
+            defaultConverter = DefaultConverterStub;
+        }
+
+        static Delegate DefaultConverterStub(Delegate dele)
+        {
+            return dele;
         }
 
         public void RegisterDelegateConvertor<T>(Func<Delegate, Delegate> action)
@@ -39,7 +46,7 @@ namespace ILRuntime.Runtime.Enviorment
             node.Adapter = new MethodDelegateAdapter<T1>();
             node.ParameterTypes = new Type[] { typeof(T1) };
             methods.Add(node);
-            RegisterDelegateConvertor<Action<T1>>((dele) => dele);
+            RegisterDelegateConvertor<Action<T1>>(defaultConverter);
         }
 
         public void RegisterMethodDelegate<T1, T2>()
@@ -48,7 +55,7 @@ namespace ILRuntime.Runtime.Enviorment
             node.Adapter = new MethodDelegateAdapter<T1, T2>();
             node.ParameterTypes = new Type[] { typeof(T1), typeof(T2) };
             methods.Add(node);
-            RegisterDelegateConvertor<Action<T1, T2>>((dele) => dele);
+            RegisterDelegateConvertor<Action<T1, T2>>(defaultConverter);
         }
 
         public void RegisterMethodDelegate<T1, T2, T3>()
@@ -57,7 +64,7 @@ namespace ILRuntime.Runtime.Enviorment
             node.Adapter = new MethodDelegateAdapter<T1, T2, T3>();
             node.ParameterTypes = new Type[] { typeof(T1), typeof(T2), typeof(T3) };
             methods.Add(node);
-            RegisterDelegateConvertor<Action<T1, T2, T3>>((dele) => dele);
+            RegisterDelegateConvertor<Action<T1, T2, T3>>(defaultConverter);
         }
 
         public void RegisterMethodDelegate<T1, T2, T3, T4>()
@@ -66,7 +73,7 @@ namespace ILRuntime.Runtime.Enviorment
             node.Adapter = new MethodDelegateAdapter<T1, T2, T3, T4>();
             node.ParameterTypes = new Type[] { typeof(T1), typeof(T2), typeof(T3), typeof(T4) };
             methods.Add(node);
-            RegisterDelegateConvertor<Action<T1, T2, T3, T4>>((dele) => dele);
+            RegisterDelegateConvertor<Action<T1, T2, T3, T4>>(defaultConverter);
         }
 
         public void RegisterFunctionDelegate<TResult>()
@@ -75,7 +82,7 @@ namespace ILRuntime.Runtime.Enviorment
             node.Adapter = new FunctionDelegateAdapter<TResult>();
             node.ParameterTypes = new Type[] { typeof(TResult) };
             functions.Add(node);
-            RegisterDelegateConvertor<Func<TResult>>((dele) => dele);
+            RegisterDelegateConvertor<Func<TResult>>(defaultConverter);
         }
 
         public void RegisterFunctionDelegate<T1, TResult>()
@@ -84,7 +91,7 @@ namespace ILRuntime.Runtime.Enviorment
             node.Adapter = new FunctionDelegateAdapter<T1, TResult>();
             node.ParameterTypes = new Type[] { typeof(T1), typeof(TResult) };
             functions.Add(node);
-            RegisterDelegateConvertor<Func<T1, TResult>>((dele) => dele);
+            RegisterDelegateConvertor<Func<T1, TResult>>(defaultConverter);
         }
 
         public void RegisterFunctionDelegate<T1, T2, TResult>()
@@ -93,7 +100,7 @@ namespace ILRuntime.Runtime.Enviorment
             node.Adapter = new FunctionDelegateAdapter<T1, T2, TResult>();
             node.ParameterTypes = new Type[] { typeof(T1), typeof(T2), typeof(TResult) };
             functions.Add(node);
-            RegisterDelegateConvertor<Func<T1, T2, TResult>>((dele) => dele);
+            RegisterDelegateConvertor<Func<T1, T2, TResult>>(defaultConverter);
         }
 
         public void RegisterFunctionDelegate<T1, T2, T3, TResult>()
@@ -102,7 +109,7 @@ namespace ILRuntime.Runtime.Enviorment
             node.Adapter = new FunctionDelegateAdapter<T1, T2, T3, TResult>();
             node.ParameterTypes = new Type[] { typeof(T1), typeof(T2), typeof(T3), typeof(TResult) };
             functions.Add(node);
-            RegisterDelegateConvertor<Func<T1, T2, T3, TResult>>((dele) => dele);
+            RegisterDelegateConvertor<Func<T1, T2, T3, TResult>>(defaultConverter);
         }
 
         public void RegisterFunctionDelegate<T1, T2, T3, T4, TResult>()
@@ -111,7 +118,7 @@ namespace ILRuntime.Runtime.Enviorment
             node.Adapter = new FunctionDelegateAdapter<T1, T2, T3, T4, TResult>();
             node.ParameterTypes = new Type[] { typeof(T1), typeof(T2), typeof(T3), typeof(T4), typeof(TResult) };
             functions.Add(node);
-            RegisterDelegateConvertor<Func<T1, T2, T3, T4, TResult>>((dele) => dele);
+            RegisterDelegateConvertor<Func<T1, T2, T3, T4, TResult>>(defaultConverter);
         }
 
         internal Delegate ConvertToDelegate(Type clrDelegateType, IDelegateAdapter adapter)
@@ -127,7 +134,83 @@ namespace ILRuntime.Runtime.Enviorment
                 return func(adapter.Delegate);
             }
             else
-                throw new KeyNotFoundException("Cannot find convertor for " + clrDelegateType);
+            {
+                StringBuilder sb = new StringBuilder();
+                string clsName, rName;
+                bool isByRef;
+                clrDelegateType.GetClassName(out clsName, out rName, out isByRef);
+                sb.AppendLine("Cannot find convertor for " + rName);
+                sb.AppendLine("Please add following code:");
+                sb.Append("appdomain.DelegateManager.RegisterDelegateConvertor<");
+                sb.Append(rName);
+                sb.AppendLine(">((act) =>");
+                sb.AppendLine("{");
+                sb.Append("    return new ");
+                sb.Append(rName);
+                sb.Append("((");
+                var mi = clrDelegateType.GetMethod("Invoke");
+                bool first = true;
+                foreach(var i in mi.GetParameters())
+                {
+                    if (first)
+                    {
+                        first = false;
+                    }
+                    else
+                        sb.Append(", ");
+                    sb.Append(i.Name);
+                }
+                sb.AppendLine(") =>");
+                sb.AppendLine("    {");
+                if(mi.ReturnType != appdomain.VoidType.TypeForCLR)
+                {
+                    sb.Append("        return ((Func<");
+                    first = true;
+                    foreach (var i in mi.GetParameters())
+                    {
+                        if (first)
+                        {
+                            first = false;
+                        }
+                        else
+                            sb.Append(", ");
+                        i.ParameterType.GetClassName(out clsName, out rName, out isByRef);
+                        sb.Append(rName);
+                    }
+                }
+                else
+                {
+                    sb.Append("        ((Action<");
+                    first = true;
+                    foreach (var i in mi.GetParameters())
+                    {
+                        if (first)
+                        {
+                            first = false;
+                        }
+                        else
+                            sb.Append(", ");
+                        i.ParameterType.GetClassName(out clsName, out rName, out isByRef);
+                        sb.Append(rName);
+                    }
+                }
+                sb.Append(">)act)(");
+                first = true;
+                foreach (var i in mi.GetParameters())
+                {
+                    if (first)
+                    {
+                        first = false;
+                    }
+                    else
+                        sb.Append(", ");
+                    sb.Append(i.Name);
+                }
+                sb.AppendLine(");");
+                sb.AppendLine("    });");
+                sb.AppendLine("});");
+                throw new KeyNotFoundException(sb.ToString());
+            }
         }
 
         internal IDelegateAdapter FindDelegateAdapter(ILTypeInstance instance, ILMethod method)

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

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

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

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 4d1d82ea4e082bc4da5829542d3f98c9
-timeCreated: 1486603950
-licenseType: Pro
+timeCreated: 1496395687
+licenseType: Free
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 93 - 0
Unity/Assets/ILRuntime/ILRuntime/Runtime/Extensions.cs

@@ -9,6 +9,89 @@ namespace ILRuntime.Runtime
 {
     static class Extensions
     {
+        public static void GetClassName(this Type type, out string clsName, out string realClsName, out bool isByRef, bool simpleClassName = false)
+        {
+            isByRef = type.IsByRef;
+            bool isArray = type.IsArray;
+            if (isByRef)
+                type = type.GetElementType();
+            if (isArray)
+                type = type.GetElementType();
+            string realNamespace = null;
+            bool isNestedGeneric = false;
+            if (type.IsNested)
+            {
+                string bClsName, bRealClsName;
+                bool tmp;
+                var rt = type.ReflectedType;
+                if(rt.IsGenericType && rt.IsGenericTypeDefinition)
+                {
+                    if (type.IsGenericType)
+                    {
+                        rt = rt.MakeGenericType(type.GetGenericArguments());
+                        isNestedGeneric = true;
+                    }
+                }
+                GetClassName(rt, out bClsName, out bRealClsName, out tmp);
+                clsName = simpleClassName ? "" : bClsName + "_";
+                realNamespace = bRealClsName + ".";
+            }
+            else
+            {
+                clsName = simpleClassName ? "" : (!string.IsNullOrEmpty(type.Namespace) ? type.Namespace.Replace(".", "_") + "_" : "");
+                realNamespace = !string.IsNullOrEmpty(type.Namespace) ? type.Namespace + "." : null;
+            }
+            clsName = clsName + type.Name.Replace(".", "_").Replace("`", "_").Replace("<", "_").Replace(">", "_");
+            bool isGeneric = false;
+            string ga = null;
+            if (type.IsGenericType && !isNestedGeneric)
+            {
+                isGeneric = true;
+                clsName += "_";
+                ga = "<";
+                var args = type.GetGenericArguments();
+                bool first = true;
+                foreach (var j in args)
+                {
+                    if (first)
+                        first = false;
+                    else
+                    {
+                        clsName += "_";
+                        ga += ", ";
+                    }
+                    string a, b;
+                    bool tmp;
+                    GetClassName(j, out a, out b, out tmp, true);
+                    clsName += a;
+                    ga += b;
+                }
+                ga += ">";
+            }
+            if (!simpleClassName)
+                clsName += "_Binding";
+            if (isArray)
+                clsName += "_Array";
+
+            realClsName = realNamespace;
+            if (isGeneric)
+            {
+                int idx = type.Name.IndexOf("`");
+                if (idx > 0)
+                {
+                    realClsName += type.Name.Substring(0, idx);
+                    realClsName += ga;
+                }
+                else
+                    realClsName += type.Name;
+            }
+            else
+                realClsName += type.Name;
+
+            if (isArray)
+                realClsName += "[]";
+
+        }
         public static int ToInt32(this object obj)
         {
             if (obj is int)
@@ -122,5 +205,15 @@ namespace ILRuntime.Runtime
                 return (double)(sbyte)obj;
             throw new InvalidCastException();
         }
+
+        public static Type GetActualType(this object value)
+        {
+            if (value is ILRuntime.Runtime.Enviorment.CrossBindingAdaptorType)
+                return ((ILRuntime.Runtime.Enviorment.CrossBindingAdaptorType)value).ILInstance.Type.ReflectionType;
+            if (value is ILRuntime.Runtime.Intepreter.ILTypeInstance)
+                return ((ILRuntime.Runtime.Intepreter.ILTypeInstance)value).Type.ReflectionType;
+            else
+                return value.GetType();
+        }
     }
 }

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

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

+ 91 - 4
Unity/Assets/ILRuntime/ILRuntime/Runtime/Intepreter/DelegateAdapter.cs

@@ -47,6 +47,13 @@ namespace ILRuntime.Runtime.Intepreter
             return new FunctionDelegateAdapter<TResult>(appdomain, instance, method);
         }
 
+        public override IDelegateAdapter Clone()
+        {
+            var res = new FunctionDelegateAdapter<TResult>(appdomain, instance, method);
+            res.isClone = true;
+            return res;
+        }
+
         public override void Combine(Delegate dele)
         {
             action += (Func<TResult>)dele;
@@ -94,6 +101,13 @@ namespace ILRuntime.Runtime.Intepreter
             return new FunctionDelegateAdapter<T1, TResult>(appdomain, instance, method);
         }
 
+        public override IDelegateAdapter Clone()
+        {
+            var res = new FunctionDelegateAdapter<T1, TResult>(appdomain, instance, method);
+            res.isClone = true;
+            return res;
+        }
+
         public override void Combine(Delegate dele)
         {
             action += (Func<T1, TResult>)dele;
@@ -141,6 +155,13 @@ namespace ILRuntime.Runtime.Intepreter
             return new FunctionDelegateAdapter<T1, T2, TResult>(appdomain, instance, method);
         }
 
+        public override IDelegateAdapter Clone()
+        {
+            var res = new FunctionDelegateAdapter<T1, T2, TResult>(appdomain, instance, method);
+            res.isClone = true;
+            return res;
+        }
+
         public override void Combine(Delegate dele)
         {
             action += (Func<T1, T2, TResult>)dele;
@@ -188,6 +209,12 @@ namespace ILRuntime.Runtime.Intepreter
             return new FunctionDelegateAdapter<T1, T2, T3, TResult>(appdomain, instance, method);
         }
 
+        public override IDelegateAdapter Clone()
+        {
+            var res = new FunctionDelegateAdapter<T1, T2, T3, TResult>(appdomain, instance, method);
+            res.isClone = true;
+            return res;
+        }
         public override void Combine(Delegate dele)
         {
             action += (Func<T1, T2, T3, TResult>)dele;
@@ -235,6 +262,13 @@ namespace ILRuntime.Runtime.Intepreter
             return new FunctionDelegateAdapter<T1, T2, T3, T4, TResult>(appdomain, instance, method);
         }
 
+        public override IDelegateAdapter Clone()
+        {
+            var res = new FunctionDelegateAdapter<T1, T2, T3, T4, TResult>(appdomain, instance, method);
+            res.isClone = true;
+            return res;
+        }
+
         public override void Combine(Delegate dele)
         {
             action += (Func<T1, T2, T3, T4, TResult>)dele;
@@ -284,6 +318,13 @@ namespace ILRuntime.Runtime.Intepreter
             return new MethodDelegateAdapter<T1>(appdomain, instance, method);
         }
 
+        public override IDelegateAdapter Clone()
+        {
+            var res = new MethodDelegateAdapter<T1>(appdomain, instance, method);
+            res.isClone = true;
+            return res;
+        }
+
         public override void Combine(Delegate dele)
         {
             action += (Action<T1>)dele;
@@ -331,6 +372,13 @@ namespace ILRuntime.Runtime.Intepreter
             return new MethodDelegateAdapter<T1, T2>(appdomain, instance, method);
         }
 
+        public override IDelegateAdapter Clone()
+        {
+            var res = new MethodDelegateAdapter<T1, T2>(appdomain, instance, method);
+            res.isClone = true;
+            return res;
+        }
+
         public override void Combine(Delegate dele)
         {
             action += (Action<T1, T2>)dele;
@@ -378,6 +426,13 @@ namespace ILRuntime.Runtime.Intepreter
             return new MethodDelegateAdapter<T1, T2, T3>(appdomain, instance, method);
         }
 
+        public override IDelegateAdapter Clone()
+        {
+            var res = new MethodDelegateAdapter<T1, T2, T3>(appdomain, instance, method);
+            res.isClone = true;
+            return res;
+        }
+
         public override void Combine(Delegate dele)
         {
             action += (Action<T1, T2, T3>)dele;
@@ -425,6 +480,13 @@ namespace ILRuntime.Runtime.Intepreter
             return new MethodDelegateAdapter<T1, T2, T3, T4>(appdomain, instance, method);
         }
 
+        public override IDelegateAdapter Clone()
+        {
+            var res = new MethodDelegateAdapter<T1, T2, T3, T4>(appdomain, instance, method);
+            res.isClone = true;
+            return res;
+        }
+
         public override void Combine(Delegate dele)
         {
             action += (Action<T1, T2, T3, T4>)dele;
@@ -472,6 +534,13 @@ namespace ILRuntime.Runtime.Intepreter
             return new MethodDelegateAdapter(appdomain, instance, method);
         }
 
+        public override IDelegateAdapter Clone()
+        {
+            var res = new MethodDelegateAdapter(appdomain, instance, method);
+            res.isClone = true;
+            return res;
+        }
+
         public override void Combine(Delegate dele)
         {
             action += (Action)dele;
@@ -518,6 +587,13 @@ namespace ILRuntime.Runtime.Intepreter
             return new DummyDelegateAdapter(appdomain, instance, method);
         }
 
+        public override IDelegateAdapter Clone()
+        {
+            var res = new DummyDelegateAdapter(appdomain, instance, method);
+            res.isClone = true;
+            return res;
+        }
+
         public override void Combine(Delegate dele)
         {
             ThrowAdapterNotFound(method);
@@ -536,6 +612,7 @@ namespace ILRuntime.Runtime.Intepreter
         protected Enviorment.AppDomain appdomain;
         Dictionary<Type, Delegate> converters;
         IDelegateAdapter next;
+        protected bool isClone;
 
         public abstract Delegate Delegate { get; }
 
@@ -552,6 +629,7 @@ namespace ILRuntime.Runtime.Intepreter
             this.appdomain = appdomain;
             this.instance = instance;
             this.method = method;
+            CLRInstance = this;
         }
 
         public override bool IsValueType
@@ -632,6 +710,16 @@ namespace ILRuntime.Runtime.Intepreter
 
         public abstract IDelegateAdapter Instantiate(Enviorment.AppDomain appdomain, ILTypeInstance instance, ILMethod method);
 
+        public new abstract IDelegateAdapter Clone();
+
+        public bool IsClone
+        {
+            get
+            {
+                return isClone;
+            }
+        }
+
         public virtual void Combine(IDelegateAdapter adapter)
         {
             if (next != null)
@@ -662,10 +750,7 @@ namespace ILRuntime.Runtime.Intepreter
             if (adapter is DelegateAdapter)
             {
                 DelegateAdapter b = (DelegateAdapter)adapter;
-                if (adapter is DummyDelegateAdapter)
-                    return instance == b.instance && next == b.next && method == b.method;
-                else
-                    return instance == b.instance && next == b.next && method == b.method && Delegate == b.Delegate;
+                return instance == b.instance && method == b.method;
             }
             else
                 return false;
@@ -761,6 +846,8 @@ namespace ILRuntime.Runtime.Intepreter
         ILMethod Method { get; }
         StackObject* ILInvoke(ILIntepreter intp, StackObject* esp, List<object> mStack);
         IDelegateAdapter Instantiate(Enviorment.AppDomain appdomain, ILTypeInstance instance, ILMethod method);
+        bool IsClone { get; }
+        IDelegateAdapter Clone();
         Delegate GetConvertor(Type type);
         void Combine(IDelegateAdapter adapter);
         void Combine(Delegate dele);

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

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

+ 317 - 245
Unity/Assets/ILRuntime/ILRuntime/Runtime/Intepreter/ILIntepreter.cs

@@ -65,11 +65,17 @@ namespace ILRuntime.Runtime.Intepreter
             int mStackBase = mStack.Count;
             StackObject* esp = stack.StackBase;
             if (method.HasThis)
+            {
+                if (instance is CrossBindingAdaptorType)
+                    instance = ((CrossBindingAdaptorType)instance).ILInstance;
+                if (instance == null)
+                    throw new NullReferenceException("instance should not be null!");
                 esp = PushObject(esp, mStack, instance);
+            }
             esp = PushParameters(method, esp, p);
             bool unhandledException;
             esp = Execute(method, esp, out unhandledException);
-            object result = method.ReturnType != domain.VoidType ? method.ReturnType.TypeForCLR.CheckCLRTypes(domain, StackObject.ToObject((esp - 1), domain, mStack)) : null;
+            object result = method.ReturnType != domain.VoidType ? method.ReturnType.TypeForCLR.CheckCLRTypes(StackObject.ToObject((esp - 1), domain, mStack)) : null;
             //ClearStack
             mStack.RemoveRange(mStackBase, mStack.Count - mStackBase);
             return result;
@@ -79,8 +85,14 @@ namespace ILRuntime.Runtime.Intepreter
             if (method == null)
                 throw new NullReferenceException();
 #if UNITY_EDITOR
-            if(System.Threading.Thread.CurrentThread.ManagedThreadId == AppDomain.UnityMainThreadID)
+            if (System.Threading.Thread.CurrentThread.ManagedThreadId == AppDomain.UnityMainThreadID)
+
+#if UNITY_5_5_OR_NEWER
                 UnityEngine.Profiling.Profiler.BeginSample(method.ToString());
+#else
+                UnityEngine.Profiler.BeginSample(method.ToString());
+#endif
+
 #endif
             OpCode[] body = method.Body;
             StackFrame frame;
@@ -128,7 +140,7 @@ namespace ILRuntime.Runtime.Intepreter
             //Managed Stack reserved for local variable
             for (int i = 0; i < method.LocalVariableCount; i++)
             {
-                var v = method.Definition.Body.Variables[i];
+                var v = method.Variables[i];
                 if (v.VariableType.IsValueType && !v.VariableType.IsPrimitive)
                 {
                     var t = AppDomain.GetType(v.VariableType, method.DeclearingType, method);
@@ -505,7 +517,7 @@ namespace ILRuntime.Runtime.Intepreter
                                                 else
                                                 {
                                                     var t = AppDomain.GetType(ip->TokenInteger);
-                                                    ((CLRType)t).GetField(idx).SetValue(obj, t.TypeForCLR.CheckCLRTypes(AppDomain, StackObject.ToObject(val, AppDomain, mStack)));
+                                                    ((CLRType)t).GetField(idx).SetValue(obj, t.TypeForCLR.CheckCLRTypes(StackObject.ToObject(val, AppDomain, mStack)));
                                                 }
                                             }
                                             break;
@@ -518,7 +530,7 @@ namespace ILRuntime.Runtime.Intepreter
                                                 }
                                                 else
                                                 {
-                                                    ((CLRType)t).GetField(objRef->ValueLow).SetValue(null, t.TypeForCLR.CheckCLRTypes(AppDomain, StackObject.ToObject(val, AppDomain, mStack)));
+                                                    ((CLRType)t).GetField(objRef->ValueLow).SetValue(null, t.TypeForCLR.CheckCLRTypes(StackObject.ToObject(val, AppDomain, mStack)));
                                                 }
                                             }
                                             break;
@@ -975,6 +987,25 @@ namespace ILRuntime.Runtime.Intepreter
                                     esp++;
                                 }
                                 break;
+                            case OpCodeEnum.Div_Un:
+                                {
+                                    StackObject* b = esp - 1;
+                                    StackObject* a = esp - 1 - 1;
+                                    esp = a;
+                                    switch (a->ObjectType)
+                                    {
+                                        case ObjectTypes.Long:
+                                            *((ulong*)&esp->Value) = *((ulong*)&a->Value) / *((ulong*)&b->Value);
+                                            break;
+                                        case ObjectTypes.Integer:
+                                            esp->Value = (int)((uint)a->Value / (uint)b->Value);
+                                            break;
+                                        default:
+                                            throw new NotImplementedException();
+                                    }
+                                    esp++;
+                                }
+                                break;
                             case OpCodeEnum.Rem:
                                 {
                                     StackObject* b = esp - 1;
@@ -1663,6 +1694,8 @@ namespace ILRuntime.Runtime.Intepreter
                                                     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;
                                                 }
                                                 esp = Execute(ilm, esp, out unhandledException);
@@ -1696,13 +1729,23 @@ namespace ILRuntime.Runtime.Intepreter
                                                         throw new NotSupportedException(cm.ToString() + " is not bound!");
 #endif
 #if UNITY_EDITOR
-                                                    if(System.Threading.Thread.CurrentThread.ManagedThreadId == AppDomain.UnityMainThreadID)
-														UnityEngine.Profiling.Profiler.BeginSample(cm.ToString());
+                                                    if (System.Threading.Thread.CurrentThread.ManagedThreadId == AppDomain.UnityMainThreadID)
+
+#if UNITY_5_5_OR_NEWER
+                                                        UnityEngine.Profiling.Profiler.BeginSample(cm.ToString());
+#else
+                                                        UnityEngine.Profiler.BeginSample(cm.ToString());
+#endif
 #endif
                                                     object result = cm.Invoke(this, esp, mStack);
 #if UNITY_EDITOR
-                                                    if(System.Threading.Thread.CurrentThread.ManagedThreadId == AppDomain.UnityMainThreadID)
-														UnityEngine.Profiling.Profiler.EndSample();
+                                                    if (System.Threading.Thread.CurrentThread.ManagedThreadId == AppDomain.UnityMainThreadID)
+#if UNITY_5_5_OR_NEWER
+                                                        UnityEngine.Profiling.Profiler.EndSample();
+#else
+                                                        UnityEngine.Profiler.EndSample();
+#endif
+
 #endif
                                                     if (result is CrossBindingAdaptorType)
                                                         result = ((CrossBindingAdaptorType)result).ILInstance;
@@ -1733,47 +1776,9 @@ namespace ILRuntime.Runtime.Intepreter
                             #region FieldOperation
                             case OpCodeEnum.Stfld:
                                 {
-                                    StackObject* objRef = GetObjectAndResolveReference(esp - 1 - 1);
-                                    if (objRef->ObjectType == ObjectTypes.Null)
-                                        throw new NullReferenceException();
-                                    object obj = null;
-                                    switch (objRef->ObjectType)
-                                    {
-                                        case ObjectTypes.Object:
-                                            obj = mStack[objRef->Value];
-                                            break;
-                                        case ObjectTypes.FieldReference:
-                                            {
-                                                obj = mStack[objRef->Value];
-                                                int idx = objRef->ValueLow;
-                                                if (obj is ILTypeInstance)
-                                                {
-                                                    obj = ((ILTypeInstance)obj)[idx];
-                                                }
-                                                else
-                                                {
-                                                    var t = AppDomain.GetType(obj.GetType());
-                                                    obj = ((CLRType)t).GetField(idx).GetValue(obj);
-                                                }
-                                            }
-                                            break;
-                                        case ObjectTypes.StaticFieldReference:
-                                            {
-                                                var t = AppDomain.GetType(objRef->Value);
-                                                int idx = objRef->ValueLow;
-                                                if (t is ILType)
-                                                {
-                                                    obj = ((ILType)t).StaticInstance[idx];
-                                                }
-                                                else
-                                                {
-                                                    obj = ((CLRType)t).GetField(idx).GetValue(null);
-                                                }
-                                            }
-                                            break;
-                                        default:
-                                            throw new NotImplementedException();
-                                    }
+                                    var objRef = GetObjectAndResolveReference(esp - 1 - 1);
+                                    object obj = RetriveObject(objRef, mStack);
+
                                     if (obj != null)
                                     {
                                         if (obj is ILTypeInstance)
@@ -1790,7 +1795,7 @@ namespace ILRuntime.Runtime.Intepreter
                                             {
                                                 var val = esp - 1;
                                                 var f = ((CLRType)type).GetField(ip->TokenInteger);
-                                                f.SetValue(obj, f.FieldType.CheckCLRTypes(domain, CheckAndCloneValueType(StackObject.ToObject(val, domain, mStack), domain)));
+                                                f.SetValue(obj, f.FieldType.CheckCLRTypes(CheckAndCloneValueType(StackObject.ToObject(val, domain, mStack), domain)));
                                                 //Writeback
                                                 if (t.IsValueType)
                                                 {
@@ -1804,7 +1809,7 @@ namespace ILRuntime.Runtime.Intepreter
                                                                 int idx = objRef->ValueLow;
                                                                 if (oldObj is ILTypeInstance)
                                                                 {
-                                                                    oldObj = ((ILTypeInstance)oldObj)[idx];
+                                                                    ((ILTypeInstance)oldObj)[idx] = obj;
                                                                 }
                                                                 else
                                                                 {
@@ -1846,46 +1851,7 @@ namespace ILRuntime.Runtime.Intepreter
                             case OpCodeEnum.Ldfld:
                                 {
                                     StackObject* objRef = GetObjectAndResolveReference(esp - 1);
-                                    if (objRef->ObjectType == ObjectTypes.Null)
-                                        throw new NullReferenceException();
-                                    object obj = null;
-                                    switch (objRef->ObjectType)
-                                    {
-                                        case ObjectTypes.Object:
-                                            obj = mStack[objRef->Value];
-                                            break;
-                                        case ObjectTypes.FieldReference:
-                                            {
-                                                obj = mStack[objRef->Value];
-                                                int idx = objRef->ValueLow;
-                                                if (obj is ILTypeInstance)
-                                                {
-                                                    obj = ((ILTypeInstance)obj)[idx];
-                                                }
-                                                else
-                                                {
-                                                    var t = AppDomain.GetType(obj.GetType());
-                                                    obj = ((CLRType)t).GetField(idx).GetValue(obj);
-                                                }
-                                            }
-                                            break;
-                                        case ObjectTypes.StaticFieldReference:
-                                            {
-                                                var t = AppDomain.GetType(objRef->Value);
-                                                int idx = objRef->ValueLow;
-                                                if (t is ILType)
-                                                {
-                                                    obj = ((ILType)t).StaticInstance[idx];
-                                                }
-                                                else
-                                                {
-                                                    obj = ((CLRType)t).GetField(idx).GetValue(null);
-                                                }
-                                            }
-                                            break;
-                                        default:
-                                            throw new NotImplementedException();
-                                    }
+                                    object obj = RetriveObject(objRef, mStack);
                                     Free(esp - 1);
                                     if (obj != null)
                                     {
@@ -1900,10 +1866,11 @@ namespace ILRuntime.Runtime.Intepreter
                                             var type = AppDomain.GetType(t);
                                             if (type != null)
                                             {
-                                                var val = ((CLRType)type).GetField(ip->TokenInteger).GetValue(obj);
+                                                var ft = ((CLRType)type).GetField(ip->TokenInteger);
+                                                var val = ft.GetValue(obj);
                                                 if (val is CrossBindingAdaptorType)
                                                     val = ((CrossBindingAdaptorType)val).ILInstance;
-                                                PushObject(esp - 1, mStack, val);
+                                                PushObject(esp - 1, mStack, val, ft.FieldType == typeof(object));
                                             }
                                             else
                                                 throw new TypeLoadException();
@@ -1917,46 +1884,8 @@ namespace ILRuntime.Runtime.Intepreter
                             case OpCodeEnum.Ldflda:
                                 {
                                     StackObject* objRef = GetObjectAndResolveReference(esp - 1);
-                                    if (objRef->ObjectType == ObjectTypes.Null)
-                                        throw new NullReferenceException();
-                                    object obj = null;
-                                    switch (objRef->ObjectType)
-                                    {
-                                        case ObjectTypes.Object:
-                                            obj = mStack[objRef->Value];
-                                            break;
-                                        case ObjectTypes.FieldReference:
-                                            {
-                                                obj = mStack[objRef->Value];
-                                                int idx = objRef->ValueLow;
-                                                if (obj is ILTypeInstance)
-                                                {
-                                                    obj = ((ILTypeInstance)obj)[idx];
-                                                }
-                                                else
-                                                {
-                                                    var t = AppDomain.GetType(obj.GetType());
-                                                    obj = ((CLRType)t).GetField(idx).GetValue(obj);
-                                                }
-                                            }
-                                            break;
-                                        case ObjectTypes.StaticFieldReference:
-                                            {
-                                                var t = AppDomain.GetType(objRef->Value);
-                                                int idx = objRef->ValueLow;
-                                                if (t is ILType)
-                                                {
-                                                    obj = ((ILType)t).StaticInstance[idx];
-                                                }
-                                                else
-                                                {
-                                                    obj = ((CLRType)t).GetField(idx).GetValue(null);
-                                                }
-                                            }
-                                            break;
-                                        default:
-                                            throw new NotImplementedException();
-                                    }
+                                    object obj = RetriveObject(objRef, mStack);
+
                                     Free(esp - 1);
                                     if (obj != null)
                                     {
@@ -1995,7 +1924,7 @@ namespace ILRuntime.Runtime.Intepreter
                                             int idx = (int)ip->TokenLong;
                                             var f = t.GetField(idx);
                                             StackObject* val = esp - 1;
-                                            f.SetValue(null, f.FieldType.CheckCLRTypes(domain, CheckAndCloneValueType(StackObject.ToObject(val, domain, mStack), domain)));
+                                            f.SetValue(null, f.FieldType.CheckCLRTypes(CheckAndCloneValueType(StackObject.ToObject(val, domain, mStack), domain)));
                                         }
                                     }
                                     else
@@ -2022,7 +1951,7 @@ namespace ILRuntime.Runtime.Intepreter
                                             var val = f.GetValue(null);
                                             if (val is CrossBindingAdaptorType)
                                                 val = ((CrossBindingAdaptorType)val).ILInstance;
-                                            PushObject(esp, mStack, val);
+                                            PushObject(esp, mStack, val, f.FieldType == typeof(object));
                                         }
                                     }
                                     else
@@ -2342,59 +2271,67 @@ namespace ILRuntime.Runtime.Intepreter
                                     else
                                     {
                                         CLRMethod cm = (CLRMethod)m;
-                                        if (cm.DeclearingType.IsDelegate)
+                                        //Means new object();
+                                        if (cm == null)
                                         {
-                                            var objRef = GetObjectAndResolveReference(esp - 1 - 1);
-                                            var mi = (IMethod)mStack[(esp - 1)->Value];
-                                            object ins;
-                                            if (objRef->ObjectType == ObjectTypes.Null)
-                                                ins = null;
-                                            else
-                                                ins = mStack[objRef->Value];
-                                            Free(esp - 1);
-                                            Free(esp - 1 - 1);
-                                            esp = esp - 1 - 1;
-                                            object dele;
-                                            if (mi is ILMethod)
+                                            esp = PushObject(esp, mStack, new object());
+                                        }
+                                        else
+                                        {
+                                            if (cm.DeclearingType.IsDelegate)
                                             {
-                                                if (ins != null)
-                                                {
-                                                    dele = ((ILTypeInstance)ins).GetDelegateAdapter((ILMethod)mi);
-                                                    if (dele == null)
-                                                        dele = domain.DelegateManager.FindDelegateAdapter((ILTypeInstance)ins, (ILMethod)mi);
-                                                }
+                                                var objRef = GetObjectAndResolveReference(esp - 1 - 1);
+                                                var mi = (IMethod)mStack[(esp - 1)->Value];
+                                                object ins;
+                                                if (objRef->ObjectType == ObjectTypes.Null)
+                                                    ins = null;
                                                 else
+                                                    ins = mStack[objRef->Value];
+                                                Free(esp - 1);
+                                                Free(esp - 1 - 1);
+                                                esp = esp - 1 - 1;
+                                                object dele;
+                                                if (mi is ILMethod)
                                                 {
-                                                    if (((ILMethod)mi).DelegateAdapter == null)
+                                                    if (ins != null)
                                                     {
-                                                        ((ILMethod)mi).DelegateAdapter = domain.DelegateManager.FindDelegateAdapter(null, (ILMethod)mi);
+                                                        dele = ((ILTypeInstance)ins).GetDelegateAdapter((ILMethod)mi);
+                                                        if (dele == null)
+                                                            dele = domain.DelegateManager.FindDelegateAdapter((ILTypeInstance)ins, (ILMethod)mi);
+                                                    }
+                                                    else
+                                                    {
+                                                        if (((ILMethod)mi).DelegateAdapter == null)
+                                                        {
+                                                            ((ILMethod)mi).DelegateAdapter = domain.DelegateManager.FindDelegateAdapter(null, (ILMethod)mi);
+                                                        }
+                                                        dele = ((ILMethod)mi).DelegateAdapter;
                                                     }
-                                                    dele = ((ILMethod)mi).DelegateAdapter;
                                                 }
+                                                else
+                                                {
+                                                    if (ins is ILTypeInstance)
+                                                        ins = ((ILTypeInstance)ins).CLRInstance;
+                                                    dele = Delegate.CreateDelegate(cm.DeclearingType.TypeForCLR, ins, ((CLRMethod)mi).MethodInfo);
+                                                }
+                                                esp = PushObject(esp, mStack, dele);
                                             }
                                             else
                                             {
-                                                if (ins is ILTypeInstance)
-                                                    ins = ((ILTypeInstance)ins).CLRInstance;
-                                                dele = Delegate.CreateDelegate(cm.DeclearingType.TypeForCLR, ins, ((CLRMethod)mi).MethodInfo);
-                                            }
-                                            esp = PushObject(esp, mStack, dele);
-                                        }
-                                        else
-                                        {
-                                            var redirect = cm.Redirection;
-                                            if (redirect != null)
-                                                esp = redirect(this, esp, mStack, cm, true);
-                                            else
-                                            {
-                                                object result = cm.Invoke(this, esp, mStack, true);
-                                                int paramCount = cm.ParameterCount;
-                                                for (int i = 1; i <= paramCount; i++)
+                                                var redirect = cm.Redirection;
+                                                if (redirect != null)
+                                                    esp = redirect(this, esp, mStack, cm, true);
+                                                else
                                                 {
-                                                    Free(esp - i);
+                                                    object result = cm.Invoke(this, esp, mStack, true);
+                                                    int paramCount = cm.ParameterCount;
+                                                    for (int i = 1; i <= paramCount; i++)
+                                                    {
+                                                        Free(esp - i);
+                                                    }
+                                                    esp = Minus(esp, paramCount);
+                                                    esp = PushObject(esp, mStack, result);//new constructedObj
                                                 }
-                                                esp = Minus(esp, paramCount);
-                                                esp = PushObject(esp, mStack, result);//new constructedObj
                                             }
                                         }
                                     }
@@ -2402,7 +2339,8 @@ namespace ILRuntime.Runtime.Intepreter
                                 break;
                             case OpCodeEnum.Constrained:
                                 {
-                                    var obj = GetObjectAndResolveReference(esp - 1);
+                                    var objRef = esp - 1;
+                                    var obj = GetObjectAndResolveReference(objRef);
                                     var type = domain.GetType(ip->TokenInteger);
                                     if (type != null)
                                     {
@@ -2412,8 +2350,43 @@ namespace ILRuntime.Runtime.Intepreter
                                             if (t.IsEnum)
                                             {
                                                 ILEnumTypeInstance ins = new ILEnumTypeInstance(t);
-                                                ins.AssignFromStack(0, obj, AppDomain, mStack);
-                                                ins.Boxed = true;
+                                                switch (obj->ObjectType)
+                                                {
+                                                    case ObjectTypes.FieldReference:
+                                                        {
+                                                            var owner = mStack[obj->Value] as ILTypeInstance;
+                                                            int idx = obj->ValueLow;
+                                                            Free(objRef);
+                                                            owner.PushToStack(idx, objRef, AppDomain, mStack);
+                                                            ins.AssignFromStack(0, objRef, AppDomain, mStack);
+                                                            ins.Boxed = true;
+                                                        }
+                                                        break;
+                                                    case ObjectTypes.StaticFieldReference:
+                                                        {
+                                                            var st = AppDomain.GetType(obj->Value) as ILType;
+                                                            int idx = obj->ValueLow;
+                                                            Free(objRef);
+                                                            st.StaticInstance.PushToStack(idx, objRef, AppDomain, mStack);
+                                                            ins.AssignFromStack(0, objRef, AppDomain, mStack);
+                                                            ins.Boxed = true;
+                                                        }
+                                                        break;
+                                                    case ObjectTypes.ArrayReference:
+                                                        {
+                                                            var arr = mStack[obj->Value];
+                                                            var idx = obj->ValueLow;
+                                                            Free(objRef);
+                                                            LoadFromArrayReference(arr, idx, objRef, t, mStack);
+                                                            ins.AssignFromStack(0, objRef, AppDomain, mStack);
+                                                            ins.Boxed = true;
+                                                        }
+                                                        break;
+                                                    default:
+                                                        ins.AssignFromStack(0, obj, AppDomain, mStack);
+                                                        ins.Boxed = true;
+                                                        break;
+                                                }
                                                 esp = PushObject(esp - 1, mStack, ins);
                                             }
                                             else
@@ -2423,9 +2396,14 @@ namespace ILRuntime.Runtime.Intepreter
                                         }
                                         else
                                         {
-                                            if (type.TypeForCLR.IsEnum)
+                                            var tt = type.TypeForCLR;
+                                            if (tt.IsEnum)
+                                            {
+                                                esp = PushObject(esp - 1, mStack, Enum.ToObject(tt, StackObject.ToObject(obj, AppDomain, mStack)));
+                                            }
+                                            else if (tt.IsPrimitive)
                                             {
-                                                esp = PushObject(esp - 1, mStack, Enum.ToObject(type.TypeForCLR, StackObject.ToObject(obj, AppDomain, mStack)));
+                                                esp = PushObject(esp - 1, mStack, tt.CheckCLRTypes(StackObject.ToObject(obj, AppDomain, mStack)));
                                             }
                                             else
                                             {
@@ -2531,7 +2509,7 @@ namespace ILRuntime.Runtime.Intepreter
                                                             esp = PushObject(obj, mStack, (short)obj->Value, true);
                                                             break;
                                                         case ObjectTypes.Null:
-                                                            esp = PushObject(obj, mStack, 0L, true);
+                                                            esp = PushObject(obj, mStack, (short)0, true);
                                                             break;
                                                         default:
                                                             throw new NotImplementedException();
@@ -2579,6 +2557,17 @@ namespace ILRuntime.Runtime.Intepreter
                                                             throw new NotImplementedException();
                                                     }
                                                 }
+                                                else if (t == typeof(char))
+                                                {
+                                                    switch (obj->ObjectType)
+                                                    {
+                                                        case ObjectTypes.Integer:
+                                                            esp = PushObject(obj, mStack, (char)obj->Value, true);
+                                                            break;
+                                                        default:
+                                                            throw new NotImplementedException();
+                                                    }
+                                                }
                                                 else if (t == typeof(uint))
                                                 {
                                                     switch (obj->ObjectType)
@@ -2587,7 +2576,7 @@ namespace ILRuntime.Runtime.Intepreter
                                                             esp = PushObject(obj, mStack, (uint)obj->Value, true);
                                                             break;
                                                         case ObjectTypes.Null:
-                                                            esp = PushObject(obj, mStack, 0L, true);
+                                                            esp = PushObject(obj, mStack, (uint)0, true);
                                                             break;
                                                         default:
                                                             throw new NotImplementedException();
@@ -2601,7 +2590,7 @@ namespace ILRuntime.Runtime.Intepreter
                                                             esp = PushObject(obj, mStack, (ushort)obj->Value, true);
                                                             break;
                                                         case ObjectTypes.Null:
-                                                            esp = PushObject(obj, mStack, 0L, true);
+                                                            esp = PushObject(obj, mStack, (ushort)0, true);
                                                             break;
                                                         default:
                                                             throw new NotImplementedException();
@@ -2615,7 +2604,7 @@ namespace ILRuntime.Runtime.Intepreter
                                                             esp = PushObject(obj, mStack, *(ulong*)&obj->Value, true);
                                                             break;
                                                         case ObjectTypes.Null:
-                                                            esp = PushObject(obj, mStack, 0L, true);
+                                                            esp = PushObject(obj, mStack, (ulong)0, true);
                                                             break;
                                                         default:
                                                             throw new NotImplementedException();
@@ -2629,7 +2618,7 @@ namespace ILRuntime.Runtime.Intepreter
                                                             esp = PushObject(obj, mStack, (sbyte)obj->Value, true);
                                                             break;
                                                         case ObjectTypes.Null:
-                                                            esp = PushObject(obj, mStack, 0L, true);
+                                                            esp = PushObject(obj, mStack, (sbyte)0, true);
                                                             break;
                                                         default:
                                                             throw new NotImplementedException();
@@ -2710,6 +2699,12 @@ namespace ILRuntime.Runtime.Intepreter
                                                         objRef->ObjectType = ObjectTypes.Double;
                                                         *(double*)&objRef->Value = val;
                                                     }
+                                                    else if (type == typeof(char))
+                                                    {
+                                                        char val = (char)obj;
+                                                        objRef->ObjectType = ObjectTypes.Integer;
+                                                        *(char*)&objRef->Value = val;
+                                                    }
                                                     else if (type == typeof(uint))
                                                     {
                                                         uint val = (uint)obj;
@@ -2851,58 +2846,48 @@ namespace ILRuntime.Runtime.Intepreter
                                     var type = domain.GetType(ip->TokenInteger);
                                     if (type != null)
                                     {
-                                        if (objRef->ObjectType != ObjectTypes.Null)
+                                        var obj = RetriveObject(objRef, mStack);
+                                        Free(objRef);
+
+                                        if (obj != null)
                                         {
-                                            var obj = mStack[objRef->Value];
-                                            Free(objRef);
-                                            if (obj != null)
+                                            if (obj is ILTypeInstance)
                                             {
-                                                if (obj is ILTypeInstance)
+                                                if (((ILTypeInstance)obj).CanAssignTo(type))
                                                 {
-                                                    if (((ILTypeInstance)obj).CanAssignTo(type))
-                                                    {
-                                                        esp = PushObject(objRef, mStack, obj);
-                                                    }
-                                                    else
-                                                    {
-#if !DEBUG
-                                                    objRef->ObjectType = ObjectTypes.Null;
-                                                    objRef->Value = -1;
-                                                    objRef->ValueLow = 0;
-#endif
-                                                    }
+                                                    esp = PushObject(objRef, mStack, obj);
                                                 }
                                                 else
                                                 {
-                                                    if (type.TypeForCLR.IsAssignableFrom(obj.GetType()))
-                                                    {
-                                                        esp = PushObject(objRef, mStack, obj, true);
-                                                    }
-                                                    else
-                                                    {
 #if !DEBUG
                                                     objRef->ObjectType = ObjectTypes.Null;
                                                     objRef->Value = -1;
                                                     objRef->ValueLow = 0;
 #endif
-                                                    }
                                                 }
                                             }
                                             else
                                             {
+                                                if (type.TypeForCLR.IsAssignableFrom(obj.GetType()))
+                                                {
+                                                    esp = PushObject(objRef, mStack, obj, true);
+                                                }
+                                                else
+                                                {
 #if !DEBUG
-                                                objRef->ObjectType = ObjectTypes.Null;
-                                                objRef->Value = -1;
-                                                objRef->ValueLow = 0;
+                                                    objRef->ObjectType = ObjectTypes.Null;
+                                                    objRef->Value = -1;
+                                                    objRef->ValueLow = 0;
 #endif
+                                                }
                                             }
                                         }
                                         else
                                         {
 #if !DEBUG
-                                            objRef->ObjectType = ObjectTypes.Null;
-                                            objRef->Value = -1;
-                                            objRef->ValueLow = 0;
+                                                objRef->ObjectType = ObjectTypes.Null;
+                                                objRef->Value = -1;
+                                                objRef->ValueLow = 0;
 #endif
                                         }
                                     }
@@ -2923,6 +2908,8 @@ namespace ILRuntime.Runtime.Intepreter
                                         if (type.TypeForCLR != typeof(ILTypeInstance))
                                         {
                                             arr = Array.CreateInstance(type.TypeForCLR, cnt->Value);
+                                            //Register Type
+                                            AppDomain.GetType(arr.GetType());
                                         }
                                         else
                                         {
@@ -2935,21 +2922,9 @@ namespace ILRuntime.Runtime.Intepreter
                                 }
                                 break;
                             case OpCodeEnum.Stelem_Ref:
-                                {
-                                    var val = esp - 1;
-                                    var idx = esp - 1 - 1;
-                                    var arrRef = esp - 1 - 1 - 1;
-                                    Array arr = mStack[arrRef->Value] as Array;
-                                    ArraySetValue(arr, mStack[val->Value], idx->Value);
-                                    Free(esp - 1);
-                                    Free(esp - 1 - 1);
-                                    Free(esp - 1 - 1 - 1);
-                                    esp = esp - 1 - 1 - 1;
-                                }
-                                break;
                             case OpCodeEnum.Stelem_Any:
                                 {
-                                    var val = esp - 1;
+                                    var val = GetObjectAndResolveReference(esp - 1);
                                     var idx = esp - 1 - 1;
                                     var arrRef = esp - 1 - 1 - 1;
                                     Array arr = mStack[arrRef->Value] as Array;
@@ -2957,6 +2932,9 @@ namespace ILRuntime.Runtime.Intepreter
                                     {
                                         switch (val->ObjectType)
                                         {
+                                            case ObjectTypes.Null:
+                                                arr.SetValue(null, idx->Value);
+                                                break;
                                             case ObjectTypes.Object:
                                                 ArraySetValue(arr, mStack[val->Value], idx->Value);
                                                 break;
@@ -2990,7 +2968,7 @@ namespace ILRuntime.Runtime.Intepreter
                                                 break;
                                             case ObjectTypes.Long:
                                                 {
-                                                    if(arr is long[])
+                                                    if (arr is long[])
                                                     {
                                                         ((long[])arr)[idx->Value] = *(long*)&val->Value;
                                                     }
@@ -3598,7 +3576,42 @@ namespace ILRuntime.Runtime.Intepreter
                                     *(double*)&obj->Value = val;
                                 }
                                 break;
-
+                            case OpCodeEnum.Conv_R_Un:
+                                {
+                                    var obj = esp - 1;
+                                    bool isDouble = false;
+                                    float val = 0;
+                                    double val2 = 0;
+                                    switch (obj->ObjectType)
+                                    {
+                                        case ObjectTypes.Long:
+                                            val2 = (double)*(ulong*)&obj->Value;
+                                            isDouble = true;
+                                            break;
+                                        case ObjectTypes.Float:
+                                            ip++;
+                                            continue;
+                                        case ObjectTypes.Integer:
+                                            val = (uint)obj->Value;
+                                            break;
+                                        case ObjectTypes.Double:
+                                            ip++;
+                                            continue;
+                                        default:
+                                            throw new NotImplementedException();
+                                    }
+                                    if (isDouble)
+                                    {
+                                        obj->ObjectType = ObjectTypes.Double;
+                                        *(double*)&obj->Value = val2;
+                                    }
+                                    else
+                                    {
+                                        obj->ObjectType = ObjectTypes.Float;
+                                        *(float*)&obj->Value = val;
+                                    }
+                                }
+                                break;
                             #endregion
 
                             #region Stack operation
@@ -3706,19 +3719,77 @@ namespace ILRuntime.Runtime.Intepreter
                 }
             }
 #if UNITY_EDITOR
-            if(System.Threading.Thread.CurrentThread.ManagedThreadId == AppDomain.UnityMainThreadID)
-				UnityEngine.Profiling.Profiler.EndSample();
+            if (System.Threading.Thread.CurrentThread.ManagedThreadId == AppDomain.UnityMainThreadID)
+#if UNITY_5_5_OR_NEWER
+                UnityEngine.Profiling.Profiler.EndSample();
+#else
+                UnityEngine.Profiler.EndSample();
+#endif
 #endif
             //ClearStack
             return stack.PopFrame(ref frame, esp, mStack);
         }
 
+        object RetriveObject(StackObject* esp, List<object> mStack)
+        {
+            StackObject* objRef = GetObjectAndResolveReference(esp);
+            if (objRef->ObjectType == ObjectTypes.Null)
+                return null;
+            object obj = null;
+            switch (objRef->ObjectType)
+            {
+                case ObjectTypes.Object:
+                    obj = mStack[objRef->Value];
+                    break;
+                case ObjectTypes.FieldReference:
+                    {
+                        obj = mStack[objRef->Value];
+                        int idx = objRef->ValueLow;
+                        if (obj is ILTypeInstance)
+                        {
+                            obj = ((ILTypeInstance)obj)[idx];
+                        }
+                        else
+                        {
+                            var t = AppDomain.GetType(obj.GetType());
+                            obj = ((CLRType)t).GetField(idx).GetValue(obj);
+                        }
+                    }
+                    break;
+                case ObjectTypes.ArrayReference:
+                    {
+                        Array arr = mStack[objRef->Value] as Array;
+                        int idx = objRef->ValueLow;
+                        obj = arr.GetValue(idx);
+                        obj = obj.GetType().CheckCLRTypes(obj);
+                    }
+                    break;
+                case ObjectTypes.StaticFieldReference:
+                    {
+                        var t = AppDomain.GetType(objRef->Value);
+                        int idx = objRef->ValueLow;
+                        if (t is ILType)
+                        {
+                            obj = ((ILType)t).StaticInstance[idx];
+                        }
+                        else
+                        {
+                            obj = ((CLRType)t).GetField(idx).GetValue(null);
+                        }
+                    }
+                    break;
+                default:
+                    throw new NotImplementedException();
+            }
+            return obj;
+        }
+
         void ArraySetValue(Array arr, object obj, int idx)
         {
             if (obj == null)
                 arr.SetValue(null, idx);
             else
-                arr.SetValue(obj.GetType().CheckCLRTypes(AppDomain, obj), idx);
+                arr.SetValue(arr.GetType().GetElementType().CheckCLRTypes(obj), idx);
         }
 
         void StoreIntValueToArray(Array arr, StackObject* val, StackObject* idx)
@@ -3733,7 +3804,7 @@ namespace ILRuntime.Runtime.Intepreter
             }
             {
                 short[] tmp = arr as short[];
-                if(tmp != null)
+                if (tmp != null)
                 {
                     tmp[idx->Value] = (short)val->Value;
                     return;
@@ -3818,7 +3889,7 @@ namespace ILRuntime.Runtime.Intepreter
 
         void LoadFromFieldReference(object obj, int idx, StackObject* dst, List<object> mStack)
         {
-            if(obj is ILTypeInstance)
+            if (obj is ILTypeInstance)
             {
                 ((ILTypeInstance)obj).PushToStack(idx, dst, AppDomain, mStack);
             }
@@ -3840,12 +3911,12 @@ namespace ILRuntime.Runtime.Intepreter
             {
                 CLRType t = AppDomain.GetType(obj.GetType()) as CLRType;
                 var fi = t.GetField(idx);
-                var v = obj.GetType().CheckCLRTypes(AppDomain, CheckAndCloneValueType(StackObject.ToObject(val, AppDomain, mStack), AppDomain));
+                var v = obj.GetType().CheckCLRTypes(CheckAndCloneValueType(StackObject.ToObject(val, AppDomain, mStack), AppDomain));
                 fi.SetValue(obj, v);
             }
         }
 
-        void LoadFromArrayReference(object obj,int idx, StackObject* objRef, IType t, List<object> mStack)
+        void LoadFromArrayReference(object obj, int idx, StackObject* objRef, IType t, List<object> mStack)
         {
             var nT = t.TypeForCLR;
             LoadFromArrayReference(obj, idx, objRef, nT, mStack);
@@ -3936,7 +4007,7 @@ namespace ILRuntime.Runtime.Intepreter
             var nT = t.TypeForCLR;
             StoreValueToArrayReference(objRef, val, nT, mStack);
         }
-        
+
         void StoreValueToArrayReference(StackObject* objRef, StackObject* val, Type nT, List<object> mStack)
         {
             if (nT.IsPrimitive)
@@ -4022,12 +4093,13 @@ namespace ILRuntime.Runtime.Intepreter
         StackObject* PushParameters(IMethod method, StackObject* esp, object[] p)
         {
             List<object> mStack = stack.ManagedStack;
-            if (p != null && p.Length > 0)
+            var plist = method.Parameters;
+            int pCnt = plist != null ? plist.Count : 0;
+            int pCnt2 = p != null ? p.Length : 0;
+            if (pCnt != pCnt2)
+                throw new ArgumentOutOfRangeException("Parameter mismatch");
+            if (pCnt2 > 0)
             {
-                var plist = method.Parameters;
-                int pCnt = plist != null ? plist.Count : 0;
-                if (pCnt != p.Length)
-                    throw new ArgumentOutOfRangeException();
                 for (int i = 0; i < p.Length; i++)
                 {
                     bool isBox = false;

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

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

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

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

+ 20 - 21
Unity/Assets/ILRuntime/ILRuntime/Runtime/Intepreter/ILTypeInstance.cs

@@ -135,13 +135,13 @@ namespace ILRuntime.Runtime.Intepreter
 
         public List<object> ManagedObjects { get { return managedObjs; } }
 
-        public object CLRInstance { get { return clrInstance; } }
+        public object CLRInstance { get { return clrInstance; } set { clrInstance = value; } }
 
         protected ILTypeInstance()
         {
 
         }
-        public ILTypeInstance(ILType type)
+        public ILTypeInstance(ILType type, bool initializeCLRInstance = true)
         {
             this.type = type;
             fields = new StackObject[type.TotalFieldCount];
@@ -151,30 +151,27 @@ namespace ILRuntime.Runtime.Intepreter
                 managedObjs.Add(null);
             }
             InitializeFields(type);
-            if (type.FirstCLRBaseType is Enviorment.CrossBindingAdaptor)
+            if (initializeCLRInstance)
             {
-                clrInstance = ((Enviorment.CrossBindingAdaptor)type.FirstCLRBaseType).CreateCLRInstance(type.AppDomain, this);
-            }
-            else
-            {
-                clrInstance = this;
-            }
-
-            if (type.Implements != null)
-            {
-                foreach (var i in type.Implements)
+                if (type.FirstCLRBaseType is Enviorment.CrossBindingAdaptor)
                 {
-                    if (i is Enviorment.CrossBindingAdaptor)
+                    clrInstance = ((Enviorment.CrossBindingAdaptor)type.FirstCLRBaseType).CreateCLRInstance(type.AppDomain, this);
+                }
+                else
+                {
+                    clrInstance = this;
+                }
+                if(type.FirstCLRInterface is Enviorment.CrossBindingAdaptor)
+                {
+                    if (clrInstance != this)//Only one CLRInstance is allowed atm, so implementing multiple interfaces is not supported
                     {
-                        if (clrInstance != this)//Only one CLRInstance is allowed atm, so implementing multiple interfaces is not supported
-                        {
-                            throw new NotSupportedException("Inheriting and implementing interface at the same time is not supported yet");
-                        }
-                        clrInstance = ((Enviorment.CrossBindingAdaptor)i).CreateCLRInstance(type.AppDomain, this);
-                        break;
+                        throw new NotSupportedException("Inheriting and implementing interface at the same time is not supported yet");
                     }
+                    clrInstance = ((Enviorment.CrossBindingAdaptor)type.FirstCLRInterface).CreateCLRInstance(type.AppDomain, this);
                 }
             }
+            else
+                clrInstance = this;
         }
 
         public unsafe object this[int index]
@@ -303,7 +300,7 @@ namespace ILRuntime.Runtime.Intepreter
                 {
                     CLRType clrType = appdomain.GetType(((Enviorment.CrossBindingAdaptor)Type.FirstCLRBaseType).BaseCLRType) as CLRType;
                     var field = clrType.GetField(fieldIdx);
-                    field.SetValue(clrInstance, field.FieldType.CheckCLRTypes(appdomain, ILIntepreter.CheckAndCloneValueType(StackObject.ToObject(esp, appdomain, managedStack), appdomain)));
+                    field.SetValue(clrInstance, field.FieldType.CheckCLRTypes(ILIntepreter.CheckAndCloneValueType(StackObject.ToObject(esp, appdomain, managedStack), appdomain)));
                 }
                 else
                     throw new TypeLoadException();
@@ -319,6 +316,8 @@ namespace ILRuntime.Runtime.Intepreter
                 field.Value = fieldIdx;
                 managedObjs[fieldIdx] = ILIntepreter.CheckAndCloneValueType(managedStack[esp->Value], Type.AppDomain);
             }
+            else if (managedObjs != null)
+                managedObjs[fieldIdx] = null;
         }
 
         public override string ToString()

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

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 8e3c8c218911bc64b836907739e04af8
-timeCreated: 1486603951
-licenseType: Pro
+timeCreated: 1496395688
+licenseType: Free
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ILRuntime/ILRuntime/Runtime/Intepreter/OpCodes/OpCode.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 2ef7583a5c2cabb4499ec0d948f9c7bb
-timeCreated: 1486603950
-licenseType: Pro
+timeCreated: 1496395687
+licenseType: Free
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ILRuntime/ILRuntime/Runtime/Intepreter/OpCodes/OpCodeEnum.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 7332c8f3285dcec4cbc6bd1494a4d846
-timeCreated: 1486603951
-licenseType: Pro
+timeCreated: 1496395688
+licenseType: Free
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 1 - 1
Unity/Assets/ILRuntime/ILRuntime/Runtime/Stack/RuntimeStack.cs

@@ -16,7 +16,7 @@ namespace ILRuntime.Runtime.Stack
         IntPtr nativePointer;
         List<object> managedStack = new List<object>(32);
         Stack<StackFrame> frames = new Stack<StackFrame>();
-        const int MAXIMAL_STACK_OBJECTS = 1024 * 128;
+        const int MAXIMAL_STACK_OBJECTS = 1024 * 16;
 
         public Stack<StackFrame> Frames { get { return frames; } }
         public RuntimeStack(ILIntepreter intepreter)

+ 2 - 2
Unity/Assets/ILRuntime/ILRuntime/Runtime/Stack/RuntimeStack.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 55de1685a7e4efa41b7f1f73a81aa07c
-timeCreated: 1486603951
-licenseType: Pro
+timeCreated: 1496395687
+licenseType: Free
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ILRuntime/ILRuntime/Runtime/Stack/StackFrame.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 7394a29fd3deece4ea7c3d67f055faca
-timeCreated: 1486603951
-licenseType: Pro
+timeCreated: 1496395688
+licenseType: Free
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ILRuntime/ILRuntime/Runtime/Stack/StackObject.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 5b8d9c7d873701f46b5f31887c908e61
-timeCreated: 1486603951
-licenseType: Pro
+timeCreated: 1496395687
+licenseType: Free
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ILRuntime/Mono.Cecil.20/MonoCecil/Mono.Cecil.Cil/Code.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 40bcd801e7a1d4c44a8a0fd2eb72617e
-timeCreated: 1486603950
-licenseType: Pro
+timeCreated: 1496395687
+licenseType: Free
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ILRuntime/Mono.Cecil.20/MonoCecil/Mono.Cecil.Cil/CodeReader.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 132761467bbd32d4fa4a028592dca8fc
-timeCreated: 1486603950
-licenseType: Pro
+timeCreated: 1496395686
+licenseType: Free
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ILRuntime/Mono.Cecil.20/MonoCecil/Mono.Cecil.Cil/CodeWriter.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: d3ec49d880028814fa48da946e502290
-timeCreated: 1486603952
-licenseType: Pro
+timeCreated: 1496395689
+licenseType: Free
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ILRuntime/Mono.Cecil.20/MonoCecil/Mono.Cecil.Cil/Document.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: e2b7c3598c4acd8468a789a015751a95
-timeCreated: 1486603952
-licenseType: Pro
+timeCreated: 1496395689
+licenseType: Free
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ILRuntime/Mono.Cecil.20/MonoCecil/Mono.Cecil.Cil/ExceptionHandler.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 21a64ac0bb4ca454a97ca76de8e7e9d6
-timeCreated: 1486603950
-licenseType: Pro
+timeCreated: 1496395687
+licenseType: Free
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ILRuntime/Mono.Cecil.20/MonoCecil/Mono.Cecil.Cil/ILProcessor.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 4646551666f3dff4aab91bb8cecdc72d
-timeCreated: 1486603950
-licenseType: Pro
+timeCreated: 1496395687
+licenseType: Free
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ILRuntime/Mono.Cecil.20/MonoCecil/Mono.Cecil.Cil/Instruction.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 4b72b64dc0086154682d81c571aca5c0
-timeCreated: 1486603950
-licenseType: Pro
+timeCreated: 1496395687
+licenseType: Free
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ILRuntime/Mono.Cecil.20/MonoCecil/Mono.Cecil.Cil/MethodBody.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 06e529fcda5f9094c9e3aef33b4579a7
-timeCreated: 1486603950
-licenseType: Pro
+timeCreated: 1496395686
+licenseType: Free
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ILRuntime/Mono.Cecil.20/MonoCecil/Mono.Cecil.Cil/OpCode.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: b9eba3eb561bcaa4cbb4b7f1e45241e2
-timeCreated: 1486603952
-licenseType: Pro
+timeCreated: 1496395688
+licenseType: Free
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ILRuntime/Mono.Cecil.20/MonoCecil/Mono.Cecil.Cil/OpCodes.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 3860582dd6338404c99c8252ecc18d1a
-timeCreated: 1486603950
-licenseType: Pro
+timeCreated: 1496395687
+licenseType: Free
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ILRuntime/Mono.Cecil.20/MonoCecil/Mono.Cecil.Cil/SequencePoint.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: f391522e276e638409767fb562f8e320
-timeCreated: 1486603953
-licenseType: Pro
+timeCreated: 1496395689
+licenseType: Free
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ILRuntime/Mono.Cecil.20/MonoCecil/Mono.Cecil.Cil/Symbols.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 37a37139bedcb334ba1cbe9291260bfb
-timeCreated: 1486603950
-licenseType: Pro
+timeCreated: 1496395687
+licenseType: Free
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ILRuntime/Mono.Cecil.20/MonoCecil/Mono.Cecil.Cil/VariableDefinition.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 649e2b8d9b4e1184b89a2b297f2ec453
-timeCreated: 1486603951
-licenseType: Pro
+timeCreated: 1496395687
+licenseType: Free
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ILRuntime/Mono.Cecil.20/MonoCecil/Mono.Cecil.Cil/VariableReference.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: a1e5f85ddde180f4ca37f6fc14f7b888
-timeCreated: 1486603951
-licenseType: Pro
+timeCreated: 1496395688
+licenseType: Free
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ILRuntime/Mono.Cecil.20/MonoCecil/Mono.Cecil.Metadata/BlobHeap.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 555efb6b67d765942ba119292afeeb5d
-timeCreated: 1486603951
-licenseType: Pro
+timeCreated: 1496395687
+licenseType: Free
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ILRuntime/Mono.Cecil.20/MonoCecil/Mono.Cecil.Metadata/Buffers.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 90d87ffd25c230e4e9483cb4406b6763
-timeCreated: 1486603951
-licenseType: Pro
+timeCreated: 1496395688
+licenseType: Free
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ILRuntime/Mono.Cecil.20/MonoCecil/Mono.Cecil.Metadata/CodedIndex.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 9265deb103a79a149b2cd0567b36901f
-timeCreated: 1486603951
-licenseType: Pro
+timeCreated: 1496395688
+licenseType: Free
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

+ 2 - 2
Unity/Assets/ILRuntime/Mono.Cecil.20/MonoCecil/Mono.Cecil.Metadata/ElementType.cs.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
 guid: 0b4fde6b99549df479e4380c17beb6a1
-timeCreated: 1486603950
-licenseType: Pro
+timeCreated: 1496395686
+licenseType: Free
 MonoImporter:
   serializedVersion: 2
   defaultReferences: []

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů