示例#1
0
        public void FixName(ValueReference val, ObjectValue oval)
        {
            KeyValuePair <ObjectValue, ValueReference> other;

            if (names.TryGetValue(oval.Name, out other))
            {
                object tn = val.DeclaringType;
                if (tn != null)
                {
                    oval.Name += " (" + ctx.Adapter.GetDisplayTypeName(ctx, tn) + ")";
                }
                if (!other.Key.Name.EndsWith(")"))
                {
                    tn = other.Value.DeclaringType;
                    if (tn != null)
                    {
                        other.Key.Name += " (" + ctx.Adapter.GetDisplayTypeName(ctx, tn) + ")";
                    }
                }
            }
            else
            {
                names [oval.Name] = new KeyValuePair <ObjectValue, ValueReference> (oval, val);
            }
        }
示例#2
0
 public ObjectValue GetExpressionValue(EvaluationContext ctx, string exp)
 {
     try {
         ValueReference var = ctx.Evaluator.Evaluate(ctx, exp);
         if (var != null)
         {
             return(var.CreateObjectValue(ctx.Options));
         }
         else
         {
             return(ObjectValue.CreateUnknown(exp));
         }
     }
     catch (ImplicitEvaluationDisabledException) {
         return(ObjectValue.CreateImplicitNotSupported(ctx.ExpressionValueSource, new ObjectPath(exp), "", ObjectValueFlags.None));
     }
     catch (NotSupportedExpressionException ex) {
         return(ObjectValue.CreateNotSupported(ctx.ExpressionValueSource, new ObjectPath(exp), ex.Message, "", ObjectValueFlags.None));
     }
     catch (EvaluatorException ex) {
         return(ObjectValue.CreateError(ctx.ExpressionValueSource, new ObjectPath(exp), "", ex.Message, ObjectValueFlags.None));
     }
     catch (Exception ex) {
         ctx.WriteDebuggerError(ex);
         return(ObjectValue.CreateUnknown(exp));
     }
 }
示例#3
0
        ObjectValue GetStackTrace(EvaluationOptions options)
        {
            ValueReference st = exception.GetChild("StackTrace", options);

            if (st == null)
            {
                return(ObjectValue.CreateUnknown("StackTrace"));
            }
            string trace = st.ObjectValue as string;

            if (trace == null)
            {
                return(ObjectValue.CreateUnknown("StackTrace"));
            }

            List <ObjectValue> frames = new List <ObjectValue> ();

            foreach (string sframe in trace.Split('\n'))
            {
                string        txt      = sframe.Trim(' ', '\r', '\n');
                string        file     = "";
                int           line     = 0;
                int           col      = 0;
                ObjectValue   fileVal  = ObjectValue.CreatePrimitive(null, new ObjectPath("File"), "", new EvaluationResult(file), ObjectValueFlags.None);
                ObjectValue   lineVal  = ObjectValue.CreatePrimitive(null, new ObjectPath("Line"), "", new EvaluationResult(line.ToString()), ObjectValueFlags.None);
                ObjectValue   colVal   = ObjectValue.CreatePrimitive(null, new ObjectPath("Col"), "", new EvaluationResult(col.ToString()), ObjectValueFlags.None);
                ObjectValue[] children = new ObjectValue[] { fileVal, lineVal, colVal };
                ObjectValue   frame    = ObjectValue.CreateObject(null, new ObjectPath(), "", new EvaluationResult(txt), ObjectValueFlags.None, children);
                frames.Add(frame);
            }
            return(ObjectValue.CreateArray(null, new ObjectPath("StackTrace"), "", frames.Count, ObjectValueFlags.None, frames.ToArray()));
        }
