Skip to content

Commit ccfaec4

Browse files
author
David Karlaš
authored
Merge pull request #98 from mono/helpLink
Added string HelpLink property to ExceptionInfo class
2 parents 621df7c + 311e5c1 commit ccfaec4

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

Mono.Debugging/Mono.Debugging.Client/ExceptionInfo.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,21 @@ public string Message {
108108
}
109109
}
110110

111+
ObjectValue helpLinkObject;
112+
public string HelpLink {
113+
get {
114+
if (helpLinkObject == null) {
115+
helpLinkObject = exception.GetChild ("HelpLink");
116+
if (helpLinkObject != null && helpLinkObject.IsEvaluating) {
117+
helpLinkObject.ValueChanged += delegate {
118+
NotifyChanged ();
119+
};
120+
}
121+
}
122+
return helpLinkObject != null ? helpLinkObject.Value : null;
123+
}
124+
}
125+
111126
public ObjectValue Instance {
112127
get {
113128
if (instance == null)
@@ -151,6 +166,10 @@ public ExceptionStackFrame[] StackTrace {
151166
stackTrace = Debugging.Evaluation.ExceptionInfoSource.GetStackTrace (stackTrace.Value);
152167
}
153168

169+
if (!stackTrace.IsArray) {
170+
return frames = new ExceptionStackFrame [0];
171+
}
172+
154173
var list = new List<ExceptionStackFrame> ();
155174
for (int i = 0; i < stackTrace.ArrayCount; i++)
156175
list.Add (new ExceptionStackFrame (stackTrace.GetArrayItem (i, EvaluationOptions.DefaultOptions)));

Mono.Debugging/Mono.Debugging.Evaluation/ExceptionInfoSource.cs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public ObjectValue CreateObjectValue (bool withTimeout, EvaluationOptions option
6060
excInstance.Name = "Instance";
6161

6262
ObjectValue messageValue = null;
63+
ObjectValue helpLinkValue = null;
6364
var exceptionType = ctx.Adapter.GetValueType (ctx, Exception.Value);
6465

6566
// Get the message
@@ -87,6 +88,31 @@ public ObjectValue CreateObjectValue (bool withTimeout, EvaluationOptions option
8788

8889
messageValue.Name = "Message";
8990

91+
// Get the help link
92+
93+
if (withTimeout) {
94+
helpLinkValue = ctx.Adapter.CreateObjectValueAsync ("HelpLink", ObjectValueFlags.None, delegate {
95+
var mref = ctx.Adapter.GetMember (ctx, Exception, exceptionType, Exception.Value, "HelpLink");
96+
if (mref != null) {
97+
string val = (string)mref.ObjectValue;
98+
return ObjectValue.CreatePrimitive (null, new ObjectPath ("HelpLink"), "string", new EvaluationResult (val), ObjectValueFlags.Literal);
99+
}
100+
101+
return ObjectValue.CreateUnknown ("HelpLink");
102+
});
103+
} else {
104+
var mref = ctx.Adapter.GetMember (ctx, Exception, exceptionType, Exception.Value, "HelpLink");
105+
if (mref != null) {
106+
string val = (string)mref.ObjectValue;
107+
helpLinkValue = ObjectValue.CreatePrimitive (null, new ObjectPath ("HelpLink"), "string", new EvaluationResult (val), ObjectValueFlags.Literal);
108+
}
109+
}
110+
111+
if (helpLinkValue == null)
112+
helpLinkValue = ObjectValue.CreateUnknown ("HelpLink");
113+
114+
helpLinkValue.Name = "HelpLink";
115+
90116
// Inner exception
91117

92118
ObjectValue childExceptionValue = null;
@@ -160,7 +186,7 @@ public ObjectValue CreateObjectValue (bool withTimeout, EvaluationOptions option
160186
stackTraceValue = GetStackTrace (stackTrace.ObjectValue as string);
161187
}
162188

163-
var children = new ObjectValue [] { excInstance, messageValue, stackTraceValue, childExceptionValue, childExceptionsValue };
189+
var children = new ObjectValue [] { excInstance, messageValue, helpLinkValue, stackTraceValue, childExceptionValue, childExceptionsValue };
164190

165191
return ObjectValue.CreateObject (null, new ObjectPath ("InnerException"), type, "", ObjectValueFlags.None, children);
166192
}

0 commit comments

Comments
 (0)