浏览代码

fix compile errors caused by unmatched API calling to foundation methods

/siyaoH-1.17-PlatformMessage
xingweizhu 4 年前
当前提交
31a9beba
共有 18 个文件被更改,包括 344 次插入273 次删除
  1. 128
      com.unity.uiwidgets/Runtime/animation/listener_helpers.mixin.gen.cs
  2. 30
      com.unity.uiwidgets/Runtime/animation/listener_helpers.mixin.njk
  3. 11
      com.unity.uiwidgets/Runtime/gestures/binding.cs
  4. 11
      com.unity.uiwidgets/Runtime/gestures/pointer_signal_resolver.cs
  5. 26
      com.unity.uiwidgets/Runtime/gestures/recognizer.cs
  6. 41
      com.unity.uiwidgets/Runtime/painting/image_provider.cs
  7. 14
      com.unity.uiwidgets/Runtime/painting/image_stream.cs
  8. 33
      com.unity.uiwidgets/Runtime/rendering/box.cs
  9. 46
      com.unity.uiwidgets/Runtime/rendering/debug_overflow_indicator.cs
  10. 23
      com.unity.uiwidgets/Runtime/rendering/flex.cs
  11. 20
      com.unity.uiwidgets/Runtime/rendering/layer.cs
  12. 108
      com.unity.uiwidgets/Runtime/rendering/object.cs
  13. 100
      com.unity.uiwidgets/Runtime/rendering/sliver.cs
  14. 4
      com.unity.uiwidgets/Runtime/services/binding.cs
  15. 2
      com.unity.uiwidgets/Runtime/widgets/binding.cs
  16. 2
      com.unity.uiwidgets/Runtime/widgets/debug.cs
  17. 16
      com.unity.uiwidgets/Runtime/widgets/framework.cs
  18. 2
      com.unity.uiwidgets/Runtime/widgets/image.cs

128
com.unity.uiwidgets/Runtime/animation/listener_helpers.mixin.gen.cs


using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.animation {
public abstract class AnimationLazyListenerMixinAnimation<T> : Animation<T> {
int _listenerCounter = 0;

}
public abstract class AnimationEagerListenerMixinAnimation<T> : Animation<T> {
protected void didRegisterListener() {
}

}
public abstract class AnimationLocalListenersMixinAnimationLazyListenerMixinAnimation<T> : AnimationLazyListenerMixinAnimation<T> {
public abstract class
AnimationLocalListenersMixinAnimationLazyListenerMixinAnimation<T> : AnimationLazyListenerMixinAnimation<T> {
readonly ObserverList<VoidCallback> _listeners = new ObserverList<VoidCallback>();
public override void addListener(VoidCallback listener) {

if (_listeners.Contains(listener)) {
listener();
}
} catch (Exception exception) {
}
catch (Exception exception) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<
AnimationLocalListenersMixinAnimationLazyListenerMixinAnimation<T>>(
"The " + GetType() + " notifying listeners was:",
this,
style: DiagnosticsTreeStyle.errorProperty
);
}
context: "while notifying listeners for " + GetType(),
informationCollector: information => {
information.AppendLine("The " + GetType() + " notifying listeners was:");
information.Append(" " + this);
}
context: new ErrorDescription("while notifying listeners for " + GetType()),
informationCollector: infoCollector
));
}
}

public abstract class AnimationLocalListenersMixinAnimationEagerListenerMixinAnimation<T> : AnimationEagerListenerMixinAnimation<T> {
public abstract class
AnimationLocalListenersMixinAnimationEagerListenerMixinAnimation<T> : AnimationEagerListenerMixinAnimation<T> {
readonly ObserverList<VoidCallback> _listeners = new ObserverList<VoidCallback>();
public override void addListener(VoidCallback listener) {

if (_listeners.Contains(listener)) {
listener();
}
} catch (Exception exception) {
}
catch (Exception exception) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<
AnimationLocalListenersMixinAnimationEagerListenerMixinAnimation<T>>(
"The " + GetType() + " notifying listeners was:",
this,
style: DiagnosticsTreeStyle.errorProperty
);
}
context: "while notifying listeners for " + GetType(),
informationCollector: information => {
information.AppendLine("The " + GetType() + " notifying listeners was:");
information.Append(" " + this);
}
context: new ErrorDescription("while notifying listeners for " + GetType()),
informationCollector: infoCollector
));
}
}