示例#4
0
        EvaluationResult IObjectValueSource.SetValue(ObjectPath path, string value, EvaluationOptions options)
        {
            try
            {
                ctx.WaitRuntimeInvokes();
                EvaluationContext cctx = GetContext(options);
                cctx.Options.AllowMethodEvaluation = true;
                cctx.Options.AllowTargetInvoke     = true;
                ValueReference vref     = cctx.Evaluator.Evaluate(cctx, value, Type);
                object         newValue = cctx.Adapter.Convert(cctx, vref.Value, Type);
                Value = newValue;
            }
            catch (Exception ex)
            {
                ctx.WriteDebuggerError(ex);
                ctx.WriteDebuggerOutput("Value assignment failed: {0}: {1}\n", ex.GetType(), ex.Message);
            }

            try
            {
                return(ctx.Evaluator.TargetObjectToExpression(ctx, Value));
            }
            catch (Exception ex)
            {
                ctx.WriteDebuggerError(ex);
                ctx.WriteDebuggerOutput("Value assignment failed: {0}: {1}\n", ex.GetType(), ex.Message);
            }

            return(null);
        }
        string AddToLocals(string name, ValueReference vr, bool shouldRename = false)
        {
            if (localValues.ContainsKey(name))
            {
                return(GetLocalName(name));
            }

            string localName;

            if (shouldRename)
            {
                localName = GenerateSymbol(name);
            }
            else if (!ExistsLocalName(name))
            {
                localName = name;
            }
            else
            {
                throw EvaluationError("Cannot use a variable named {0} inside lambda", name);
            }

            AssertPublicValueReference(vr);

            var valu = vr != null ? vr.Value : null;
            var pair = Tuple.Create(localName, valu);

            localValues.Add(name, pair);
            return(localName);
        }
示例#6
0
        public virtual ValueReference GetChild(string name, EvaluationOptions options)
        {
            object obj = Value;

            if (obj == null)
            {
                return(null);
            }

            if (name[0] == '[' && ctx.Adapter.IsArray(Context, obj))
            {
                // Parse the array indices
                string[] sinds   = name.Substring(1, name.Length - 2).Split(',');
                int[]    indices = new int [sinds.Length];
                for (int n = 0; n < sinds.Length; n++)
                {
                    indices [n] = int.Parse(sinds [n]);
                }

                return(new ArrayValueReference(ctx, obj, indices));
            }

            if (ctx.Adapter.IsClassInstance(Context, obj))
            {
                ValueReference val = ctx.Adapter.GetMember(GetChildrenContext(options), this, obj, name);
                return(val);
            }

            return(null);
        }
示例#7
0
        public EvaluationResult SetValue(ObjectPath path, string value, EvaluationOptions options)
        {
            if (path.Length != 2)
            {
                throw new NotSupportedException();
            }

            int[] idx = StringToIndices(path [1]);

            object val;

            try {
                EvaluationContext cctx = ctx.Clone();
                EvaluationOptions ops  = options ?? cctx.Options;
                ops.AllowMethodEvaluation = true;
                ops.AllowTargetInvoke     = true;
                cctx.Options = ops;
                ValueReference var = ctx.Evaluator.Evaluate(ctx, value, array.ElementType);
                val = var.Value;
                val = ctx.Adapter.Convert(ctx, val, array.ElementType);
                array.SetElement(idx, val);
            } catch {
                val = array.GetElement(idx);
            }
            try {
                return(ctx.Evaluator.TargetObjectToExpression(ctx, val));
            } catch (Exception ex) {
                ctx.WriteDebuggerError(ex);
                return(new EvaluationResult("? (" + ex.Message + ")"));
            }
        }
