Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffrey Stedfast <jestedfa@microsoft.com>2020-01-22 20:19:23 +0300
committerMatt Ward <ward.matt@gmail.com>2020-01-23 12:53:44 +0300
commit6956c908c589e6097aa8aa2a86f83083446385e5 (patch)
tree991f17c762c1425f4e782c14da65e3ef1c7c6a53
parent89d6f74529f786cd0ede4bb35c57f6d1aa8a7de8 (diff)
[Debugger] Fix InvalidCastException in MacObjectValueTreeView.OnCopy()
Based on "Find References" on GetRawValue(), it seems that this can sometimes return RawValueString instead of string. Make sure that we handle this instead of assuming the value returned by GetRawValue() is always a string. Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1054038/
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacObjectValueTreeView.cs18
1 files changed, 12 insertions, 6 deletions
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacObjectValueTreeView.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacObjectValueTreeView.cs
index fa11d2a3f4..ad7ec71480 100644
--- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacObjectValueTreeView.cs
+++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacObjectValueTreeView.cs
@@ -32,6 +32,7 @@ using AppKit;
using Foundation;
using CoreGraphics;
+using Mono.Debugging.Client;
using Mono.Debugging.Evaluation;
using MonoDevelop.Core;
@@ -778,7 +779,7 @@ namespace MonoDevelop.Debugger
if (SelectedRowCount == 0)
return;
- var str = new StringBuilder ();
+ var builder = new StringBuilder ();
var needsNewLine = false;
var selectedRows = SelectedRows;
@@ -791,7 +792,7 @@ namespace MonoDevelop.Debugger
break;
if (needsNewLine)
- str.AppendLine ();
+ builder.AppendLine ();
needsNewLine = true;
@@ -807,22 +808,27 @@ namespace MonoDevelop.Debugger
var opt = DebuggerService.Frame.GetStackFrame ().DebuggerSession.Options.EvaluationOptions.Clone ();
opt.EllipsizeStrings = false;
- var rawValue = (string) objVal.GetRawValue (opt);
+ var rawValue = objVal.GetRawValue (opt);
+ var str = rawValue as string;
- value = '"' + Mono.Debugging.Evaluation.ExpressionEvaluator.EscapeString (rawValue) + '"';
+ if (str == null && rawValue is RawValueString rawValueString)
+ str = rawValueString.Value;
+
+ if (str != null)
+ value = '"' + ExpressionEvaluator.EscapeString (str) + '"';
} catch (EvaluatorException) {
// fall back to using the DisplayValue that we would have used anyway...
}
}
}
- str.Append (value);
+ builder.Append (value);
}
var clipboard = NSPasteboard.GeneralPasteboard;
clipboard.ClearContents ();
- clipboard.SetStringForType (str.ToString (), NSPasteboard.NSPasteboardTypeString);
+ clipboard.SetStringForType (builder.ToString (), NSPasteboard.NSPasteboardTypeString);
//Gtk.Clipboard.Get (Gdk.Selection.Clipboard).Text = str.ToString ();
}