Example #1
0
		public static IEnumerable<TreeNode> LazyGetChildNodesOfArray(TreeNode parent, Expression expression, ArrayDimensions dimensions)
		{
			if (dimensions.TotalElementCount == 0)
				return new TreeNode[] { new TreeNode(null, "(empty)", null, null, parent, null) };
			
			return new ArrayRangeNode(parent, expression, dimensions, dimensions).ChildNodes;
		}
Example #2
0
			public InfoNode(TreeNode parent, string name, string text, Func<TreeNode, List<TreeNode>> children)
				: base(parent)
			{
				this.Name = name;
				this.Text = text;
				this.children = children(this);
			}
		public SharpTreeNodeAdapter(TreeNode node)
		{
			if (node == null)
				throw new ArgumentNullException("node");
			this.Node = node;
			this.LazyLoading = true;
		}
Example #4
0
		public TreeNodeWrapper(TreeNode node)
		{
			if (node == null)
				throw new ArgumentNullException("node");
			Node = node;
			LazyLoading = true;
		}
		public static bool ContainsItem(this ObservableCollection<TreeNode> collection, TreeNode node)
		{
			foreach (var item in collection)
				if (item.CompareTo(node) == 0)
					return true;
			
			return false;
		}
Example #6
0
		public IListNode(TreeNode parent, Expression targetListObject)
			: base(parent)
		{
			this.targetList = targetListObject;
			
			this.Name = "IList";
			this.listCount = this.targetList.GetIListCount();
			this.childNodes = Utils.LazyGetItemsOfIList(this, this.targetList);
		}
Example #7
0
		public ArrayRangeNode(TreeNode parent, Expression arrayTarget, ArrayDimensions bounds, ArrayDimensions originalBounds)
			: base(parent)
		{
			this.arrayTarget = arrayTarget;
			this.bounds = bounds;
			this.originalBounds = originalBounds;
			
			this.Name = GetName();
			this.childNodes = LazyGetChildren();
		}
Example #8
0
		public IEnumerableNode(TreeNode parent, Expression targetObject, DebugType itemType)
			: base(parent)
		{
			this.targetObject = targetObject;
			
			this.Name = "IEnumerable";
			this.Text = "Expanding will enumerate the IEnumerable";
			DebugType debugListType;
			this.debugListExpression = DebuggerHelpers.CreateDebugListExpression(targetObject, itemType, out debugListType);
			this.childNodes = Utils.LazyGetItemsOfIList(this, this.debugListExpression);
		}
Example #9
0
		public TreeNode(TreeNode parent)
		{
			this.Parent = parent;
		}
Example #10
0
		public TreeNode(IImage iconImage, string name, string text, string type, TreeNode parent, Func<TreeNode, IEnumerable<TreeNode>> childNodes)
			: this(parent)
		{
			this.iconImage = iconImage;
			this.name = name;
			this.text = text;
			this.type = type;
			this.childNodes = childNodes(this);
		}