示例#8
0
        public ValueReference GetMember(EvaluationContext ctx, IObjectSource objectSource, object t, object co, string name)
        {
            ValueReference m = GetMember(ctx, t, co, name);

            if (m != null)
            {
                m.ParentSource = objectSource;
            }
            return(m);
        }
 void AssertPublicValueReference(ValueReference vr)
 {
     if (!(vr is NamespaceValueReference))
     {
         var typ = vr.Type;
         AssertPublicType(typ);
     }
     if (!IsPublicValueFlag(vr.Flags))
     {
         throw EvaluationError("Not Support to reference non-public thing: `{0}'", vr.Name);
     }
 }
        public void SetMemberValue(string name, object value, EvaluationOptions options)
        {
            EvaluationContext localContext = ctx.WithOptions(options);
            object            type         = localContext.Adapter.GetValueType(localContext, targetObject);
            ValueReference    val          = localContext.Adapter.GetMember(localContext, source, type, targetObject, name);

            if (val == null)
            {
                throw new EvaluatorException("Member '{0}' not found", name);
            }
            val.Value = localContext.Adapter.FromRawValue(localContext, value);
        }
示例#11
0
        public string EvaluateDisplayString(EvaluationContext ctx, object obj, string exp)
        {
            StringBuilder sb   = new StringBuilder();
            int           last = 0;
            int           i    = exp.IndexOf("{");

            while (i != -1 && i < exp.Length)
            {
                sb.Append(exp.Substring(last, i - last));
                i++;
                int j = exp.IndexOf("}", i);
                if (j == -1)
                {
                    return(exp);
                }
                string mem = exp.Substring(i, j - i).Trim();
                if (mem.Length == 0)
                {
                    return(exp);
                }

                string[]       props  = mem.Split(new char[] { '.' });
                ValueReference member = null;
                object         val    = obj;

                for (int k = 0; k < props.Length; k++)
                {
                    member = GetMember(ctx, null, GetValueType(ctx, val), val, props[k]);
                    if (member == null)
                    {
                        break;
                    }

                    val = member.Value;
                }

                if (member != null)
                {
                    sb.Append(ctx.Evaluator.TargetObjectToString(ctx, val));
                }
                else
                {
                    sb.Append("{Unknown member '" + mem + "'}");
                }
                last = j + 1;
                i    = exp.IndexOf("{", last);
            }
            sb.Append(exp.Substring(last));
            return(sb.ToString());
        }
示例#12
0
        protected virtual ValueReference GetMember(EvaluationContext ctx, object t, object co, string name)
        {
            ValueReference best = null;

            foreach (ValueReference var in GetMembers(ctx, t, co, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static))
            {
                if (var.Name == name)
                {
                    return(var);
                }
                if (!ctx.Evaluator.CaseSensitive && var.Name.Equals(name, StringComparison.CurrentCultureIgnoreCase))
                {
                    best = var;
                }
            }
            return(best);
        }
示例#13
0
        protected virtual ValueReference OnGetParameter(EvaluationContext ctx, string name)
        {
            ValueReference best = null;

            foreach (ValueReference var in GetParameters(ctx))
            {
                if (var.Name == name)
                {
                    return(var);
                }
                if (!ctx.Evaluator.CaseSensitive && var.Name.Equals(name, StringComparison.CurrentCultureIgnoreCase))
                {
                    best = var;
                }
            }
            return(best);
        }
示例#14
0
        public virtual ValueReference GetChild(ObjectPath vpath, EvaluationOptions options)
        {
            if (vpath.Length == 0)
            {
                return(this);
            }

            ValueReference val = GetChild(vpath[0], options);

            if (val != null)
            {
                return(val.GetChild(vpath.GetSubpath(1), options));
            }
            else
            {
                return(null);
            }
        }
