Beispiel #1
0
 void Content_OnEditCellStart(int column, string value, DbgObject context, ref bool cancel)
 {
     if (column != 1)
     {
         cancel = true;
     }
 }
        public void AddWatchObject(DbgObject item)
        {
            int insertionPosition = listView1.Items.Count;

            if (listView1.Items.Count > 0 && listView1.Items[listView1.Items.Count - 1].Tag == AddNewPlaceholder)
            {
                insertionPosition--;
            }
            listView1.Items.Insert(insertionPosition, item.ToListViewItem());
        }
        //public static IEnumerable<ListViewItem> AllItems(this ListViewItem listView)
        //{
        //    return listView.Items.Cast<ListViewItem>().Select(x => x.Tag as DbgObject);
        //}

        public static int IndexOfObject(this ListView listView, DbgObject item)
        {
            for (int i = 0; i < listView.Items.Count; i++)
            {
                if (listView.Items[i].Tag == item)
                {
                    return(i);
                }
            }
            return(-1);
        }
Beispiel #4
0
 public void CopyDbgDataFrom(DbgObject source)
 {
     this.DbgId        = source.DbgId;
     this.Value        = source.Value;
     this.DispayValue  = source.DispayValue;
     this.Type         = source.Type;
     this.IsStatic     = source.IsStatic;
     this.IsArray      = source.IsArray;
     this.IsList       = source.IsList;
     this.IsDictionary = source.IsDictionary;
     this.IsFake       = source.IsFake;
     this.IsField      = source.IsField;
     this.IsPublic     = source.IsPublic;
     this.IsCurrent    = source.IsCurrent;
     this.Tooltip      = source.Tooltip;
     this.IsModified   = source.IsModified;
     this.HasChildren  = source.HasChildren;
 }
        public void UpdateData(string data)
        {
            DbgObject[] freshObjects = ToWatchObjects(data);

            var nestedObjects = freshObjects.Where(x => x.Children != null).SelectMany(x => x.Children).ToArray();

            freshObjects = freshObjects.Concat(nestedObjects).ToArray(); //some can be nested

            var nonRootItems = new List <ListViewItem>();

            bool updated = false;


            foreach (ListViewItem item in listView1.Items)
            {
                var itemObject = item.GetDbgObject();
                if (itemObject != null)
                {
                    itemObject.IsModified = false;
                    DbgObject update = freshObjects.Where(x => x.Path == itemObject.Path).FirstOrDefault();

                    if (update != null)
                    {
                        itemObject.CopyDbgDataFrom(update);
                        itemObject.IsModified = (item.SubItems[1].Text != update.Value);
                        item.SubItems[1].Text = update.DispayValue;
                        item.SubItems[2].Text = update.Type;
                        item.ToolTipText      = update.Tooltip;
                        updated = true;
                    }
                }
            }

            nonRootItems.ForEach(x =>
                                 listView1.Items.Remove(x));

            if (updated)
            {
                listView1.Invalidate();
            }
            ResizeValueColumn();
        }
        public static ListViewItem ToListViewItem(this DbgObject item)
        {
            string name = item.Name;

            var li = new ListViewItem(name);

            li.SubItems.Add(item.DispayValue);
            li.SubItems.Add(item.Type);
            li.Tag = item;
            if (item.IsEditPlaceholder)
            {
                li.ToolTipText = "Double-click to add/edit";
            }
            else
            {
                li.ToolTipText = item.Tooltip;
            }

            return(li);
        }