public abstract class AnimationLocalStatusListenersMixinAnimationLocalListenersMixinAnimationLazyListenerMixinAnimation<T> : AnimationLocalListenersMixinAnimationLazyListenerMixinAnimation<T> {
public abstract class
AnimationLocalStatusListenersMixinAnimationLocalListenersMixinAnimationLazyListenerMixinAnimation<T> :
AnimationLocalListenersMixinAnimationLazyListenerMixinAnimation<T> {
readonly ObserverList<AnimationStatusListener> _statusListeners = new ObserverList<AnimationStatusListener>();
public override void addStatusListener(AnimationStatusListener listener) {

if (_statusListeners.Contains(listener)) {
listener(status);
}
} catch (Exception exception) {
}
catch (Exception exception) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<
AnimationLocalStatusListenersMixinAnimationLocalListenersMixinAnimationLazyListenerMixinAnimation
<T>>(
"The " + GetType() + " notifying listeners was:",
this,
style: DiagnosticsTreeStyle.errorProperty
);
}
context: "while notifying status listeners for " + GetType(),
informationCollector: information => {
information.AppendLine("The " + GetType() + " notifying status listeners was:");
information.Append(" " + this);
}
context: new ErrorDescription("while notifying status listeners for " + GetType()),
informationCollector: infoCollector
));
}
}

public abstract class AnimationLocalStatusListenersMixinAnimationLazyListenerMixinAnimation<T> : AnimationLazyListenerMixinAnimation<T> {
public abstract class
AnimationLocalStatusListenersMixinAnimationLazyListenerMixinAnimation<T> : AnimationLazyListenerMixinAnimation<T
> {
readonly ObserverList<AnimationStatusListener> _statusListeners = new ObserverList<AnimationStatusListener>();
public override void addStatusListener(AnimationStatusListener listener) {

if (_statusListeners.Contains(listener)) {
listener(status);
}
} catch (Exception exception) {
}
catch (Exception exception) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<
AnimationLocalStatusListenersMixinAnimationLazyListenerMixinAnimation<T>>(
"The " + GetType() + " notifying listeners was:",
this,
style: DiagnosticsTreeStyle.errorProperty
);
}
context: "while notifying status listeners for " + GetType(),
informationCollector: information => {
information.AppendLine("The " + GetType() + " notifying status listeners was:");
information.Append(" " + this);
}
context: new ErrorDescription("while notifying status listeners for " + GetType()),
informationCollector: infoCollector
));
}
}

public abstract class AnimationLocalStatusListenersMixinAnimationLocalListenersMixinAnimationEagerListenerMixinAnimation<T> : AnimationLocalListenersMixinAnimationEagerListenerMixinAnimation<T> {
public abstract class
AnimationLocalStatusListenersMixinAnimationLocalListenersMixinAnimationEagerListenerMixinAnimation<T> :
AnimationLocalListenersMixinAnimationEagerListenerMixinAnimation<T> {
readonly ObserverList<AnimationStatusListener> _statusListeners = new ObserverList<AnimationStatusListener>();
public override void addStatusListener(AnimationStatusListener listener) {

if (_statusListeners.Contains(listener)) {
listener(status);
}
} catch (Exception exception) {
}
catch (Exception exception) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<
AnimationLocalStatusListenersMixinAnimationLocalListenersMixinAnimationEagerListenerMixinAnimation
<T>>(
"The " + GetType() + " notifying listeners was:",
this,
style: DiagnosticsTreeStyle.errorProperty
);
}
context: "while notifying status listeners for " + GetType(),
informationCollector: information => {
information.AppendLine("The " + GetType() + " notifying status listeners was:");
information.Append(" " + this);
}
context: new ErrorDescription("while notifying status listeners for " + GetType()),
informationCollector: infoCollector
}

30
com.unity.uiwidgets/Runtime/animation/listener_helpers.mixin.njk