示例#15
0
        public string EvaluateDisplayString(EvaluationContext ctx, object obj, string exp)
        {
            StringBuilder sb   = new StringBuilder();
            int           last = 0;
            int           i    = exp.IndexOf("{");

            while (i != -1 && i < exp.Length)
            {
                sb.Append(exp.Substring(last, i - last));
                i++;
                int j = exp.IndexOf("}", i);
                if (j == -1)
                {
                    return(exp);
                }
                string mem = exp.Substring(i, j - i).Trim();
                if (mem.Length == 0)
                {
                    return(exp);
                }

                ValueReference member = GetMember(ctx, null, GetValueType(ctx, obj), obj, mem);
                if (member != null)
                {
                    object val = member.Value;
                    sb.Append(ctx.Evaluator.TargetObjectToString(ctx, val));
                }
                else
                {
                    sb.Append("{Unknown member '" + mem + "'}");
                }
                last = j + 1;
                i    = exp.IndexOf("{", last);
            }
            sb.Append(exp.Substring(last));
            return(sb.ToString());
        }
        public virtual ValueReference Evaluate(EvaluationContext ctx, string exp, object expectedType)
        {
            foreach (ValueReference var in ctx.Adapter.GetLocalVariables(ctx))
            {
                if (var.Name == exp)
                {
                    return(var);
                }
            }

            foreach (ValueReference var in ctx.Adapter.GetParameters(ctx))
            {
                if (var.Name == exp)
                {
                    return(var);
                }
            }

            ValueReference thisVar = ctx.Adapter.GetThisReference(ctx);

            if (thisVar != null)
            {
                if (thisVar.Name == exp)
                {
                    return(thisVar);
                }
                foreach (ValueReference cv in thisVar.GetChildReferences(ctx.Options))
                {
                    if (cv.Name == exp)
                    {
                        return(cv);
                    }
                }
            }
            throw new EvaluatorException("Invalid Expression: '{0}'", exp);
        }
示例#17
0
 public ExceptionInfoSource(EvaluationContext ctx, ValueReference exception)
 {
     this.exception = exception;
     this.ctx       = ctx;
 }