Beispiel #7
0
 void Content_OnEditCellComplete(int column, string oldValue, string newValue, DbgObject context, ref bool cancel)
 {
     if (column == 1) //set value
     {
         Debugger.InvokeResolve("resolve", context.Name + "=" + newValue.Trim());
         cancel = true; //debugger will send the update with the fresh actual value
     }
 }
        DbgObject[] ToWatchObjects(string data)
        {
            if (string.IsNullOrEmpty(data))
            {
                return(new DbgObject[0]);
            }

            var root = XElement.Parse(data);

            var values = root.Elements().Select(dbgValue =>
            {
                string valName = dbgValue.Attribute("name").Value;

                if (valName.EndsWith("__BackingField")) //ignore auto-property backing fields
                {
                    return(null);
                }

                Func <string, bool> getBoolAttribute = attrName =>
                {
                    var attr = dbgValue.Attributes(attrName).FirstOrDefault();
                    return(attr != null && attr.Value == "true");
                };

                var dbgObject          = new DbgObject();
                dbgObject.DbgId        = dbgValue.Attribute("id").Value;
                dbgObject.Name         = valName;
                dbgObject.Type         = dbgValue.Attribute("typeName").Value.ReplaceClrAliaces();
                dbgObject.IsArray      = getBoolAttribute("isArray");
                dbgObject.IsList       = getBoolAttribute("isList");
                dbgObject.IsFake       = getBoolAttribute("isFake");
                dbgObject.IsPublic     = getBoolAttribute("isPublic");
                dbgObject.IsDictionary = getBoolAttribute("isDictionary");
                dbgObject.HasChildren  = getBoolAttribute("isComplex");
                dbgObject.IsField      = !getBoolAttribute("isProperty");
                dbgObject.IsStatic     = getBoolAttribute("isStatic");

                if (!dbgObject.HasChildren)
                {
                    // This is a catch-all for primitives.
                    string stValue  = dbgValue.Attribute("value").Value;
                    dbgObject.Value = stValue;
                }
                else
                {
                    XAttribute displayValue = dbgValue.Attribute("rawDisplayValue");
                    if (displayValue != null)
                    {
                        dbgObject.Value = displayValue.Value;
                    }
                }
                return(dbgObject);
            })
                         .Where(x => x != null)
                         .ToArray();

            var staticMembers  = values.Where(x => x.IsStatic);
            var fakeMembers    = values.Where(x => x.IsFake);
            var privateMembers = values.Where(x => !x.IsPublic);

            var result = new List <DbgObject>();

            if (values.Count() == 1 && !values[0].HasChildren) //it is a primitive value
            {
                result.Add(values[0]);
            }
            else
            {
                var instanceMembers = values.Where(x => !x.IsStatic && !x.IsFake && x.IsPublic);
                result.AddRange(instanceMembers);

                if (staticMembers.Any())
                {
                    result.Add(
                        new DbgObject
                    {
                        Name        = "Static members",
                        HasChildren = true,
                        IsSeparator = true,
                        IsStatic    = true,
                        Children    = staticMembers.ToArray()
                    });
                }

                if (privateMembers.Any())
                {
                    result.Add(
                        new DbgObject
                    {
                        Name        = "Non-Public members",
                        HasChildren = true,
                        IsSeparator = true,
                        Children    = privateMembers.ToArray()
                    });
                }
            }

            if (fakeMembers.Any())
            {
                var decoratedResult = new List <DbgObject>(fakeMembers);
                decoratedResult.Add(new DbgObject
                {
                    Name        = "Raw View",
                    HasChildren = true,
                    IsSeparator = true,
                    Children    = result.ToArray()
                });
                return(decoratedResult.ToArray());
            }
            else
            {
                return(result.ToArray());
            }
        }
Beispiel #9
0
        void content_OnEditCellComplete(int column, string oldValue, string newValue, DbgObject context, ref bool cancel)
        {
            if (column == 0) //change watch variable name
            {
                bool evalRefreshRequest = (newValue != null && newValue.IsInvokeExpression());

                if (oldValue != newValue || evalRefreshRequest)
                {
                    if (!string.IsNullOrEmpty(oldValue))
                    {
                        Debugger.RemoveWatch(oldValue);
                    }

                    if (!string.IsNullOrEmpty(newValue))
                    {
                        Debugger.AddWatch(newValue);
                    }
                }
            }
            else if (column == 1) //set value
            {
                Debugger.InvokeResolve("resolve", context.Name + "=" + newValue.Trim());
                cancel = true; //debugger will send the update with the fresh actual value
            }
        }
Beispiel #10
0
 void content_OnPinClicked(DbgObject dbgObject)
 {
     content.AddWatchExpression(dbgObject.Path);
 }
Beispiel #11
0
 private void Content_ReevaluateRequest(DbgObject context)
 {
     Debugger.RemoveWatch(context.Name);
     Debugger.AddWatch(context.Name);
 }