listener();
}
} catch (Exception exception) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<AnimationLocalListenersMixin{{with | safe}}>(
"The " + this.GetType() + " notifying listeners was:",
this,
style: DiagnosticsTreeStyle.errorProperty
);
}
context: "while notifying listeners for " + this.GetType(),
informationCollector: information => {
information.AppendLine("The " + this.GetType() + " notifying listeners was:");
information.Append(" " + this);
}
context: new ErrorDescription("while notifying listeners for " + this.GetType()),
informationCollector: infoCollector
));
}
}

listener(status);
}
} catch (Exception exception) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<AnimationLocalStatusListenersMixin{{with | safe}}>(
"The " + this.GetType() + " notifying listeners was:",
this,
style: DiagnosticsTreeStyle.errorProperty
);
}
context: "while notifying status listeners for " + this.GetType(),
informationCollector: information => {
information.AppendLine("The " + this.GetType() + " notifying status listeners was:");
information.Append(" " + this);
}
context: new ErrorDescription("while notifying status listeners for " + this.GetType()),
informationCollector: infoCollector
));
}
}

11
com.unity.uiwidgets/Runtime/gestures/binding.cs


pointerRouter.route(evt);
}
catch (Exception ex) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<PointerEvent>("Event", evt, style: DiagnosticsTreeStyle.errorProperty);
}
context: "while dispatching a non-hit-tested pointer event",
informationCollector: information => {
information.AppendLine("Event: ");
information.AppendFormat(" {0}", evt);
}
context: new ErrorDescription("while dispatching a non-hit-tested pointer event"),
informationCollector: infoCollector
)
);
}

11
com.unity.uiwidgets/Runtime/gestures/pointer_signal_resolver.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.foundation;
namespace Unity.UIWidgets.gestures {

_firstRegisteredCallback(_currentEvent);
}
catch (Exception exception) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<PointerSignalEvent>("Event", evt, style: DiagnosticsTreeStyle.errorProperty);
}
context: "while resolving a PointerSignalEvent",
informationCollector: information => {
information.AppendLine("Event: ");
information.AppendFormat(" {0}", evt);
}
context: new ErrorDescription("while resolving a PointerSignalEvent"),
informationCollector: infoCollector
)
);
}

26
com.unity.uiwidgets/Runtime/gestures/recognizer.cs


result = callback();
}
catch (Exception ex) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new StringProperty("Handler", name);
yield return new DiagnosticsProperty<GestureRecognizer>("Recognizer", this, style: DiagnosticsTreeStyle.errorProperty);
}
context: "while handling a gesture",
informationCollector: information => {
information.AppendLine("Handler: " + name);
information.AppendLine("Recognizer:");
information.AppendLine(" " + this);
}
context: new ErrorDescription("while handling a gesture"),
informationCollector: infoCollector
));
}

}
catch (Exception ex) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new StringProperty("Handler", name);
yield return new DiagnosticsProperty<GestureRecognizer>("Recognizer", this, style: DiagnosticsTreeStyle.errorProperty);
}
context: "while handling a gesture",
informationCollector: information => {
information.AppendLine("Handler: " + name);
information.AppendLine("Recognizer:");
information.AppendLine(" " + this);
}
context: new ErrorDescription("while handling a gesture"),
informationCollector: infoCollector
));
}

41
com.unity.uiwidgets/Runtime/painting/image_provider.cs


