Exemplo n.º 1
0
        public string ValueAsString(RuntimeThread thread)
        {
            if (IsNull)
            {
                return("null");
            }

            if (IsReference)
            {
                return(Dereference().ValueAsString(thread));
            }
            if (IsString)
            {
                return(GetStringValue());
            }
            if (IsArray)
            {
                return(string.Format("{0}[{1}]", GetArrayElementType(), string.Join(",", GetArrayDimensions())));
            }
            if (IsObject)
            {
                if (DebuggerBase.Instance.Settings.GetValue <bool>("Visualizers.EnableFunctionEvaluation"))
                {
                    var type = Type;
                    while (type != null)
                    {
                        var module = Session.AssemblyResolver.ResolveModule(type.Class.Module.Name);
                        if (module != null)
                        {
                            var resolvedType = module.ResolveMember(type.Class.Token.GetToken()) as ITypeDefinition;
                            if (resolvedType != null)
                            {
                                var toStringMethod = resolvedType.FindMethod("ToString");
                                if (toStringMethod != null)
                                {
                                    var value = RuntimeEvaluation.InvokeMethod(thread, type.Class.Module.GetFunction((uint)toStringMethod.MetaDataToken));
                                    if (value != null)
                                    {
                                        return(value.ValueAsString(thread));
                                    }
                                }
                            }
                        }
                        type = type.BaseType;
                    }
                }
                return("{" + Type.ToString() + "}");
            }

            var primitive = GetPrimitiveValue();

            if (primitive == null)
            {
                return("null");
            }
            return(primitive.ToString());
        }
Exemplo n.º 2
0
        public RuntimeEvaluation CreateEvaluation()
        {
            ICorDebugEval comEval;

            _comThread.CreateEval(out comEval);
            var eval = new RuntimeEvaluation(this, comEval);

            Session.ComInstanceCollector.SetWrapper(comEval, eval);
            return(eval);
        }
 public RuntimeEvaluation CreateEvaluation()
 {
     ICorDebugEval comEval;
     _comThread.CreateEval(out comEval);
     var eval = new RuntimeEvaluation(this, comEval);
     Session.ComInstanceCollector.SetWrapper(comEval, eval);
     return eval;
 }