Browse Source

Call "ToString" on objects

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2901 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 18 years ago
parent
commit
b3b9282fa7
  1. 7
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ValueNode.cs
  2. 9
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Values/Value.Object.cs
  3. 3
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Values/Value.cs

7
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ValueNode.cs

@ -52,7 +52,7 @@ namespace Debugger.AddIn.TreeModel
if (ShowValuesInHexadecimal && val.IsInteger) { if (ShowValuesInHexadecimal && val.IsInteger) {
this.Text = String.Format("0x{0:X}", val.PrimitiveValue); this.Text = String.Format("0x{0:X}", val.PrimitiveValue);
} else { } else {
this.Text = val.AsString; this.Text = val.AsString;
} }
if (val.Type != null) { if (val.Type != null) {
@ -69,6 +69,11 @@ namespace Debugger.AddIn.TreeModel
} else { } else {
this.ChildNodes = null; this.ChildNodes = null;
} }
// Do last since it may expire the object
if (val.IsObject) {
this.Text = val.InvokeToString();
}
} }
public bool CanSetText { public bool CanSetText {

9
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Values/Value.Object.cs

@ -235,6 +235,15 @@ namespace Debugger
); );
} }
/// <summary> Invoke the ToString() method </summary>
public string InvokeToString()
{
if (!IsObject) {
throw new DebuggerException("ToString can be only invoked on object");
}
return Eval.InvokeMethod(Process, typeof(object), "ToString", this, new Value[] {}).AsString;
}
#region Convenience overload methods #region Convenience overload methods
/// <summary> Asynchronously invoke the method </summary> /// <summary> Asynchronously invoke the method </summary>

3
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Values/Value.cs

@ -45,10 +45,9 @@ namespace Debugger
/// <summary> Gets a string representation of the value </summary> /// <summary> Gets a string representation of the value </summary>
public string AsString { public string AsString {
get { get {
if (IsNull) return "<null>"; if (IsNull) return "null";
if (IsArray) return "{" + this.Type.FullName + "}"; if (IsArray) return "{" + this.Type.FullName + "}";
if (IsObject) return "{" + this.Type.FullName + "}"; if (IsObject) return "{" + this.Type.FullName + "}";
//if (IsObject) return Eval.InvokeMethod(Process, typeof(object), "ToString", this, new Value[] {}).AsString;
if (IsPrimitive) return PrimitiveValue != null ? PrimitiveValue.ToString() : String.Empty; if (IsPrimitive) return PrimitiveValue != null ? PrimitiveValue.ToString() : String.Empty;
throw new DebuggerException("Unknown value type"); throw new DebuggerException("Unknown value type");
} }

Loading…
Cancel
Save