stream.setCompleter(imageCompleter);
InformationCollector collector = null;
D.assert(() => {
collector = (sb) => {
sb.Append(new DiagnosticsProperty<ImageProvider>("Image provider", this));
sb.Append(new DiagnosticsProperty<ImageConfiguration>("Image configuration",
configuration));
sb.Append(new DiagnosticsProperty<T>("Image key", key, defaultValue: null));
};
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<ImageProvider>("Image provider", this);
yield return new DiagnosticsProperty<ImageConfiguration>("Image configuration",
configuration);
yield return new DiagnosticsProperty<T>("Image key", key, defaultValue: null);
}
collector = infoCollector;
return true;
});
imageCompleter.setError(

}
protected override ImageStreamCompleter load(AssetBundleImageKey key, DecoderCallback decode) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<ImageProvider>("Image provider", this);
yield return new DiagnosticsProperty<AssetBundleImageKey>("Image key", key);
}
informationCollector: information => {
information.AppendLine($"Image provider: {this}");
information.Append($"Image key: {key}");
}
informationCollector: infoCollector
);
}

}
protected override ImageStreamCompleter load(NetworkImage key, DecoderCallback decode) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new ErrorDescription($"url: {url}");
}
informationCollector: information => {
information.AppendLine($"Image provider: {this}");
information.Append($"Image key: {key}");
}
informationCollector: infoCollector
);
}

}
protected override ImageStreamCompleter load(FileImage key, DecoderCallback decode) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new ErrorDescription($"Path: {file}");
}
informationCollector: information => { information.AppendLine($"Path: {file}"); });
informationCollector: infoCollector);
}
Future<Codec> _loadAsync(FileImage key, DecoderCallback decode) {

bool silent = false
) {
reportError(
context: context.toDescription(),
context: context,
exception: exception,
informationCollector: informationCollector,
silent: silent

14
com.unity.uiwidgets/Runtime/painting/image_stream.cs


}
catch (Exception ex) {
reportError(
context: "by a synchronously-called image listener",
context: new ErrorDescription("by a synchronously-called image listener"),
exception: ex
);
}

new UIWidgetsErrorDetails(
exception: ex,
library: "image resource service",
context: "when reporting an error to an image listener"
context: new ErrorDescription("when reporting an error to an image listener")
)
);
}

}
catch (Exception ex) {
reportError(
context: "by an image listener",
context: new ErrorDescription("by an image listener"),
exception: ex
);
}