示例#18
0
        public virtual CompletionData GetExpressionCompletionData(EvaluationContext ctx, string exp)
        {
            int i;

            if (exp.Length == 0)
            {
                return(null);
            }

            if (exp [exp.Length - 1] == '.')
            {
                exp = exp.Substring(0, exp.Length - 1);
                i   = 0;
                while (i < exp.Length)
                {
                    ValueReference vr = null;
                    try {
                        vr = ctx.Evaluator.Evaluate(ctx, exp.Substring(i), null);
                        if (vr != null)
                        {
                            CompletionData data = new CompletionData();
                            foreach (ValueReference cv in vr.GetChildReferences(ctx.Options))
                            {
                                data.Items.Add(new CompletionItem(cv.Name, cv.Flags));
                            }
                            data.ExpressionLenght = 0;
                            return(data);
                        }
                    } catch (Exception ex) {
                        Console.WriteLine(ex);
                    }
                    i++;
                }
                return(null);
            }

            i = exp.Length - 1;
            bool lastWastLetter = false;

            while (i >= 0)
            {
                char c = exp [i--];
                if (!char.IsLetterOrDigit(c) && c != '_')
                {
                    break;
                }
                lastWastLetter = !char.IsDigit(c);
            }
            if (lastWastLetter)
            {
                string partialWord = exp.Substring(i + 1);

                CompletionData data = new CompletionData();
                data.ExpressionLenght = partialWord.Length;

                // Local variables

                foreach (ValueReference vc in GetLocalVariables(ctx))
                {
                    if (vc.Name.StartsWith(partialWord))
                    {
                        data.Items.Add(new CompletionItem(vc.Name, vc.Flags));
                    }
                }

                // Parameters

                foreach (ValueReference vc in GetParameters(ctx))
                {
                    if (vc.Name.StartsWith(partialWord))
                    {
                        data.Items.Add(new CompletionItem(vc.Name, vc.Flags));
                    }
                }

                // Members

                ValueReference thisobj = GetThisReference(ctx);

                if (thisobj != null)
                {
                    data.Items.Add(new CompletionItem("this", ObjectValueFlags.Field | ObjectValueFlags.ReadOnly));
                }

                object type = GetEnclosingType(ctx);

                foreach (ValueReference vc in GetMembers(ctx, null, type, thisobj != null ? thisobj.Value : null))
                {
                    if (vc.Name.StartsWith(partialWord))
                    {
                        data.Items.Add(new CompletionItem(vc.Name, vc.Flags));
                    }
                }

                if (data.Items.Count > 0)
                {
                    return(data);
                }
            }
            return(null);
        }
		public ExceptionInfoSource (EvaluationContext ctx, ValueReference exception)
		{
			this.exception = exception;
			this.ctx = ctx;
		}
        protected virtual CompletionData GetMemberCompletionData(EvaluationContext ctx, ValueReference vr)
        {
            var data = new CompletionData ();

            foreach (ValueReference cv in vr.GetChildReferences (ctx.Options))
                data.Items.Add (new CompletionItem (cv.Name, cv.Flags));

            data.ExpressionLength = 0;

            return data;
        }
		object EvaluateBinaryOperatorExpression (ValueReference left, ICSharpCode.NRefactory.Ast.Expression rightExp, BinaryOperatorType oper, object data)
		{
			// Shortcut ops
			
			switch (oper) {
				case BinaryOperatorType.LogicalAnd: {
					object val = left.ObjectValue;
					if (!(val is bool))
						throw CreateParseError ("Left operand of logical And must be a boolean");
					if (!(bool)val)
						return LiteralValueReference.CreateObjectLiteral (ctx, name, false);
					ValueReference vr = (ValueReference) rightExp.AcceptVisitor (this, data);
					if (ctx.Adapter.GetTypeName (ctx, vr.Type) != "System.Boolean")
						throw CreateParseError ("Right operand of logical And must be a boolean");
					return vr;
				}
				case BinaryOperatorType.LogicalOr: {
					object val = left.ObjectValue;
					if (!(val is bool))
						throw CreateParseError ("Left operand of logical Or must be a boolean");
					if ((bool)val)
						return LiteralValueReference.CreateObjectLiteral (ctx, name, true);
					ValueReference vr = (ValueReference) rightExp.AcceptVisitor (this, data);
					if (ctx.Adapter.GetTypeName (ctx, vr.Type) != "System.Boolean")
						throw CreateParseError ("Right operand of logical Or must be a boolean");
					return vr;
				}
			}

			ValueReference right = (ValueReference) rightExp.AcceptVisitor (this, data);
			object targetVal1 = left.Value;
			object targetVal2 = right.Value;
			object val1 = left.ObjectValue;
			object val2 = right.ObjectValue;
			
			if (oper == BinaryOperatorType.Add || oper == BinaryOperatorType.Concat) {
				if (val1 is string || val2 is string) {
					if (!(val1 is string) && val1 != null)
						val1 = ctx.Adapter.CallToString (ctx, targetVal1);
					if (!(val2 is string) && val2 != null)
						val2 = ctx.Adapter.CallToString (ctx, targetVal2);
					return LiteralValueReference.CreateObjectLiteral (ctx, name, (string) val1 + (string) val2);
				}
			}
			
			if ((oper == BinaryOperatorType.ExclusiveOr) && (val1 is bool) && (val2 is bool))
				return LiteralValueReference.CreateObjectLiteral (ctx, name, (bool)val1 ^ (bool)val2);

			if ((val1 == null || !val1.GetType ().IsPrimitive) && (val2 == null || !val2.GetType ().IsPrimitive)) {
				switch (oper) {
					case BinaryOperatorType.Equality:
						if (val1 == null || val2 == null)
							return LiteralValueReference.CreateObjectLiteral (ctx, name, val1 == val2);
						return LiteralValueReference.CreateObjectLiteral (ctx, name, val1.Equals (val2));
					case BinaryOperatorType.InEquality:
						if (val1 == null || val2 == null)
							return LiteralValueReference.CreateObjectLiteral (ctx, name, val1 != val2);
						return LiteralValueReference.CreateObjectLiteral (ctx, name, !val1.Equals (val2));
					case BinaryOperatorType.ReferenceEquality:
						return LiteralValueReference.CreateObjectLiteral (ctx, name, val1 == val2);
					case BinaryOperatorType.ReferenceInequality:
						return LiteralValueReference.CreateObjectLiteral (ctx, name, val1 != val2);
					case BinaryOperatorType.Concat:
						throw CreateParseError ("Invalid binary operator.");
				}
			}
			
			if (val1 == null || val2 == null || (val1 is bool) || (val2 is bool))
				throw CreateParseError ("Invalid operands in binary operator");
			
			long v1, v2;
			object longType = ctx.Adapter.GetType (ctx, "System.Int64");
			
			try {
				object c1 = ctx.Adapter.Cast (ctx, targetVal1, longType);
				v1 = (long) ctx.Adapter.TargetObjectToObject (ctx, c1);
					
				object c2 = ctx.Adapter.Cast (ctx, targetVal2, longType);
				v2 = (long) ctx.Adapter.TargetObjectToObject (ctx, c2);
			} catch {
				throw CreateParseError ("Invalid operands in binary operator");
			}
			
			object res;
			
			switch (oper) {
				case BinaryOperatorType.Add: res = v1 + v2; break;
				case BinaryOperatorType.BitwiseAnd: res = v1 & v2; break;
				case BinaryOperatorType.BitwiseOr: res = v1 | v2; break;
				case BinaryOperatorType.ExclusiveOr: res = v1 ^ v2; break;
				case BinaryOperatorType.DivideInteger:
				case BinaryOperatorType.Divide: res = v1 / v2; break;
				case BinaryOperatorType.Modulus: res = v1 % v2; break;
				case BinaryOperatorType.Multiply: res = v1 * v2; break;
				case BinaryOperatorType.Power: res = v1 ^ v2; break;
				case BinaryOperatorType.ShiftLeft: res = v1 << (int)v2; break;
				case BinaryOperatorType.ShiftRight: res = v1 >> (int)v2; break;
				case BinaryOperatorType.Subtract: res = v1 - v2; break;
				case BinaryOperatorType.GreaterThan: res = v1 > v2; break;
				case BinaryOperatorType.GreaterThanOrEqual: res = v1 >= v2; break;
				case BinaryOperatorType.LessThan: res = v1 < v2; break;
				case BinaryOperatorType.LessThanOrEqual: res = v1 <= v2; break;
				case BinaryOperatorType.ReferenceEquality:
				case BinaryOperatorType.Equality: res = v1 == v2; break;
				case BinaryOperatorType.ReferenceInequality:
				case BinaryOperatorType.InEquality: res = v1 != v2; break;
				default: throw CreateParseError ("Invalid binary operator.");
			}
			
			if (!(res is bool))
				res = (long) Convert.ChangeType (res, GetCommonType (v1, v2));
			
			if (ctx.Adapter.IsEnum (ctx, targetVal1)) {
				object tval = ctx.Adapter.Cast (ctx, ctx.Adapter.CreateValue (ctx, res), ctx.Adapter.GetValueType (ctx, targetVal1));
				return LiteralValueReference.CreateTargetObjectLiteral (ctx, name, tval);
			}
			if (ctx.Adapter.IsEnum (ctx, targetVal2)) {
				object tval = ctx.Adapter.Cast (ctx, ctx.Adapter.CreateValue (ctx, res), ctx.Adapter.GetValueType (ctx, targetVal2));
				return LiteralValueReference.CreateTargetObjectLiteral (ctx, name, tval);
			}
			
			return LiteralValueReference.CreateObjectLiteral (ctx, name, res);
		}