Example #11
0
		public static List<TreeNode> GetDebugInfo(TreeNode parent, AppDomain appDomain, ICorDebugValue corValue)
		{
			List<TreeNode> items = new List<TreeNode>();
			
			if (corValue is ICorDebugValue) {
				InfoNode info = new InfoNode(parent, "ICorDebugValue", "");
				info.AddChild("Address", corValue.GetAddress().ToString("X8"));
				info.AddChild("Type", ((CorElementType)corValue.GetTheType()).ToString());
				info.AddChild("Size", corValue.GetSize().ToString());
				items.Add(info);
			}
			if (corValue is ICorDebugValue2) {
				InfoNode info = new InfoNode(parent, "ICorDebugValue2", "");
				ICorDebugValue2 corValue2 = (ICorDebugValue2)corValue;
				string fullname;
				try {
					fullname = DebugType.CreateFromCorType(appDomain, corValue2.GetExactType()).FullName;
				} catch (DebuggerException e) {
					fullname = e.Message;
				}
				info.AddChild("ExactType", fullname);
				items.Add(info);
			}
			if (corValue is ICorDebugGenericValue) {
				InfoNode info = new InfoNode(parent, "ICorDebugGenericValue", "");
				try {
					byte[] bytes = ((ICorDebugGenericValue)corValue).GetRawValue();
					for(int i = 0; i < bytes.Length; i += 8) {
						string val = "";
						for(int j = i; j < bytes.Length && j < i + 8; j++) {
							val += bytes[j].ToString("X2") + " ";
						}
						info.AddChild("Value" + i.ToString("X2"), val);
					}
				} catch (ArgumentException) {
					info.AddChild("Value", "N/A");
				}
				items.Add(info);
			}
			if (corValue is ICorDebugReferenceValue) {
				InfoNode info = new InfoNode(parent, "ICorDebugReferenceValue", "");
				ICorDebugReferenceValue refValue = (ICorDebugReferenceValue)corValue;
				info.AddChild("IsNull", (refValue.IsNull() != 0).ToString());
				if (refValue.IsNull() == 0) {
					info.AddChild("Value", refValue.GetValue().ToString("X8"));
					if (refValue.Dereference() != null) {
						info.AddChild("Dereference", "", p => GetDebugInfo(p, appDomain, refValue.Dereference()));
					} else {
						info.AddChild("Dereference", "N/A");
					}
				}
				items.Add(info);
			}
			if (corValue is ICorDebugHeapValue) {
				InfoNode info = new InfoNode(parent, "ICorDebugHeapValue", "");
				items.Add(info);
			}
			if (corValue is ICorDebugHeapValue2) {
				InfoNode info = new InfoNode(parent, "ICorDebugHeapValue2", "");
				items.Add(info);
			}
			if (corValue is ICorDebugObjectValue) {
				InfoNode info = new InfoNode(parent, "ICorDebugObjectValue", "");
				ICorDebugObjectValue objValue = (ICorDebugObjectValue)corValue;
				info.AddChild("Class", objValue.GetClass().GetToken().ToString("X8"));
				info.AddChild("IsValueClass", (objValue.IsValueClass() != 0).ToString());
				items.Add(info);
			}
			if (corValue is ICorDebugObjectValue2) {
				InfoNode info = new InfoNode(parent, "ICorDebugObjectValue2", "");
				items.Add(info);
			}
			if (corValue is ICorDebugBoxValue) {
				InfoNode info = new InfoNode(parent, "ICorDebugBoxValue", "");
				ICorDebugBoxValue boxValue = (ICorDebugBoxValue)corValue;
				info.AddChild("Object", "", p => GetDebugInfo(p, appDomain, boxValue.GetObject()));
				items.Add(info);
			}
			if (corValue is ICorDebugStringValue) {
				InfoNode info = new InfoNode(parent, "ICorDebugStringValue", "");
				ICorDebugStringValue stringValue = (ICorDebugStringValue)corValue;
				info.AddChild("Length", stringValue.GetLength().ToString());
				info.AddChild("String", stringValue.GetString());
				items.Add(info);
			}
			if (corValue is ICorDebugArrayValue) {
				InfoNode info = new InfoNode(parent, "ICorDebugArrayValue", "");
				info.AddChild("...", "...");
				items.Add(info);
			}
			if (corValue is ICorDebugHandleValue) {
				InfoNode info = new InfoNode(parent, "ICorDebugHandleValue", "");
				ICorDebugHandleValue handleValue = (ICorDebugHandleValue)corValue;
				info.AddChild("HandleType", handleValue.GetHandleType().ToString());
				items.Add(info);
			}
			
			return items;
		}
Example #12
0
			public InfoNode(TreeNode parent, string name, string text)
				: this(parent, name, text, null)
			{
				
			}
		public static IEnumerable<TreeNode> LazyGetMembersOfObject(TreeNode parent, Expression expression, MemberInfo[] members)
		{
			List<TreeNode> nodes = new List<TreeNode>();
			foreach(MemberInfo memberInfo in members) {
				string imageName;
				var image = ExpressionNode.GetImageForMember((IDebugMemberInfo)memberInfo, out imageName);
				var exp = new ExpressionNode(parent, image, memberInfo.Name, expression.AppendMemberReference((IDebugMemberInfo)memberInfo));
				exp.ImageName = imageName;
				nodes.Add(exp);
			}
			nodes.Sort();
			return nodes;
		}