protected void reportError(
string context = null,
DiagnosticsNode context = null,
Exception exception = null,
InformationCollector informationCollector = null,
bool silent = false) {

catch (Exception ex) {
UIWidgetsError.reportError(
new UIWidgetsErrorDetails(
context: "when reporting an error to an image listener",
context: new ErrorDescription("when reporting an error to an image listener"),
library: "image resource service",
exception: ex
)

image.then_(result => { setImage(result); }).catchError(err => {
reportError(
context: "resolving a single-frame image stream",
context: new ErrorDescription("resolving a single-frame image stream"),
exception: err,
informationCollector: informationCollector,
silent: true

codec.then_((Action<Codec>) _handleCodecReady, ex => {
reportError(
context: "resolving an image codec",
context: new ErrorDescription("resolving an image codec"),
exception: ex,
informationCollector: informationCollector,
silent: true

33
com.unity.uiwidgets/Runtime/rendering/box.cs


InformationCollector informationCollector = null
) {
D.assert(() => {
var throwError = new Action<string>(message => {
var information = new StringBuilder();
var throwError = new Action<DiagnosticsNode>(message => {
var diagnositicsInfo = new List<DiagnosticsNode>();
diagnositicsInfo.Add(message);
informationCollector(information);
diagnositicsInfo.AddRange(informationCollector.Invoke());
throw new UIWidgetsError($"{message}\n{information}The offending constraints were:\n {this}");
diagnositicsInfo.Add(new DiagnosticsProperty<BoxConstraints>("The offending constraints were", this, style: DiagnosticsTreeStyle.errorProperty));
throw new UIWidgetsError(
diagnositicsInfo
);
});
if (minWidth.isNaN() ||

whichFields = affectedFieldsList.Single();
}
throwError("BoxConstraints has NaN values in " + whichFields + ".");
throwError(new ErrorSummary("BoxConstraints has NaN values in " + whichFields + "."));
throwError("BoxConstraints has both a negative minimum width and a negative minimum height.");
throwError(new ErrorSummary("BoxConstraints has both a negative minimum width and a negative minimum height."));
throwError("BoxConstraints has a negative minimum width.");
throwError(new ErrorSummary("BoxConstraints has a negative minimum width."));
throwError("BoxConstraints has a negative minimum height.");
throwError(new ErrorSummary("BoxConstraints has a negative minimum height."));
throwError("BoxConstraints has both width and height constraints non-normalized.");
throwError(new ErrorSummary("BoxConstraints has both width and height constraints non-normalized."));
throwError("BoxConstraints has non-normalized width constraints.");
throwError(new ErrorSummary("BoxConstraints has non-normalized width constraints."));
throwError("BoxConstraints has non-normalized height constraints.");
throwError(new ErrorSummary("BoxConstraints has non-normalized height constraints."));
throwError("BoxConstraints forces an infinite width and infinite height.");
throwError(new ErrorSummary("BoxConstraints forces an infinite width and infinite height."));
throwError("BoxConstraints forces an infinite width.");
throwError(new ErrorSummary("BoxConstraints forces an infinite width."));
throwError("BoxConstraints forces an infinite height.");
throwError(new ErrorSummary("BoxConstraints forces an infinite height."));
}
}

46
com.unity.uiwidgets/Runtime/rendering/debug_overflow_indicator.cs


using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEditor.PackageManager;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
using Gradient = Unity.UIWidgets.ui.Gradient;

return regions;
}
static void _reportOverflow(RenderObject renderObject, RelativeRect overflow, string overflowHints) {
overflowHints = overflowHints ?? $"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()}.\n" +
"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.";
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) {

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)));
}
context: "during layout",
informationCollector: (information) => {
information.AppendLine(overflowHints);
information.AppendLine($"The specific {renderObject.GetType()} in question is:");
information.AppendLine($" {renderObject.toStringShallow(joiner: "\n ")}");
information.AppendLine(string.Concat(Enumerable.Repeat("◢◤", 32)));
}
context: new ErrorDescription("during layout"),
informationCollector: infoCollector
)
);
}

Offset offset,
Rect containerRect,
Rect childRect,
string overflowHints = null
List<DiagnosticsNode> overflowHints = null
) {
RelativeRect overflow = RelativeRect.fromRect(containerRect, childRect);

23
com.unity.uiwidgets/Runtime/rendering/flex.cs


context.pushClipRect(needsCompositing, offset, Offset.zero & size, defaultPaint);
D.assert(() => {
string debugOverflowHints =
$"The overflowing {GetType()} has an orientation of {_direction}.\n" +
List<DiagnosticsNode> debugOverflowHints = new List<DiagnosticsNode>{
new ErrorDescription(
$"The overflowing {GetType()} has an orientation of {_direction}."
),
new ErrorDescription(
"in the rendering with a yellow and black striped pattern. This is " +
$"usually caused by the contents being too big for the {GetType()}. " +
"in the rendering with a yellow and black striped pattern. This is " +
"usually caused by the contents being too big for the $runtimeType."
),
new ErrorHint(
"space instead of being sized to their natural size.\n" +
"space instead of being sized to their natural size."
),
new ErrorHint(
"than a Flex, like a ListView.";
"than a Flex, like a ListView."
)
};
Rect overflowChildRect;
switch (_direction) {
case Axis.horizontal:

20
com.unity.uiwidgets/Runtime/rendering/layer.cs


}
List<PictureLayer> _processConflictingPhysicalLayers(PhysicalModelLayer predecessor, PhysicalModelLayer child) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return child.toDiagnosticsNode(name: "Attempted to composite layer",
style: DiagnosticsTreeStyle.errorProperty);
yield return predecessor.toDiagnosticsNode(name: "after layer",
style: DiagnosticsTreeStyle.errorProperty);
yield return new ErrorDescription("which occupies the same area at a higher elevation.");
}
context: "during compositing",
informationCollector: (StringBuilder builder) => {
builder.AppendLine("Attempted to composite layer");
builder.AppendLine(child.ToString());
builder.AppendLine("after layer");
builder.AppendLine(predecessor.ToString());
builder.AppendLine("which occupies the same area at a higher elevation.");
}
library: "rendering library",
context: new ErrorDescription("during compositing"),
informationCollector: infoCollector
return new List<PictureLayer> {
_highlightConflictingLayer(predecessor),
_highlightConflictingLayer(child)

108
com.unity.uiwidgets/Runtime/rendering/object.cs


public object debugCreator;
void _debugReportException(string method, Exception exception) {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsDebugCreator(debugCreator);
yield return describeForError("The following RenderObject was being processed when the exception was fired");
yield return describeForError("RenderObject", style: DiagnosticsTreeStyle.truncateChildren);
}
context: "during " + method,
context: new ErrorDescription("during " + method),
informationCollector: information => {
information.AppendLine(
"The following RenderObject was being processed when the exception was fired:");
information.AppendLine(" " + toStringShallow(joiner: "\n "));
var descendants = new List<string>();
const int maxDepth = 5;
int depth = 0;
const int maxLines = 25;
int lines = 0;
RenderObjectVisitor visitor = null;
visitor = new RenderObjectVisitor((RenderObject child) => {
if (lines < maxLines) {
depth += 1;
descendants.Add(new string(' ', 2 * depth) + child);
if (depth < maxDepth) {
child.visitChildren(visitor);
}
depth -= 1;
}
else if (lines == maxLines) {
descendants.Add(" ...(descendants list truncated after " + lines + " lines)");
}
lines += 1;
});
visitChildren(visitor);
if (lines > 1) {
information.AppendLine(
"This RenderObject had the following descendants (showing up to depth " +
maxDepth + "):");
}
else if (descendants.Count == 1) {
information.AppendLine("This RenderObject had the following child:");
}
else {
information.AppendLine("This RenderObject has no descendants.");
}
information.Append(string.Join("\n", descendants.ToArray()));
}
informationCollector: infoCollector
));
}

public void layout(Constraints constraints, bool parentUsesSize = false) {
D.assert(constraints != null);
D.assert(constraints.debugAssertIsValid(
isAppliedConstraint: true,
informationCollector: information => {
// final List<String> stack = StackTrace.current.toString().split('\n');
// int targetFrame;
// final Pattern layoutFramePattern = RegExp(r'^#[0-9]+ +RenderObject.layout \(');
// for (int i = 0; i < stack.length; i += 1) {
// if (layoutFramePattern.matchAsPrefix(stack[i]) != null) {
// targetFrame = i + 1;
// break;
// }
// }
// if (targetFrame != null && targetFrame < stack.length) {
// information.writeln(
// 'These invalid constraints were provided to $runtimeType\'s layout() '
// 'function by the following function, which probably computed the '
// 'invalid constraints in question:'
// );
// final Pattern targetFramePattern = RegExp(r'^#[0-9]+ +(.+)$');
// final Match targetFrameMatch = targetFramePattern.matchAsPrefix(stack[targetFrame]);
// if (targetFrameMatch != null && targetFrameMatch.groupCount > 0) {
// information.writeln(' ${targetFrameMatch.group(1)}');
// } else {
// information.writeln(stack[targetFrame]);
// }
// }
}));
D.assert(
() => {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new ErrorDescription(
$"These invalid constraints were provided to {GetType()}'s layout() " +
"function by the following function, which probably computed the " +
"invalid constraints in question:\n" +
" unknown");
}
return constraints.debugAssertIsValid(
isAppliedConstraint: true,
informationCollector: infoCollector);
}
);
D.assert(!_debugDoingThisResize);
D.assert(!_debugDoingThisLayout);

);
}
}
protected DiagnosticsNode describeForError(String name, DiagnosticsTreeStyle style = DiagnosticsTreeStyle.shallow) {
return toDiagnosticsNode(name: name, style: style);
}
}
public interface RenderObjectWithChildMixin {

public UIWidgetsErrorDetailsForRendering(
Exception exception = null,
string library = null,
string context = null,
DiagnosticsNode context = null,
RenderObject renderObject = null,
InformationCollector informationCollector = null,
bool silent = false

}
public readonly RenderObject renderObject;
}
public class DiagnosticsDebugCreator : DiagnosticsProperty<object> {
public DiagnosticsDebugCreator(object value) :
base(
"debugCreator",
value,
level: DiagnosticLevel.hidden
) {
D.assert(value != null);
}
}
}

