IEnumerable<TreeNode> LazyGetChildNodes() { foreach(DebugParameterInfo par in stackFrame.MethodInfo.GetParameters()) { var image = ExpressionNode.GetImageForParameter(); var expression = new ExpressionNode(image, par.Name, par.GetExpression()); yield return expression; } var ip = this.StackFrame.IP; if (ip.IsValid) { foreach (DebugLocalVariableInfo locVar in stackFrame.MethodInfo.GetLocalVariables(ip.Offset)) { var image = ExpressionNode.GetImageForLocalVariable(); var expression = new ExpressionNode(image, locVar.Name, locVar.GetExpression()); yield return expression; } } if (stackFrame.Thread.CurrentException != null) { yield return new ExpressionNode(null, "__exception", new IdentifierExpression("__exception")); } }
IEnumerable<TreeNode> LazyGetChildNodes() { foreach(DebugParameterInfo par in stackFrame.MethodInfo.GetParameters()) { string imageName; var image = ExpressionNode.GetImageForParameter(out imageName); var expression = new ExpressionNode(image, par.Name, par.GetExpression()); expression.ImageName = imageName; yield return expression; } foreach(DebugLocalVariableInfo locVar in stackFrame.MethodInfo.GetLocalVariables(this.StackFrame.IP)) { string imageName; var image = ExpressionNode.GetImageForLocalVariable(out imageName); var expression = new ExpressionNode(image, locVar.Name, locVar.GetExpression()); expression.ImageName = imageName; yield return expression; } if (stackFrame.Thread.CurrentException != null) { yield return new ExpressionNode(null, "__exception", new IdentifierExpression("__exception")); } }
internal ITreeNode GetNode(string variable, string currentImageName = null) { try { var expression = GetExpression(variable); string imageName; ImageSource image; if (string.IsNullOrEmpty(currentImageName)) { image = ExpressionNode.GetImageForLocalVariable(out imageName); } else { image = ImageService.GetImage(currentImageName); imageName = currentImageName; } ExpressionNode expressionNode = new ExpressionNode(image, variable, expression); expressionNode.ImageName = imageName; return expressionNode; } catch (GetValueException) { return null; } }
/// <summary> /// Gets the tooltip control that shows the value of given variable. /// Return null if no tooltip is available. /// </summary> public object GetTooltipControl(AstLocation logicalPosition, string variableName) { try { var tooltipExpression = GetExpression(variableName); if (tooltipExpression == null) return null; string imageName; var image = ExpressionNode.GetImageForLocalVariable(out imageName); ExpressionNode expressionNode = new ExpressionNode(image, variableName, tooltipExpression); expressionNode.ImageName = imageName; return new DebuggerTooltipControl(logicalPosition, expressionNode); } catch (GetValueException) { return null; } }
IEnumerable<TreeNode> LazyGetChildren() { // The whole array is small - just add all elements as childs if (bounds.TotalElementCount <= MaxElementCount) { foreach(int[] indices in bounds.Indices) { string imageName; var image = ExpressionNode.GetImageForArrayIndexer(out imageName); var expression = new ExpressionNode(image, GetName(indices), arrayTarget.AppendIndexer(indices)); expression.ImageName = imageName; yield return expression; } yield break; } // Find a dimension of size at least 2 int splitDimensionIndex = bounds.Count - 1; for(int i = 0; i < bounds.Count; i++) { if (bounds[i].Count > 1) { splitDimensionIndex = i; break; } } ArrayDimension splitDim = bounds[splitDimensionIndex]; // Split the dimension int elementsPerSegment = 1; while (splitDim.Count > elementsPerSegment * MaxElementCount) { elementsPerSegment *= MaxElementCount; } for(int i = splitDim.LowerBound; i <= splitDim.UpperBound; i += elementsPerSegment) { List<ArrayDimension> newDims = new List<ArrayDimension>(bounds); newDims[splitDimensionIndex] = new ArrayDimension(i, Math.Min(i + elementsPerSegment - 1, splitDim.UpperBound)); yield return new ArrayRangeNode(arrayTarget, new ArrayDimensions(newDims), originalBounds); } yield break; }
public static IEnumerable<TreeNode> LazyGetItemsOfIList(Expression targetObject) { // This is needed for expanding IEnumerable<T> var type = new SimpleType() { Identifier = typeof(IList).FullName }; type.AddAnnotation(typeof(IList)); targetObject = new CastExpression() { Expression = targetObject.Clone(), Type = type }; int count = 0; GetValueException error = null; try { count = GetIListCount(targetObject); } 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); } else if (count == 0) { yield return new TreeNode(null, "(empty)", null, null, null); } else { for(int i = 0; i < count; i++) { string imageName; var image = ExpressionNode.GetImageForArrayIndexer(out imageName); var expression = new ExpressionNode(image, "[" + i + "]", targetObject.AppendIndexer(i)); expression.ImageName = imageName; yield return expression; } } }
public static IEnumerable<TreeNode> LazyGetMembersOfObject(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(image, memberInfo.Name, expression.AppendMemberReference((IDebugMemberInfo)memberInfo)); exp.ImageName = imageName; nodes.Add(exp); } return nodes; }