diff options
author | Lluis Sanchez <lluis@xamarin.com> | 2020-01-28 11:37:58 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-28 11:37:58 +0300 |
commit | 561b48656ca2548acff9aaa5909e552cfece7072 (patch) | |
tree | 180358325c074772a4d342b555cab42593f0a8ec | |
parent | 92973d97d9db919d8cc6d422e9c0599cf9995c47 (diff) | |
parent | 013fa4be61511354b4405d3c0f94a14ea54ff276 (diff) |
Merge pull request #9585 from mono/backport-pr-9584-to-release-8.4
[release-8.4] [Debugger] Fix InvalidCastException in MacObjectValueTreeView.OnCopy()
-rw-r--r-- | main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacObjectValueTreeView.cs | 18 |
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 544f28acac..97788ee98c 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; @@ -765,7 +766,7 @@ namespace MonoDevelop.Debugger if (SelectedRowCount == 0) return; - var str = new StringBuilder (); + var builder = new StringBuilder (); var needsNewLine = false; var selectedRows = SelectedRows; @@ -778,7 +779,7 @@ namespace MonoDevelop.Debugger break; if (needsNewLine) - str.AppendLine (); + builder.AppendLine (); needsNewLine = true; @@ -794,22 +795,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 (); } |