浏览代码

Fixes #2649 - Unit Tests on Windows are failing (#2650)

* attempt to fix

* Removed unneeded ToString() calls

* Forced all unit tests to use FakeClipboard
Tig 2 年之前
父节点
当前提交
4d6781e5f9
共有 51 个文件被更改,包括 240 次插入230 次删除
  1. 9 5
      Terminal.Gui/Clipboard/Clipboard.cs
  2. 14 14
      Terminal.Gui/ConsoleDrivers/WindowsDriver.cs
  3. 1 1
      Terminal.Gui/FileServices/DefaultFileOperations.cs
  4. 1 1
      Terminal.Gui/Text/Autocomplete/AppendAutocomplete.cs
  5. 1 1
      Terminal.Gui/View/ViewText.cs
  6. 1 1
      Terminal.Gui/Views/ComboBox.cs
  7. 19 14
      Terminal.Gui/Views/DateField.cs
  8. 2 2
      Terminal.Gui/Views/FileDialog.cs
  9. 1 1
      Terminal.Gui/Views/StatusBar.cs
  10. 1 1
      Terminal.Gui/Views/TextField.cs
  11. 2 2
      Terminal.Gui/Views/TextValidateField.cs
  12. 3 3
      Terminal.Gui/Views/TextView.cs
  13. 1 1
      Terminal.Gui/Views/TimeField.cs
  14. 2 2
      Terminal.Gui/Views/Toplevel.cs
  15. 1 1
      UICatalog/Scenarios/AutoSizeAndDirectionText.cs
  16. 1 1
      UICatalog/Scenarios/Buttons.cs
  17. 1 1
      UICatalog/Scenarios/ConfigurationEditor.cs
  18. 2 2
      UICatalog/Scenarios/ContextMenus.cs
  19. 4 4
      UICatalog/Scenarios/CsvEditor.cs
  20. 3 3
      UICatalog/Scenarios/Dialogs.cs
  21. 1 1
      UICatalog/Scenarios/DynamicMenuBar.cs
  22. 3 3
      UICatalog/Scenarios/DynamicStatusBar.cs
  23. 12 12
      UICatalog/Scenarios/Editor.cs
  24. 4 4
      UICatalog/Scenarios/Frames.cs
  25. 1 1
      UICatalog/Scenarios/InteractiveTree.cs
  26. 1 1
      UICatalog/Scenarios/LabelsAsButtons.cs
  27. 1 1
      UICatalog/Scenarios/ListColumns.cs
  28. 6 6
      UICatalog/Scenarios/MessageBoxes.cs
  29. 1 1
      UICatalog/Scenarios/MultiColouredTable.cs
  30. 12 12
      UICatalog/Scenarios/Notepad.cs
  31. 1 1
      UICatalog/Scenarios/Progress.cs
  32. 1 1
      UICatalog/Scenarios/SendKeys.cs
  33. 3 3
      UICatalog/Scenarios/SpinnerStyles.cs
  34. 2 2
      UICatalog/Scenarios/TableEditor.cs
  35. 2 2
      UICatalog/Scenarios/Text.cs
  36. 1 1
      UICatalog/Scenarios/TextViewAutocompletePopup.cs
  37. 1 1
      UICatalog/Scenarios/TileViewNesting.cs
  38. 3 3
      UICatalog/Scenarios/WindowsAndFrameViews.cs
  39. 2 2
      UICatalog/Scenarios/Wizards.cs
  40. 6 6
      UICatalog/UICatalog.cs
  41. 8 8
      UnitTests/Clipboard/ClipboardTests.cs
  42. 42 42
      UnitTests/Dialogs/WizardTests.cs
  43. 1 1
      UnitTests/TestHelpers.cs
  44. 2 2
      UnitTests/Text/AutocompleteTests.cs
  45. 4 4
      UnitTests/UICatalog/ScenarioTests.cs
  46. 7 7
      UnitTests/View/TitleTests.cs
  47. 17 17
      UnitTests/Views/AppendAutocompleteTests.cs
  48. 4 4
      UnitTests/Views/MenuTests.cs
  49. 1 1
      UnitTests/Views/ScrollViewTests.cs
  50. 1 1
      UnitTests/Views/TextFieldTests.cs
  51. 19 18
      UnitTests/Views/TextViewTests.cs

+ 9 - 5
Terminal.Gui/Clipboard/Clipboard.cs