Example #14
0
		public TextNode(TreeNode parent, string text, SupportedLanguage language)
			: base(parent)
		{
			this.Name = text;
			this.Language = language;
		}
		public static IEnumerable<TreeNode> LazyGetChildNodesOfObject(TreeNode current, Expression targetObject, DebugType shownType)
		{
			MemberInfo[] publicStatic      = shownType.GetFieldsAndNonIndexedProperties(BindingFlags.Public    | BindingFlags.Static   | BindingFlags.DeclaredOnly);
			MemberInfo[] publicInstance    = shownType.GetFieldsAndNonIndexedProperties(BindingFlags.Public    | BindingFlags.Instance | BindingFlags.DeclaredOnly);
			MemberInfo[] nonPublicStatic   = shownType.GetFieldsAndNonIndexedProperties(BindingFlags.NonPublic | BindingFlags.Static   | BindingFlags.DeclaredOnly);
			MemberInfo[] nonPublicInstance = shownType.GetFieldsAndNonIndexedProperties(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly);
			
			DebugType baseType = (DebugType)shownType.BaseType;
			if (baseType != null) {
				yield return new TreeNode(
					DebuggerResourceService.GetImage("Icons.16x16.Class"),
					StringParser.Parse("${res:MainWindow.Windows.Debug.LocalVariables.BaseClass}"),
					baseType.Name,
					baseType.FullName,
					current,
					newNode => baseType.FullName == "System.Object" ? null : Utils.LazyGetChildNodesOfObject(newNode, targetObject, baseType)
				);
			}
			
			if (nonPublicInstance.Length > 0) {
				yield return new TreeNode(
					null,
					StringParser.Parse("${res:MainWindow.Windows.Debug.LocalVariables.NonPublicMembers}"),
					string.Empty,
					string.Empty,
					current,
					newNode => Utils.LazyGetMembersOfObject(newNode, targetObject, nonPublicInstance)
				);
			}
			
			if (publicStatic.Length > 0 || nonPublicStatic.Length > 0) {
				yield return new TreeNode(
					null,
					StringParser.Parse("${res:MainWindow.Windows.Debug.LocalVariables.StaticMembers}"),
					string.Empty,
					string.Empty,
					current,
					p => {
						var children = Utils.LazyGetMembersOfObject(p, targetObject, publicStatic);
						if (nonPublicStatic.Length > 0) {
							TreeNode nonPublicStaticNode = new TreeNode(
								null,
								StringParser.Parse("${res:MainWindow.Windows.Debug.LocalVariables.NonPublicStaticMembers}"),
								string.Empty,
								string.Empty,
								p,
								newNode => Utils.LazyGetMembersOfObject(newNode, targetObject, nonPublicStatic)
							);
							children = Utils.PrependNode(nonPublicStaticNode, children);
						}
						return children;
					}
				);
			}
			
			DebugType iListType = (DebugType)shownType.GetInterface(typeof(IList).FullName);
			if (iListType != null) {
				yield return new IListNode(current, targetObject);
			} else {
				DebugType iEnumerableType, itemType;
				if (shownType.ResolveIEnumerableImplementation(out iEnumerableType, out itemType)) {
					yield return new IEnumerableNode(current, targetObject, itemType);
				}
			}
			
			foreach(TreeNode node in LazyGetMembersOfObject(current, targetObject, publicInstance)) {
				yield return node;
			}
		}
		public static IEnumerable<TreeNode> PrependNode(TreeNode node, IEnumerable<TreeNode> rest)
		{
			yield return node;
			if (rest != null) {
				foreach(TreeNode absNode in rest) {
					yield return absNode;
				}
			}
		}
		public static IEnumerable<TreeNode> LazyGetItemsOfIList(TreeNode parent, Expression targetObject)
		{
			// Add a cast, so that we are sure the expression has an indexer.
			// (The expression can be e.g. of type 'object' but its value is a List.
			// Without the cast, evaluating "expr[i]" would fail, because object does not have an indexer).
			targetObject = targetObject.CastToIList();
			int count = 0;
			GetValueException error = null;
			try {
				count = targetObject.GetIListCount();
			} catch (GetValueException e) {
				// Cannot yield a value in the body of a catch clause (CS1631)
				error = e;
			}
			if (error != null) {
				yield return new TreeNode(null, "(error)", error.Message, null, null, null);
			} else if (count == 0) {
				yield return new TreeNode(null, "(empty)", null, null, null, null);
			} else {
				for(int i = 0; i < count; i++) {
					string imageName;
					var image = ExpressionNode.GetImageForArrayIndexer(out imageName);
					var itemNode = new ExpressionNode(parent, image, "[" + i + "]", targetObject.AppendIndexer(i));
					itemNode.ImageName = imageName;
					yield return itemNode;
				}
			}
		}
Example #18
0
        public static bool ContainsItem(this ObservableCollection <TreeNode> collection, TreeNode node)
        {
            foreach (var item in collection)
            {
                if (item.CompareTo(node) == 0)
                {
                    return(true);
                }
            }

            return(false);
        }
Example #19
0
		void ExpandChildren(TreeNode node, TreeViewItem treeViewItem)
		{
			if (node != null && node.HasChildNodes && treeViewItem != null) {
				
				WorkbenchSingleton.SafeThreadAsyncCall((Action)(() => {
				                                                	((HierarchicalDataTemplate)treeViewItem.ItemTemplate).ItemsSource = new Binding("ChildNodes");
				                                                	treeViewItem.ItemsSource = node.ChildNodes;
				                                                }));
			}
		}