100
com.unity.uiwidgets/Runtime/rendering/sliver.cs


using System;
using System.Collections.Generic;
using System.Text;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;

InformationCollector informationCollector = null
) {
D.assert(() => {
bool hasErrors = false;
StringBuilder errorMessage = new StringBuilder("\n");
var information = new StringBuilder();
if (informationCollector != null) {
informationCollector(information);
}
throw new UIWidgetsError(
$"{GetType()} is not valid: {message}\n{information}The offending constraints were: \n {this}");
hasErrors = true;
errorMessage.AppendLine($" {message}");
});
verify(scrollOffset >= 0.0f, "The \"scrollOffset\" is negative.");

verify(remainingCacheExtent >= 0.0f, "The \"remainingCacheExtent\" is negative.");
verify(cacheOrigin <= 0.0f, "The \"cacheOrigin\" is positive.");
verify(isNormalized, "The constraints are not normalized.");
if (hasErrors) {
List<DiagnosticsNode> diagnosticInfo = new List<DiagnosticsNode>();
diagnosticInfo.Add(new ErrorSummary($"{GetType()} is not valid: {errorMessage}"));
if (informationCollector != null) {
diagnosticInfo.AddRange(informationCollector.Invoke());
}
diagnosticInfo.Add(new DiagnosticsProperty<SliverConstraints>("The offending constraints were", this, style: DiagnosticsTreeStyle.errorProperty));
throw new UIWidgetsError(
diagnosticInfo);
}
return true;
});

