public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { base.debugFillProperties(properties); properties.add(DiagnosticsNode.message(this.firstChild != null ? "currently live children: " + this.indexOf(this.firstChild) + " to " + this.indexOf(this.lastChild) : "no children current live")); }
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { base.debugFillProperties(properties); properties.add( new StringProperty( "text", text, showName: false, defaultValue: null ) ); if (style == null && text == null && children == null) { properties.add(DiagnosticsNode.message("(empty)")); } properties.add(new DiagnosticsProperty <GestureRecognizer>( "recognizer", recognizer, description: recognizer?.GetType()?.ToString(), defaultValue: null )); if (semanticsLabel != null) { properties.add(new StringProperty("semanticsLabel", semanticsLabel)); } }
private Config() { Gui = GuiNode.GetDefault(); ContextMenu = ContextMenuNode.GetDefault(); Overlay = OverlayNode.GetDefault(); Diagnostics = DiagnosticsNode.GetDefault(); }
private Config(GuiNode gui, ContextMenuNode contextMenu, OverlayNode overlay, DiagnosticsNode diagnostics) { Gui = gui; ContextMenu = contextMenu; Overlay = overlay; Diagnostics = diagnostics; }
public override List <DiagnosticsNode> debugDescribeChildren() { if (this._children.isEmpty()) { return(new List <DiagnosticsNode> { DiagnosticsNode.message("table is empty") }); } List <DiagnosticsNode> children = new List <DiagnosticsNode>(); for (int y = 0; y < this.rows; y++) { for (int x = 0; x < this.columns; x++) { int xy = x + y * this.columns; RenderBox child = this._children[xy]; string name = $"child ({x}, {y})"; if (child != null) { children.Add(child.toDiagnosticsNode(name: name)); } else { children.Add(new DiagnosticsProperty <object>(name, null, ifNull: "is null", showSeparator: false)); } } } return(children); }
public override List <DiagnosticsNode> debugDescribeChildren() { List <DiagnosticsNode> offstageChildren = new List <DiagnosticsNode>(); List <DiagnosticsNode> onstageChildren = new List <DiagnosticsNode>(); int count = 1; bool onstage = false; RenderBox child = firstChild; RenderBox firstOnstageChild = _firstOnstageChild; while (child != null) { if (child == firstOnstageChild) { onstage = true; count = 1; } if (onstage) { onstageChildren.Add( child.toDiagnosticsNode( name: $"onstage {count}" ) ); } else { offstageChildren.Add( child.toDiagnosticsNode( name: $"offstage {count}", style: DiagnosticsTreeStyle.offstage ) ); } StackParentData childParentData = child.parentData as StackParentData; child = childParentData.nextSibling; count += 1; } List <DiagnosticsNode> result = new List <DiagnosticsNode>(); result.AddRange(onstageChildren); if (offstageChildren.isNotEmpty()) { result.AddRange(offstageChildren); } else { result.Add(DiagnosticsNode.message("no offstage children", style: DiagnosticsTreeStyle.offstage)); } return(result); }
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { base.debugFillProperties(properties); string message = "disabled"; D.assert(() => { message = "'DEBUG'"; return(true); }); properties.add(DiagnosticsNode.message(message)); }
public Dictionary <string, object> getSelectedRenderObject(string previousSelectionId, string groupName) { DiagnosticsNode previousSelection = this.toObject(previousSelectionId) as DiagnosticsNode; RenderObject current = this.selection == null ? null : this.selection.current; return(this._nodeToJson( current == (previousSelection == null ? null : previousSelection.valueObject) ? previousSelection : (current == null ? null : current.toDiagnosticsNode()), new _SerializeConfig(groupName: groupName))); }
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { D.assert(() => { properties.add(DiagnosticsNode.message("debug mode enabled")); return(true); }); properties.add(new DiagnosticsProperty <Size>("window size", Window.instance.physicalSize, tooltip: "in physical pixels")); properties.add(new FloatProperty("device pixel ratio", Window.instance.devicePixelRatio, tooltip: "physical pixels per logical pixel")); properties.add(new DiagnosticsProperty <ViewConfiguration>("configuration", configuration, tooltip: "in logical pixels")); }
public void setError( DiagnosticsNode context, Exception exception, string stack, InformationCollector informationCollector, bool silent = false ) { reportError( context: context, exception: exception, informationCollector: informationCollector, silent: silent ); }
public UIWidgetsErrorDetails( Exception exception = null, string library = "UIWidgets framework", DiagnosticsNode context = null, IterableFilter <string> stackFilter = null, InformationCollector informationCollector = null, bool silent = false ) { this.exception = exception; this.library = library; this.context = context; this.stackFilter = stackFilter; this.informationCollector = informationCollector; this.silent = silent; }
internal static UIWidgetsErrorDetails _debugReportException( DiagnosticsNode context, Exception exception, InformationCollector informationCollector = null ) { var details = new UIWidgetsErrorDetails( exception: exception, library: "widgets library", context: context, informationCollector: informationCollector ); UIWidgetsError.reportError(details); return(details); }
bool _shouldShowInSummaryTree(DiagnosticsNode node) { var value = node.valueObject; if (!(value is Diagnosticable)) { return(true); } if (!(value is Element) || !this.isWidgetCreationTracked()) { return(true); } return(this._isValueCreatedByLocalProject(value)); }
public Dictionary <string, object> getSelectedWidget(string previousSelectionId, string groupName) { DiagnosticsNode previousSelection = (DiagnosticsNode)this.toObject(previousSelectionId); Element current = null; if (this.selection != null) { current = this.selection.currentElement; } return(this._nodeToJson( current == (previousSelection == null ? null : previousSelection.valueObject) ? previousSelection : (current == null ? null : current.toDiagnosticsNode()), new _SerializeConfig(groupName: groupName))); }
void _invokeFrameCallback(FrameCallback callback, TimeSpan timeStamp, string callbackStack = null) { D.assert(callback != null); D.assert(_FrameCallbackEntry.debugCurrentCallbackStack == null); D.assert(() => { _FrameCallbackEntry.debugCurrentCallbackStack = callbackStack; return(true); }); try { callback(timeStamp: timeStamp); } catch (Exception ex) { IEnumerable <DiagnosticsNode> infoCollector() { yield return(DiagnosticsNode.message( "\nThis exception was thrown in the context of a scheduler callback. " + "When the scheduler callback was _registered_ (as opposed to when the " + "exception was thrown), this was the stack:")); var builder = new StringBuilder(); foreach (var line in UIWidgetsError.defaultStackFilter( callbackStack.TrimEnd().Split('\n'))) { builder.AppendLine(value: line); } yield return(DiagnosticsNode.message(builder.ToString())); } UIWidgetsError.reportError(new UIWidgetsErrorDetails( exception: ex, "scheduler library", new ErrorDescription("during a scheduler callback"), informationCollector: callbackStack == null ? (InformationCollector)null : infoCollector )); } D.assert(() => { _FrameCallbackEntry.debugCurrentCallbackStack = null; return(true); }); }
public override List <DiagnosticsNode> debugDescribeChildren() { if (children == null) { return(new List <DiagnosticsNode>()); } return(LinqUtils <DiagnosticsNode, InlineSpan> .SelectList(children, ((child) => { if (child != null) { return child.toDiagnosticsNode(); } else { return DiagnosticsNode.message("<null child>"); } }))); }
bool handleEventLoopCallback() { if (_taskQueue.isEmpty || locked) { return(false); } var entry = _taskQueue.first; if (schedulingStrategy(priority: entry.priority, this)) { try { _taskQueue.removeFirst(); entry.run(); } catch (Exception exception) { string callbackStack = null; D.assert(() => { callbackStack = entry.debugStack; return(true); }); IEnumerable <DiagnosticsNode> infoCollector() { yield return(DiagnosticsNode.message( "\nThis exception was thrown in the context of a scheduler callback. " + "When the scheduler callback was _registered_ (as opposed to when the " + "exception was thrown), this was the stack: " + callbackStack)); } UIWidgetsError.reportError(new UIWidgetsErrorDetails( exception: exception, "scheduler library", new ErrorDescription("during a task callback"), informationCollector: callbackStack == null ? (InformationCollector)null : infoCollector )); } return(_taskQueue.isNotEmpty); } return(false); }
public override List <DiagnosticsNode> debugDescribeChildren() { if (this.children == null) { return(new List <DiagnosticsNode>()); } return(this.children.Select((child) => { if (child != null) { return child.toDiagnosticsNode(); } else { return DiagnosticsNode.message("<null child>"); } }).ToList()); }
public override List <DiagnosticsNode> debugDescribeChildren() { var children = new List <DiagnosticsNode>(); if (this.child != null) { children.Add(this.child.toDiagnosticsNode(name: "onstage")); } if (this.firstChild != null) { var child = this.firstChild; int count = 1; while (true) { children.Add( child.toDiagnosticsNode( name: $"offstage {count}", style: DiagnosticsTreeStyle.offstage ) ); if (child == this.lastChild) { break; } var childParentData = (StackParentData)child.parentData; child = childParentData.nextSibling; count += 1; } } else { children.Add( DiagnosticsNode.message( "no offstage children", style: DiagnosticsTreeStyle.offstage ) ); } return(children); }
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { base.debugFillProperties(properties); DiagnosticsNode verb = context != null ? new ErrorDescription($"thrown {new ErrorDescription($" {context}")}") : new ErrorDescription(""); Diagnosticable diagnosticable = _exceptionToDiagnosticable(); if (exception is NullReferenceException) { properties.add(new ErrorDescription($"The null value was {verb}.")); } else { DiagnosticsNode errorName; errorName = new ErrorDescription($"{exception.GetType()}"); properties.add(new ErrorDescription($"The following {errorName} was {verb}:")); if (diagnosticable != null) { diagnosticable.debugFillProperties(properties); } else { string prefix = $"{exception.GetType()}"; string message = exceptionAsString(); if (message.StartsWith(prefix)) { message = message.Substring(prefix.Length); } properties.add(new ErrorSummary(message)); } } if (informationCollector != null) { properties.add(new ErrorSpacer()); foreach (var diagnosticsNode in informationCollector()) { properties.add(diagnosticsNode); } } }
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { base.debugFillProperties(properties); if (this._recognizers == null) { properties.add(DiagnosticsNode.message("DISPOSED")); } else { List <string> gestures = this._recognizers.Values.Select(recognizer => recognizer.debugDescription) .ToList(); properties.add(new EnumerableProperty <string>("gestures", gestures, ifEmpty: "<none>")); properties.add(new EnumerableProperty <GestureRecognizer>("recognizers", this._recognizers.Values, level: DiagnosticLevel.fine)); } properties.add(new EnumProperty <HitTestBehavior?>("behavior", this.widget.behavior, defaultValue: Diagnostics.kNullDefaultValue)); }
List <DiagnosticsNode> _getChildrenFiltered(DiagnosticsNode node, _SerializeConfig config) { var children = new List <DiagnosticsNode>(); foreach (var child in node.getChildren()) { if (!config.summaryTree || this._shouldShowInSummaryTree(child)) { children.Add(child); } else { children.AddRange(this._getChildrenFiltered(child, config)); } } return(children); }
protected void reportError( DiagnosticsNode context = null, Exception exception = null, InformationCollector informationCollector = null, bool silent = false) { _currentError = new UIWidgetsErrorDetails( exception: exception, library: "image resource service", context: context, informationCollector: informationCollector, silent: silent ); var localErrorListeners = LinqUtils <ImageErrorListener> .WhereList( LinqUtils <ImageErrorListener, ImageStreamListener> .SelectList(_listeners, (l => l.onError)), (l => l != null)); if (localErrorListeners.isEmpty()) { UIWidgetsError.reportError(_currentError); } else { foreach (var errorListener in localErrorListeners) { try { errorListener(exception); } catch (Exception ex) { UIWidgetsError.reportError( new UIWidgetsErrorDetails( context: new ErrorDescription("when reporting an error to an image listener"), library: "image resource service", exception: ex ) ); } } } }
public static Config TryParse(ConfigNode node) { if (node != null) { var gui = GuiNode.TryParse(node.GetNode("GUI")) ?? GuiNode.GetDefault(); var contextMenu = ContextMenuNode.TryParse(node.GetNode("CONTEXT_MENU")) ?? ContextMenuNode.GetDefault(); var overlay = OverlayNode.TryParse(node.GetNode("OVERLAY")) ?? OverlayNode.GetDefault(); var diagnostics = DiagnosticsNode.TryParse(node.GetNode("DIAGNOSTICS")) ?? DiagnosticsNode.GetDefault(); return(new Config(gui, contextMenu, overlay, diagnostics)); } Log.Debug("Could not parse missing HOT_SPOT node"); return(null); }
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { base.debugFillProperties(properties); properties.defaultDiagnosticsTreeStyle = DiagnosticsTreeStyle.whitespace; // Properties on style are added as if they were properties directly on // this TextSpan. if (this.style != null) { this.style.debugFillProperties(properties); } properties.add(new DiagnosticsProperty <GestureRecognizer>( "recognizer", this.recognizer, description: this.recognizer == null ? "" : this.recognizer.GetType().FullName, defaultValue: Diagnostics.kNullDefaultValue )); properties.add(new StringProperty("text", this.text, showName: false, defaultValue: Diagnostics.kNullDefaultValue)); if (this.style == null && this.text == null && this.children == null) { properties.add(DiagnosticsNode.message("(empty)")); } }
public static DiagnosticsNode _createStackFrame(string frame) { return(DiagnosticsNode.message(frame, allowWrap: false)); }
bool _hitTestHelper( List <RenderObject> hits, List <RenderObject> edgeHits, Offset position, RenderObject renderObject, Matrix3 transform ) { var hit = false; var inverse = Matrix3.I(); var invertible = transform.invert(inverse); if (!invertible) { return(false); } var localPosition = inverse.mapPoint(position); List <DiagnosticsNode> children = renderObject.debugDescribeChildren(); for (int i = children.Count - 1; i >= 0; --i) { DiagnosticsNode diagnostics = children[i]; D.assert(diagnostics != null); if (diagnostics.style == DiagnosticsTreeStyle.offstage || (!(diagnostics.valueObject is RenderObject))) { continue; } RenderObject child = (RenderObject)diagnostics.valueObject; Rect paintClip = renderObject.describeApproximatePaintClip(child); if (paintClip != null && !paintClip.contains(localPosition)) { continue; } var childTransform = new Matrix3(transform); renderObject.applyPaintTransform(child, childTransform); if (this._hitTestHelper(hits, edgeHits, position, child, childTransform)) { hit = true; } } Rect bounds = renderObject.semanticBounds; if (bounds.contains(localPosition)) { hit = true; if (!bounds.deflate(_edgeHitMargin).contains(localPosition)) { edgeHits.Add(renderObject); } } if (hit) { hits.Add(renderObject); } return(hit); }
Dictionary <string, object> _nodeToJson(DiagnosticsNode node, _SerializeConfig config) { if (node == null) { return(null); } var ret = node.toJsonMap(); var value = node.valueObject; ret["objectId"] = this.toId(node, config.groupName); ret["valueId"] = this.toId(value, config.groupName); if (config.summaryTree) { ret["summaryTree"] = config.summaryTree; } var createdByLocalProject = true; // todo; if (config.subtreeDepth > 0 || (config.pathToInclude != null && config.pathToInclude.Count > 0)) { ret["children"] = this._nodesToJson(this._getChildrenFiltered(node, config), config); } if (config.includeProperties) { ret["properties"] = this._nodesToJson( node.getProperties().Where((n) => !n.isFiltered(createdByLocalProject ? DiagnosticLevel.fine : DiagnosticLevel.info)).ToList(), new _SerializeConfig(groupName: config.groupName, subtreeDepth: 1, expandPropertyValues: true) ); } var typeDef = typeof(DiagnosticsProperty <>); var nodeType = node.GetType(); if (nodeType.IsGenericType && nodeType.GetGenericTypeDefinition() == typeDef) { if (value is Color) { ret["valueProperties"] = new Dictionary <string, object> { { "red", ((Color)value).red }, { "green", ((Color)value).green }, { "blue", ((Color)value).blue }, { "alpha", ((Color)value).alpha }, }; } else if (value is IconData) { ret["valueProperties"] = new Dictionary <string, object> { { "codePoint", ((IconData)value).codePoint } }; } if (config.expandPropertyValues && value is Diagnosticable) { ret["properties"] = this._nodesToJson( ((Diagnosticable)value).toDiagnosticsNode().getProperties() .Where(n => !n.isFiltered(DiagnosticLevel.info)).ToList(), new _SerializeConfig(groupName: config.groupName, subtreeDepth: 0, expandPropertyValues: false) ); } } return(ret); }
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { base.debugFillProperties(properties); properties.add(DiagnosticsNode.message(firstChild != null ? $"currently live children: {indexOf(firstChild)} to {indexOf(lastChild)}" : "no children current live")); }
static void _reportOverflow(RenderObject renderObject, RelativeRect overflow, List <DiagnosticsNode> overflowHints) { overflowHints = overflowHints ?? new List <DiagnosticsNode>(); if (overflowHints.isEmpty()) { overflowHints.Add( new ErrorDescription( $"The edge of the {renderObject.GetType()} that is " + "overflowing has been marked in the rendering with a yellow and black " + "striped pattern. This is usually caused by the contents being too big " + $"for the {renderObject.GetType()}.")); overflowHints.Add( new ErrorHint( "This is considered an error condition because it indicates that there " + "is content that cannot be seen. If the content is legitimately bigger " + "than the available space, consider clipping it with a ClipRect widget " + $"before putting it in the {renderObject.GetType()}, or using a scrollable " + "container, like a ListView.")); } List <string> overflows = new List <string>(); if (overflow.left > 0.0f) { overflows.Add($"{_formatPixels(overflow.left)} pixels on the left"); } if (overflow.top > 0.0f) { overflows.Add($"{_formatPixels(overflow.top)} pixels on the top"); } if (overflow.bottom > 0.0f) { overflows.Add($"{_formatPixels(overflow.bottom)} pixels on the bottom"); } if (overflow.right > 0.0f) { overflows.Add($"{_formatPixels(overflow.right)} pixels on the right"); } string overflowText = ""; D.assert(overflows.isNotEmpty(), () => $"Somehow {renderObject.GetType()} didn't actually overflow like it thought it did."); switch (overflows.Count) { case 1: overflowText = overflows.first(); break; case 2: overflowText = $"{overflows.first()} and {overflows.last()}"; break; default: overflows[overflows.Count - 1] = $"and {overflows[overflows.Count - 1]}"; overflowText = string.Join(", ", overflow); break; } IEnumerable <DiagnosticsNode> infoCollector() { foreach (var hint in overflowHints) { yield return(hint); } yield return(DiagnosticsNode.message($"The specific {renderObject.GetType()} in question is: {renderObject.toStringShallow(joiner: "\n ")}")); yield return(DiagnosticsNode.message(string.Concat(Enumerable.Repeat("◢◤", 32)), allowWrap: false)); } UIWidgetsError.reportError( new UIWidgetsErrorDetails( exception: new Exception($"A {renderObject.GetType()} overflowed by {overflowText}."), library: "rendering library", context: new ErrorDescription("during layout"), informationCollector: infoCollector ) ); }