@@ -34,13 +34,17 @@ namespace Terminal.Gui {
 			get {
 				try {
 					if (IsSupported) {
-						return contents = Application.Driver.Clipboard.GetClipboardData ();
-					} else {
-						return contents;
+						var clipData = Application.Driver.Clipboard.GetClipboardData ();
+						if (clipData == null) {
+							// throw new InvalidOperationException ($"{Application.Driver.GetType ().Name}.GetClipboardData returned null instead of string.Empty");
+							clipData = string.Empty;
+						}
+						contents = clipData;
 					}
 				} catch (Exception) {
-					return contents;
+					contents = string.Empty;
 				}
+				return contents;
 			}
 			set {
 				try {
@@ -48,7 +52,7 @@ namespace Terminal.Gui {
 						if (value == null) {
 							value = string.Empty;
 						}
-						Application.Driver.Clipboard.SetClipboardData (value.ToString ());
+						Application.Driver.Clipboard.SetClipboardData (value);
 					}
 					contents = value;
 				} catch (NotSupportedException e) {

+ 14 - 14
Terminal.Gui/ConsoleDrivers/WindowsDriver.cs

@@ -1526,10 +1526,10 @@ namespace Terminal.Gui {
 
 		public override void AddRune (Rune rune)
 		{
-			if (!IsRuneSupported(rune)) {
+			if (!IsRuneSupported (rune)) {
 				rune = Rune.ReplacementChar;
 			}
-			
+
 			rune = rune.MakePrintable ();
 			var runeWidth = rune.GetColumns ();
 			var position = GetOutputBufferPosition ();
@@ -2015,34 +2015,34 @@ namespace Terminal.Gui {
 
 		protected override string GetClipboardDataImpl ()
 		{
-			//if (!IsClipboardFormatAvailable (cfUnicodeText))
-			//	return null;
-
 			try {
-				if (!OpenClipboard (IntPtr.Zero))
-					return null;
+				if (!OpenClipboard (IntPtr.Zero)) {
+					return string.Empty;
+				}
 
 				IntPtr handle = GetClipboardData (cfUnicodeText);
-				if (handle == IntPtr.Zero)
-					return null;
+				if (handle == IntPtr.Zero) {
+					return string.Empty;
+				}
 
 				IntPtr pointer = IntPtr.Zero;
 
 				try {
 					pointer = GlobalLock (handle);
-					if (pointer == IntPtr.Zero)
-						return null;
+					if (pointer == IntPtr.Zero) {
+						return string.Empty;
+					}
 
 					int size = GlobalSize (handle);
 					byte [] buff = new byte [size];
 
 					Marshal.Copy (pointer, buff, 0, size);
 
-					return System.Text.Encoding.Unicode.GetString (buff)
-						.TrimEnd ('\0');
+					return Encoding.Unicode.GetString (buff).TrimEnd ('\0');
 				} finally {
-					if (pointer != IntPtr.Zero)
+					if (pointer != IntPtr.Zero) {
 						GlobalUnlock (handle);
+					}
 				}
 			} finally {
 				CloseClipboard ();

+ 1 - 1
Terminal.Gui/FileServices/DefaultFileOperations.cs

@@ -82,7 +82,7 @@ namespace Terminal.Gui {
 
 			Application.Run (dlg);
 
-			result = tf.Text?.ToString ();
+			result = tf.Text;
 
 			return confirm;
 		}

+ 1 - 1
Terminal.Gui/Text/Autocomplete/AppendAutocomplete.cs

@@ -128,7 +128,7 @@ namespace Terminal.Gui {
 			if (this.MakingSuggestion ()) {
 
 				var insert = this.Suggestions.ElementAt (this.SelectedIdx);
-				var newText = textField.Text.ToString ();
+				var newText = textField.Text;
 				newText = newText.Substring (0, newText.Length - insert.Remove);
 				newText += insert.Replacement;
 				textField.Text = newText;

+ 1 - 1
Terminal.Gui/View/ViewText.cs

@@ -37,7 +37,7 @@ namespace Terminal.Gui {
 
 #if DEBUG
 				if (_text != null && string.IsNullOrEmpty (Id)) {
-					Id = _text.ToString ();
+					Id = _text;
 				}
 #endif
 			}

+ 1 - 1
Terminal.Gui/Views/ComboBox.cs

@@ -823,7 +823,7 @@ namespace Terminal.Gui {
 				ResetSearchSet (noCopy: true);
 
 				foreach (var item in source.ToList ()) { // Iterate to preserver object type and force deep copy
-					if (item.ToString ().StartsWith (search.Text.ToString (), StringComparison.CurrentCultureIgnoreCase)) {
+					if (item.ToString ().StartsWith (search.Text, StringComparison.CurrentCultureIgnoreCase)) {
 						searchset.Add (item);
 					}
 				}

+ 19 - 14
Terminal.Gui/Views/DateField.cs

@@ -109,7 +109,7 @@ namespace Terminal.Gui {
 		void DateField_Changed (object sender, TextChangedEventArgs e)
 		{
 			try {
-				if (!DateTime.TryParseExact (GetDate (Text).ToString (), GetInvarianteFormat (), CultureInfo.CurrentCulture, DateTimeStyles.None, out DateTime result))
+				if (!DateTime.TryParseExact (GetDate (Text), GetInvarianteFormat (), CultureInfo.CurrentCulture, DateTimeStyles.None, out DateTime result))
 					Text = e.OldValue;
 			} catch (Exception) {
 				Text = e.OldValue;
@@ -211,31 +211,31 @@ namespace Terminal.Gui {
 			string [] frm = format.Split (sepChar);
 			bool isValidDate = true;
 			int idx = GetFormatIndex (frm, "y");
-			int year = Int32.Parse (vals [idx].ToString ());
+			int year = Int32.Parse (vals [idx]);
 			int month;
 			int day;
 			idx = GetFormatIndex (frm, "M");
-			if (Int32.Parse (vals [idx].ToString ()) < 1) {
+			if (Int32.Parse (vals [idx]) < 1) {
 				isValidDate = false;
 				month = 1;
 				vals [idx] = "1";
-			} else if (Int32.Parse (vals [idx].ToString ()) > 12) {
+			} else if (Int32.Parse (vals [idx]) > 12) {
 				isValidDate = false;
 				month = 12;
 				vals [idx] = "12";
 			} else
-				month = Int32.Parse (vals [idx].ToString ());
+				month = Int32.Parse (vals [idx]);
 			idx = GetFormatIndex (frm, "d");
-			if (Int32.Parse (vals [idx].ToString ()) < 1) {
+			if (Int32.Parse (vals [idx]) < 1) {
 				isValidDate = false;
 				day = 1;
 				vals [idx] = "1";
-			} else if (Int32.Parse (vals [idx].ToString ()) > 31) {
+			} else if (Int32.Parse (vals [idx]) > 31) {
 				isValidDate = false;
 				day = DateTime.DaysInMonth (year, month);
 				vals [idx] = day.ToString ();
 			} else
-				day = Int32.Parse (vals [idx].ToString ());
+				day = Int32.Parse (vals [idx]);
 			string d = GetDate (month, day, year, frm);
 
 			if (!DateTime.TryParseExact (d, format, CultureInfo.CurrentCulture, DateTimeStyles.None, out DateTime result) ||
@@ -331,18 +331,22 @@ namespace Terminal.Gui {
 		public override bool ProcessKey (KeyEvent kb)
 		{
 			var result = InvokeKeybindings (kb);
-			if (result != null)
+			if (result != null) {
 				return (bool)result;
-
+			}
 			// Ignore non-numeric characters.
-			if (kb.Key < (Key)((int)'0') || kb.Key > (Key)((int)'9'))
+			if (kb.Key < (Key)((int)'0') || kb.Key > (Key)((int)'9')) {
 				return false;
+			}
 
-			if (ReadOnly)
+			if (ReadOnly) {
 				return true;
+			}
 
-			if (SetText (TextModel.ToRunes (((Rune)(uint)kb.Key).ToString ()).First ()))
+			// BUGBUG: This is a hack, we should be able to just use ((Rune)(uint)kb.Key) directly.
+			if (SetText (TextModel.ToRunes (((Rune)(uint)kb.Key).ToString ()).First ())) {
 				IncCursorPosition ();
+			}
 
 			return true;
 		}
@@ -375,8 +379,9 @@ namespace Terminal.Gui {
 		/// <inheritdoc/>
 		public override void DeleteCharLeft (bool useOldCursorPos = true)
 		{
-			if (ReadOnly)
+			if (ReadOnly) {
 				return;
+			}
 
 			SetText ((Rune)'0');
 			DecCursorPosition ();

+ 2 - 2
Terminal.Gui/Views/FileDialog.cs

@@ -510,7 +510,7 @@ namespace Terminal.Gui {
 				return;
 			}
 
-			PushState (new SearchState (State?.Directory, this, tbFind.Text.ToString ()), true);
+			PushState (new SearchState (State?.Directory, this, tbFind.Text), true);
 		}
 
 		/// <inheritdoc/>
@@ -1205,7 +1205,7 @@ namespace Terminal.Gui {
 				return;
 			}
 
-			var path = this.tbPath.Text?.ToString ();
+			var path = this.tbPath.Text;
 
 			if (string.IsNullOrWhiteSpace (path)) {
 				return;

+ 1 - 1
Terminal.Gui/Views/StatusBar.cs

@@ -128,7 +128,7 @@ namespace Terminal.Gui {
 			var scheme = GetNormalColor ();
 			Driver.SetAttribute (scheme);
 			for (int i = 0; i < Items.Length; i++) {
-				var title = Items [i].Title.ToString ();
+				var title = Items [i].Title;
 				for (int n = 0; n < Items [i].Title.GetRuneCount (); n++) {
 					if (title [n] == '~') {
 						scheme = ToggleScheme (scheme);

+ 1 - 1
Terminal.Gui/Views/TextField.cs

@@ -1129,7 +1129,7 @@ namespace Terminal.Gui {
 				length = Math.Abs (x + direction <= text.Count ? x + direction - selectedStart : text.Count - selectedStart);
 				SetSelectedStartSelectedLength ();
 				if (start > -1 && length > 0) {
-					selectedText = length > 0 ? StringExtensions.ToString (text).ToString ().Substring (
+					selectedText = length > 0 ? StringExtensions.ToString (text).Substring (
 						start < 0 ? 0 : start, length > text.Count ? text.Count : length) : "";
 					if (first > start) {
 						first = start;

+ 2 - 2
Terminal.Gui/Views/TextValidateField.cs

@@ -123,7 +123,7 @@ namespace Terminal.Gui {
 				}
 				set {
 					var current = provider != null ? provider.ToString (false, false) : string.Empty;
-					provider = new MaskedTextProvider (value == string.Empty ? "&&&&&&" : value.ToString ());
+					provider = new MaskedTextProvider (value == string.Empty ? "&&&&&&" : value);
 					if (string.IsNullOrEmpty (current) == false) {
 						provider.Set (current);
 					}
@@ -136,7 +136,7 @@ namespace Terminal.Gui {
 					return provider.ToString ();
 				}
 				set {
-					provider.Set (value.ToString ());
+					provider.Set (value);
 				}
 			}
 

+ 3 - 3
Terminal.Gui/Views/TextView.cs

@@ -365,7 +365,7 @@ namespace Terminal.Gui {
 			for (int i = 0; i < _lines.Count; i++) {
 				var x = _lines [i];
 				var txt = GetText (x);
-				var matchText = !matchCase ? text.ToUpper ().ToString () : text.ToString ();
+				var matchText = !matchCase ? text.ToUpper () : text;
 				var col = txt.IndexOf (matchText);
 				while (col > -1) {
 					if (matchWholeWord && !MatchWholeWord (txt, matchText, col)) {
@@ -441,7 +441,7 @@ namespace Terminal.Gui {
 				if (!matchCase) {
 					txt = txt.ToUpper ();
 				}
-				var matchText = !matchCase ? text.ToUpper ().ToString () : text.ToString ();
+				var matchText = !matchCase ? text.ToUpper () : text;
 				var col = txt.IndexOf (matchText, Math.Min (start.X, txt.Length));
 				if (col > -1 && matchWholeWord && !MatchWholeWord (txt, matchText, col)) {
 					continue;
@@ -469,7 +469,7 @@ namespace Terminal.Gui {
 				if (start.Y != i) {
 					start.X = Math.Max (x.Count - 1, 0);
 				}
-				var matchText = !matchCase ? text.ToUpper ().ToString () : text.ToString ();
+				var matchText = !matchCase ? text.ToUpper (): text;
 				var col = txt.LastIndexOf (matchText, _toFind.found ? start.X - 1 : start.X);
 				if (col > -1 && matchWholeWord && !MatchWholeWord (txt, matchText, col)) {
 					continue;

+ 1 - 1
Terminal.Gui/Views/TimeField.cs

@@ -109,7 +109,7 @@ namespace Terminal.Gui {
 		void TextField_TextChanged (object sender, TextChangedEventArgs e)
 		{
 			try {
-				if (!TimeSpan.TryParseExact (Text.ToString ().Trim (), format.Trim (), CultureInfo.CurrentCulture, TimeSpanStyles.None, out TimeSpan result))
+				if (!TimeSpan.TryParseExact (Text.Trim (), format.Trim (), CultureInfo.CurrentCulture, TimeSpanStyles.None, out TimeSpan result))
 					Text = e.OldValue;
 			} catch (Exception) {
 				Text = e.OldValue;

+ 2 - 2
Terminal.Gui/Views/Toplevel.cs

@@ -1001,7 +1001,7 @@ namespace Terminal.Gui {
 				throw new ArgumentNullException ();
 
 			int hCode = 0;
-			if (int.TryParse (obj.Id.ToString (), out int result)) {
+			if (int.TryParse (obj.Id, out int result)) {
 				hCode = result;
 			}
 			return hCode.GetHashCode ();
@@ -1029,7 +1029,7 @@ namespace Terminal.Gui {
 			else if (y == null)
 				return 1;
 			else
-				return string.Compare (x.Id.ToString (), y.Id.ToString ());
+				return string.Compare (x.Id, y.Id);
 		}
 	}
 }

+ 1 - 1
UICatalog/Scenarios/AutoSizeAndDirectionText.cs

@@ -91,7 +91,7 @@ namespace UICatalog.Scenarios {
 			Win.Add (ckbWideText);
 
 			Win.KeyUp += (s,e) =>
-				labelH.Text = labelV.Text = text = editText.Text.ToString ();
+				labelH.Text = labelV.Text = text = editText.Text;
 		}
 	}
 }

+ 1 - 1
UICatalog/Scenarios/Buttons.cs

@@ -43,7 +43,7 @@ namespace UICatalog.Scenarios {
 			static void DoMessage (Button button, string txt)
 			{
 				button.Clicked += (s,e) => {
-					var btnText = button.Text.ToString ();
+					var btnText = button.Text;
 					MessageBox.Query ("Message", $"Did you click {txt}?", "Yes", "No");
 				};
 			}

+ 1 - 1
UICatalog/Scenarios/ConfigurationEditor.cs

@@ -129,7 +129,7 @@ namespace UICatalog.Scenarios {
 					Directory.CreateDirectory (FileInfo.DirectoryName!);
 				}
 				using var writer = File.CreateText (FileInfo.FullName);
-				writer.Write (Text.ToString ());
+				writer.Write (Text);
 				writer.Close ();
 				Tile.Title = Tile.Title.TrimEnd ('*');
 				IsDirty = false;

+ 2 - 2
UICatalog/Scenarios/ContextMenus.cs

@@ -154,10 +154,10 @@ namespace UICatalog.Scenarios {
 			void CreateAction (List<MenuItem> supportedCultures, MenuItem culture)
 			{
 				culture.Action += () => {
-					Thread.CurrentThread.CurrentUICulture = new CultureInfo (culture.Help.ToString ());
+					Thread.CurrentThread.CurrentUICulture = new CultureInfo (culture.Help);
 					culture.Checked = true;
 					foreach (var item in supportedCultures) {
-						item.Checked = item.Help.ToString () == Thread.CurrentThread.CurrentUICulture.Name;
+						item.Checked = item.Help == Thread.CurrentThread.CurrentUICulture.Name;
 					}
 				};
 			}

+ 4 - 4
UICatalog/Scenarios/CsvEditor.cs

@@ -105,7 +105,7 @@ namespace UICatalog.Scenarios {
 				return;
 
 			// change selected cell to the one the user has typed into the box
-			var match = Regex.Match (_selectedCellLabel.Text.ToString (), "^(\\d+),(\\d+)$");
+			var match = Regex.Match (_selectedCellLabel.Text, "^(\\d+),(\\d+)$");
 			if (match.Success) {
 
 				tableView.SelectedColumn = int.Parse (match.Groups [1].Value);
@@ -397,8 +397,8 @@ namespace UICatalog.Scenarios {
 
 			Application.Run (ofd);
 
-			if (!ofd.Canceled && !string.IsNullOrWhiteSpace (ofd.Path?.ToString ())) {
-				Open (ofd.Path.ToString ());
+			if (!ofd.Canceled && !string.IsNullOrWhiteSpace (ofd.Path)) {
+				Open (ofd.Path);
 			}
 		}
 
@@ -534,7 +534,7 @@ namespace UICatalog.Scenarios {
 
 			Application.Run (d);
 
-			enteredText = okPressed ? tf.Text.ToString () : null;
+			enteredText = okPressed ? tf.Text : null;
 			return okPressed;
 		}
 		private void EditCurrentCell (object sender, CellActivatedEventArgs e)

+ 3 - 3
UICatalog/Scenarios/Dialogs.cs

@@ -160,11 +160,11 @@ namespace UICatalog.Scenarios {
 					Dialog dialog = null;
 
 					int width = 0;
-					int.TryParse (widthEdit.Text.ToString (), out width);
+					int.TryParse (widthEdit.Text, out width);
 					int height = 0;
-					int.TryParse (heightEdit.Text.ToString (), out height);
+					int.TryParse (heightEdit.Text, out height);
 					int numButtons = 3;
-					int.TryParse (numButtonsEdit.Text.ToString (), out numButtons);
+					int.TryParse (numButtonsEdit.Text, out numButtons);
 
 					var buttons = new List<Button> ();
 					var clicked = -1;

+ 1 - 1
UICatalog/Scenarios/DynamicMenuBar.cs

@@ -84,7 +84,7 @@ namespace UICatalog.Scenarios {
 					Height = 4
 				};
 
-				var _txtDelimiter = new TextField (MenuBar.ShortcutDelimiter.ToString ()) {
+				var _txtDelimiter = new TextField (MenuBar.ShortcutDelimiter) {
 					X = Pos.Center (),
 					Width = 2,
 				};

+ 3 - 3
UICatalog/Scenarios/DynamicStatusBar.cs

@@ -72,7 +72,7 @@ namespace UICatalog.Scenarios {
 					Height = 4
 				};
 
-				var _txtDelimiter = new TextField (StatusBar.ShortcutDelimiter.ToString ()) {
+				var _txtDelimiter = new TextField (StatusBar.ShortcutDelimiter) {
 					X = Pos.Center (),
 					Width = 2,
 				};
@@ -332,11 +332,11 @@ namespace UICatalog.Scenarios {
 			public static string SetTitleText (string title, string shortcut)
 			{
 				var txt = title;
-				var split = title.ToString ().Split ('~');
+				var split = title.Split ('~');
 				if (split.Length > 1) {
 					txt = split [2].Trim (); ;
 				}
-				if (string.IsNullOrEmpty (shortcut.ToString ())) {
+				if (string.IsNullOrEmpty (shortcut)) {
 					return txt;
 				}
 

+ 12 - 12
UICatalog/Scenarios/Editor.cs

@@ -386,7 +386,7 @@ namespace UICatalog.Scenarios {
 			if (_fileName != null) {
 				// FIXED: BUGBUG: #279 TextView does not know how to deal with \r\n, only \r 
 				// As a result files saved on Windows and then read back will show invalid chars.
-				return SaveFile (Win.Title.ToString (), _fileName);
+				return SaveFile (Win.Title, _fileName);
 			} else {
 				return SaveAs ();
 			}
@@ -400,20 +400,20 @@ namespace UICatalog.Scenarios {
 			};
 			var sd = new SaveDialog ("Save file", aTypes);
 
-			sd.Path = System.IO.Path.Combine (sd.FileName.ToString (), Win.Title.ToString ());
+			sd.Path = System.IO.Path.Combine (sd.FileName, Win.Title);
 			Application.Run (sd);
 
 			if (!sd.Canceled) {
-				if (System.IO.File.Exists (sd.Path.ToString ())) {
+				if (System.IO.File.Exists (sd.Path)) {
 					if (MessageBox.Query ("Save File",
 						"File already exists. Overwrite any way?", "No", "Ok") == 1) {
-						return SaveFile (sd.FileName.ToString (), sd.Path.ToString ());
+						return SaveFile (sd.FileName, sd.Path);
 					} else {
 						_saved = false;
 						return _saved;
 					}
 				} else {
-					return SaveFile (sd.FileName.ToString (), sd.Path.ToString ());
+					return SaveFile (sd.FileName, sd.Path);
 				}
 			} else {
 				_saved = false;
@@ -426,7 +426,7 @@ namespace UICatalog.Scenarios {
 			try {
 				Win.Title = title;
 				_fileName = file;
-				System.IO.File.WriteAllText (_fileName, _textView.Text.ToString ());
+				System.IO.File.WriteAllText (_fileName, _textView.Text);
 				_originalText = Encoding.Unicode.GetBytes(_textView.Text);
 				_saved = true;
 				_textView.ClearHistoryChanges ();
@@ -509,10 +509,10 @@ namespace UICatalog.Scenarios {
 			void CreateAction (List<MenuItem> supportedCultures, MenuItem culture)
 			{
 				culture.Action += () => {
-					Thread.CurrentThread.CurrentUICulture = new CultureInfo (culture.Help.ToString ());
+					Thread.CurrentThread.CurrentUICulture = new CultureInfo (culture.Help);
 					culture.Checked = true;
 					foreach (var item in supportedCultures) {
-						item.Checked = item.Help.ToString () == Thread.CurrentThread.CurrentUICulture.Name;
+						item.Checked = item.Help == Thread.CurrentThread.CurrentUICulture.Name;
 					}
 				};
 			}
@@ -563,7 +563,7 @@ namespace UICatalog.Scenarios {
 					// setup autocomplete with all words currently in the editor
 					singleWordGenerator.AllSuggestions =
 
-					Regex.Matches (_textView.Text.ToString (), "\\w+")
+					Regex.Matches (_textView.Text, "\\w+")
 					.Select (s => s.Value)
 					.Distinct ().ToList ();
 				} else {
@@ -827,7 +827,7 @@ namespace UICatalog.Scenarios {
 			d.Add (btnFindPrevious);
 
 			txtToFind.TextChanged += (s, e) => {
-				_textToFind = txtToFind.Text.ToString ();
+				_textToFind = txtToFind.Text;
 				_textView.FindTextChanged ();
 				btnFindNext.Enabled = !string.IsNullOrEmpty(txtToFind.Text);
 				btnFindPrevious.Enabled = !string.IsNullOrEmpty(txtToFind.Text);
@@ -921,7 +921,7 @@ namespace UICatalog.Scenarios {
 				Y = Pos.Top (label),
 				Width = 20
 			};
-			txtToReplace.TextChanged += (s, e) => _textToReplace = txtToReplace.Text.ToString ();
+			txtToReplace.TextChanged += (s, e) => _textToReplace = txtToReplace.Text;
 			d.Add (txtToReplace);
 
 			var btnFindPrevious = new Button ("Replace _Previous") {
@@ -947,7 +947,7 @@ namespace UICatalog.Scenarios {
 			d.Add (btnReplaceAll);
 
 			txtToFind.TextChanged += (s, e) => {
-				_textToFind = txtToFind.Text.ToString ();
+				_textToFind = txtToFind.Text;
 				_textView.FindTextChanged ();
 				btnFindNext.Enabled = !string.IsNullOrEmpty(txtToFind.Text);
 				btnFindPrevious.Enabled = !string.IsNullOrEmpty(txtToFind.Text);

+ 4 - 4
UICatalog/Scenarios/Frames.cs

@@ -160,23 +160,23 @@ namespace UICatalog.Scenarios {
 					switch (sender.ToString ()) {
 					case var s when s == _topEdit.ToString ():
 						Thickness = new Thickness (Thickness.Left,
-							int.Parse (e.NewText.ToString ()), Thickness.Right,
+							int.Parse (e.NewText), Thickness.Right,
 							Thickness.Bottom);
 						break;
 					case var s when s == _leftEdit.ToString ():
-						Thickness = new Thickness (int.Parse (e.NewText.ToString ()),
+						Thickness = new Thickness (int.Parse (e.NewText),
 							Thickness.Top, Thickness.Right,
 							Thickness.Bottom);
 						break;
 					case var s when s == _rightEdit.ToString ():
 						Thickness = new Thickness (Thickness.Left,
-							Thickness.Top, int.Parse (e.NewText.ToString ()),
+							Thickness.Top, int.Parse (e.NewText),
 							Thickness.Bottom);
 						break;
 					case var s when s == _bottomEdit.ToString ():
 						Thickness = new Thickness (Thickness.Left,
 							Thickness.Top, Thickness.Right,
-							int.Parse (e.NewText.ToString ()));
+							int.Parse (e.NewText));
 						break;
 					}
 				} catch {

+ 1 - 1
UICatalog/Scenarios/InteractiveTree.cs

@@ -134,7 +134,7 @@ namespace UICatalog.Scenarios {
 
 			Application.Run (d);
 
-			enteredText = okPressed ? tf.Text.ToString () : null;
+			enteredText = okPressed ? tf.Text : null;
 			return okPressed;
 		}
 

+ 1 - 1
UICatalog/Scenarios/LabelsAsButtons.cs

@@ -48,7 +48,7 @@ namespace UICatalog.Scenarios {
 			static void DoMessage (Label Label, string txt)
 			{
 				Label.Clicked += (s,e) => {
-					var btnText = Label.Text.ToString ();
+					var btnText = Label.Text;
 					MessageBox.Query ("Message", $"Did you click {txt}?", "Yes", "No");
 				};
 			}

+ 1 - 1
UICatalog/Scenarios/ListColumns.cs

@@ -285,7 +285,7 @@ namespace UICatalog.Scenarios {
 			if (accepted) {
 
 				try {
-					setter (listColView, int.Parse (tf.Text.ToString ()));
+					setter (listColView, int.Parse (tf.Text));
 				} catch (Exception ex) {
 					MessageBox.ErrorQuery (60, 20, "Failed to set", ex.Message, "Ok");
 				}

+ 6 - 6
UICatalog/Scenarios/MessageBoxes.cs

@@ -188,10 +188,10 @@ namespace UICatalog.Scenarios {
 			};
 			showMessageBoxButton.Clicked += (s,e) => {
 				try {
-					int width = int.Parse (widthEdit.Text.ToString ());
-					int height = int.Parse (heightEdit.Text.ToString ());
-					int numButtons = int.Parse (numButtonsEdit.Text.ToString ());
-					int defaultButton = int.Parse (defaultButtonEdit.Text.ToString ());
+					int width = int.Parse (widthEdit.Text);
+					int height = int.Parse (heightEdit.Text);
+					int numButtons = int.Parse (numButtonsEdit.Text);
+					int defaultButton = int.Parse (defaultButtonEdit.Text);
 
 					var btns = new List<string> ();
 					for (int i = 0; i < numButtons; i++) {
@@ -199,9 +199,9 @@ namespace UICatalog.Scenarios {
 						btns.Add (NumberToWords.Convert (i));
 					}
 					if (styleRadioGroup.SelectedItem == 0) {
-						buttonPressedLabel.Text = $"{MessageBox.Query (width, height, titleEdit.Text.ToString (), messageEdit.Text.ToString (), defaultButton, (bool)ckbWrapMessage.Checked, btns.ToArray ())}";
+						buttonPressedLabel.Text = $"{MessageBox.Query (width, height, titleEdit.Text, messageEdit.Text, defaultButton, (bool)ckbWrapMessage.Checked, btns.ToArray ())}";
 					} else {
-						buttonPressedLabel.Text = $"{MessageBox.ErrorQuery (width, height, titleEdit.Text.ToString (), messageEdit.Text.ToString (), defaultButton, (bool)ckbWrapMessage.Checked, btns.ToArray ())}";
+						buttonPressedLabel.Text = $"{MessageBox.ErrorQuery (width, height, titleEdit.Text, messageEdit.Text, defaultButton, (bool)ckbWrapMessage.Checked, btns.ToArray ())}";
 					}
 				} catch (FormatException) {
 					buttonPressedLabel.Text = "Invalid Options";

+ 1 - 1
UICatalog/Scenarios/MultiColouredTable.cs

@@ -97,7 +97,7 @@ namespace UICatalog.Scenarios {
 
 			Application.Run (d);
 
-			enteredText = okPressed ? tf.Text.ToString () : null;
+			enteredText = okPressed ? tf.Text : null;
 			return okPressed;
 		}
 		private void EditCurrentCell (object sender, CellActivatedEventArgs e)

+ 12 - 12
UICatalog/Scenarios/Notepad.cs

@@ -198,7 +198,7 @@ namespace UICatalog.Scenarios {
 
 			if (tab.UnsavedChanges) {
 
-				int result = MessageBox.Query ("Save Changes", $"Save changes to {tab.Text.ToString ().TrimEnd ('*')}", "Yes", "No", "Cancel");
+				int result = MessageBox.Query ("Save Changes", $"Save changes to {tab.Text.TrimEnd ('*')}", "Yes", "No", "Cancel");
 
 				if (result == -1 || result == 2) {
 
@@ -312,7 +312,7 @@ namespace UICatalog.Scenarios {
 			var fd = new SaveDialog ();
 			Application.Run (fd);
 
-			if (string.IsNullOrWhiteSpace (fd.Path?.ToString ())) {
+			if (string.IsNullOrWhiteSpace (fd.Path)) {
 				return false;
 			}
 			
@@ -320,8 +320,8 @@ namespace UICatalog.Scenarios {
 				return false;
 			}
 
-			tab.File = new FileInfo (fd.Path.ToString ());
-			tab.Text = fd.FileName.ToString ();
+			tab.File = new FileInfo (fd.Path);
+			tab.Text = fd.FileName;
 			tab.Save ();
 
 			return true;
@@ -336,14 +336,14 @@ namespace UICatalog.Scenarios {
 			/// <value></value>
 			public string SavedText { get; set; }
 
-			public bool UnsavedChanges => !string.Equals (SavedText, View.Text.ToString ());
+			public bool UnsavedChanges => !string.Equals (SavedText, View.Text);
 
 			public OpenedFile (TabView parent, string name, FileInfo file) 
 				: base (name, CreateTextView(file))
 			{
 
 				File = file;
-				SavedText = View.Text.ToString ();
+				SavedText = View.Text;
 				RegisterTextViewEvents (parent);
 			}
 
@@ -357,16 +357,16 @@ namespace UICatalog.Scenarios {
 					var areDiff = this.UnsavedChanges;
 
 					if (areDiff) {
-						if (!this.Text.ToString ().EndsWith ('*')) {
+						if (!this.Text.EndsWith ('*')) {
 
-							this.Text = this.Text.ToString () + '*';
+							this.Text = this.Text + '*';
 							parent.SetNeedsDisplay ();
 						}
 					} else {
 						
-						if (Text.ToString ().EndsWith ('*')) {
+						if (Text.EndsWith ('*')) {
 
-							Text = Text.ToString ().TrimEnd ('*');
+							Text = Text.TrimEnd ('*');
 							parent.SetNeedsDisplay ();
 						}
 					}
@@ -398,12 +398,12 @@ namespace UICatalog.Scenarios {
 			}
 			internal void Save ()
 			{
-				var newText = View.Text.ToString ();
+				var newText = View.Text;
 
 				System.IO.File.WriteAllText (File.FullName, newText);
 				SavedText = newText;
 
-				Text = Text.ToString ().TrimEnd ('*');
+				Text = Text.TrimEnd ('*');
 			}
 		}
 

+ 1 - 1
UICatalog/Scenarios/Progress.cs

@@ -240,7 +240,7 @@ namespace UICatalog.Scenarios {
 			mainLoopTimeoutDemo.Speed.Text = $"{_mainLooopTimeoutTick}";
 			mainLoopTimeoutDemo.Speed.TextChanged += (s, a) => {
 				uint result;
-				if (uint.TryParse (mainLoopTimeoutDemo.Speed.Text.ToString (), out result)) {
+				if (uint.TryParse (mainLoopTimeoutDemo.Speed.Text, out result)) {
 					_mainLooopTimeoutTick = result;
 					if (mainLoopTimeoutDemo.Started) {
 						mainLoopTimeoutDemo.Start ();

+ 1 - 1
UICatalog/Scenarios/SendKeys.cs

@@ -103,7 +103,7 @@ namespace UICatalog.Scenarios {
 				IsAlt = false;
 				IsCtrl = false;
 				txtResult.SetFocus ();
-				foreach (var r in txtInput.Text.ToString ()) {
+				foreach (var r in txtInput.Text) {
 					var ck = char.IsLetter (r)
 						? (ConsoleKey)char.ToUpper (r) : (ConsoleKey)r;
 					Application.Driver.SendKeys (r, ck, (bool)ckbShift.Checked,

+ 3 - 3
UICatalog/Scenarios/SpinnerStyles.cs

@@ -83,7 +83,7 @@ namespace UICatalog.Scenarios {
 			};
 			Win.Add (delayField);
 			delayField.TextChanged += (s, e) => {
-				if (ushort.TryParse (delayField.Text.ToString (), out var i))
+				if (ushort.TryParse (delayField.Text, out var i))
 					spinner.SpinDelay = i;
 			};
 
@@ -154,14 +154,14 @@ namespace UICatalog.Scenarios {
 			{
 				if (customField.Text.Length > 0) {
 					spinner.Visible = true;
-					if (ushort.TryParse (delayField.Text.ToString (), out var d))
+					if (ushort.TryParse (delayField.Text, out var d))
 						spinner.SpinDelay = d;
 					else {
 						delayField.Text = DEFAULT_DELAY.ToString ();
 						spinner.SpinDelay = DEFAULT_DELAY;
 					}
 					var str = new List<string> ();
-					foreach (var c in customField.Text.ToString ().ToCharArray ()) {
+					foreach (var c in customField.Text.ToCharArray ()) {
 						str.Add (c.ToString ());
 					}
 					spinner.Sequence = str.ToArray ();

+ 2 - 2
UICatalog/Scenarios/TableEditor.cs

@@ -334,7 +334,7 @@ namespace UICatalog.Scenarios {
 			if (accepted) {
 
 				try {
-					setter (style, int.Parse (tf.Text.ToString ()));
+					setter (style, int.Parse (tf.Text));
 				} catch (Exception ex) {
 					MessageBox.ErrorQuery (60, 20, "Failed to set", ex.Message, "Ok");
 				}
@@ -883,7 +883,7 @@ namespace UICatalog.Scenarios {
 			if (okPressed) {
 
 				try {
-					currentTable.Rows [e.Row] [tableCol] = string.IsNullOrWhiteSpace (tf.Text.ToString ()) ? DBNull.Value : (object)tf.Text;
+					currentTable.Rows [e.Row] [tableCol] = string.IsNullOrWhiteSpace (tf.Text) ? DBNull.Value : (object)tf.Text;
 				} catch (Exception ex) {
 					MessageBox.ErrorQuery (60, 20, "Failed to set text", ex.Message, "Ok");
 				}

+ 2 - 2
UICatalog/Scenarios/Text.cs

@@ -31,7 +31,7 @@ namespace UICatalog.Scenarios {
 
 			void TextField_TextChanging (object sender, TextChangingEventArgs e)
 			{
-				singleWordGenerator.AllSuggestions = Regex.Matches (e.NewText.ToString (), "\\w+")
+				singleWordGenerator.AllSuggestions = Regex.Matches (e.NewText, "\\w+")
 				    .Select (s => s.Value)
 				    .Distinct ().ToList ();
 			}
@@ -61,7 +61,7 @@ namespace UICatalog.Scenarios {
 			// This shows how to enable autocomplete in TextView.
 			void TextView_DrawContent (object sender, DrawEventArgs e)
 			{
-				singleWordGenerator.AllSuggestions = Regex.Matches (textView.Text.ToString (), "\\w+")
+				singleWordGenerator.AllSuggestions = Regex.Matches (textView.Text, "\\w+")
 				    .Select (s => s.Value)
 				    .Distinct ().ToList ();
 			}

+ 1 - 1
UICatalog/Scenarios/TextViewAutocompletePopup.cs

@@ -122,7 +122,7 @@ namespace UICatalog.Scenarios {
 
 		private void SetAllSuggestions (TextView view)
 		{
-			((SingleWordSuggestionGenerator)view.Autocomplete.SuggestionGenerator).AllSuggestions = Regex.Matches (view.Text.ToString (), "\\w+")
+			((SingleWordSuggestionGenerator)view.Autocomplete.SuggestionGenerator).AllSuggestions = Regex.Matches (view.Text, "\\w+")
 				.Select (s => s.Value)
 				.Distinct ().ToList ();
 		}

+ 1 - 1
UICatalog/Scenarios/TileViewNesting.cs

@@ -225,7 +225,7 @@ namespace UICatalog.Scenarios {
 
 		private int GetNumberOfViews ()
 		{
-			if (int.TryParse (textField.Text.ToString (), out var views) && views >= 0) {
+			if (int.TryParse (textField.Text, out var views) && views >= 0) {
 
 				return views;
 			} else {

+ 3 - 3
UICatalog/Scenarios/WindowsAndFrameViews.cs

@@ -78,7 +78,7 @@ namespace UICatalog.Scenarios {
 					ColorScheme = Colors.Error,
 				};
 				pressMeButton.Clicked += (s,e) =>
-					MessageBox.ErrorQuery (win.Title.ToString (), "Neat?", "Yes", "No");
+					MessageBox.ErrorQuery (win.Title, "Neat?", "Yes", "No");
 				win.Add (pressMeButton);
 				var subWin = new Window () {
 					Title = "Sub Window",
@@ -89,7 +89,7 @@ namespace UICatalog.Scenarios {
 					ColorScheme = Colors.Base,
 					Text = "The Text in the Window",
 				};
-				subWin.Add (new TextField ("Edit me! " + win.Title.ToString ()) {
+				subWin.Add (new TextField ("Edit me! " + win.Title) {
 					Y = 1,
 					ColorScheme = Colors.Error
 				});
@@ -136,7 +136,7 @@ namespace UICatalog.Scenarios {
 				X = Pos.Center (),
 				Y = 0,
 				ColorScheme = Colors.Error,
-				//Clicked = () => MessageBox.ErrorQuery (frame.Title.ToString (), "Neat?", "Yes", "No")
+				//Clicked = () => MessageBox.ErrorQuery (frame.Title, "Neat?", "Yes", "No")
 			});
 			var subWinofFV = new Window () {
 				Title = "This is a Sub-Window",

+ 2 - 2
UICatalog/Scenarios/Wizards.cs

@@ -99,9 +99,9 @@ namespace UICatalog.Scenarios {
 			showWizardButton.Clicked += (s, e) => {
 				try {
 					int width = 0;
-					int.TryParse (widthEdit.Text.ToString (), out width);
+					int.TryParse (widthEdit.Text, out width);
 					int height = 0;
-					int.TryParse (heightEdit.Text.ToString (), out height);
+					int.TryParse (heightEdit.Text, out height);
 
 					if (width < 1 || height < 1) {
 						MessageBox.ErrorQuery ("Nope", "Height and width must be greater than 0 (much bigger)", "Ok");

+ 6 - 6
UICatalog/UICatalog.cs

@@ -505,7 +505,7 @@ namespace UICatalog {
 				miUseSubMenusSingleFrame = new MenuItem {
 					Title = "Enable _Sub-Menus Single Frame"
 				};
-				miUseSubMenusSingleFrame.Shortcut = Key.CtrlMask | Key.AltMask | (Key)miUseSubMenusSingleFrame!.Title!.ToString ()!.Substring (8, 1) [0];
+				miUseSubMenusSingleFrame.Shortcut = Key.CtrlMask | Key.AltMask | (Key)miUseSubMenusSingleFrame!.Title!.Substring (8, 1) [0];
 				miUseSubMenusSingleFrame.CheckType |= MenuItemCheckStyle.Checked;
 				miUseSubMenusSingleFrame.Action += () => {
 					miUseSubMenusSingleFrame.Checked = (bool)!miUseSubMenusSingleFrame.Checked!;
@@ -522,7 +522,7 @@ namespace UICatalog {
 				miIsMenuBorderDisabled = new MenuItem {
 					Title = "Disable Menu _Border"
 				};
-				miIsMenuBorderDisabled.Shortcut = Key.CtrlMask | Key.AltMask | (Key)miIsMenuBorderDisabled!.Title!.ToString ()!.Substring (14, 1) [0];
+				miIsMenuBorderDisabled.Shortcut = Key.CtrlMask | Key.AltMask | (Key)miIsMenuBorderDisabled!.Title!.Substring (14, 1) [0];
 				miIsMenuBorderDisabled.CheckType |= MenuItemCheckStyle.Checked;
 				miIsMenuBorderDisabled.Action += () => {
 					miIsMenuBorderDisabled.Checked = (bool)!miIsMenuBorderDisabled.Checked!;
@@ -539,7 +539,7 @@ namespace UICatalog {
 				miIsMouseDisabled = new MenuItem {
 					Title = "_Disable Mouse"
 				};
-				miIsMouseDisabled.Shortcut = Key.CtrlMask | Key.AltMask | (Key)miIsMouseDisabled!.Title!.ToString ()!.Substring (1, 1) [0];
+				miIsMouseDisabled.Shortcut = Key.CtrlMask | Key.AltMask | (Key)miIsMouseDisabled!.Title!.Substring (1, 1) [0];
 				miIsMouseDisabled.CheckType |= MenuItemCheckStyle.Checked;
 				miIsMouseDisabled.Action += () => {
 					miIsMouseDisabled.Checked = Application.IsMouseDisabled = (bool)!miIsMouseDisabled.Checked!;
@@ -572,7 +572,7 @@ namespace UICatalog {
 				List<MenuItem> menuItems = new List<MenuItem> ();
 				miEnableConsoleScrolling = new MenuItem ();
 				miEnableConsoleScrolling.Title = "_Enable Console Scrolling";
-				miEnableConsoleScrolling.Shortcut = Key.CtrlMask | Key.AltMask | (Key)miEnableConsoleScrolling.Title.ToString ()!.Substring (1, 1) [0];
+				miEnableConsoleScrolling.Shortcut = Key.CtrlMask | Key.AltMask | (Key)miEnableConsoleScrolling.Title!.Substring (1, 1) [0];
 				miEnableConsoleScrolling.CheckType |= MenuItemCheckStyle.Checked;
 				miEnableConsoleScrolling.Action += () => {
 					miEnableConsoleScrolling.Checked = !miEnableConsoleScrolling.Checked;
@@ -647,7 +647,7 @@ namespace UICatalog {
 
 				Enum GetDiagnosticsEnumValue (string title)
 				{
-					return title!.ToString () switch {
+					return title switch {
 						FRAME_RULER => ConsoleDriver.DiagnosticFlags.FrameRuler,
 						FRAME_PADDING => ConsoleDriver.DiagnosticFlags.FramePadding,
 						_ => null!,
@@ -741,7 +741,7 @@ namespace UICatalog {
 				}
 				checkedThemeMenu = _themeMenuItems?.Where (m => m != null && m.Title == CM.Themes?.Theme).FirstOrDefault ();
 				if (checkedThemeMenu != null) {
-					CM.Themes!.Theme = checkedThemeMenu.Title.ToString ()!;
+					CM.Themes!.Theme = checkedThemeMenu.Title!;
 					checkedThemeMenu.Checked = true;
 				}
 

+ 8 - 8
UnitTests/Clipboard/ClipboardTests.cs

@@ -43,7 +43,7 @@ namespace Terminal.Gui.ClipboardTests {
 			Application.Iteration += () => Application.RequestStop ();
 			Application.Run ();
 
-			Assert.Equal (clipText, Clipboard.Contents.ToString ());
+			Assert.Equal (clipText, Clipboard.Contents);
 		}
 
 		[Fact, AutoInitShutdown (useFakeClipboard: false)]
@@ -60,7 +60,7 @@ namespace Terminal.Gui.ClipboardTests {
 			Application.Iteration += () => Application.RequestStop ();
 			Application.Run ();
 
-			Assert.Equal (clipText, Clipboard.Contents.ToString ());
+			Assert.Equal (clipText, Clipboard.Contents);
 		}
 
 		[Fact, AutoInitShutdown (useFakeClipboard: false)]
@@ -78,7 +78,7 @@ namespace Terminal.Gui.ClipboardTests {
 			Application.Iteration += () => Application.RequestStop ();
 			Application.Run ();
 
-			Assert.Equal (clipText, Clipboard.Contents.ToString ());
+			Assert.Equal (clipText, Clipboard.Contents);
 		}
 
 		[Fact, AutoInitShutdown (useFakeClipboard: true)]
@@ -96,7 +96,7 @@ namespace Terminal.Gui.ClipboardTests {
 			Application.Iteration += () => Application.RequestStop ();
 			Application.Run ();
 
-			Assert.Equal (clipText, Clipboard.Contents.ToString ());
+			Assert.Equal (clipText, Clipboard.Contents);
 		}
 
 		[Fact, AutoInitShutdown (useFakeClipboard: false)]
@@ -162,12 +162,12 @@ namespace Terminal.Gui.ClipboardTests {
 				if (RuntimeInformation.IsOSPlatform (OSPlatform.Windows)) {
 					(exitCode, result) = ClipboardProcessRunner.Process ("powershell.exe", $"-command \"Set-Clipboard -Value \\\"{clipText}\\\"\"");
 					output.WriteLine ($"  Windows: powershell.exe Set-Clipboard: exitCode = {exitCode}, result = {result}");
-					getClipText = Clipboard.Contents.ToString ();
+					getClipText = Clipboard.Contents;
 
 				} else if (RuntimeInformation.IsOSPlatform (OSPlatform.OSX)) {
 					(exitCode, result) = ClipboardProcessRunner.Process ("pbcopy", string.Empty, clipText);
 					output.WriteLine ($"  OSX: pbcopy: exitCode = {exitCode}, result = {result}");
-					getClipText = Clipboard.Contents.ToString ();
+					getClipText = Clipboard.Contents;
 
 				} else if (RuntimeInformation.IsOSPlatform (OSPlatform.Linux)) {
 					if (Is_WSL_Platform ()) {
@@ -181,7 +181,7 @@ namespace Terminal.Gui.ClipboardTests {
 
 						if (!failed) {
 							// If we set the OS clipboard via Powershell, then getting Contents should return the same text.
-							getClipText = Clipboard.Contents.ToString ();
+							getClipText = Clipboard.Contents;
 							output.WriteLine ($"  WSL: Clipboard.Contents: {getClipText}");
 						}
 						Application.RequestStop ();
@@ -200,7 +200,7 @@ namespace Terminal.Gui.ClipboardTests {
 					output.WriteLine ($"  Linux: bash xclip -sel clip -i: exitCode = {exitCode}, result = {result}");
 
 					if (!failed) {
-						getClipText = Clipboard.Contents.ToString ();
+						getClipText = Clipboard.Contents;
 						output.WriteLine ($"  Linux via xclip: Clipboard.Contents: {getClipText}");
 					}
 				}

+ 42 - 42
UnitTests/Dialogs/WizardTests.cs

@@ -53,15 +53,15 @@ namespace Terminal.Gui.DialogTests {
 			};
 
 			r.Title = expectedDuring = expectedAfter = "title";
-			Assert.Equal (expectedAfter, r.Title.ToString ());
+			Assert.Equal (expectedAfter, r.Title);
 
 			r.Title = expectedDuring = expectedAfter = "a different title";
-			Assert.Equal (expectedAfter, r.Title.ToString ());
+			Assert.Equal (expectedAfter, r.Title);
 
 			// Now setup cancelling the change and change it back to "title"
 			cancel = true;
 			r.Title = expectedDuring = "title";
-			Assert.Equal (expectedAfter, r.Title.ToString ());
+			Assert.Equal (expectedAfter, r.Title);
 			r.Dispose ();
 
 		}
@@ -79,11 +79,11 @@ namespace Terminal.Gui.DialogTests {
 
 			expected = "title";
 			r.Title = expected;
-			Assert.Equal (expected, r.Title.ToString ());
+			Assert.Equal (expected, r.Title);
 
 			expected = "another title";
 			r.Title = expected;
-			Assert.Equal (expected, r.Title.ToString ());
+			Assert.Equal (expected, r.Title);
 			r.Dispose ();
 
 		}
@@ -247,7 +247,7 @@ namespace Terminal.Gui.DialogTests {
 			wizard.AddStep (step1);
 
 			// If no current step, should be last step
-			Assert.Equal (step1.Title.ToString (), wizard.GetPreviousStep ().Title.ToString ());
+			Assert.Equal (step1.Title, wizard.GetPreviousStep ().Title);
 
 			wizard.CurrentStep = step1;
 			// If there is 1 step it's current step should be null
@@ -262,7 +262,7 @@ namespace Terminal.Gui.DialogTests {
 			wizard.AddStep (step2);
 			wizard.CurrentStep = step2;
 			step1.Enabled = true;
-			Assert.Equal (step1.Title.ToString (), wizard.GetPreviousStep ().Title.ToString ());
+			Assert.Equal (step1.Title, wizard.GetPreviousStep ().Title);
 
 			// If two steps and at 2 and step 1 is `Enabled = false` should be null
 			step1.Enabled = false;
@@ -280,9 +280,9 @@ namespace Terminal.Gui.DialogTests {
 			step3.Enabled = true;
 			Assert.Null (wizard.GetPreviousStep ());
 			wizard.CurrentStep = step2;
-			Assert.Equal (step1.Title.ToString (), wizard.GetPreviousStep ().Title.ToString ());
+			Assert.Equal (step1.Title, wizard.GetPreviousStep ().Title);
 			wizard.CurrentStep = step3;
-			Assert.Equal (step2.Title.ToString (), wizard.GetPreviousStep ().Title.ToString ());
+			Assert.Equal (step2.Title, wizard.GetPreviousStep ().Title);
 
 			// If three steps with Step2.Enabled = false
 			//   At step 1 should be null
@@ -293,7 +293,7 @@ namespace Terminal.Gui.DialogTests {
 			wizard.CurrentStep = step1;
 			Assert.Null (wizard.GetPreviousStep ());
 			wizard.CurrentStep = step3;
-			Assert.Equal (step1.Title.ToString (), wizard.GetPreviousStep ().Title.ToString ());
+			Assert.Equal (step1.Title, wizard.GetPreviousStep ().Title);
 
 			// If three steps with Step1.Enabled = false & Step2.Enabled = false
 			//   At step 3 should be null
@@ -303,27 +303,27 @@ namespace Terminal.Gui.DialogTests {
 			step1.Enabled = true;
 			step2.Enabled = true;
 			step3.Enabled = true;
-			Assert.Equal (step3.Title.ToString (), wizard.GetPreviousStep ().Title.ToString ());
+			Assert.Equal (step3.Title, wizard.GetPreviousStep ().Title);
 
 			step1.Enabled = false;
 			step2.Enabled = true;
 			step3.Enabled = true;
-			Assert.Equal (step3.Title.ToString (), wizard.GetPreviousStep ().Title.ToString ());
+			Assert.Equal (step3.Title, wizard.GetPreviousStep ().Title);
 
 			step1.Enabled = false;
 			step2.Enabled = false;
 			step3.Enabled = true;
-			Assert.Equal (step3.Title.ToString (), wizard.GetPreviousStep ().Title.ToString ());
+			Assert.Equal (step3.Title, wizard.GetPreviousStep ().Title);
 
 			step1.Enabled = false;
 			step2.Enabled = true;
 			step3.Enabled = false;
-			Assert.Equal (step2.Title.ToString (), wizard.GetPreviousStep ().Title.ToString ());
+			Assert.Equal (step2.Title, wizard.GetPreviousStep ().Title);
 
 			step1.Enabled = true;
 			step2.Enabled = false;
 			step3.Enabled = false;
-			Assert.Equal (step1.Title.ToString (), wizard.GetPreviousStep ().Title.ToString ());
+			Assert.Equal (step1.Title, wizard.GetPreviousStep ().Title);
 		}
 
 		[Fact, AutoInitShutdown]
@@ -338,7 +338,7 @@ namespace Terminal.Gui.DialogTests {
 			wizard.AddStep (step1);
 
 			// If no current step, should be first step
-			Assert.Equal (step1.Title.ToString (), wizard.GetNextStep ().Title.ToString ());
+			Assert.Equal (step1.Title, wizard.GetNextStep ().Title);
 
 			wizard.CurrentStep = step1;
 			// If there is 1 step it's current step should be null
@@ -351,7 +351,7 @@ namespace Terminal.Gui.DialogTests {
 			// If two steps and at 1 and step 2 is `Enabled = true`should be step 2
 			var step2 = new Wizard.WizardStep () { Title = "step2" };
 			wizard.AddStep (step2);
-			Assert.Equal (step2.Title.ToString (), wizard.GetNextStep ().Title.ToString ());
+			Assert.Equal (step2.Title, wizard.GetNextStep ().Title);
 
 			// If two steps and at 1 and step 2 is `Enabled = false` should be null
 			step1.Enabled = true;
@@ -369,9 +369,9 @@ namespace Terminal.Gui.DialogTests {
 			wizard.CurrentStep = step1;
 			step2.Enabled = true;
 			step3.Enabled = true;
-			Assert.Equal (step2.Title.ToString (), wizard.GetNextStep ().Title.ToString ());
+			Assert.Equal (step2.Title, wizard.GetNextStep ().Title);
 			wizard.CurrentStep = step2;
-			Assert.Equal (step3.Title.ToString (), wizard.GetNextStep ().Title.ToString ());
+			Assert.Equal (step3.Title, wizard.GetNextStep ().Title);
 			wizard.CurrentStep = step3;
 			Assert.Null (wizard.GetNextStep ());
 
@@ -382,7 +382,7 @@ namespace Terminal.Gui.DialogTests {
 			wizard.CurrentStep = step1;
 			step2.Enabled = false;
 			step3.Enabled = true;
-			Assert.Equal (step3.Title.ToString (), wizard.GetNextStep ().Title.ToString ());
+			Assert.Equal (step3.Title, wizard.GetNextStep ().Title);
 			wizard.CurrentStep = step3;
 			Assert.Null (wizard.GetNextStep ());
 
@@ -399,27 +399,27 @@ namespace Terminal.Gui.DialogTests {
 			step1.Enabled = true;
 			step2.Enabled = true;
 			step3.Enabled = true;
-			Assert.Equal (step1.Title.ToString (), wizard.GetNextStep ().Title.ToString ());
+			Assert.Equal (step1.Title, wizard.GetNextStep ().Title);
 
 			step1.Enabled = false;
 			step2.Enabled = true;
 			step3.Enabled = true;
-			Assert.Equal (step2.Title.ToString (), wizard.GetNextStep ().Title.ToString ());
+			Assert.Equal (step2.Title, wizard.GetNextStep ().Title);
 
 			step1.Enabled = false;
 			step2.Enabled = false;
 			step3.Enabled = true;
-			Assert.Equal (step3.Title.ToString (), wizard.GetNextStep ().Title.ToString ());
+			Assert.Equal (step3.Title, wizard.GetNextStep ().Title);
 
 			step1.Enabled = false;
 			step2.Enabled = true;
 			step3.Enabled = false;
-			Assert.Equal (step2.Title.ToString (), wizard.GetNextStep ().Title.ToString ());
+			Assert.Equal (step2.Title, wizard.GetNextStep ().Title);
 
 			step1.Enabled = true;
 			step2.Enabled = false;
 			step3.Enabled = false;
-			Assert.Equal (step1.Title.ToString (), wizard.GetNextStep ().Title.ToString ());
+			Assert.Equal (step1.Title, wizard.GetNextStep ().Title);
 		}
 
 		[Fact, AutoInitShutdown]
@@ -459,25 +459,25 @@ namespace Terminal.Gui.DialogTests {
 
 			var step1 = new Wizard.WizardStep () { Title = "step1" };
 			wizard.AddStep (step1);
-			Assert.Equal (step1.Title.ToString (), wizard.GetFirstStep ().Title.ToString ());
+			Assert.Equal (step1.Title, wizard.GetFirstStep ().Title);
 
 			var step2 = new Wizard.WizardStep () { Title = "step2" };
 			wizard.AddStep (step2);
-			Assert.Equal (step1.Title.ToString (), wizard.GetFirstStep ().Title.ToString ());
+			Assert.Equal (step1.Title, wizard.GetFirstStep ().Title);
 
 			var step3 = new Wizard.WizardStep () { Title = "step3" };
 			wizard.AddStep (step3);
-			Assert.Equal (step1.Title.ToString (), wizard.GetFirstStep ().Title.ToString ());
+			Assert.Equal (step1.Title, wizard.GetFirstStep ().Title);
 
 			step1.Enabled = false;
-			Assert.Equal (step2.Title.ToString (), wizard.GetFirstStep ().Title.ToString ());
+			Assert.Equal (step2.Title, wizard.GetFirstStep ().Title);
 
 			step1.Enabled = true;
-			Assert.Equal (step1.Title.ToString (), wizard.GetFirstStep ().Title.ToString ());
+			Assert.Equal (step1.Title, wizard.GetFirstStep ().Title);
 
 			step1.Enabled = false;
 			step2.Enabled = false;
-			Assert.Equal (step3.Title.ToString (), wizard.GetFirstStep ().Title.ToString ());
+			Assert.Equal (step3.Title, wizard.GetFirstStep ().Title);
 		}
 
 		[Fact, AutoInitShutdown]
@@ -489,25 +489,25 @@ namespace Terminal.Gui.DialogTests {
 
 			var step1 = new Wizard.WizardStep () { Title = "step1" };
 			wizard.AddStep (step1);
-			Assert.Equal (step1.Title.ToString (), wizard.GetLastStep ().Title.ToString ());
+			Assert.Equal (step1.Title, wizard.GetLastStep ().Title);
 
 			var step2 = new Wizard.WizardStep () { Title = "step2" };
 			wizard.AddStep (step2);
-			Assert.Equal (step2.Title.ToString (), wizard.GetLastStep ().Title.ToString ());
+			Assert.Equal (step2.Title, wizard.GetLastStep ().Title);
 
 			var step3 = new Wizard.WizardStep () { Title = "step3" };
 			wizard.AddStep (step3);
-			Assert.Equal (step3.Title.ToString (), wizard.GetLastStep ().Title.ToString ());
+			Assert.Equal (step3.Title, wizard.GetLastStep ().Title);
 
 			step3.Enabled = false;
-			Assert.Equal (step2.Title.ToString (), wizard.GetLastStep ().Title.ToString ());
+			Assert.Equal (step2.Title, wizard.GetLastStep ().Title);
 
 			step3.Enabled = true;
-			Assert.Equal (step3.Title.ToString (), wizard.GetLastStep ().Title.ToString ());
+			Assert.Equal (step3.Title, wizard.GetLastStep ().Title);
 
 			step3.Enabled = false;
 			step2.Enabled = false;
-			Assert.Equal (step1.Title.ToString (), wizard.GetLastStep ().Title.ToString ());
+			Assert.Equal (step1.Title, wizard.GetLastStep ().Title);
 		}
 
 		[Fact, AutoInitShutdown]
@@ -561,13 +561,13 @@ namespace Terminal.Gui.DialogTests {
 			runstate = Application.Begin (wizard);
 			Application.RunMainLoopIteration (ref runstate, true, ref firstIteration);
 
-			Assert.Equal (step1.Title.ToString (), wizard.CurrentStep.Title.ToString ());
+			Assert.Equal (step1.Title, wizard.CurrentStep.Title);
 			wizard.NextFinishButton.OnClicked ();
 			Assert.False (finishedFired);
 			Assert.False (closedFired);
 
-			Assert.Equal (step2.Title.ToString (), wizard.CurrentStep.Title.ToString ());
-			Assert.Equal (wizard.GetLastStep ().Title.ToString (), wizard.CurrentStep.Title.ToString ());
+			Assert.Equal (step2.Title, wizard.CurrentStep.Title);
+			Assert.Equal (wizard.GetLastStep ().Title, wizard.CurrentStep.Title);
 			wizard.NextFinishButton.OnClicked ();
 			Application.End (runstate);
 			Assert.True (finishedFired);
@@ -599,8 +599,8 @@ namespace Terminal.Gui.DialogTests {
 			runstate = Application.Begin (wizard);
 			Application.RunMainLoopIteration (ref runstate, true, ref firstIteration);
 
-			Assert.Equal (step2.Title.ToString (), wizard.CurrentStep.Title.ToString ());
-			Assert.Equal (wizard.GetLastStep ().Title.ToString (), wizard.CurrentStep.Title.ToString ());
+			Assert.Equal (step2.Title, wizard.CurrentStep.Title);
+			Assert.Equal (wizard.GetLastStep ().Title, wizard.CurrentStep.Title);
 			wizard.NextFinishButton.OnClicked ();
 			Application.End (runstate);
 			Assert.True (finishedFired);

+ 1 - 1
UnitTests/TestHelpers.cs

@@ -40,7 +40,7 @@ public class AutoInitShutdownAttribute : Xunit.Sdk.BeforeAfterTestAttribute {
 	/// load from.</param>
 	public AutoInitShutdownAttribute (bool autoInit = true, bool autoShutdown = true,
 		Type consoleDriverType = null,
-		bool useFakeClipboard = false,
+		bool useFakeClipboard = true,
 		bool fakeClipboardAlwaysThrowsNotSupportedException = false,
 		bool fakeClipboardIsSupportedAlwaysTrue = false,
 		ConfigurationManager.ConfigLocations configLocation = ConfigurationManager.ConfigLocations.DefaultOnly)

+ 2 - 2
UnitTests/Text/AutocompleteTests.cs

@@ -83,7 +83,7 @@ namespace Terminal.Gui.TextTests {
 			var g = (SingleWordSuggestionGenerator)tv.Autocomplete.SuggestionGenerator;
 
 			Assert.Empty (g.AllSuggestions);
-			g.AllSuggestions = Regex.Matches (tv.Text.ToString (), "\\w+")
+			g.AllSuggestions = Regex.Matches (tv.Text, "\\w+")
 				.Select (s => s.Value)
 				.Distinct ().ToList ();
 			Assert.Equal (3, g.AllSuggestions.Count);
@@ -176,7 +176,7 @@ namespace Terminal.Gui.TextTests {
 			};
 
 			var g = (SingleWordSuggestionGenerator)tv.Autocomplete.SuggestionGenerator;
-			g.AllSuggestions = Regex.Matches (tv.Text.ToString (), "\\w+")
+			g.AllSuggestions = Regex.Matches (tv.Text, "\\w+")
 					.Select (s => s.Value)
 					.Distinct ().ToList ();
 			var top = Application.Top;

+ 4 - 4
UnitTests/UICatalog/ScenarioTests.cs

@@ -349,7 +349,7 @@ namespace UICatalog.Tests {
 
 			_xText.TextChanged += (s, args) => {
 				try {
-					_xVal = int.Parse (_xText.Text.ToString ());
+					_xVal = int.Parse (_xText.Text);
 					DimPosChanged (_curView);
 				} catch {
 
@@ -358,7 +358,7 @@ namespace UICatalog.Tests {
 
 			_yText.TextChanged += (s, e) => {
 				try {
-					_yVal = int.Parse (_yText.Text.ToString ());
+					_yVal = int.Parse (_yText.Text);
 					DimPosChanged (_curView);
 				} catch {
 
@@ -371,7 +371,7 @@ namespace UICatalog.Tests {
 
 			_wText.TextChanged += (s, args) => {
 				try {
-					_wVal = int.Parse (_wText.Text.ToString ());
+					_wVal = int.Parse (_wText.Text);
 					DimPosChanged (_curView);
 				} catch {
 
@@ -380,7 +380,7 @@ namespace UICatalog.Tests {
 
 			_hText.TextChanged += (s, args) => {
 				try {
-					_hVal = int.Parse (_hText.Text.ToString ());
+					_hVal = int.Parse (_hText.Text);
 					DimPosChanged (_curView);
 				} catch {
 

+ 7 - 7
UnitTests/View/TitleTests.cs

@@ -36,17 +36,17 @@ namespace Terminal.Gui.ViewTests {
 
 			expectedOld = string.Empty;
 			r.Title = expectedDuring = expectedAfter = "title";
-			Assert.Equal (expectedAfter, r.Title.ToString ());
+			Assert.Equal (expectedAfter, r.Title);
 
-			expectedOld = r.Title.ToString ();
+			expectedOld = r.Title;
 			r.Title = expectedDuring = expectedAfter = "a different title";
-			Assert.Equal (expectedAfter, r.Title.ToString ());
+			Assert.Equal (expectedAfter, r.Title);
 
 			// Now setup cancelling the change and change it back to "title"
 			cancel = true;
-			expectedOld = r.Title.ToString ();
+			expectedOld = r.Title;
 			r.Title = expectedDuring = "title";
-			Assert.Equal (expectedAfter, r.Title.ToString ());
+			Assert.Equal (expectedAfter, r.Title);
 			r.Dispose ();
 
 		}
@@ -65,9 +65,9 @@ namespace Terminal.Gui.ViewTests {
 			};
 
 			expected = "title";
-			expectedOld = r.Title.ToString ();
+			expectedOld = r.Title;
 			r.Title = expected;
-			Assert.Equal (expected, r.Title.ToString ());
+			Assert.Equal (expected, r.Title);
 		}
 
 	}

+ 17 - 17
UnitTests/Views/AppendAutocompleteTests.cs

@@ -31,13 +31,13 @@ namespace Terminal.Gui.TextTests {
 
 			tf.Draw ();
 			TestHelpers.AssertDriverContentsAre ("fish", output);
-			Assert.Equal ("f", tf.Text.ToString ());
+			Assert.Equal ("f", tf.Text);
 
 			Application.Driver.SendKeys ('\t', ConsoleKey.Tab, false, false, false);
 
 			tf.Draw ();
 			TestHelpers.AssertDriverContentsAre ("fish", output);
-			Assert.Equal ("fish", tf.Text.ToString ());
+			Assert.Equal ("fish", tf.Text);
 
 			// Tab should autcomplete but not move focus
 			Assert.Same (tf, Application.Top.Focused);
@@ -66,13 +66,13 @@ namespace Terminal.Gui.TextTests {
 			// Even though there is no match on case we should still get the suggestion
 			tf.Draw ();
 			TestHelpers.AssertDriverContentsAre ("my fISH", output);
-			Assert.Equal ("my f", tf.Text.ToString ());
+			Assert.Equal ("my f", tf.Text);
 
 			// When tab completing the case of the whole suggestion should be applied
 			Application.Driver.SendKeys ('\t', ConsoleKey.Tab, false, false, false);
 			tf.Draw ();
 			TestHelpers.AssertDriverContentsAre ("my FISH", output);
-			Assert.Equal ("my FISH", tf.Text.ToString ());
+			Assert.Equal ("my FISH", tf.Text);
 		}
 
 		[Fact, AutoInitShutdown]
@@ -84,7 +84,7 @@ namespace Terminal.Gui.TextTests {
 			Application.Driver.SendKeys ('f', ConsoleKey.F, false, false, false);
 			tf.Draw ();
 			TestHelpers.AssertDriverContentsAre ("fish", output);
-			Assert.Equal ("f", tf.Text.ToString ());
+			Assert.Equal ("f", tf.Text);
 
 			// When cancelling autocomplete
 			Application.Driver.SendKeys ('e', ConsoleKey.Escape, false, false, false);
@@ -92,7 +92,7 @@ namespace Terminal.Gui.TextTests {
 			// Suggestion should disapear
 			tf.Draw ();
 			TestHelpers.AssertDriverContentsAre ("f", output);
-			Assert.Equal ("f", tf.Text.ToString ());
+			Assert.Equal ("f", tf.Text);
 
 			// Still has focus though
 			Assert.Same (tf, Application.Top.Focused);
@@ -111,7 +111,7 @@ namespace Terminal.Gui.TextTests {
 			Application.Driver.SendKeys ('f', ConsoleKey.F, false, false, false);
 			tf.Draw ();
 			TestHelpers.AssertDriverContentsAre ("fish", output);
-			Assert.Equal ("f", tf.Text.ToString ());
+			Assert.Equal ("f", tf.Text);
 
 			// When cancelling autocomplete
 			Application.Driver.SendKeys ('e', ConsoleKey.Escape, false, false, false);
@@ -119,14 +119,14 @@ namespace Terminal.Gui.TextTests {
 			// Suggestion should disapear
 			tf.Draw ();
 			TestHelpers.AssertDriverContentsAre ("f", output);
-			Assert.Equal ("f", tf.Text.ToString ());
+			Assert.Equal ("f", tf.Text);
 
 			// Should reapear when you press next letter
 			Application.Driver.SendKeys ('i', ConsoleKey.I, false, false, false);
 			tf.Draw ();
 			// BUGBUG: v2 - I broke this test and don't have time to figure out why. @tznind - help!
 			//TestHelpers.AssertDriverContentsAre ("fish", output);
-			Assert.Equal ("fi", tf.Text.ToString ());
+			Assert.Equal ("fi", tf.Text);
 		}
 
 		[Theory, AutoInitShutdown]
@@ -141,7 +141,7 @@ namespace Terminal.Gui.TextTests {
 			Application.Driver.SendKeys ('f', ConsoleKey.F, false, false, false);
 			tf.Draw ();
 			TestHelpers.AssertDriverContentsAre (expectRender, output);
-			Assert.Equal ("f", tf.Text.ToString ());
+			Assert.Equal ("f", tf.Text);
 		}
 
 		[Theory, AutoInitShutdown]
@@ -155,20 +155,20 @@ namespace Terminal.Gui.TextTests {
 			Application.Driver.SendKeys ('f', ConsoleKey.F, false, false, false);
 			tf.Draw ();
 			TestHelpers.AssertDriverContentsAre ("fish", output);
-			Assert.Equal ("f", tf.Text.ToString ());
+			Assert.Equal ("f", tf.Text);
 
 			// When cycling autocomplete
 			Application.Driver.SendKeys (' ', cycleKey, false, false, false);
 
 			tf.Draw ();
 			TestHelpers.AssertDriverContentsAre ("friend", output);
-			Assert.Equal ("f", tf.Text.ToString ());
+			Assert.Equal ("f", tf.Text);
 
 			// Should be able to cycle in circles endlessly
 			Application.Driver.SendKeys (' ', cycleKey, false, false, false);
 			tf.Draw ();
 			TestHelpers.AssertDriverContentsAre ("fish", output);
-			Assert.Equal ("f", tf.Text.ToString ());
+			Assert.Equal ("f", tf.Text);
 		}
 
 		[Fact, AutoInitShutdown]
@@ -180,13 +180,13 @@ namespace Terminal.Gui.TextTests {
 			Application.Driver.SendKeys ('f', ConsoleKey.F, false, false, false);
 			tf.Draw ();
 			TestHelpers.AssertDriverContentsAre ("fish", output);
-			Assert.Equal ("f", tf.Text.ToString ());
+			Assert.Equal ("f", tf.Text);
 
 			// x is typed and suggestion should disapear
 			Application.Driver.SendKeys ('x', ConsoleKey.F, false, false, false);
 			tf.Draw ();
 			TestHelpers.AssertDriverContentsAre ("fx", output);
-			Assert.Equal ("fx", tf.Text.ToString ());
+			Assert.Equal ("fx", tf.Text);
 		}
 
 		[Fact, AutoInitShutdown]
@@ -198,7 +198,7 @@ namespace Terminal.Gui.TextTests {
 			Application.Driver.SendKeys ('f', ConsoleKey.F, false, false, false);
 			tf.Draw ();
 			TestHelpers.AssertDriverContentsAre ("fish", output);
-			Assert.Equal ("f", tf.Text.ToString ());
+			Assert.Equal ("f", tf.Text);
 
 			// add a space then go back 1
 			Application.Driver.SendKeys (' ', ConsoleKey.Spacebar, false, false, false);
@@ -206,7 +206,7 @@ namespace Terminal.Gui.TextTests {
 
 			tf.Draw ();
 			TestHelpers.AssertDriverContentsAre ("f", output);
-			Assert.Equal ("f ", tf.Text.ToString ());
+			Assert.Equal ("f ", tf.Text);
 		}
 
 

+ 4 - 4
UnitTests/Views/MenuTests.cs

@@ -572,17 +572,17 @@ Edit
 
 			string GetCurrentMenuBarItemTitle ()
 			{
-				return mbiCurrent != null ? mbiCurrent.Title.ToString () : "Closed";
+				return mbiCurrent != null ? mbiCurrent.Title : "Closed";
 			}
 
 			string GetCurrenParenttMenuItemTitle ()
 			{
-				return miCurrent?.Parent != null ? miCurrent.Parent.Title.ToString () : "None";
+				return miCurrent?.Parent != null ? miCurrent.Parent.Title : "None";
 			}
 
 			string GetCurrentMenuTitle ()
 			{
-				return miCurrent != null ? miCurrent.Title.ToString () : "None";
+				return miCurrent != null ? miCurrent.Title : "None";
 			}
 		}
 
@@ -1123,7 +1123,7 @@ Edit
 				get {
 					string txt = string.Empty;
 					foreach (var m in Menus)
-						txt += " " + m.Title.ToString () + " ";
+						txt += " " + m.Title + " ";
 					return txt;
 				}
 			}

+ 1 - 1
UnitTests/Views/ScrollViewTests.cs

@@ -438,7 +438,7 @@ namespace Terminal.Gui.ViewsTests {
 		//					fillText.Append (fill);
 		//				}
 		//			}
-		//			labelFill.Text = fillText.ToString ();
+		//			labelFill.Text = fillText;
 		//		};
 
 		//		labelText = new Label (text) { X = Pos.Center (), Y = Pos.Center () };

+ 1 - 1
UnitTests/Views/TextFieldTests.cs

@@ -914,7 +914,7 @@ namespace Terminal.Gui.ViewsTests {
 		}
 
 		[Fact]
-		[AutoInitShutdown]
+		[AutoInitShutdown(useFakeClipboard:true)]
 		public void KeyBindings_Command ()
 		{
 			var tf = new TextField ("This is a test.") { Width = 20 };

+ 19 - 18
UnitTests/Views/TextViewTests.cs

@@ -28,6 +28,7 @@ namespace Terminal.Gui.ViewsTests {
 			public static string txt = "TAB to jump between text fields.";
 			public override void Before (MethodInfo methodUnderTest)
 			{
+				FakeDriver.FakeBehaviors.UseFakeClipboard = true;
 				base.Before (methodUnderTest);
 
 				//                   1         2         3 
@@ -971,15 +972,15 @@ namespace Terminal.Gui.ViewsTests {
 					_textView.ProcessKey (new KeyEvent (Key.K | Key.CtrlMask, new KeyModifiers ()));
 					Assert.Equal (0, _textView.CursorPosition.X);
 					Assert.Equal (0, _textView.CursorPosition.Y);
-					Assert.Equal ($"{Environment.NewLine}This is the second line.", _textView.Text.ToString ());
-					Assert.Equal ("This is the first line.", Clipboard.Contents.ToString ());
+					Assert.Equal ($"{Environment.NewLine}This is the second line.", _textView.Text);
+					Assert.Equal ("This is the first line.", Clipboard.Contents);
 					break;
 				case 1:
 					_textView.ProcessKey (new KeyEvent (Key.DeleteChar | Key.CtrlMask | Key.ShiftMask, new KeyModifiers ()));
 					Assert.Equal (0, _textView.CursorPosition.X);
 					Assert.Equal (0, _textView.CursorPosition.Y);
-					Assert.Equal ("This is the second line.", _textView.Text.ToString ());
-					Assert.Equal ($"This is the first line.{Environment.NewLine}", Clipboard.Contents.ToString ());
+					Assert.Equal ("This is the second line.", _textView.Text);
+					Assert.Equal ($"This is the first line.{Environment.NewLine}", Clipboard.Contents);
 					break;
 				case 2:
 					_textView.ProcessKey (new KeyEvent (Key.K | Key.CtrlMask, new KeyModifiers ()));
@@ -1015,26 +1016,26 @@ namespace Terminal.Gui.ViewsTests {
 					_textView.ProcessKey (new KeyEvent (Key.K | Key.AltMask, new KeyModifiers ()));
 					Assert.Equal (0, _textView.CursorPosition.X);
 					Assert.Equal (1, _textView.CursorPosition.Y);
-					Assert.Equal ($"This is the first line.{Environment.NewLine}", _textView.Text.ToString ());
-					Assert.Equal ($"This is the second line.", Clipboard.Contents.ToString ());
+					Assert.Equal ($"This is the first line.{Environment.NewLine}", _textView.Text);
+					Assert.Equal ($"This is the second line.", Clipboard.Contents);
 					break;
 				case 1:
 					_textView.ProcessKey (new KeyEvent (Key.Backspace | Key.CtrlMask | Key.ShiftMask, new KeyModifiers ()));
 					Assert.Equal (23, _textView.CursorPosition.X);
 					Assert.Equal (0, _textView.CursorPosition.Y);
-					Assert.Equal ("This is the first line.", _textView.Text.ToString ());
-					Assert.Equal ($"This is the second line.{Environment.NewLine}", Clipboard.Contents.ToString ());
+					Assert.Equal ("This is the first line.", _textView.Text);
+					Assert.Equal ($"This is the second line.{Environment.NewLine}", Clipboard.Contents);
 					break;
 				case 2:
 					_textView.ProcessKey (new KeyEvent (Key.K | Key.AltMask, new KeyModifiers ()));
 					Assert.Equal (0, _textView.CursorPosition.X);
 					Assert.Equal (0, _textView.CursorPosition.Y);
-					Assert.Equal ("", _textView.Text.ToString ());
-					Assert.Equal ($"This is the second line.{Environment.NewLine}This is the first line.", Clipboard.Contents.ToString ());
+					Assert.Equal ("", _textView.Text);
+					Assert.Equal ($"This is the second line.{Environment.NewLine}This is the first line.", Clipboard.Contents);
 
 					// Paste inverted
 					_textView.ProcessKey (new KeyEvent (Key.Y | Key.CtrlMask, new KeyModifiers ()));
-					Assert.Equal ($"This is the second line.{Environment.NewLine}This is the first line.", _textView.Text.ToString ());
+					Assert.Equal ($"This is the second line.{Environment.NewLine}This is the first line.", _textView.Text);
 					break;
 				default:
 					iterationsFinished = true;
@@ -1450,7 +1451,7 @@ namespace Terminal.Gui.ViewsTests {
 			Assert.Equal (1, eventcount);
 			_textView.ProcessKey (new KeyEvent (Key.Y, new KeyModifiers ()));
 			Assert.Equal (1, eventcount);
-			Assert.Equal ("Yay", _textView.Text.ToString ());
+			Assert.Equal ("Yay", _textView.Text);
 		}
 
 		[Fact]
@@ -2526,7 +2527,7 @@ line.
 		}
 
 		[Fact]
-		[AutoInitShutdown]
+		[AutoInitShutdown (useFakeClipboard:true)]
 		public void KeyBindings_Command ()
 		{
 			var text = "This is the first line.\nThis is the second line.\nThis is the third line.";
@@ -2579,7 +2580,7 @@ line.
 			Assert.True (tv.ProcessKey (new KeyEvent (Key.Backspace, new KeyModifiers ())));
 			Assert.Equal ($"This is the first line.{Environment.NewLine}This is the second line.{Environment.NewLine}This is the third line.", tv.Text);
 			Assert.Equal (new Point (23, 2), tv.CursorPosition);
-			g.AllSuggestions = Regex.Matches (tv.Text.ToString (), "\\w+")
+			g.AllSuggestions = Regex.Matches (tv.Text, "\\w+")
 				.Select (s => s.Value)
 				.Distinct ().ToList ();
 			Assert.Equal (7, g.AllSuggestions.Count);
@@ -4656,7 +4657,7 @@ line.
 		}
 
 		[Fact]
-		[AutoInitShutdown]
+		[AutoInitShutdown (useFakeClipboard:true)]
 		public void HistoryText_Undo_Redo_Copy_Without_Selection_Multi_Line_Paste ()
 		{
 			var text = "This is the first line.\nThis is the second line.\nThis is the third line.";
@@ -4690,7 +4691,7 @@ line.
 		}
 
 		[Fact]
-		[AutoInitShutdown]
+		[AutoInitShutdown (useFakeClipboard: true)]
 		public void HistoryText_Undo_Redo_Simple_Copy_Multi_Line_Selected_Paste ()
 		{
 			var text = "This is the first line.\nThis is the second line.\nThis is the third line.";
@@ -4727,7 +4728,7 @@ line.
 		}
 
 		[Fact]
-		[AutoInitShutdown]
+		[AutoInitShutdown (useFakeClipboard: true)]
 		public void HistoryText_Undo_Redo_Multi_Line_Selected_Copy_Simple_Paste_Starting_On_Space ()
 		{
 			var text = "This is the first line.\nThis is the second line.\nThis is the third line.";
@@ -6707,7 +6708,7 @@ This is the second line.
 			expectedCol = 1;
 			tv.ProcessKey (new KeyEvent (Key.Y, new KeyModifiers ()));
 			Assert.Equal (3, eventcount);
-			Assert.Equal ("Yay", tv.Text.ToString ());
+			Assert.Equal ("Yay", tv.Text);
 		}
 
 		[Fact, TextViewTestsAutoInitShutdown]