public readonly float cacheExtent;
public const float precisionErrorTolerance = 1e-10f;
internal static string _debugCompareFloats(string labelA, float valueA, string labelB, float valueB) {
internal static List<DiagnosticsNode> _debugCompareFloats(string labelA, float valueA, string labelB, float valueB) {
List<DiagnosticsNode> diagnosticInfo = new List<DiagnosticsNode>();
return $"The {labelA} is {valueA:F1}, but the {labelB} is {valueB:F1}. ";
diagnosticInfo.Add(new ErrorDescription($"The {labelA} is {valueA:F1}, but the {labelB} is {valueB:F1}. "));
}
else {
diagnosticInfo.Add(new ErrorDescription($"The {labelA} is {valueA}, but the {labelB} is {valueB}."));
diagnosticInfo.Add(new ErrorHint("Maybe you have fallen prey to floating point rounding errors, and should explicitly " +
$"apply the min() or max() functions, or the clamp() method, to the {labelB}? "));
return string.Format(
"The {0} is {1}, but the {2} is {3}. " +
"Maybe you have fallen prey to floating point rounding errors, and should explicitly " +
"apply the min() or max() functions, or the clamp() method, to the {2}? ",
labelA, valueA, labelB, valueB);
return diagnosticInfo;
var verify = new Action<bool, string>((bool check, string message) => {
void verify(bool check, string summary, List<DiagnosticsNode> details = null) {
List<DiagnosticsNode> diagnosticInfo = new List<DiagnosticsNode>();
diagnosticInfo.Add(new ErrorSummary($"{GetType()} is not valid: {summary}"));
if (details != null) {
diagnosticInfo.AddRange(details);
}
var information = new StringBuilder();
informationCollector(information);
diagnosticInfo.AddRange(informationCollector.Invoke());
throw new UIWidgetsError($"{GetType()} is not valid: {message}\n{information}");
});
throw new UIWidgetsError(diagnosticInfo);
};
verify(scrollExtent >= 0.0f, "The \"scrollExtent\" is negative.");
verify(paintExtent >= 0.0f, "The \"paintExtent\" is negative.");

verify(false,
"The \"layoutExtent\" exceeds the \"paintExtent\".\n" +
_debugCompareFloats("paintExtent", paintExtent, "layoutExtent",
"The \"layoutExtent\" exceeds the \"paintExtent\".",
details: _debugCompareFloats("paintExtent", paintExtent, "layoutExtent",
var details = _debugCompareFloats("maxPaintExtent", maxPaintExtent, "paintExtent",
paintExtent);
details.Add(new ErrorDescription("By definition, a sliver can\"t paint more than the maximum that it can paint!"));
"The \"maxPaintExtent\" is less than the \"paintExtent\".\n" +
_debugCompareFloats("maxPaintExtent", maxPaintExtent, "paintExtent",
paintExtent) +
"By definition, a sliver can\"t paint more than the maximum that it can paint!"
"The \"maxPaintExtent\" is less than the \"paintExtent\".",
details: details
);
}

}
protected override void debugAssertDoesMeetConstraints() {
D.assert(geometry.debugAssertIsValid(
informationCollector: (information) => {
information.AppendLine("The RenderSliver that returned the offending geometry was:");
information.AppendLine(" " + toStringShallow(joiner: "\n "));
}));
D.assert(
() => {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return describeForError("The RenderSliver that returned the offending geometry was");
}
return geometry.debugAssertIsValid(
informationCollector: infoCollector);
});
List<DiagnosticsNode> diagnosticInfo = new List<DiagnosticsNode>();
diagnosticInfo.Add(new ErrorSummary("SliverGeometry has a paintOffset that exceeds the remainingPaintExtent from the constraints."));
diagnosticInfo.Add(describeForError("The render object whose geometry violates the constraints is the following:"));
diagnosticInfo.AddRange(SliverGeometry._debugCompareFloats("remainingPaintExtent", constraints.remainingPaintExtent,
"paintExtent", geometry.paintExtent));
diagnosticInfo.Add(new ErrorDescription("The paintExtent must cause the child sliver to paint within the viewport, and so " +
"cannot exceed the remainingPaintExtent."));
"SliverGeometry has a paintOffset that exceeds the remainingPaintExtent from the constraints.\n" +
"The render object whose geometry violates the constraints is the following:\n" +
" " + toStringShallow(joiner: "\n ") + "\n" +
SliverGeometry._debugCompareFloats(
"remainingPaintExtent", constraints.remainingPaintExtent,
"paintExtent", geometry.paintExtent) +
"The paintExtent must cause the child sliver to paint within the viewport, and so " +
"cannot exceed the remainingPaintExtent."
diagnosticInfo
);
}