示例#22
0
		/// <summary>
		/// Disambiguate the ObjectValue's name (in the case where the property name also exists in a base class).
		/// </summary>
		/// <param name='val'>
		/// The ValueReference.
		/// </param>
		/// <param name='oval'>
		/// The ObjectValue.
		/// </param>
		public void Disambiguate (ValueReference val, ObjectValue oval)
		{
			KeyValuePair<ObjectValue, ValueReference> other;
			if (names.TryGetValue (oval.Name, out other)) {
				object tn = val.DeclaringType;
				
				if (tn != null)
					oval.Name += " (" + ctx.Adapter.GetDisplayTypeName (ctx, tn) + ")";
				if (!other.Key.Name.EndsWith (")")) {
					tn = other.Value.DeclaringType;
					if (tn != null)
						other.Key.Name += " (" + ctx.Adapter.GetDisplayTypeName (ctx, tn) + ")";
				}
			}
			
			names [oval.Name] = new KeyValuePair<ObjectValue, ValueReference> (oval, val);
		}
示例#23
0
        public ObjectValue CreateObjectValue(bool withTimeout, EvaluationOptions options)
        {
            string type = ctx.Adapter.GetTypeName(ctx, exception.Type);

            ObjectValue excInstance = exception.CreateObjectValue(withTimeout, options);

            excInstance.Name = "Instance";

            ObjectValue messageValue = null;

            // Get the message

            if (withTimeout)
            {
                messageValue = ctx.Adapter.CreateObjectValueAsync("Message", ObjectValueFlags.None, delegate {
                    ValueReference mref = exception.GetChild("Message", options);
                    if (mref != null)
                    {
                        string val = (string)mref.ObjectValue;
                        return(ObjectValue.CreatePrimitive(null, new ObjectPath("Message"), "System.String", new EvaluationResult(val), ObjectValueFlags.Literal));
                    }
                    else
                    {
                        return(ObjectValue.CreateUnknown("Message"));
                    }
                });
            }
            else
            {
                ValueReference mref = exception.GetChild("Message", options);
                if (mref != null)
                {
                    string val = (string)mref.ObjectValue;
                    messageValue = ObjectValue.CreatePrimitive(null, new ObjectPath("Message"), "System.String", new EvaluationResult(val), ObjectValueFlags.Literal);
                }
            }
            if (messageValue == null)
            {
                messageValue = ObjectValue.CreateUnknown("Message");
            }

            messageValue.Name = "Message";

            // Inner exception

            ObjectValue childExceptionValue = null;

            if (withTimeout)
            {
                childExceptionValue = ctx.Adapter.CreateObjectValueAsync("InnerException", ObjectValueFlags.None, delegate {
                    ValueReference inner = exception.GetChild("InnerException", options);
                    if (inner != null && !ctx.Adapter.IsNull(ctx, inner.Value))
                    {
                        Console.WriteLine("pp got child:" + type);
                        ExceptionInfoSource innerSource = new ExceptionInfoSource(ctx, inner);
                        ObjectValue res = innerSource.CreateObjectValue(false, options);
                        return(res);
                    }
                    else
                    {
                        return(ObjectValue.CreateUnknown("InnerException"));
                    }
                });
            }
            else
            {
                ValueReference inner = exception.GetChild("InnerException", options);
                if (inner != null && !ctx.Adapter.IsNull(ctx, inner.Value))
                {
                    Console.WriteLine("pp got child:" + type);
                    ExceptionInfoSource innerSource = new ExceptionInfoSource(ctx, inner);
                    childExceptionValue      = innerSource.CreateObjectValue(false, options);
                    childExceptionValue.Name = "InnerException";
                }
            }
            if (childExceptionValue == null)
            {
                childExceptionValue = ObjectValue.CreateUnknown("InnerException");
            }

            // Stack trace

            ObjectValue stackTraceValue;

            if (withTimeout)
            {
                stackTraceValue = ctx.Adapter.CreateObjectValueAsync("StackTrace", ObjectValueFlags.None, delegate {
                    return(GetStackTrace(options));
                });
            }
            else
            {
                stackTraceValue = GetStackTrace(options);
            }

            ObjectValue[] children = new ObjectValue [] { excInstance, messageValue, stackTraceValue, childExceptionValue };
            return(ObjectValue.CreateObject(null, new ObjectPath("InnerException"), type, "", ObjectValueFlags.None, children));
        }