4
com.unity.uiwidgets/Runtime/services/binding.cs


UIWidgetsError.reportError(new UIWidgetsErrorDetails(
exception: exception,
library: "services library",
context: "during a platform message response callback"
context: new ErrorDescription("during a platform message response callback")
));
}
});

UIWidgetsError.reportError(new UIWidgetsErrorDetails(
exception: exception,
library: "services library",
context: "during a platform message callback")
context: new ErrorDescription("during a platform message callback"))
);
callback(null);
return FutureOr.nil;

2
com.unity.uiwidgets/Runtime/widgets/binding.cs


var details = new UIWidgetsErrorDetails(
exception: ex,
library: "widgets library",
context: "attaching to the render tree"
context: new ErrorDescription("attaching to the render tree")
);
UIWidgetsError.reportError(details);

2
com.unity.uiwidgets/Runtime/widgets/debug.cs


var details = new UIWidgetsErrorDetails(
exception: exception,
library: "widgets library",
context: context,
context: new ErrorDescription(context),
informationCollector: informationCollector
);
UIWidgetsError.reportError(details);

16
com.unity.uiwidgets/Runtime/widgets/framework.cs


_dirtyElements[index].rebuild();
}
catch (Exception ex) {
IEnumerable<DiagnosticsNode> infoCollector() {
//yield return new DiagnosticsDebugCreator(new DebugCreator(_dirtyElements[index]));
yield return _dirtyElements[index].describeElement($"The element being rebuilt at the time was index {index} of {dirtyCount}");
}
informationCollector: (information) => {
information.AppendLine(
"The element being rebuilt at the time was index "
+ index + " of " + dirtyCount + ":");
information.Append(" " + _dirtyElements[index]);
}
informationCollector: infoCollector
);
}

public delegate Widget ErrorWidgetBuilder(UIWidgetsErrorDetails details);
internal class _ElementDiagnosticableTreeNode : _DiagnosticableTreeNode {
internal class _ElementDiagnosticableTreeNode : DiagnosticableTreeNode {
internal _ElementDiagnosticableTreeNode(
Element value,
DiagnosticsTreeStyle style,

}
catch (UIWidgetsError e) {
UIWidgetsError.reportError(new UIWidgetsErrorDetails(
context: "while apply parent data",
context: new ErrorDescription("while apply parent data"),
exception: e
));
}

2
com.unity.uiwidgets/Runtime/widgets/image.cs


}
else {
UIWidgetsError.reportError(new UIWidgetsErrorDetails(
context: "image failed to precache",
context: new ErrorDescription("image failed to precache"),
library: "image resource service",
exception: exception,
silent: true

正在加载...
取消
保存