Browse Source

Resolving merge conflicts.

BDisp 1 year ago
parent
commit
308227761f
100 changed files with 1951 additions and 2027 deletions
  1. 22 0
      Terminal.Gui/ConsoleDrivers/FakeDriver/FakeDriver.cs
  2. 2 3
      Terminal.Gui/View/Layout/Dim.cs
  3. 5 2
      Terminal.Gui/View/Layout/DimAuto.cs
  4. 5 7
      Terminal.Gui/View/Layout/DimAutoStyle.cs
  5. 2 2
      Terminal.Gui/View/Layout/DimPercent.cs
  6. 1 1
      Terminal.Gui/View/Layout/DimPercentMode.cs
  7. 0 38
      Terminal.Gui/View/Layout/LayoutStyle.cs
  8. 2 2
      Terminal.Gui/View/Layout/Pos.cs
  9. 20 106
      Terminal.Gui/View/Layout/ViewLayout.cs
  10. 17 20
      Terminal.Gui/View/View.cs
  11. 111 52
      Terminal.Gui/View/ViewContent.cs
  12. 6 6
      Terminal.Gui/View/ViewDrawing.cs
  13. 9 9
      Terminal.Gui/View/ViewText.cs
  14. 6 6
      Terminal.Gui/View/ViewportSettings.cs
  15. 1 2
      Terminal.Gui/Views/Button.cs
  16. 1 2
      Terminal.Gui/Views/CheckBox.cs
  17. 3 3
      Terminal.Gui/Views/ColorPicker.cs
  18. 2 2
      Terminal.Gui/Views/ComboBox.cs
  19. 2 2
      Terminal.Gui/Views/DateField.cs
  20. 10 14
      Terminal.Gui/Views/Dialog.cs
  21. 2 3
      Terminal.Gui/Views/FrameView.cs
  22. 2 2
      Terminal.Gui/Views/HexView.cs
  23. 1 1
      Terminal.Gui/Views/Menu/MenuBar.cs
  24. 1 1
      Terminal.Gui/Views/MessageBox.cs
  25. 1 2
      Terminal.Gui/Views/RadioGroup.cs
  26. 2 4
      Terminal.Gui/Views/ScrollBarView.cs
  27. 20 21
      Terminal.Gui/Views/ScrollView.cs
  28. 1 1
      Terminal.Gui/Views/StatusBar.cs
  29. 2 2
      Terminal.Gui/Views/TabView.cs
  30. 5 5
      Terminal.Gui/Views/TableView/TableView.cs
  31. 1 2
      Terminal.Gui/Views/TextField.cs
  32. 1 2
      Terminal.Gui/Views/TextValidateField.cs
  33. 59 97
      Terminal.Gui/Views/TextView.cs
  34. 1 1
      Terminal.Gui/Views/TimeField.cs
  35. 2 4
      Terminal.Gui/Views/Toplevel.cs
  36. 1 2
      Terminal.Gui/Views/Window.cs
  37. 1 2
      Terminal.Gui/Views/Wizard/Wizard.cs
  38. 1 2
      Terminal.Gui/Views/Wizard/WizardStep.cs
  39. 3 2
      UICatalog/Scenarios/ASCIICustomButton.cs
  40. 0 4
      UICatalog/Scenarios/AllViewsTester.cs
  41. 2 1
      UICatalog/Scenarios/Clipping.cs
  42. 12 11
      UICatalog/Scenarios/ContentScrolling.cs
  43. 1 32
      UICatalog/Scenarios/Editor.cs
  44. 2 1
      UICatalog/Scenarios/Scrolling.cs
  45. 0 12
      UICatalog/Scenarios/Wizards.cs
  46. 4 4
      UnitTests/Application/ApplicationTests.cs
  47. 5 0
      UnitTests/Application/KeyboardTests.cs
  48. 2 0
      UnitTests/Application/MainLoopTests.cs
  49. 4 0
      UnitTests/Application/MouseTests.cs
  50. 10 1
      UnitTests/Dialogs/DialogTests.cs
  51. 32 41
      UnitTests/Dialogs/WizardTests.cs
  52. 0 6
      UnitTests/Drawing/AttributeTests.cs
  53. 3 3
      UnitTests/Drawing/ColorTests.ParsingAndFormatting.cs
  54. 121 114
      UnitTests/Drawing/LineCanvasTests.cs
  55. 16 16
      UnitTests/Drawing/RulerTests.cs
  56. 10 16
      UnitTests/Drawing/ThicknessTests.cs
  57. 30 21
      UnitTests/FileServices/FileDialogTests.cs
  58. 72 74
      UnitTests/Input/EscSeqUtilsTests.cs
  59. 3 1
      UnitTests/TestHelpers.cs
  60. 38 40
      UnitTests/Text/AutocompleteTests.cs
  61. 2 21
      UnitTests/UICatalog/ScenarioTests.cs
  62. 58 53
      UnitTests/View/Adornment/BorderTests.cs
  63. 2 5
      UnitTests/View/Adornment/MarginTests.cs
  64. 5 8
      UnitTests/View/Adornment/PaddingTests.cs
  65. 7 6
      UnitTests/View/DiagnosticsTests.cs
  66. 17 14
      UnitTests/View/DrawTests.cs
  67. 4 4
      UnitTests/View/InitTests.cs
  68. 28 65
      UnitTests/View/Layout/AbsoluteLayoutTests.cs
  69. 22 6
      UnitTests/View/Layout/Dim.AutoTests.cs
  70. 1 0
      UnitTests/View/Layout/Dim.FillTests.cs
  71. 71 159
      UnitTests/View/Layout/Dim.Tests.cs
  72. 0 6
      UnitTests/View/Layout/FrameTests.cs
  73. 2 0
      UnitTests/View/Layout/Pos.AnchorEndTests.cs
  74. 24 24
      UnitTests/View/Layout/Pos.CenterTests.cs
  75. 3 2
      UnitTests/View/Layout/Pos.CombineTests.cs
  76. 12 13
      UnitTests/View/Layout/Pos.PercentTests.cs
  77. 45 4
      UnitTests/View/Layout/ViewportTests.cs
  78. 1 0
      UnitTests/View/MouseTests.cs
  79. 17 12
      UnitTests/View/NavigationTests.cs
  80. 42 1
      UnitTests/View/SubviewTests.cs
  81. 14 6
      UnitTests/View/TextTests.cs
  82. 1 1
      UnitTests/View/TitleTests.cs
  83. 6 3
      UnitTests/View/ViewKeyBindingTests.cs
  84. 118 114
      UnitTests/View/ViewTests.cs
  85. 9 4
      UnitTests/Views/AppendAutocompleteTests.cs
  86. 7 14
      UnitTests/Views/ButtonTests.cs
  87. 43 42
      UnitTests/Views/CheckBoxTests.cs
  88. 5 6
      UnitTests/Views/ColorPickerTests.cs
  89. 16 11
      UnitTests/Views/ComboBoxTests.cs
  90. 86 63
      UnitTests/Views/ContextMenuTests.cs
  91. 1 1
      UnitTests/Views/DateFieldTests.cs
  92. 3 1
      UnitTests/Views/DatePickerTests.cs
  93. 15 17
      UnitTests/Views/FrameViewTests.cs
  94. 15 10
      UnitTests/Views/HexViewTests.cs
  95. 185 184
      UnitTests/Views/LabelTests.cs
  96. 78 57
      UnitTests/Views/ListViewTests.cs
  97. 229 211
      UnitTests/Views/MenuBarTests.cs
  98. 13 1
      UnitTests/Views/OverlappedTests.cs
  99. 15 15
      UnitTests/Views/RadioGroupTests.cs
  100. 28 30
      UnitTests/Views/RuneCellTests.cs

+ 22 - 0
Terminal.Gui/ConsoleDrivers/FakeDriver/FakeDriver.cs

@@ -40,6 +40,28 @@ public class FakeDriver : ConsoleDriver
     public static Behaviors FakeBehaviors = new ();
     public static Behaviors FakeBehaviors = new ();
     public override bool SupportsTrueColor => false;
     public override bool SupportsTrueColor => false;
 
 
+    /// <inheritdoc />
+    public override int Cols
+    {
+        get => base.Cols;
+        internal set
+        {
+            base.Cols = value;
+            FakeConsole.SetBufferSize (Cols, Rows);
+        }
+    }
+
+    /// <inheritdoc />
+    public override int Rows
+    {
+        get => base.Rows;
+        internal set
+        {
+            base.Rows = value;
+            FakeConsole.SetBufferSize (Cols, Rows);
+        }
+    }
+
     public FakeDriver ()
     public FakeDriver ()
     {
     {
         Cols = FakeConsole.WindowWidth = FakeConsole.BufferWidth = FakeConsole.WIDTH;
         Cols = FakeConsole.WindowWidth = FakeConsole.BufferWidth = FakeConsole.WIDTH;

+ 2 - 3
Terminal.Gui/View/Layout/Dim.cs

@@ -6,8 +6,7 @@ namespace Terminal.Gui;
 /// <summary>
 /// <summary>
 ///     <para>
 ///     <para>
 ///         A Dim object describes the dimensions of a <see cref="View"/>. Dim is the type of the
 ///         A Dim object describes the dimensions of a <see cref="View"/>. Dim is the type of the
-///         <see cref="View.Width"/> and <see cref="View.Height"/> properties of <see cref="View"/>. Dim objects enable
-///         Computed Layout (see <see cref="LayoutStyle.Computed"/>) to automatically manage the dimensions of a view.
+///         <see cref="View.Width"/> and <see cref="View.Height"/> properties of <see cref="View"/>.
 ///     </para>
 ///     </para>
 ///     <para>
 ///     <para>
 ///         Integer values are implicitly convertible to an absolute <see cref="Dim"/>. These objects are created using
 ///         Integer values are implicitly convertible to an absolute <see cref="Dim"/>. These objects are created using
@@ -187,7 +186,7 @@ public abstract class Dim
     ///     Gets a dimension that is anchored to a certain point in the layout.
     ///     Gets a dimension that is anchored to a certain point in the layout.
     ///     This method is typically used internally by the layout system to determine the size of a View.
     ///     This method is typically used internally by the layout system to determine the size of a View.
     /// </summary>
     /// </summary>
-    /// <param name="size">The width of the area where the View is being sized (Superview.ContentSize).</param>
+    /// <param name="size">The width of the area where the View is being sized (Superview.GetContentSize ()).</param>
     /// <returns>
     /// <returns>
     ///     An integer representing the calculated dimension. The way this dimension is calculated depends on the specific
     ///     An integer representing the calculated dimension. The way this dimension is calculated depends on the specific
     ///     subclass of Dim that is used. For example, DimAbsolute returns a fixed dimension, DimFactor returns a
     ///     subclass of Dim that is used. For example, DimAbsolute returns a fixed dimension, DimFactor returns a

+ 5 - 2
Terminal.Gui/View/Layout/DimAuto.cs

@@ -69,12 +69,15 @@ public class DimAuto () : Dim
 
 
         if (Style.FastHasFlags (DimAutoStyle.Content))
         if (Style.FastHasFlags (DimAutoStyle.Content))
         {
         {
-            if (us._contentSize is { })
+            if (!us.ContentSizeTracksViewport)
             {
             {
-                subviewsSize = dimension == Dimension.Width ? us.ContentSize.Width : us.ContentSize.Height;
+                // ContentSize was explicitly set. Ignore subviews.
+                subviewsSize = dimension == Dimension.Width ? us.GetContentSize ().Width : us.GetContentSize ().Height;
             }
             }
             else
             else
             {
             {
+                // ContentSize was NOT explicitly set. Use subviews to determine size.
+
                 // TODO: This whole body of code is a WIP (for https://github.com/gui-cs/Terminal.Gui/pull/3451).
                 // TODO: This whole body of code is a WIP (for https://github.com/gui-cs/Terminal.Gui/pull/3451).
                 subviewsSize = 0;
                 subviewsSize = 0;
 
 

+ 5 - 7
Terminal.Gui/View/Layout/DimAutoStyle.cs

@@ -10,11 +10,9 @@ namespace Terminal.Gui;
 public enum DimAutoStyle
 public enum DimAutoStyle
 {
 {
     /// <summary>
     /// <summary>
-    ///     The dimensions will be computed based on the View's non-Text content.
+    ///     The dimensions will be computed based on the View's <see cref="View.GetContentSize ()"/> and/or <see cref="View.Subviews"/>.
     ///     <para>
     ///     <para>
-    ///         If <see cref="View.ContentSize"/> is explicitly set (is not <see langword="null"/>) then
-    ///         <see cref="View.ContentSize"/>
-    ///         will be used to determine the dimension.
+    ///         If <see cref="View.GetContentSize ()TracksViewport"/> is <see langword="true"/>, <see cref="View.GetContentSize ()"/> will be used to determine the dimension.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
     ///         Otherwise, the Subview in <see cref="View.Subviews"/> with the largest corresponding position plus dimension
     ///         Otherwise, the Subview in <see cref="View.Subviews"/> with the largest corresponding position plus dimension
@@ -33,14 +31,14 @@ public enum DimAutoStyle
     ///         will be used to determine the dimension.
     ///         will be used to determine the dimension.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
-    ///         The corresponding dimensions of the <see cref="View.Subviews"/> will be ignored.
+    ///         The corresponding dimensions of <see cref="View.GetContentSize ()"/> and/or <see cref="View.Subviews"/> will be ignored.
     ///     </para>
     ///     </para>
     /// </summary>
     /// </summary>
     Text = 2,
     Text = 2,
 
 
     /// <summary>
     /// <summary>
-    ///     The dimension will be computed using both the view's <see cref="View.Text"/> and
-    ///     <see cref="View.Subviews"/> (whichever is larger).
+    ///     The dimension will be computed using the largest of the view's <see cref="View.Text"/>, <see cref="View.GetContentSize ()"/>, and
+    ///     <see cref="View.Subviews"/> corresponding dimension
     /// </summary>
     /// </summary>
     Auto = Content | Text,
     Auto = Content | Text,
 }
 }

+ 2 - 2
Terminal.Gui/View/Layout/DimPercent.cs

@@ -11,7 +11,7 @@ namespace Terminal.Gui;
 /// <param name="percent">The percentage.</param>
 /// <param name="percent">The percentage.</param>
 /// <param name="mode">
 /// <param name="mode">
 ///     If <see cref="DimPercentMode.Position"/> the dimension is computed using the View's position (<see cref="View.X"/> or
 ///     If <see cref="DimPercentMode.Position"/> the dimension is computed using the View's position (<see cref="View.X"/> or
-///     <see cref="View.Y"/>); otherwise, the dimension is computed using the View's <see cref="View.ContentSize"/>.
+///     <see cref="View.Y"/>); otherwise, the dimension is computed using the View's <see cref="View.GetContentSize ()"/>.
 /// </param>
 /// </param>
 public class DimPercent (int percent, DimPercentMode mode = DimPercentMode.ContentSize) : Dim
 public class DimPercent (int percent, DimPercentMode mode = DimPercentMode.ContentSize) : Dim
 {
 {
@@ -32,7 +32,7 @@ public class DimPercent (int percent, DimPercentMode mode = DimPercentMode.Conte
     public override string ToString () { return $"Percent({Percent},{Mode})"; }
     public override string ToString () { return $"Percent({Percent},{Mode})"; }
 
 
     /// <summary>
     /// <summary>
-    ///     Gets whether the dimension is computed using the View's position or ContentSize.
+    ///     Gets whether the dimension is computed using the View's position or GetContentSize ().
     /// </summary>
     /// </summary>
     public DimPercentMode Mode { get; } = mode;
     public DimPercentMode Mode { get; } = mode;
 
 

+ 1 - 1
Terminal.Gui/View/Layout/DimPercentMode.cs

@@ -15,7 +15,7 @@ public enum DimPercentMode
     Position = 0,
     Position = 0,
 
 
     /// <summary>
     /// <summary>
-    /// The dimension is computed using the View's <see cref="View.ContentSize"/>.
+    /// The dimension is computed using the View's <see cref="View.GetContentSize ()"/>.
     /// </summary>
     /// </summary>
     ContentSize = 1
     ContentSize = 1
 }
 }

+ 0 - 38
Terminal.Gui/View/Layout/LayoutStyle.cs

@@ -1,38 +0,0 @@
-using Terminal.Gui.Analyzers.Internal.Attributes;
-
-namespace Terminal.Gui;
-
-/// <summary>
-///     <para>Indicates the LayoutStyle for the <see cref="View"/>.</para>
-///     <para>
-///         If Absolute, the <see cref="View.X"/>, <see cref="View.Y"/>, <see cref="View.Width"/>, and
-///         <see cref="View.Height"/> objects are all absolute values and are not relative. The position and size of the
-///         view is described by <see cref="View.Frame"/>.
-///     </para>
-///     <para>
-///         If Computed, one or more of the <see cref="View.X"/>, <see cref="View.Y"/>, <see cref="View.Width"/>, or
-///         <see cref="View.Height"/> objects are relative to the <see cref="View.SuperView"/> and are computed at layout
-///         time.
-///     </para>
-/// </summary>
-[GenerateEnumExtensionMethods]
-public enum LayoutStyle
-{
-    /// <summary>
-    ///     Indicates the <see cref="View.X"/>, <see cref="View.Y"/>, <see cref="View.Width"/>, and
-    ///     <see cref="View.Height"/> objects are all absolute values and are not relative. The position and size of the view
-    ///     is described by <see cref="View.Frame"/>.
-    /// </summary>
-    Absolute,
-
-    /// <summary>
-    ///     Indicates one or more of the <see cref="View.X"/>, <see cref="View.Y"/>, <see cref="View.Width"/>, or
-    ///     <see cref="View.Height"/>
-    ///     objects are relative to the <see cref="View.SuperView"/> and are computed at layout time.  The position and size of
-    ///     the
-    ///     view
-    ///     will be computed based on these objects at layout time. <see cref="View.Frame"/> will provide the absolute computed
-    ///     values.
-    /// </summary>
-    Computed
-}

+ 2 - 2
Terminal.Gui/View/Layout/Pos.cs

@@ -296,12 +296,12 @@ public abstract class Pos
 
 
     /// <summary>
     /// <summary>
     ///     Gets the starting point of an element based on the size of the parent element (typically
     ///     Gets the starting point of an element based on the size of the parent element (typically
-    ///     <c>Superview.ContentSize</c>).
+    ///     <c>Superview.GetContentSize ()</c>).
     ///     This method is meant to be overridden by subclasses to provide different ways of calculating the starting point.
     ///     This method is meant to be overridden by subclasses to provide different ways of calculating the starting point.
     ///     This method is used
     ///     This method is used
     ///     internally by the layout system to determine where a View should be positioned.
     ///     internally by the layout system to determine where a View should be positioned.
     /// </summary>
     /// </summary>
-    /// <param name="size">The size of the parent element (typically <c>Superview.ContentSize</c>).</param>
+    /// <param name="size">The size of the parent element (typically <c>Superview.GetContentSize ()</c>).</param>
     /// <returns>
     /// <returns>
     ///     An integer representing the calculated position. The way this position is calculated depends on the specific
     ///     An integer representing the calculated position. The way this position is calculated depends on the specific
     ///     subclass of Pos that is used. For example, PosAbsolute returns a fixed position, PosAnchorEnd returns a
     ///     subclass of Pos that is used. For example, PosAbsolute returns a fixed position, PosAnchorEnd returns a

+ 20 - 106
Terminal.Gui/View/Layout/ViewLayout.cs

@@ -1,6 +1,5 @@
 #nullable enable
 #nullable enable
 using System.Diagnostics;
 using System.Diagnostics;
-using Microsoft.CodeAnalysis;
 
 
 namespace Terminal.Gui;
 namespace Terminal.Gui;
 
 
@@ -13,14 +12,13 @@ public partial class View
     /// <summary>Gets or sets the absolute location and dimension of the view.</summary>
     /// <summary>Gets or sets the absolute location and dimension of the view.</summary>
     /// <value>
     /// <value>
     ///     The rectangle describing absolute location and dimension of the view, in coordinates relative to the
     ///     The rectangle describing absolute location and dimension of the view, in coordinates relative to the
-    ///     <see cref="SuperView"/>'s Content, which is bound by <see cref="ContentSize"/>.
+    ///     <see cref="SuperView"/>'s Content, which is bound by <see cref="GetContentSize ()"/>.
     /// </value>
     /// </value>
     /// <remarks>
     /// <remarks>
-    ///     <para>Frame is relative to the <see cref="SuperView"/>'s Content, which is bound by <see cref="ContentSize"/>.</para>
+    ///     <para>Frame is relative to the <see cref="SuperView"/>'s Content, which is bound by <see cref="GetContentSize ()"/>.</para>
     ///     <para>
     ///     <para>
     ///         Setting Frame will set <see cref="X"/>, <see cref="Y"/>, <see cref="Width"/>, and <see cref="Height"/> to the
     ///         Setting Frame will set <see cref="X"/>, <see cref="Y"/>, <see cref="Width"/>, and <see cref="Height"/> to the
     ///         values of the corresponding properties of the <paramref name="value"/> parameter.
     ///         values of the corresponding properties of the <paramref name="value"/> parameter.
-    ///         This causes <see cref="LayoutStyle"/> to be <see cref="LayoutStyle.Absolute"/>.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
     ///         Altering the Frame will eventually (when the view hierarchy is next laid out via  see
     ///         Altering the Frame will eventually (when the view hierarchy is next laid out via  see
@@ -41,8 +39,7 @@ public partial class View
 
 
             SetFrame (value with { Width = Math.Max (value.Width, 0), Height = Math.Max (value.Height, 0) });
             SetFrame (value with { Width = Math.Max (value.Width, 0), Height = Math.Max (value.Height, 0) });
 
 
-            // If Frame gets set, by definition, the View is now LayoutStyle.Absolute, so
-            // set all Pos/Dim to Absolute values.
+            // If Frame gets set, set all Pos/Dim to Absolute values.
             _x = _frame.X;
             _x = _frame.X;
             _y = _frame.Y;
             _y = _frame.Y;
             _width = _frame.Width;
             _width = _frame.Width;
@@ -136,7 +133,7 @@ public partial class View
     /// <value>The <see cref="Pos"/> object representing the X position.</value>
     /// <value>The <see cref="Pos"/> object representing the X position.</value>
     /// <remarks>
     /// <remarks>
     ///     <para>
     ///     <para>
-    ///         The position is relative to the <see cref="SuperView"/>'s Content, which is bound by <see cref="ContentSize"/>.
+    ///         The position is relative to the <see cref="SuperView"/>'s Content, which is bound by <see cref="GetContentSize ()"/>.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
     ///         If set to a relative value (e.g. <see cref="Pos.Center"/>) the value is indeterminate until the view has been
     ///         If set to a relative value (e.g. <see cref="Pos.Center"/>) the value is indeterminate until the view has been
@@ -148,8 +145,7 @@ public partial class View
     ///         <see cref="LayoutSubview(View, Size)"/> and <see cref="OnDrawContent(Rectangle)"/> methods to be called.
     ///         <see cref="LayoutSubview(View, Size)"/> and <see cref="OnDrawContent(Rectangle)"/> methods to be called.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
-    ///         Changing this property will cause <see cref="Frame"/> to be updated. If the new value is not of type
-    ///         <see cref="PosAbsolute"/> the <see cref="LayoutStyle"/> will change to <see cref="LayoutStyle.Computed"/>.
+    ///         Changing this property will cause <see cref="Frame"/> to be updated.
     ///     </para>
     ///     </para>
     ///     <para>The default value is <c>Pos.At (0)</c>.</para>
     ///     <para>The default value is <c>Pos.At (0)</c>.</para>
     /// </remarks>
     /// </remarks>
@@ -175,7 +171,7 @@ public partial class View
     /// <value>The <see cref="Pos"/> object representing the Y position.</value>
     /// <value>The <see cref="Pos"/> object representing the Y position.</value>
     /// <remarks>
     /// <remarks>
     ///     <para>
     ///     <para>
-    ///         The position is relative to the <see cref="SuperView"/>'s Content, which is bound by <see cref="ContentSize"/>.
+    ///         The position is relative to the <see cref="SuperView"/>'s Content, which is bound by <see cref="GetContentSize ()"/>.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
     ///         If set to a relative value (e.g. <see cref="Pos.Center"/>) the value is indeterminate until the view has been
     ///         If set to a relative value (e.g. <see cref="Pos.Center"/>) the value is indeterminate until the view has been
@@ -187,8 +183,7 @@ public partial class View
     ///         <see cref="LayoutSubview(View, Size)"/> and <see cref="OnDrawContent(Rectangle)"/> methods to be called.
     ///         <see cref="LayoutSubview(View, Size)"/> and <see cref="OnDrawContent(Rectangle)"/> methods to be called.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
-    ///         Changing this property will cause <see cref="Frame"/> to be updated. If the new value is not of type
-    ///         <see cref="PosAbsolute"/> the <see cref="LayoutStyle"/> will change to <see cref="LayoutStyle.Computed"/>.
+    ///         Changing this property will cause <see cref="Frame"/> to be updated.
     ///     </para>
     ///     </para>
     ///     <para>The default value is <c>Pos.At (0)</c>.</para>
     ///     <para>The default value is <c>Pos.At (0)</c>.</para>
     /// </remarks>
     /// </remarks>
@@ -213,7 +208,7 @@ public partial class View
     /// <value>The <see cref="Dim"/> object representing the height of the view (the number of rows).</value>
     /// <value>The <see cref="Dim"/> object representing the height of the view (the number of rows).</value>
     /// <remarks>
     /// <remarks>
     ///     <para>
     ///     <para>
-    ///         The dimension is relative to the <see cref="SuperView"/>'s Content, which is bound by <see cref="ContentSize"/>
+    ///         The dimension is relative to the <see cref="SuperView"/>'s Content, which is bound by <see cref="GetContentSize ()"/>
     ///         .
     ///         .
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
@@ -226,8 +221,7 @@ public partial class View
     ///         <see cref="LayoutSubview(View, Size)"/> and <see cref="OnDrawContent(Rectangle)"/> methods to be called.
     ///         <see cref="LayoutSubview(View, Size)"/> and <see cref="OnDrawContent(Rectangle)"/> methods to be called.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
-    ///         Changing this property will cause <see cref="Frame"/> to be updated. If the new value is not of type
-    ///         <see cref="DimAbsolute"/> the <see cref="LayoutStyle"/> will change to <see cref="LayoutStyle.Computed"/>.
+    ///         Changing this property will cause <see cref="Frame"/> to be updated.
     ///     </para>
     ///     </para>
     ///     <para>The default value is <c>Dim.Sized (0)</c>.</para>
     ///     <para>The default value is <c>Dim.Sized (0)</c>.</para>
     /// </remarks>
     /// </remarks>
@@ -259,7 +253,7 @@ public partial class View
     /// <value>The <see cref="Dim"/> object representing the width of the view (the number of columns).</value>
     /// <value>The <see cref="Dim"/> object representing the width of the view (the number of columns).</value>
     /// <remarks>
     /// <remarks>
     ///     <para>
     ///     <para>
-    ///         The dimension is relative to the <see cref="SuperView"/>'s Content, which is bound by <see cref="ContentSize"/>
+    ///         The dimension is relative to the <see cref="SuperView"/>'s Content, which is bound by <see cref="GetContentSize ()"/>
     ///         .
     ///         .
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
@@ -272,8 +266,7 @@ public partial class View
     ///         <see cref="LayoutSubview(View, Size)"/> and <see cref="OnDrawContent(Rectangle)"/> methods to be called.
     ///         <see cref="LayoutSubview(View, Size)"/> and <see cref="OnDrawContent(Rectangle)"/> methods to be called.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
-    ///         Changing this property will cause <see cref="Frame"/> to be updated. If the new value is not of type
-    ///         <see cref="DimAbsolute"/> the <see cref="LayoutStyle"/> will change to <see cref="LayoutStyle.Computed"/>.
+    ///         Changing this property will cause <see cref="Frame"/> to be updated.
     ///     </para>
     ///     </para>
     ///     <para>The default value is <c>Dim.Sized (0)</c>.</para>
     ///     <para>The default value is <c>Dim.Sized (0)</c>.</para>
     /// </remarks>
     /// </remarks>
@@ -303,78 +296,6 @@ public partial class View
 
 
     #region Layout Engine
     #region Layout Engine
 
 
-
-    // @tig Notes on layout flow. Ignore for now.
-    // BeginLayout
-    //   If !LayoutNeeded return
-    //   If !SizeNeeded return
-    //   Call OnLayoutStarted
-    //      Views and subviews can update things
-    //   
-
-
-    // EndLayout
-
-    private bool _excludeFromLayout;
-
-    /// <summary>
-    ///  Gets or sets whether this View will be excluded from layout computations. 
-    /// </summary>
-    /// <remarks>
-    /// If set to <see langword="true"/>, the layout engine will ignore this view. Any subviews of this view will still be laid out.
-    /// Any views that have Pos or Dim objects that reference this view must have <see cref="ExcludeFromLayout"/> set to <see langword="true"/> as well
-    /// </remarks>
-    public bool ExcludeFromLayout
-    {
-        get => _excludeFromLayout;
-        set
-        {
-            if (value == _excludeFromLayout)
-            {
-                return;
-            }
-            _excludeFromLayout = value;
-            SetNeedsLayout();
-        }
-    }
-
-    /// <summary>
-    ///     Controls how the View's <see cref="Frame"/> is computed during <see cref="LayoutSubviews"/>. If the style is
-    ///     set to <see cref="LayoutStyle.Absolute"/>, LayoutSubviews does not change the <see cref="Frame"/>. If the style is
-    ///     <see cref="LayoutStyle.Computed"/> the <see cref="Frame"/> is updated using the <see cref="X"/>, <see cref="Y"/>,
-    ///     <see cref="Width"/>, and <see cref="Height"/> properties.
-    /// </summary>
-    /// <remarks>
-    ///     <para>
-    ///         Setting this property to <see cref="LayoutStyle.Absolute"/> will cause <see cref="Frame"/> to determine the
-    ///         size and position of the view. <see cref="X"/> and <see cref="Y"/> will be set to <see cref="DimAbsolute"/>
-    ///         using <see cref="Frame"/>.
-    ///     </para>
-    ///     <para>
-    ///         Setting this property to <see cref="LayoutStyle.Computed"/> will cause the view to use the
-    ///         <see cref="LayoutSubviews"/> method to size and position of the view. If either of the <see cref="X"/> and
-    ///         <see cref="Y"/> properties are `null` they will be set to <see cref="PosAbsolute"/> using the current value
-    ///         of <see cref="Frame"/>. If either of the <see cref="Width"/> and <see cref="Height"/> properties are `null`
-    ///         they will be set to <see cref="DimAbsolute"/> using <see cref="Frame"/>.
-    ///     </para>
-    /// </remarks>
-    /// <value>The layout style.</value>
-    public LayoutStyle LayoutStyle
-    {
-        get
-        {
-            if (_x is PosAbsolute
-                && _y is PosAbsolute
-                && _width is DimAbsolute
-                && _height is DimAbsolute)
-            {
-                return LayoutStyle.Absolute;
-            }
-
-            return LayoutStyle.Computed;
-        }
-    }
-
     #endregion Layout Engine
     #endregion Layout Engine
 
 
     /// <summary>
     /// <summary>
@@ -649,7 +570,7 @@ public partial class View
 
 
         CheckDimAuto ();
         CheckDimAuto ();
 
 
-        var contentSize = ContentSize;
+        var contentSize = GetContentSize ();
         OnLayoutStarted (new (contentSize));
         OnLayoutStarted (new (contentSize));
 
 
         LayoutAdornments ();
         LayoutAdornments ();
@@ -673,7 +594,7 @@ public partial class View
         {
         {
             foreach ((View from, View to) in edges)
             foreach ((View from, View to) in edges)
             {
             {
-                LayoutSubview (to, from.ContentSize);
+                LayoutSubview (to, from.GetContentSize ());
             }
             }
         }
         }
 
 
@@ -726,8 +647,8 @@ public partial class View
         // Determine our container's ContentSize - 
         // Determine our container's ContentSize - 
         //  First try SuperView.Viewport, then Application.Top, then Driver.Viewport.
         //  First try SuperView.Viewport, then Application.Top, then Driver.Viewport.
         //  Finally, if none of those are valid, use int.MaxValue (for Unit tests).
         //  Finally, if none of those are valid, use int.MaxValue (for Unit tests).
-        Size superViewContentSize = SuperView is { IsInitialized: true } ? SuperView.ContentSize :
-                           Application.Top is { } && Application.Top != this && Application.Top.IsInitialized ? Application.Top.ContentSize :
+        Size superViewContentSize = SuperView is { IsInitialized: true } ? SuperView.GetContentSize () :
+                           Application.Top is { } && Application.Top != this && Application.Top.IsInitialized ? Application.Top.GetContentSize () :
                            Application.Driver?.Screen.Size ?? new (int.MaxValue, int.MaxValue);
                            Application.Driver?.Screen.Size ?? new (int.MaxValue, int.MaxValue);
 
 
         SetTextFormatterSize ();
         SetTextFormatterSize ();
@@ -769,7 +690,7 @@ public partial class View
 
 
     /// <summary>
     /// <summary>
     ///     Adjusts <see cref="Frame"/> given the SuperView's ContentSize (nominally the same as
     ///     Adjusts <see cref="Frame"/> given the SuperView's ContentSize (nominally the same as
-    ///     <c>this.SuperView.ContentSize</c>)
+    ///     <c>this.SuperView.GetContentSize ()</c>)
     ///     and the position (<see cref="X"/>, <see cref="Y"/>) and dimension (<see cref="Width"/>, and
     ///     and the position (<see cref="X"/>, <see cref="Y"/>) and dimension (<see cref="Width"/>, and
     ///     <see cref="Height"/>).
     ///     <see cref="Height"/>).
     /// </summary>
     /// </summary>
@@ -781,7 +702,7 @@ public partial class View
     ///     </para>
     ///     </para>
     /// </remarks>
     /// </remarks>
     /// <param name="superviewContentSize">
     /// <param name="superviewContentSize">
-    ///     The size of the SuperView's content (nominally the same as <c>this.SuperView.ContentSize</c>).
+    ///     The size of the SuperView's content (nominally the same as <c>this.SuperView.GetContentSize ()</c>).
     /// </param>
     /// </param>
     internal void SetRelativeLayout (Size superviewContentSize)
     internal void SetRelativeLayout (Size superviewContentSize)
     {
     {
@@ -819,8 +740,7 @@ public partial class View
 
 
         if (Frame != newFrame)
         if (Frame != newFrame)
         {
         {
-            // Set the frame. Do NOT use `Frame` as it overwrites X, Y, Width, and Height, making
-            // the view LayoutStyle.Absolute.
+            // Set the frame. Do NOT use `Frame` as it overwrites X, Y, Width, and Height
             SetFrame (newFrame);
             SetFrame (newFrame);
 
 
             if (_x is PosAbsolute)
             if (_x is PosAbsolute)
@@ -858,12 +778,6 @@ public partial class View
         foreach (View? v in from.InternalSubviews)
         foreach (View? v in from.InternalSubviews)
         {
         {
             nNodes.Add (v);
             nNodes.Add (v);
-
-            if (v.LayoutStyle != LayoutStyle.Computed)
-            {
-                continue;
-            }
-
             CollectPos (v.X, v, ref nNodes, ref nEdges);
             CollectPos (v.X, v, ref nNodes, ref nEdges);
             CollectPos (v.Y, v, ref nNodes, ref nEdges);
             CollectPos (v.Y, v, ref nNodes, ref nEdges);
             CollectDim (v.Width, v, ref nNodes, ref nEdges);
             CollectDim (v.Width, v, ref nNodes, ref nEdges);
@@ -1072,13 +986,13 @@ public partial class View
         // Verify none of the subviews are using Dim objects that depend on the SuperView's dimensions.
         // Verify none of the subviews are using Dim objects that depend on the SuperView's dimensions.
         foreach (View view in Subviews)
         foreach (View view in Subviews)
         {
         {
-            if (widthAuto is { } && widthAuto.Style.FastHasFlags (DimAutoStyle.Content) && _contentSize is null)
+            if (widthAuto is { } && widthAuto.Style.FastHasFlags (DimAutoStyle.Content) && ContentSizeTracksViewport)
             {
             {
                 ThrowInvalid (view, view.Width, nameof (view.Width));
                 ThrowInvalid (view, view.Width, nameof (view.Width));
                 ThrowInvalid (view, view.X, nameof (view.X));
                 ThrowInvalid (view, view.X, nameof (view.X));
             }
             }
 
 
-            if (heightAuto is { } && heightAuto.Style.FastHasFlags (DimAutoStyle.Content) && _contentSize is null)
+            if (heightAuto is { } && heightAuto.Style.FastHasFlags (DimAutoStyle.Content) && ContentSizeTracksViewport)
             {
             {
                 ThrowInvalid (view, view.Height, nameof (view.Height));
                 ThrowInvalid (view, view.Height, nameof (view.Height));
                 ThrowInvalid (view, view.Y, nameof (view.Y));
                 ThrowInvalid (view, view.Y, nameof (view.Y));

+ 17 - 20
Terminal.Gui/View/View.cs

@@ -43,13 +43,6 @@ namespace Terminal.Gui;
 ///         more subviews, can respond to user input and render themselves on the screen.
 ///         more subviews, can respond to user input and render themselves on the screen.
 ///     </para>
 ///     </para>
 ///     <para>
 ///     <para>
-///         View supports two layout styles: <see cref="LayoutStyle.Absolute"/> or <see cref="LayoutStyle.Computed"/>.
-///         The style is determined by the values of <see cref="X"/>, <see cref="Y"/>, <see cref="Width"/>, and
-///         <see cref="Height"/>. If any of these is set to non-absolute <see cref="Pos"/> or <see cref="Dim"/> object,
-///         then the layout style is <see cref="LayoutStyle.Computed"/>. Otherwise it is <see cref="LayoutStyle.Absolute"/>
-///         .
-///     </para>
-///     <para>
 ///         To create a View using Absolute layout, call a constructor that takes a Rect parameter to specify the
 ///         To create a View using Absolute layout, call a constructor that takes a Rect parameter to specify the
 ///         absolute position and size or simply set <see cref="View.Frame "/>). To create a View using Computed layout use
 ///         absolute position and size or simply set <see cref="View.Frame "/>). To create a View using Computed layout use
 ///         a constructor that does not take a Rect parameter and set the X, Y, Width and Height properties on the view to
 ///         a constructor that does not take a Rect parameter and set the X, Y, Width and Height properties on the view to
@@ -79,9 +72,7 @@ namespace Terminal.Gui;
 ///         To flag the entire view for redraw call <see cref="SetNeedsDisplay()"/>.
 ///         To flag the entire view for redraw call <see cref="SetNeedsDisplay()"/>.
 ///     </para>
 ///     </para>
 ///     <para>
 ///     <para>
-///         The <see cref="LayoutSubviews"/> method is invoked when the size or layout of a view has changed. The default
-///         processing system will keep the size and dimensions for views that use the <see cref="LayoutStyle.Absolute"/>,
-///         and will recompute the Adornments for the views that use <see cref="LayoutStyle.Computed"/>.
+///         The <see cref="LayoutSubviews"/> method is invoked when the size or layout of a view has changed.
 ///     </para>
 ///     </para>
 ///     <para>
 ///     <para>
 ///         Views have a <see cref="ColorScheme"/> property that defines the default colors that subviews should use for
 ///         Views have a <see cref="ColorScheme"/> property that defines the default colors that subviews should use for
@@ -127,15 +118,7 @@ public partial class View : Responder, ISupportInitializeNotification
     /// <remarks>
     /// <remarks>
     ///     <para>
     ///     <para>
     ///         Use <see cref="X"/>, <see cref="Y"/>, <see cref="Width"/>, and <see cref="Height"/> properties to dynamically
     ///         Use <see cref="X"/>, <see cref="Y"/>, <see cref="Width"/>, and <see cref="Height"/> properties to dynamically
-    ///         control the size and location of the view. The <see cref="View"/> will be created using
-    ///         <see cref="LayoutStyle.Absolute"/> coordinates. The initial size ( <see cref="View.Frame"/>) will be adjusted
-    ///         to fit the contents of <see cref="Text"/>, including newlines ('\n') for multiple lines.
-    ///     </para>
-    ///     <para>If <see cref="Height"/> is greater than one, word wrapping is provided.</para>
-    ///     <para>
-    ///         This constructor initialize a View with a <see cref="LayoutStyle"/> of <see cref="LayoutStyle.Absolute"/>.
-    ///         Use <see cref="X"/>, <see cref="Y"/>, <see cref="Width"/>, and <see cref="Height"/> properties to dynamically
-    ///         control the size and location of the view, changing it to <see cref="LayoutStyle.Computed"/>.
+    ///         control the size and location of the view.
     ///     </para>
     ///     </para>
     /// </remarks>
     /// </remarks>
     public View ()
     public View ()
@@ -520,9 +503,23 @@ public partial class View : Responder, ISupportInitializeNotification
     /// <returns></returns>
     /// <returns></returns>
     public override string ToString () { return $"{GetType ().Name}({Id}){Frame}"; }
     public override string ToString () { return $"{GetType ().Name}({Id}){Frame}"; }
 
 
-    /// <inheritdoc/>
+    /// <summary>Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.</summary>
+    /// <remarks>
+    /// <para>
+    ///     Subviews added to this view via <see cref="Add(View)"/> have their lifetime owned by this view and <see cref="Dispose"/> will
+    ///     dispose them. To prevent this, and have the creator of the Subview instance handle disposal, use <see cref="Remove"/> to remove
+    ///     the subview first.
+    /// </para>
+    /// <para>
+    ///     If disposing equals true, the method has been called directly or indirectly by a user's code. Managed and
+    ///     unmanaged resources can be disposed. If disposing equals false, the method has been called by the runtime from
+    ///     inside the finalizer, and you should not reference other objects. Only unmanaged resources can be disposed.
+    /// </para>
+    /// </remarks>
+    /// <param name="disposing"></param>
     protected override void Dispose (bool disposing)
     protected override void Dispose (bool disposing)
     {
     {
+        // BUGBUG: We should only dispose these objects if disposing == true
         LineCanvas.Dispose ();
         LineCanvas.Dispose ();
 
 
         DisposeAdornments ();
         DisposeAdornments ();

+ 111 - 52
Terminal.Gui/View/ViewContent.cs

@@ -1,6 +1,4 @@
-using System.Diagnostics;
-
-namespace Terminal.Gui;
+namespace Terminal.Gui;
 
 
 public partial class View
 public partial class View
 {
 {
@@ -13,33 +11,31 @@ public partial class View
     /// </summary>
     /// </summary>
     /// <remarks>
     /// <remarks>
     ///     <para>
     ///     <para>
-    ///         By default, the content size is set to <see langword="null"/>.
-    ///     </para>
-    /// </remarks>
-    /// <param name="contentSize">
-    ///     <para>
-    ///         If <see langword="null"/>, and the View has no visible subviews, <see cref="ContentSize"/> will track the size of <see cref="Viewport"/>.
+    ///         Negative sizes are not supported.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
-    ///         If <see langword="null"/>, and the View has visible subviews, <see cref="ContentSize"/> will track the maximum position plus size of any
-    ///         visible Subviews
-    ///         and <c>Viewport.Location</c>  will track the minimum position and size of any visible Subviews.
+    ///         If not explicitly set, and the View has no visible subviews, <see cref="GetContentSize ()"/> will return the
+    ///         size of
+    ///         <see cref="Viewport"/>.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
-    ///         If not <see langword="null"/>, <see cref="ContentSize"/> is set to the passed value and <see cref="Viewport"/> describes the portion of the content currently visible
-    ///         to the user. This enables virtual scrolling.
+    ///         If not explicitly set, and the View has visible subviews, <see cref="GetContentSize ()"/> will return the
+    ///         maximum
+    ///         position + dimension of the Subviews, supporting <see cref="Dim.Auto"/> with the
+    ///         <see cref="DimAutoStyle.Content"/> flag set.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
-    ///         If not <see langword="null"/>, <see cref="ContentSize"/> is set to the passed value and the behavior of <see cref="DimAutoStyle.Content"/> will be to use the ContentSize
-    ///         to determine the size of the view.
+    ///         If set <see cref="Viewport"/> describes the portion of the content currently visible to the user. This enables
+    ///         virtual scrolling.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
-    ///         Negative sizes are not supported.
+    ///         If set the behavior of <see cref="DimAutoStyle.Content"/> will be to use the ContentSize to determine the size
+    ///         of the view.
     ///     </para>
     ///     </para>
-    /// </param>
+    /// </remarks>
     public void SetContentSize (Size? contentSize)
     public void SetContentSize (Size? contentSize)
     {
     {
-        if (ContentSize.Width < 0 || ContentSize.Height < 0)
+        if (contentSize is { } && (contentSize.Value.Width < 0 || contentSize.Value.Height < 0))
         {
         {
             throw new ArgumentException (@"ContentSize cannot be negative.", nameof (contentSize));
             throw new ArgumentException (@"ContentSize cannot be negative.", nameof (contentSize));
         }
         }
@@ -56,19 +52,86 @@ public partial class View
     /// <summary>
     /// <summary>
     ///     Gets the size of the View's content.
     ///     Gets the size of the View's content.
     /// </summary>
     /// </summary>
-    /// <remarks>
+    /// <remarks>a>
     ///     <para>
     ///     <para>
-    ///         Use <see cref="SetContentSize"/> to change to change the content size.
+    ///         If the content size was not explicitly set by <see cref="SetContentSize"/>, and the View has no visible subviews, <see cref="GetContentSize ()"/> will return the
+    ///         size of
+    ///         <see cref="Viewport"/>.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
-    ///         If the content size has not been explicitly set with <see cref="SetContentSize"/>, the value tracks
-    ///         <see cref="Viewport"/>.
+    ///         If the content size was not explicitly set by <see cref="SetContentSize"/>, and the View has visible subviews, <see cref="GetContentSize ()"/> will return the
+    ///         maximum
+    ///         position + dimension of the Subviews, supporting <see cref="Dim.Auto"/> with the
+    ///         <see cref="DimAutoStyle.Content"/> flag set.
+    ///     </para>
+    ///     <para>
+    ///         If set <see cref="Viewport"/> describes the portion of the content currently visible to the user. This enables
+    ///         virtual scrolling.
+    ///     </para>
+    ///     <para>
+    ///         If set the behavior of <see cref="DimAutoStyle.Content"/> will be to use the ContentSize to determine the size
+    ///         of the view.
     ///     </para>
     ///     </para>
     /// </remarks>
     /// </remarks>
-    public Size ContentSize => _contentSize ?? Viewport.Size;
+    /// <returns>
+    ///     If the content size was not explicitly set by <see cref="SetContentSize"/>, <see cref="GetContentSize ()"/> will
+    ///     return the size of the <see cref="Viewport"/> and <see cref="ContentSizeTracksViewport"/> will be <see langword="true"/>.
+    /// </returns>
+    public Size GetContentSize () { return _contentSize ?? Viewport.Size; }
 
 
     /// <summary>
     /// <summary>
-    /// Called when <see cref="ContentSize"/> has changed.
+    ///     Gets or sets a value indicating whether the view's content size tracks the <see cref="Viewport"/>'s
+    ///     size or not.
+    /// </summary>
+    /// <remarks>
+    ///     <list type="bullet">
+    ///         <listheader>
+    ///             <term>Value</term> <description>Result</description>
+    ///         </listheader>
+    ///         <item>
+    ///             <term>
+    ///                 <see langword="true"/>
+    ///             </term>
+    ///             <description>
+    ///                 <para>
+    ///                     <see cref="GetContentSize ()"/> will return the <see cref="Viewport"/>'s size. Content scrolling
+    ///                     will be
+    ///                     disabled.
+    ///                 </para>
+    ///                 <para>
+    ///                     The behavior of <see cref="DimAutoStyle.Content"/> will be to use position and size of the Subviews
+    ///                     to
+    ///                     determine the size of the view, ignoring <see cref="GetContentSize ()"/>.
+    ///                 </para>
+    ///             </description>
+    ///         </item>
+    ///         <item>
+    ///             <term>
+    ///                 <see langword="false"/>
+    ///             </term>
+    ///             <description>
+    ///                 <para>
+    ///                     The return value of <see cref="GetContentSize ()"/> is independent of <see cref="Viewport"/> and <see cref="Viewport"/>
+    ///                     describes the portion of the content currently visible to the user enabling content scrolling.
+    ///                 </para>
+    ///                 <para>
+    ///                     The behavior of <see cref="DimAutoStyle.Content"/> will be to use <see cref="GetContentSize ()"/>
+    ///                     to
+    ///                     determine the
+    ///                     size of the view, ignoring the position and size of the Subviews.
+    ///                 </para>
+    ///             </description>
+    ///         </item>
+    ///     </list>
+    /// </remarks>
+    public bool ContentSizeTracksViewport
+    {
+        get => _contentSize is null;
+        set => _contentSize = value ? null : _contentSize;
+    }
+
+    /// <summary>
+    ///     Called when <see cref="GetContentSize ()"/> has changed.
     /// </summary>
     /// </summary>
     /// <param name="e"></param>
     /// <param name="e"></param>
     /// <returns></returns>
     /// <returns></returns>
@@ -79,6 +142,7 @@ public partial class View
         if (e.Cancel != true)
         if (e.Cancel != true)
         {
         {
             OnResizeNeeded ();
             OnResizeNeeded ();
+
             //SetNeedsLayout ();
             //SetNeedsLayout ();
             //SetNeedsDisplay ();
             //SetNeedsDisplay ();
         }
         }
@@ -87,7 +151,7 @@ public partial class View
     }
     }
 
 
     /// <summary>
     /// <summary>
-    ///     Event raised when the <see cref="ContentSize"/> changes.
+    ///     Event raised when the <see cref="GetContentSize ()"/> changes.
     /// </summary>
     /// </summary>
     public event EventHandler<SizeChangedEventArgs> ContentSizeChanged;
     public event EventHandler<SizeChangedEventArgs> ContentSizeChanged;
 
 
@@ -155,37 +219,35 @@ public partial class View
     /// <summary>
     /// <summary>
     ///     The location of the viewport into the view's content (0,0) is the top-left corner of the content. The Content
     ///     The location of the viewport into the view's content (0,0) is the top-left corner of the content. The Content
     ///     area's size
     ///     area's size
-    ///     is <see cref="ContentSize"/>.
+    ///     is <see cref="GetContentSize ()"/>.
     /// </summary>
     /// </summary>
     private Point _viewportLocation;
     private Point _viewportLocation;
 
 
     /// <summary>
     /// <summary>
     ///     Gets or sets the rectangle describing the portion of the View's content that is visible to the user.
     ///     Gets or sets the rectangle describing the portion of the View's content that is visible to the user.
     ///     The viewport Location is relative to the top-left corner of the inner rectangle of <see cref="Padding"/>.
     ///     The viewport Location is relative to the top-left corner of the inner rectangle of <see cref="Padding"/>.
-    ///     If the viewport Size is the same as <see cref="ContentSize"/>, or <see cref="ContentSize"/> is
+    ///     If the viewport Size is the same as <see cref="GetContentSize ()"/>, or <see cref="GetContentSize ()"/> is
     ///     <see langword="null"/> the Location will be <c>0, 0</c>.
     ///     <see langword="null"/> the Location will be <c>0, 0</c>.
     /// </summary>
     /// </summary>
     /// <value>
     /// <value>
     ///     The rectangle describing the location and size of the viewport into the View's virtual content, described by
     ///     The rectangle describing the location and size of the viewport into the View's virtual content, described by
-    ///     <see cref="ContentSize"/>.
+    ///     <see cref="GetContentSize ()"/>.
     /// </value>
     /// </value>
     /// <remarks>
     /// <remarks>
     ///     <para>
     ///     <para>
     ///         Positive values for the location indicate the visible area is offset into (down-and-right) the View's virtual
     ///         Positive values for the location indicate the visible area is offset into (down-and-right) the View's virtual
-    ///         <see cref="ContentSize"/>. This enables scrolling down and to the right (e.g. in a <see cref="ListView"/>.
+    ///         <see cref="GetContentSize ()"/>. This enables scrolling down and to the right (e.g. in a <see cref="ListView"/>
+    ///         .
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
     ///         Negative values for the location indicate the visible area is offset above (up-and-left) the View's virtual
     ///         Negative values for the location indicate the visible area is offset above (up-and-left) the View's virtual
-    ///         <see cref="ContentSize"/>. This enables scrolling up and to the left (e.g. in an image viewer that supports zoom
+    ///         <see cref="GetContentSize ()"/>. This enables scrolling up and to the left (e.g. in an image viewer that
+    ///         supports
+    ///         zoom
     ///         where the image stays centered).
     ///         where the image stays centered).
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
-    ///         The <see cref="ViewportSettings"/> property controls how scrolling is handled. 
-    ///     </para>
-    ///     <para>
-    ///         If <see cref="LayoutStyle"/> is <see cref="LayoutStyle.Computed"/> the value of Viewport is indeterminate until
-    ///         the view has been initialized ( <see cref="IsInitialized"/> is true) and <see cref="LayoutSubviews"/> has been
-    ///         called.
+    ///         The <see cref="ViewportSettings"/> property controls how scrolling is handled.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
     ///         Updates to the Viewport Size updates <see cref="Frame"/>, and has the same impact as updating the
     ///         Updates to the Viewport Size updates <see cref="Frame"/>, and has the same impact as updating the
@@ -207,6 +269,7 @@ public partial class View
             }
             }
 
 
             Thickness thickness = GetAdornmentsThickness ();
             Thickness thickness = GetAdornmentsThickness ();
+
             return new (
             return new (
                         _viewportLocation,
                         _viewportLocation,
                         new (
                         new (
@@ -239,6 +302,7 @@ public partial class View
             }
             }
 
 
             OnViewportChanged (new (IsInitialized ? Viewport : Rectangle.Empty, oldViewport));
             OnViewportChanged (new (IsInitialized ? Viewport : Rectangle.Empty, oldViewport));
+
             return;
             return;
         }
         }
 
 
@@ -254,9 +318,9 @@ public partial class View
         {
         {
             if (!ViewportSettings.HasFlag (ViewportSettings.AllowXGreaterThanContentWidth))
             if (!ViewportSettings.HasFlag (ViewportSettings.AllowXGreaterThanContentWidth))
             {
             {
-                if (newViewport.X >= ContentSize.Width)
+                if (newViewport.X >= GetContentSize ().Width)
                 {
                 {
-                    newViewport.X = ContentSize.Width - 1;
+                    newViewport.X = GetContentSize ().Width - 1;
                 }
                 }
             }
             }
 
 
@@ -271,9 +335,9 @@ public partial class View
 
 
             if (!ViewportSettings.HasFlag (ViewportSettings.AllowYGreaterThanContentHeight))
             if (!ViewportSettings.HasFlag (ViewportSettings.AllowYGreaterThanContentHeight))
             {
             {
-                if (newViewport.Y >= ContentSize.Height)
+                if (newViewport.Y >= GetContentSize ().Height)
                 {
                 {
-                    newViewport.Y = ContentSize.Height - 1;
+                    newViewport.Y = GetContentSize ().Height - 1;
                 }
                 }
             }
             }
 
 
@@ -289,7 +353,8 @@ public partial class View
     }
     }
 
 
     /// <summary>
     /// <summary>
-    ///     Fired when the <see cref="Viewport"/> changes. This event is fired after the <see cref="Viewport"/> has been updated.
+    ///     Fired when the <see cref="Viewport"/> changes. This event is fired after the <see cref="Viewport"/> has been
+    ///     updated.
     /// </summary>
     /// </summary>
     [CanBeNull]
     [CanBeNull]
     public event EventHandler<DrawEventArgs> ViewportChanged;
     public event EventHandler<DrawEventArgs> ViewportChanged;
@@ -298,10 +363,7 @@ public partial class View
     ///     Called when the <see cref="Viewport"/> changes. Invokes the <see cref="ViewportChanged"/> event.
     ///     Called when the <see cref="Viewport"/> changes. Invokes the <see cref="ViewportChanged"/> event.
     /// </summary>
     /// </summary>
     /// <param name="e"></param>
     /// <param name="e"></param>
-    protected virtual void OnViewportChanged (DrawEventArgs e)
-    {
-        ViewportChanged?.Invoke (this, e);
-    }
+    protected virtual void OnViewportChanged (DrawEventArgs e) { ViewportChanged?.Invoke (this, e); }
 
 
     /// <summary>
     /// <summary>
     ///     Converts a <see cref="Viewport"/>-relative location and size to a screen-relative location and size.
     ///     Converts a <see cref="Viewport"/>-relative location and size to a screen-relative location and size.
@@ -311,10 +373,7 @@ public partial class View
     /// </remarks>
     /// </remarks>
     /// <param name="viewport">Viewport-relative location and size.</param>
     /// <param name="viewport">Viewport-relative location and size.</param>
     /// <returns>Screen-relative location and size.</returns>
     /// <returns>Screen-relative location and size.</returns>
-    public Rectangle ViewportToScreen (in Rectangle viewport)
-    {
-        return viewport with { Location = ViewportToScreen (viewport.Location) };
-    }
+    public Rectangle ViewportToScreen (in Rectangle viewport) { return viewport with { Location = ViewportToScreen (viewport.Location) }; }
 
 
     /// <summary>
     /// <summary>
     ///     Converts a <see cref="Viewport"/>-relative location to a screen-relative location.
     ///     Converts a <see cref="Viewport"/>-relative location to a screen-relative location.
@@ -367,7 +426,7 @@ public partial class View
     /// <returns><see langword="true"/> if the <see cref="Viewport"/> was changed.</returns>
     /// <returns><see langword="true"/> if the <see cref="Viewport"/> was changed.</returns>
     public bool? ScrollVertical (int rows)
     public bool? ScrollVertical (int rows)
     {
     {
-        if (ContentSize == Size.Empty || ContentSize == Viewport.Size)
+        if (GetContentSize () == Size.Empty || GetContentSize () == Viewport.Size)
         {
         {
             return false;
             return false;
         }
         }
@@ -388,7 +447,7 @@ public partial class View
     /// <returns><see langword="true"/> if the <see cref="Viewport"/> was changed.</returns>
     /// <returns><see langword="true"/> if the <see cref="Viewport"/> was changed.</returns>
     public bool? ScrollHorizontal (int cols)
     public bool? ScrollHorizontal (int cols)
     {
     {
-        if (ContentSize == Size.Empty || ContentSize == Viewport.Size)
+        if (GetContentSize () == Size.Empty || GetContentSize () == Viewport.Size)
         {
         {
             return false;
             return false;
         }
         }

+ 6 - 6
Terminal.Gui/View/ViewDrawing.cs

@@ -106,7 +106,7 @@ public partial class View
 
 
         if (ViewportSettings.HasFlag (ViewportSettings.ClearContentOnly))
         if (ViewportSettings.HasFlag (ViewportSettings.ClearContentOnly))
         {
         {
-            Rectangle visibleContent = ViewportToScreen (new Rectangle (new (-Viewport.X, -Viewport.Y), ContentSize));
+            Rectangle visibleContent = ViewportToScreen (new Rectangle (new (-Viewport.X, -Viewport.Y), GetContentSize ()));
             toClear = Rectangle.Intersect (toClear, visibleContent);
             toClear = Rectangle.Intersect (toClear, visibleContent);
         }
         }
 
 
@@ -172,7 +172,7 @@ public partial class View
         if (ViewportSettings.HasFlag (ViewportSettings.ClipContentOnly))
         if (ViewportSettings.HasFlag (ViewportSettings.ClipContentOnly))
         {
         {
             // Clamp the Clip to the just content area that is within the viewport
             // Clamp the Clip to the just content area that is within the viewport
-            Rectangle visibleContent = ViewportToScreen (new Rectangle (new (-Viewport.X, -Viewport.Y), ContentSize));
+            Rectangle visibleContent = ViewportToScreen (new Rectangle (new (-Viewport.X, -Viewport.Y), GetContentSize ()));
             clip = Rectangle.Intersect (clip, visibleContent);
             clip = Rectangle.Intersect (clip, visibleContent);
         }
         }
 
 
@@ -445,12 +445,12 @@ public partial class View
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
     ///         The <see cref="Viewport"/> Location and Size indicate what part of the View's content, defined
     ///         The <see cref="Viewport"/> Location and Size indicate what part of the View's content, defined
-    ///         by <see cref="ContentSize"/>, is visible and should be drawn. The coordinates taken by <see cref="Move"/> and
+    ///         by <see cref="GetContentSize ()"/>, is visible and should be drawn. The coordinates taken by <see cref="Move"/> and
     ///         <see cref="AddRune"/> are relative to <see cref="Viewport"/>, thus if <c>ViewPort.Location.Y</c> is <c>5</c>
     ///         <see cref="AddRune"/> are relative to <see cref="Viewport"/>, thus if <c>ViewPort.Location.Y</c> is <c>5</c>
     ///         the 6th row of the content should be drawn using <c>MoveTo (x, 5)</c>.
     ///         the 6th row of the content should be drawn using <c>MoveTo (x, 5)</c>.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
-    ///         If <see cref="ContentSize"/> is larger than <c>ViewPort.Size</c> drawing code should use <see cref="Viewport"/>
+    ///         If <see cref="GetContentSize ()"/> is larger than <c>ViewPort.Size</c> drawing code should use <see cref="Viewport"/>
     ///         to constrain drawing for better performance.
     ///         to constrain drawing for better performance.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
@@ -485,7 +485,7 @@ public partial class View
 
 
             // This should NOT clear 
             // This should NOT clear 
             // TODO: If the output is not in the Viewport, do nothing
             // TODO: If the output is not in the Viewport, do nothing
-            var drawRect = new Rectangle (ContentToScreen (Point.Empty), ContentSize);
+            var drawRect = new Rectangle (ContentToScreen (Point.Empty), GetContentSize ());
 
 
             TextFormatter?.Draw (
             TextFormatter?.Draw (
                                  drawRect,
                                  drawRect,
@@ -594,7 +594,7 @@ public partial class View
     /// <remarks>
     /// <remarks>
     ///     <para>
     ///     <para>
     ///         The location of <paramref name="region"/> is relative to the View's content, bound by <c>Size.Empty</c> and
     ///         The location of <paramref name="region"/> is relative to the View's content, bound by <c>Size.Empty</c> and
-    ///         <see cref="ContentSize"/>.
+    ///         <see cref="GetContentSize ()"/>.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
     ///         If the view has not been initialized (<see cref="IsInitialized"/> is <see langword="false"/>), the area to be
     ///         If the view has not been initialized (<see cref="IsInitialized"/> is <see langword="false"/>), the area to be

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

@@ -37,11 +37,11 @@ public partial class View
     ///         to <see cref="TextAlignment"/> and <see cref="TextDirection"/>.
     ///         to <see cref="TextAlignment"/> and <see cref="TextDirection"/>.
     ///     </para>
     ///     </para>
     ///     <para>
     ///     <para>
-    ///         The text will word-wrap to additional lines if it does not fit horizontally. If <see cref="ContentSize"/>'s height
+    ///         The text will word-wrap to additional lines if it does not fit horizontally. If <see cref="GetContentSize ()"/>'s height
     ///         is 1, the text will be clipped.
     ///         is 1, the text will be clipped.
     ///     </para>
     ///     </para>
     ///     <para>If <see cref="View.Width"/> or <see cref="View.Height"/> are using <see cref="DimAutoStyle.Text"/>,
     ///     <para>If <see cref="View.Width"/> or <see cref="View.Height"/> are using <see cref="DimAutoStyle.Text"/>,
-    ///     the <see cref="ContentSize"/> will be adjusted to fit the text.</para>
+    ///     the <see cref="GetContentSize ()"/> will be adjusted to fit the text.</para>
     ///     <para>When the text changes, the <see cref="TextChanged"/> is fired.</para>
     ///     <para>When the text changes, the <see cref="TextChanged"/> is fired.</para>
     /// </remarks>
     /// </remarks>
     public virtual string Text
     public virtual string Text
@@ -84,7 +84,7 @@ public partial class View
     ///     redisplay the <see cref="View"/>.
     ///     redisplay the <see cref="View"/>.
     /// </summary>
     /// </summary>
     /// <remarks>
     /// <remarks>
-    ///     <para> <see cref="View.Width"/> or <see cref="View.Height"/> are using <see cref="DimAutoStyle.Text"/>, the <see cref="ContentSize"/> will be adjusted to fit the text.</para>
+    ///     <para> <see cref="View.Width"/> or <see cref="View.Height"/> are using <see cref="DimAutoStyle.Text"/>, the <see cref="GetContentSize ()"/> will be adjusted to fit the text.</para>
     /// </remarks>
     /// </remarks>
     /// <value>The text alignment.</value>
     /// <value>The text alignment.</value>
     public virtual Alignment TextAlignment
     public virtual Alignment TextAlignment
@@ -103,7 +103,7 @@ public partial class View
     ///     <see cref="View"/>.
     ///     <see cref="View"/>.
     /// </summary>
     /// </summary>
     /// <remarks>
     /// <remarks>
-    ///     <para> <see cref="View.Width"/> or <see cref="View.Height"/> are using <see cref="DimAutoStyle.Text"/>, the <see cref="ContentSize"/> will be adjusted to fit the text.</para>
+    ///     <para> <see cref="View.Width"/> or <see cref="View.Height"/> are using <see cref="DimAutoStyle.Text"/>, the <see cref="GetContentSize ()"/> will be adjusted to fit the text.</para>
     /// </remarks>
     /// </remarks>
     /// <value>The text direction.</value>
     /// <value>The text direction.</value>
     public virtual TextDirection TextDirection
     public virtual TextDirection TextDirection
@@ -127,7 +127,7 @@ public partial class View
     ///     the <see cref="View"/>.
     ///     the <see cref="View"/>.
     /// </summary>
     /// </summary>
     /// <remarks>
     /// <remarks>
-    ///     <para> <see cref="View.Width"/> or <see cref="View.Height"/> are using <see cref="DimAutoStyle.Text"/>, the <see cref="ContentSize"/> will be adjusted to fit the text.</para>
+    ///     <para> <see cref="View.Width"/> or <see cref="View.Height"/> are using <see cref="DimAutoStyle.Text"/>, the <see cref="GetContentSize ()"/> will be adjusted to fit the text.</para>
     /// </remarks>
     /// </remarks>
     /// <value>The vertical text alignment.</value>
     /// <value>The vertical text alignment.</value>
     public virtual Alignment VerticalTextAlignment
     public virtual Alignment VerticalTextAlignment
@@ -179,8 +179,8 @@ public partial class View
         // We need to ensure TextFormatter is accurate by calling it here.
         // We need to ensure TextFormatter is accurate by calling it here.
         UpdateTextFormatterText ();
         UpdateTextFormatterText ();
 
 
-        // Default is to use ContentSize.
-        var size = ContentSize;
+        // Default is to use GetContentSize ().
+        var size = GetContentSize ();
 
 
         // TODO: This is a hack. Figure out how to move this into DimDimAuto
         // TODO: This is a hack. Figure out how to move this into DimDimAuto
         // Use _width & _height instead of Width & Height to avoid debug spew
         // Use _width & _height instead of Width & Height to avoid debug spew
@@ -193,12 +193,12 @@ public partial class View
 
 
             if (widthAuto is null || !widthAuto.Style.FastHasFlags (DimAutoStyle.Text))
             if (widthAuto is null || !widthAuto.Style.FastHasFlags (DimAutoStyle.Text))
             {
             {
-                size.Width = ContentSize.Width;
+                size.Width = GetContentSize ().Width;
             }
             }
 
 
             if (heightAuto is null || !heightAuto.Style.FastHasFlags (DimAutoStyle.Text))
             if (heightAuto is null || !heightAuto.Style.FastHasFlags (DimAutoStyle.Text))
             {
             {
-                size.Height = ContentSize.Height;
+                size.Height = GetContentSize ().Height;
             }
             }
         }
         }
 
 

+ 6 - 6
Terminal.Gui/View/ViewportSettings.cs

@@ -47,13 +47,13 @@ public enum ViewportSettings
     AllowNegativeLocation = AllowNegativeX | AllowNegativeY,
     AllowNegativeLocation = AllowNegativeX | AllowNegativeY,
 
 
     /// <summary>
     /// <summary>
-    ///     If set, <see cref="View.Viewport"/><c>.X</c> can be set values greater than <see cref="View.ContentSize"/>
+    ///     If set, <see cref="View.Viewport"/><c>.X</c> can be set values greater than <see cref="View.GetContentSize ()"/>
     ///     <c>.Width</c> enabling scrolling beyond the right
     ///     <c>.Width</c> enabling scrolling beyond the right
     ///     of the content area.
     ///     of the content area.
     /// </summary>
     /// </summary>
     /// <remarks>
     /// <remarks>
     ///     <para>
     ///     <para>
-    ///         When not set, <see cref="View.Viewport"/><c>.X</c> is constrained to <see cref="View.ContentSize"/>
+    ///         When not set, <see cref="View.Viewport"/><c>.X</c> is constrained to <see cref="View.GetContentSize ()"/>
     ///         <c>.Width - 1</c>.
     ///         <c>.Width - 1</c>.
     ///         This means the last column of the content will remain visible even if there is an attempt to scroll the
     ///         This means the last column of the content will remain visible even if there is an attempt to scroll the
     ///         Viewport past the last column.
     ///         Viewport past the last column.
@@ -65,13 +65,13 @@ public enum ViewportSettings
     AllowXGreaterThanContentWidth = 4,
     AllowXGreaterThanContentWidth = 4,
 
 
     /// <summary>
     /// <summary>
-    ///     If set, <see cref="View.Viewport"/><c>.Y</c> can be set values greater than <see cref="View.ContentSize"/>
+    ///     If set, <see cref="View.Viewport"/><c>.Y</c> can be set values greater than <see cref="View.GetContentSize ()"/>
     ///     <c>.Height</c> enabling scrolling beyond the right
     ///     <c>.Height</c> enabling scrolling beyond the right
     ///     of the content area.
     ///     of the content area.
     /// </summary>
     /// </summary>
     /// <remarks>
     /// <remarks>
     ///     <para>
     ///     <para>
-    ///         When not set, <see cref="View.Viewport"/><c>.Y</c> is constrained to <see cref="View.ContentSize"/>
+    ///         When not set, <see cref="View.Viewport"/><c>.Y</c> is constrained to <see cref="View.GetContentSize ()"/>
     ///         <c>.Height - 1</c>.
     ///         <c>.Height - 1</c>.
     ///         This means the last row of the content will remain visible even if there is an attempt to scroll the Viewport
     ///         This means the last row of the content will remain visible even if there is an attempt to scroll the Viewport
     ///         past the last row.
     ///         past the last row.
@@ -83,13 +83,13 @@ public enum ViewportSettings
     AllowYGreaterThanContentHeight = 8,
     AllowYGreaterThanContentHeight = 8,
 
 
     /// <summary>
     /// <summary>
-    ///     If set, <see cref="View.Viewport"/><c>.Size</c> can be set values greater than <see cref="View.ContentSize"/>
+    ///     If set, <see cref="View.Viewport"/><c>.Size</c> can be set values greater than <see cref="View.GetContentSize ()"/>
     ///     enabling scrolling beyond the bottom-right
     ///     enabling scrolling beyond the bottom-right
     ///     of the content area.
     ///     of the content area.
     /// </summary>
     /// </summary>
     /// <remarks>
     /// <remarks>
     ///     <para>
     ///     <para>
-    ///         When not set, <see cref="View.Viewport"/> is constrained to <see cref="View.ContentSize"/><c> -1</c>.
+    ///         When not set, <see cref="View.Viewport"/> is constrained to <see cref="View.GetContentSize ()"/><c> -1</c>.
     ///         This means the last column and row of the content will remain visible even if there is an attempt to
     ///         This means the last column and row of the content will remain visible even if there is an attempt to
     ///         scroll the Viewport past the last column or row.
     ///         scroll the Viewport past the last column or row.
     ///     </para>
     ///     </para>

+ 1 - 2
Terminal.Gui/Views/Button.cs

@@ -33,8 +33,7 @@ public class Button : View
     private readonly Rune _rightDefault;
     private readonly Rune _rightDefault;
     private bool _isDefault;
     private bool _isDefault;
 
 
-    /// <summary>Initializes a new instance of <see cref="Button"/> using <see cref="LayoutStyle.Computed"/> layout.</summary>
-    /// <remarks>The width of the <see cref="Button"/> is computed based on the text length. The height will always be 1.</remarks>
+    /// <summary>Initializes a new instance of <see cref="Button"/>.</summary>
     public Button ()
     public Button ()
     {
     {
         TextAlignment = Alignment.Center;
         TextAlignment = Alignment.Center;

+ 1 - 2
Terminal.Gui/Views/CheckBox.cs

@@ -11,8 +11,7 @@ public class CheckBox : View
     private bool? _checked = false;
     private bool? _checked = false;
 
 
     /// <summary>
     /// <summary>
-    ///     Initializes a new instance of <see cref="CheckBox"/> based on the given text, using
-    ///     <see cref="LayoutStyle.Computed"/> layout.
+    ///     Initializes a new instance of <see cref="CheckBox"/>.
     /// </summary>
     /// </summary>
     public CheckBox ()
     public CheckBox ()
     {
     {

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

@@ -39,7 +39,7 @@ public class ColorPicker : View
 
 
         Width = Dim.Auto (minimumContentDim: _boxWidth * _cols);
         Width = Dim.Auto (minimumContentDim: _boxWidth * _cols);
         Height = Dim.Auto (minimumContentDim: _boxHeight * _rows);
         Height = Dim.Auto (minimumContentDim: _boxHeight * _rows);
-        SetContentSize(new (_boxWidth * _cols, _boxHeight * _rows));
+        SetContentSize (new (_boxWidth * _cols, _boxHeight * _rows));
 
 
         MouseClick += ColorPicker_MouseClick;
         MouseClick += ColorPicker_MouseClick;
     }
     }
@@ -178,9 +178,9 @@ public class ColorPicker : View
         Driver.SetAttribute (HasFocus ? ColorScheme.Focus : GetNormalColor ());
         Driver.SetAttribute (HasFocus ? ColorScheme.Focus : GetNormalColor ());
         var colorIndex = 0;
         var colorIndex = 0;
 
 
-        for (var y = 0; y < Math.Max(2, viewport.Height / BoxHeight); y++)
+        for (var y = 0; y < Math.Max (2, viewport.Height / BoxHeight); y++)
         {
         {
-            for (var x = 0; x < Math.Max(8, viewport.Width / BoxWidth); x++)
+            for (var x = 0; x < Math.Max (8, viewport.Width / BoxWidth); x++)
             {
             {
                 int foregroundColorIndex = y == 0 ? colorIndex + _cols : colorIndex - _cols;
                 int foregroundColorIndex = y == 0 ? colorIndex + _cols : colorIndex - _cols;
                 Driver.SetAttribute (new Attribute ((ColorName)foregroundColorIndex, (ColorName)colorIndex));
                 Driver.SetAttribute (new Attribute ((ColorName)foregroundColorIndex, (ColorName)colorIndex));

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

@@ -619,8 +619,8 @@ public class ComboBox : View
         {
         {
             _search.Width = _listview.Width = _autoHide ? Viewport.Width - 1 : Viewport.Width;
             _search.Width = _listview.Width = _autoHide ? Viewport.Width - 1 : Viewport.Width;
             _listview.Height = CalculatetHeight ();
             _listview.Height = CalculatetHeight ();
-            _search.SetRelativeLayout (ContentSize);
-            _listview.SetRelativeLayout (ContentSize);
+            _search.SetRelativeLayout (GetContentSize ());
+            _listview.SetRelativeLayout (GetContentSize ());
         }
         }
     }
     }
 
 

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

@@ -21,10 +21,10 @@ public class DateField : TextField
     private string _format;
     private string _format;
     private string _separator;
     private string _separator;
 
 
-    /// <summary>Initializes a new instance of <see cref="DateField"/> using <see cref="LayoutStyle.Computed"/> layout.</summary>
+    /// <summary>Initializes a new instance of <see cref="DateField"/>.</summary>
     public DateField () : this (DateTime.MinValue) { }
     public DateField () : this (DateTime.MinValue) { }
 
 
-    /// <summary>Initializes a new instance of <see cref="DateField"/> using <see cref="LayoutStyle.Computed"/> layout.</summary>
+    /// <summary>Initializes a new instance of <see cref="DateField"/>.</summary>
     /// <param name="date"></param>
     /// <param name="date"></param>
     public DateField (DateTime date)
     public DateField (DateTime date)
     {
     {

+ 10 - 14
Terminal.Gui/Views/Dialog.cs

@@ -9,7 +9,8 @@ namespace Terminal.Gui;
 /// </summary>
 /// </summary>
 /// <remarks>
 /// <remarks>
 ///     To run the <see cref="Dialog"/> modally, create the <see cref="Dialog"/>, and pass it to
 ///     To run the <see cref="Dialog"/> modally, create the <see cref="Dialog"/>, and pass it to
-///     <see cref="Application.Run(Toplevel, Func{Exception, bool}, ConsoleDriver)"/>. This will execute the dialog until it terminates via the
+///     <see cref="Application.Run(Toplevel, Func{Exception, bool}, ConsoleDriver)"/>. This will execute the dialog until
+///     it terminates via the
 ///     [ESC] or [CTRL-Q] key, or when one of the views or buttons added to the dialog calls
 ///     [ESC] or [CTRL-Q] key, or when one of the views or buttons added to the dialog calls
 ///     <see cref="Application.RequestStop"/>.
 ///     <see cref="Application.RequestStop"/>.
 /// </remarks>
 /// </remarks>
@@ -41,7 +42,6 @@ public class Dialog : Window
     [SerializableConfigurationProperty (Scope = typeof (ThemeScope))]
     [SerializableConfigurationProperty (Scope = typeof (ThemeScope))]
     public static int DefaultMinimumHeight { get; set; } = 25;
     public static int DefaultMinimumHeight { get; set; } = 25;
 
 
-
     // TODO: Reenable once border/borderframe design is settled
     // TODO: Reenable once border/borderframe design is settled
     /// <summary>
     /// <summary>
     ///     Defines the default border styling for <see cref="Dialog"/>. Can be configured via
     ///     Defines the default border styling for <see cref="Dialog"/>. Can be configured via
@@ -55,13 +55,12 @@ public class Dialog : Window
     private readonly List<Button> _buttons = new ();
     private readonly List<Button> _buttons = new ();
 
 
     /// <summary>
     /// <summary>
-    ///     Initializes a new instance of the <see cref="Dialog"/> class using <see cref="LayoutStyle.Computed"/>
-    ///     positioning with no <see cref="Button"/>s.
+    ///     Initializes a new instance of the <see cref="Dialog"/> class with no <see cref="Button"/>s.
     /// </summary>
     /// </summary>
     /// <remarks>
     /// <remarks>
-    ///     By default, <see cref="View.X"/> and <see cref="View.Y"/> are set to <c>Pos.Center ()</c> and
-    ///     <see cref="View.Width"/> and <see cref="View.Height"/> are set to <c>Width = Dim.Percent (85)</c>, centering the
-    ///     Dialog vertically and horizontally.
+    ///     By default, <see cref="View.X"/>, <see cref="View.Y"/>, <see cref="View.Width"/>, and <see cref="View.Height"/> are
+    ///     set
+    ///     such that the <see cref="Dialog"/> will be centered in, and no larger than 90% of the screen dimensions.
     /// </remarks>
     /// </remarks>
     public Dialog ()
     public Dialog ()
     {
     {
@@ -69,8 +68,8 @@ public class Dialog : Window
         X = Pos.Center ();
         X = Pos.Center ();
         Y = Pos.Center ();
         Y = Pos.Center ();
 
 
-        Width = Dim.Auto (DimAutoStyle.Content, minimumContentDim: Dim.Percent (DefaultMinimumWidth), Dim.Percent (90));
-        Height = Dim.Auto (DimAutoStyle.Content, minimumContentDim: Dim.Percent (DefaultMinimumHeight), Dim.Percent (90));
+        Width = Dim.Auto (DimAutoStyle.Content, Dim.Percent (DefaultMinimumWidth), Dim.Percent (90));
+        Height = Dim.Auto (DimAutoStyle.Content, Dim.Percent (DefaultMinimumHeight), Dim.Percent (90));
         ColorScheme = Colors.ColorSchemes ["Dialog"];
         ColorScheme = Colors.ColorSchemes ["Dialog"];
 
 
         Modal = true;
         Modal = true;
@@ -87,7 +86,6 @@ public class Dialog : Window
                         return true;
                         return true;
                     });
                     });
         KeyBindings.Add (Key.Esc, Command.QuitToplevel);
         KeyBindings.Add (Key.Esc, Command.QuitToplevel);
-
     }
     }
 
 
     private bool _canceled;
     private bool _canceled;
@@ -115,8 +113,6 @@ public class Dialog : Window
             }
             }
 #endif
 #endif
             _canceled = value;
             _canceled = value;
-
-            return;
         }
         }
     }
     }
 
 
@@ -125,7 +121,7 @@ public class Dialog : Window
     public Alignment ButtonAlignment { get; set; }
     public Alignment ButtonAlignment { get; set; }
 
 
     /// <summary>
     /// <summary>
-    /// Gets or sets the alignment modes for the dialog's buttons.
+    ///     Gets or sets the alignment modes for the dialog's buttons.
     /// </summary>
     /// </summary>
     public AlignmentModes ButtonAlignmentModes { get; set; }
     public AlignmentModes ButtonAlignmentModes { get; set; }
 
 
@@ -160,7 +156,7 @@ public class Dialog : Window
         }
         }
 
 
         // Use a distinct GroupId so users can use Pos.Align for other views in the Dialog
         // Use a distinct GroupId so users can use Pos.Align for other views in the Dialog
-        button.X = Pos.Align (ButtonAlignment, ButtonAlignmentModes, groupId: GetHashCode ());
+        button.X = Pos.Align (ButtonAlignment, ButtonAlignmentModes, GetHashCode ());
         button.Y = Pos.AnchorEnd ();
         button.Y = Pos.AnchorEnd ();
 
 
         _buttons.Add (button);
         _buttons.Add (button);

+ 2 - 3
Terminal.Gui/Views/FrameView.cs

@@ -3,13 +3,12 @@
 namespace Terminal.Gui;
 namespace Terminal.Gui;
 
 
 /// <summary>
 /// <summary>
-///     The FrameView is a container frame that draws a frame around the contents. It is similar to a GroupBox in
-///     Windows.
+///     The FrameView is a container View with a border around it. 
 /// </summary>
 /// </summary>
 public class FrameView : View
 public class FrameView : View
 {
 {
     /// <summary>
     /// <summary>
-    ///     Initializes a new instance of the <see cref="Gui.FrameView"/> class using <see cref="LayoutStyle.Computed"/>
+    ///     Initializes a new instance of the <see cref="Gui.FrameView"/> class.
     ///     layout.
     ///     layout.
     /// </summary>
     /// </summary>
     public FrameView ()
     public FrameView ()

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

@@ -38,7 +38,7 @@ public class HexView : View
     private static readonly Rune SpaceCharRune = new (' ');
     private static readonly Rune SpaceCharRune = new (' ');
     private static readonly Rune PeriodCharRune = new ('.');
     private static readonly Rune PeriodCharRune = new ('.');
 
 
-    /// <summary>Initializes a <see cref="HexView"/> class using <see cref="LayoutStyle.Computed"/> layout.</summary>
+    /// <summary>Initializes a <see cref="HexView"/> class.</summary>
     /// <param name="source">
     /// <param name="source">
     ///     The <see cref="Stream"/> to view and edit as hex, this <see cref="Stream"/> must support seeking,
     ///     The <see cref="Stream"/> to view and edit as hex, this <see cref="Stream"/> must support seeking,
     ///     or an exception will be thrown.
     ///     or an exception will be thrown.
@@ -98,7 +98,7 @@ public class HexView : View
         LayoutComplete += HexView_LayoutComplete;
         LayoutComplete += HexView_LayoutComplete;
     }
     }
 
 
-    /// <summary>Initializes a <see cref="HexView"/> class using <see cref="LayoutStyle.Computed"/> layout.</summary>
+    /// <summary>Initializes a <see cref="HexView"/> class.</summary>
     public HexView () : this (new MemoryStream ()) { }
     public HexView () : this (new MemoryStream ()) { }
 
 
     /// <summary>
     /// <summary>

+ 1 - 1
Terminal.Gui/Views/Menu/MenuBar.cs

@@ -256,7 +256,7 @@ public class MenuBar : View
         X = 0;
         X = 0;
         Y = 0;
         Y = 0;
         Width = Dim.Fill ();
         Width = Dim.Fill ();
-        Height = 1; // BUGBUG: Views should avoid setting Height as doing so implies Frame.Size == ContentSize
+        Height = 1; // BUGBUG: Views should avoid setting Height as doing so implies Frame.Size == GetContentSize ().
         Menus = new MenuBarItem [] { };
         Menus = new MenuBarItem [] { };
 
 
         //CanFocus = true;
         //CanFocus = true;

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

@@ -405,7 +405,7 @@ public static class MessageBox
             Size GetWrapSize ()
             Size GetWrapSize ()
             {
             {
                 // A bit of a hack to get the height of the wrapped text.
                 // A bit of a hack to get the height of the wrapped text.
-                messageLabel.TextFormatter.Size = d.ContentSize with { Height = 1000 };
+                messageLabel.TextFormatter.Size = d.GetContentSize () with { Height = 1000 };
                 return messageLabel.TextFormatter.FormatAndGetSize ();
                 return messageLabel.TextFormatter.FormatAndGetSize ();
             }
             }
         }
         }

+ 1 - 2
Terminal.Gui/Views/RadioGroup.cs

@@ -11,8 +11,7 @@ public class RadioGroup : View
     private int _selected;
     private int _selected;
 
 
     /// <summary>
     /// <summary>
-    ///     Initializes a new instance of the <see cref="RadioGroup"/> class using <see cref="LayoutStyle.Computed"/>
-    ///     layout.
+    ///     Initializes a new instance of the <see cref="RadioGroup"/> class.
     /// </summary>
     /// </summary>
     public RadioGroup ()
     public RadioGroup ()
     {
     {

+ 2 - 4
Terminal.Gui/Views/ScrollBarView.cs

@@ -33,8 +33,7 @@ public class ScrollBarView : View
     private bool _vertical;
     private bool _vertical;
 
 
     /// <summary>
     /// <summary>
-    ///     Initializes a new instance of the <see cref="Gui.ScrollBarView"/> class using
-    ///     <see cref="LayoutStyle.Computed"/> layout.
+    ///     Initializes a new instance of the <see cref="Gui.ScrollBarView"/> class.
     /// </summary>
     /// </summary>
     public ScrollBarView ()
     public ScrollBarView ()
     {
     {
@@ -46,8 +45,7 @@ public class ScrollBarView : View
     }
     }
 
 
     /// <summary>
     /// <summary>
-    ///     Initializes a new instance of the <see cref="Gui.ScrollBarView"/> class using
-    ///     <see cref="LayoutStyle.Computed"/> layout.
+    ///     Initializes a new instance of the <see cref="Gui.ScrollBarView"/> class.
     /// </summary>
     /// </summary>
     /// <param name="host">The view that will host this scrollbar.</param>
     /// <param name="host">The view that will host this scrollbar.</param>
     /// <param name="isVertical">If set to <c>true</c> this is a vertical scrollbar, otherwise, the scrollbar is horizontal.</param>
     /// <param name="isVertical">If set to <c>true</c> this is a vertical scrollbar, otherwise, the scrollbar is horizontal.</param>

+ 20 - 21
Terminal.Gui/Views/ScrollView.cs

@@ -21,7 +21,7 @@ namespace Terminal.Gui;
 ///     <para>
 ///     <para>
 ///         The subviews that are added to this <see cref="Gui.ScrollView"/> are offset by the
 ///         The subviews that are added to this <see cref="Gui.ScrollView"/> are offset by the
 ///         <see cref="ContentOffset"/> property.  The view itself is a window into the space represented by the
 ///         <see cref="ContentOffset"/> property.  The view itself is a window into the space represented by the
-///         <see cref="View.ContentSize"/>.
+///         <see cref="View.GetContentSize ()"/>.
 ///     </para>
 ///     </para>
 ///     <para>Use the</para>
 ///     <para>Use the</para>
 /// </remarks>
 /// </remarks>
@@ -38,8 +38,7 @@ public class ScrollView : View
     private bool _showVerticalScrollIndicator;
     private bool _showVerticalScrollIndicator;
 
 
     /// <summary>
     /// <summary>
-    ///     Initializes a new instance of the <see cref="Gui.ScrollView"/> class using <see cref="LayoutStyle.Computed"/>
-    ///     positioning.
+    ///     Initializes a new instance of the <see cref="Gui.ScrollView"/> class.
     /// </summary>
     /// </summary>
     public ScrollView ()
     public ScrollView ()
     {
     {
@@ -88,10 +87,10 @@ public class ScrollView : View
         AddCommand (Command.PageDown, () => ScrollDown (Viewport.Height));
         AddCommand (Command.PageDown, () => ScrollDown (Viewport.Height));
         AddCommand (Command.PageLeft, () => ScrollLeft (Viewport.Width));
         AddCommand (Command.PageLeft, () => ScrollLeft (Viewport.Width));
         AddCommand (Command.PageRight, () => ScrollRight (Viewport.Width));
         AddCommand (Command.PageRight, () => ScrollRight (Viewport.Width));
-        AddCommand (Command.TopHome, () => ScrollUp (ContentSize.Height));
-        AddCommand (Command.BottomEnd, () => ScrollDown (ContentSize.Height));
-        AddCommand (Command.LeftHome, () => ScrollLeft (ContentSize.Width));
-        AddCommand (Command.RightEnd, () => ScrollRight (ContentSize.Width));
+        AddCommand (Command.TopHome, () => ScrollUp (GetContentSize ().Height));
+        AddCommand (Command.BottomEnd, () => ScrollDown (GetContentSize ().Height));
+        AddCommand (Command.LeftHome, () => ScrollLeft (GetContentSize ().Width));
+        AddCommand (Command.RightEnd, () => ScrollRight (GetContentSize ().Width));
 
 
         // Default keybindings for this view
         // Default keybindings for this view
         KeyBindings.Add (Key.CursorUp, Command.ScrollUp);
         KeyBindings.Add (Key.CursorUp, Command.ScrollUp);
@@ -127,7 +126,7 @@ public class ScrollView : View
                            }
                            }
 
 
                            SetContentOffset (_contentOffset);
                            SetContentOffset (_contentOffset);
-                           _contentView.Frame = new Rectangle (ContentOffset, ContentSize);
+                           _contentView.Frame = new Rectangle (ContentOffset, GetContentSize ());
 
 
                            // PERF: How about calls to Point.Offset instead?
                            // PERF: How about calls to Point.Offset instead?
                            _vertical.ChangedPosition += delegate { ContentOffset = new Point (ContentOffset.X, _vertical.Position); };
                            _vertical.ChangedPosition += delegate { ContentOffset = new Point (ContentOffset.X, _vertical.Position); };
@@ -220,12 +219,12 @@ public class ScrollView : View
     //    get => ContentSize;
     //    get => ContentSize;
     //    set
     //    set
     //    {
     //    {
-    //        if (ContentSize != value)
+    //        if (GetContentSize () != value)
     //        {
     //        {
     //            ContentSize = value;
     //            ContentSize = value;
     //            _contentView.Frame = new Rectangle (_contentOffset, value);
     //            _contentView.Frame = new Rectangle (_contentOffset, value);
-    //            _vertical.Size = ContentSize.Height;
-    //            _horizontal.Size = ContentSize.Width;
+    //            _vertical.Size = GetContentSize ().Height;
+    //            _horizontal.Size = GetContentSize ().Width;
     //            SetNeedsDisplay ();
     //            SetNeedsDisplay ();
     //        }
     //        }
     //    }
     //    }
@@ -244,26 +243,26 @@ public class ScrollView : View
                 _horizontal.OtherScrollBarView.KeepContentAlwaysInViewport = value;
                 _horizontal.OtherScrollBarView.KeepContentAlwaysInViewport = value;
                 Point p = default;
                 Point p = default;
 
 
-                if (value && -_contentOffset.X + Viewport.Width > ContentSize.Width)
+                if (value && -_contentOffset.X + Viewport.Width > GetContentSize ().Width)
                 {
                 {
                     p = new Point (
                     p = new Point (
-                                   ContentSize.Width - Viewport.Width + (_showVerticalScrollIndicator ? 1 : 0),
+                                   GetContentSize ().Width - Viewport.Width + (_showVerticalScrollIndicator ? 1 : 0),
                                    -_contentOffset.Y
                                    -_contentOffset.Y
                                   );
                                   );
                 }
                 }
 
 
-                if (value && -_contentOffset.Y + Viewport.Height > ContentSize.Height)
+                if (value && -_contentOffset.Y + Viewport.Height > GetContentSize ().Height)
                 {
                 {
                     if (p == default (Point))
                     if (p == default (Point))
                     {
                     {
                         p = new Point (
                         p = new Point (
                                        -_contentOffset.X,
                                        -_contentOffset.X,
-                                       ContentSize.Height - Viewport.Height + (_showHorizontalScrollIndicator ? 1 : 0)
+                                       GetContentSize ().Height - Viewport.Height + (_showHorizontalScrollIndicator ? 1 : 0)
                                       );
                                       );
                     }
                     }
                     else
                     else
                     {
                     {
-                        p.Y = ContentSize.Height - Viewport.Height + (_showHorizontalScrollIndicator ? 1 : 0);
+                        p.Y = GetContentSize ().Height - Viewport.Height + (_showHorizontalScrollIndicator ? 1 : 0);
                     }
                     }
                 }
                 }
 
 
@@ -607,7 +606,7 @@ public class ScrollView : View
     {
     {
         // INTENT: Unclear intent. How about a call to Offset?
         // INTENT: Unclear intent. How about a call to Offset?
         _contentOffset = new Point (-Math.Abs (offset.X), -Math.Abs (offset.Y));
         _contentOffset = new Point (-Math.Abs (offset.X), -Math.Abs (offset.Y));
-        _contentView.Frame = new Rectangle (_contentOffset, ContentSize);
+        _contentView.Frame = new Rectangle (_contentOffset, GetContentSize ());
         int p = Math.Max (0, -_contentOffset.Y);
         int p = Math.Max (0, -_contentOffset.Y);
 
 
         if (_vertical.Position != p)
         if (_vertical.Position != p)
@@ -638,7 +637,7 @@ public class ScrollView : View
         bool v = false, h = false;
         bool v = false, h = false;
         var p = false;
         var p = false;
 
 
-        if (ContentSize is { } && (Viewport.Height == 0 || Viewport.Height > ContentSize.Height))
+        if (GetContentSize () is { } && (Viewport.Height == 0 || Viewport.Height > GetContentSize ().Height))
         {
         {
             if (ShowVerticalScrollIndicator)
             if (ShowVerticalScrollIndicator)
             {
             {
@@ -647,7 +646,7 @@ public class ScrollView : View
 
 
             v = false;
             v = false;
         }
         }
-        else if (ContentSize is { } && Viewport.Height > 0 && Viewport.Height == ContentSize.Height)
+        else if (GetContentSize () is { } && Viewport.Height > 0 && Viewport.Height == GetContentSize ().Height)
         {
         {
             p = true;
             p = true;
         }
         }
@@ -661,7 +660,7 @@ public class ScrollView : View
             v = true;
             v = true;
         }
         }
 
 
-        if (ContentSize is { } && (Viewport.Width == 0 || Viewport.Width > ContentSize.Width))
+        if (GetContentSize () is { } && (Viewport.Width == 0 || Viewport.Width > GetContentSize ().Width))
         {
         {
             if (ShowHorizontalScrollIndicator)
             if (ShowHorizontalScrollIndicator)
             {
             {
@@ -670,7 +669,7 @@ public class ScrollView : View
 
 
             h = false;
             h = false;
         }
         }
-        else if (ContentSize is { } && Viewport.Width > 0 && Viewport.Width == ContentSize.Width && p)
+        else if (GetContentSize () is { } && Viewport.Width > 0 && Viewport.Width == GetContentSize ().Width && p)
         {
         {
             if (ShowHorizontalScrollIndicator)
             if (ShowHorizontalScrollIndicator)
             {
             {

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

@@ -93,7 +93,7 @@ public class StatusBar : View
         X = 0;
         X = 0;
         Y = Pos.AnchorEnd (1);
         Y = Pos.AnchorEnd (1);
         Width = Dim.Fill ();
         Width = Dim.Fill ();
-        Height = 1; // BUGBUG: Views should avoid setting Height as doing so implies Frame.Size == ContentSize
+        Height = 1; // BUGBUG: Views should avoid setting Height as doing so implies Frame.Size == GetContentSize ().
         AddCommand (Command.Accept, InvokeItem);
         AddCommand (Command.Accept, InvokeItem);
     }
     }
 
 

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

@@ -21,7 +21,7 @@ public class TabView : View
     private TabToRender [] _tabLocations;
     private TabToRender [] _tabLocations;
     private int _tabScrollOffset;
     private int _tabScrollOffset;
 
 
-    /// <summary>Initializes a <see cref="TabView"/> class using <see cref="LayoutStyle.Computed"/> layout.</summary>
+    /// <summary>Initializes a <see cref="TabView"/> class.</summary>
     public TabView ()
     public TabView ()
     {
     {
         CanFocus = true;
         CanFocus = true;
@@ -564,7 +564,7 @@ public class TabView : View
             _host = host;
             _host = host;
 
 
             CanFocus = true;
             CanFocus = true;
-            Height = 1; // BUGBUG: Views should avoid setting Height as doing so implies Frame.Size == ContentSize
+            Height = 1; // BUGBUG: Views should avoid setting Height as doing so implies Frame.Size == GetContentSize ().
             Width = Dim.Fill ();
             Width = Dim.Fill ();
 
 
             _rightScrollIndicator = new View
             _rightScrollIndicator = new View

+ 5 - 5
Terminal.Gui/Views/TableView/TableView.cs

@@ -37,12 +37,12 @@ public class TableView : View
     private TableStyle style = new ();
     private TableStyle style = new ();
     private ITableSource table;
     private ITableSource table;
 
 
-    /// <summary>Initializes a <see cref="TableView"/> class using <see cref="LayoutStyle.Computed"/> layout.</summary>
+    /// <summary>Initializes a <see cref="TableView"/> class.</summary>
     /// <param name="table">The table to display in the control</param>
     /// <param name="table">The table to display in the control</param>
     public TableView (ITableSource table) : this () { Table = table; }
     public TableView (ITableSource table) : this () { Table = table; }
 
 
     /// <summary>
     /// <summary>
-    ///     Initializes a <see cref="TableView"/> class using <see cref="LayoutStyle.Computed"/> layout. Set the
+    ///     Initializes a <see cref="TableView"/> class. Set the
     ///     <see cref="Table"/> property to begin editing
     ///     <see cref="Table"/> property to begin editing
     /// </summary>
     /// </summary>
     public TableView ()
     public TableView ()
@@ -908,10 +908,10 @@ public class TableView : View
         // What columns to render at what X offset in viewport
         // What columns to render at what X offset in viewport
         ColumnToRender [] columnsToRender = CalculateViewport (Viewport).ToArray ();
         ColumnToRender [] columnsToRender = CalculateViewport (Viewport).ToArray ();
 
 
-        Driver.SetAttribute (GetNormalColor ());
+        Driver?.SetAttribute (GetNormalColor ());
 
 
         //invalidate current row (prevents scrolling around leaving old characters in the frame
         //invalidate current row (prevents scrolling around leaving old characters in the frame
-        Driver.AddStr (new string (' ', Viewport.Width));
+        Driver?.AddStr (new string (' ', Viewport.Width));
 
 
         var line = 0;
         var line = 0;
 
 
@@ -2014,7 +2014,7 @@ public class TableView : View
 
 
     /// <summary>
     /// <summary>
     ///     Returns true if the <see cref="Table"/> is not set or all the columns in the <see cref="Table"/> have an
     ///     Returns true if the <see cref="Table"/> is not set or all the columns in the <see cref="Table"/> have an
-    ///     explicit <see cref="ColumnStyle"/> that marks them <see cref="ColumnStyle.visible"/> <see langword="false"/>.
+    ///     explicit <see cref="ColumnStyle"/> that marks them <see cref="ColumnStyle.Visible"/> <see langword="false"/>.
     /// </summary>
     /// </summary>
     /// <returns></returns>
     /// <returns></returns>
     private bool TableIsNullOrInvisible ()
     private bool TableIsNullOrInvisible ()

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

@@ -21,8 +21,7 @@ public class TextField : View
     private List<Rune> _text;
     private List<Rune> _text;
 
 
     /// <summary>
     /// <summary>
-    ///     Initializes a new instance of the <see cref="TextField"/> class using <see cref="LayoutStyle.Computed"/>
-    ///     positioning.
+    ///     Initializes a new instance of the <see cref="TextField"/> class.
     /// </summary>
     /// </summary>
     public TextField ()
     public TextField ()
     {
     {

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

@@ -392,8 +392,7 @@ namespace Terminal.Gui
         private ITextValidateProvider _provider;
         private ITextValidateProvider _provider;
 
 
         /// <summary>
         /// <summary>
-        ///     Initializes a new instance of the <see cref="TextValidateField"/> class using
-        ///     <see cref="LayoutStyle.Computed"/> positioning.
+        ///     Initializes a new instance of the <see cref="TextValidateField"/> class.
         /// </summary>
         /// </summary>
         public TextValidateField ()
         public TextValidateField ()
         {
         {

+ 59 - 97
Terminal.Gui/Views/TextView.cs

@@ -2588,25 +2588,6 @@ public class TextView : View
     /// </summary>
     /// </summary>
     public IAutocomplete Autocomplete { get; protected set; } = new TextViewAutocomplete ();
     public IAutocomplete Autocomplete { get; protected set; } = new TextViewAutocomplete ();
 
 
-    /// <summary>
-    ///     The bottom offset needed to use a horizontal scrollbar or for another reason. This is only needed with the
-    ///     keyboard navigation.
-    /// </summary>
-    public int BottomOffset
-    {
-        get => _bottomOffset;
-        set
-        {
-            if (CurrentRow == Lines - 1 && _bottomOffset > 0 && value == 0)
-            {
-                _topRow = Math.Max (_topRow - _bottomOffset, 0);
-            }
-
-            _bottomOffset = value;
-            Adjust ();
-        }
-    }
-
     /// <summary>Get the <see cref="ContextMenu"/> for this view.</summary>
     /// <summary>Get the <see cref="ContextMenu"/> for this view.</summary>
     public ContextMenu? ContextMenu { get; }
     public ContextMenu? ContextMenu { get; }
 
 
@@ -2678,7 +2659,7 @@ public class TextView : View
     public int Lines => _model.Count;
     public int Lines => _model.Count;
 
 
     /// <summary>Gets the maximum visible length line.</summary>
     /// <summary>Gets the maximum visible length line.</summary>
-    public int Maxlength => _model.GetMaxVisibleLine (_topRow, _topRow + Frame.Height, TabWidth);
+    public int Maxlength => _model.GetMaxVisibleLine (_topRow, _topRow + Viewport.Height, TabWidth);
 
 
     /// <summary>Gets or sets a value indicating whether this <see cref="TextView"/> is a multiline text view.</summary>
     /// <summary>Gets or sets a value indicating whether this <see cref="TextView"/> is a multiline text view.</summary>
     public bool Multiline
     public bool Multiline
@@ -2736,30 +2717,12 @@ public class TextView : View
                 _isReadOnly = value;
                 _isReadOnly = value;
 
 
                 SetNeedsDisplay ();
                 SetNeedsDisplay ();
+                WrapTextModel ();
                 Adjust ();
                 Adjust ();
             }
             }
         }
         }
     }
     }
 
 
-    /// <summary>
-    ///     The right offset needed to use a vertical scrollbar or for another reason. This is only needed with the
-    ///     keyboard navigation.
-    /// </summary>
-    public int RightOffset
-    {
-        get => _rightOffset;
-        set
-        {
-            if (!_wordWrap && CurrentColumn == GetCurrentLine ().Count && _rightOffset > 0 && value == 0)
-            {
-                _leftColumn = Math.Max (_leftColumn - _rightOffset, 0);
-            }
-
-            _rightOffset = value;
-            Adjust ();
-        }
-    }
-
     /// <summary>Length of the selected text.</summary>
     /// <summary>Length of the selected text.</summary>
     public int SelectedLength => GetSelectedLength ();
     public int SelectedLength => GetSelectedLength ();
 
 
@@ -2852,7 +2815,7 @@ public class TextView : View
             if (_wordWrap)
             if (_wordWrap)
             {
             {
                 _wrapManager = new (_model);
                 _wrapManager = new (_model);
-                _model = _wrapManager.WrapModel (_frameWidth, out _, out _, out _, out _);
+                _model = _wrapManager.WrapModel (Viewport.Width, out _, out _, out _, out _);
             }
             }
 
 
             OnTextChanged (old, Text);
             OnTextChanged (old, Text);
@@ -2897,7 +2860,7 @@ public class TextView : View
             if (_wordWrap)
             if (_wordWrap)
             {
             {
                 _wrapManager = new (_model);
                 _wrapManager = new (_model);
-                _model = _wrapManager.WrapModel (_frameWidth, out _, out _, out _, out _);
+                WrapTextModel ();
             }
             }
             else if (!_wordWrap && _wrapManager is { })
             else if (!_wordWrap && _wrapManager is { })
             {
             {
@@ -2908,7 +2871,6 @@ public class TextView : View
         }
         }
     }
     }
 
 
-    private int _frameWidth => Math.Max (Frame.Width - (RightOffset != 0 ? 2 : 1), 0);
 
 
     /// <summary>Allows clearing the <see cref="HistoryText.HistoryTextItem"/> items updating the original text.</summary>
     /// <summary>Allows clearing the <see cref="HistoryText.HistoryTextItem"/> items updating the original text.</summary>
     public void ClearHistoryChanges () { _historyText?.Clear (Text); }
     public void ClearHistoryChanges () { _historyText?.Clear (Text); }
@@ -3389,34 +3351,34 @@ public class TextView : View
 
 
             if (_model.Count > 0 && _shiftSelecting && Selecting)
             if (_model.Count > 0 && _shiftSelecting && Selecting)
             {
             {
-                if (CurrentRow - _topRow + BottomOffset >= Frame.Height - 1 && _model.Count + BottomOffset > _topRow + CurrentRow)
+                if (CurrentRow - _topRow >= Viewport.Height - 1 && _model.Count > _topRow + CurrentRow)
                 {
                 {
-                    ScrollTo (_topRow + Frame.Height);
+                    ScrollTo (_topRow + Viewport.Height);
                 }
                 }
                 else if (_topRow > 0 && CurrentRow <= _topRow)
                 else if (_topRow > 0 && CurrentRow <= _topRow)
                 {
                 {
-                    ScrollTo (_topRow - Frame.Height);
+                    ScrollTo (_topRow - Viewport.Height);
                 }
                 }
-                else if (ev.Position.Y >= Frame.Height)
+                else if (ev.Position.Y >= Viewport.Height)
                 {
                 {
-                    ScrollTo (_model.Count + BottomOffset);
+                    ScrollTo (_model.Count);
                 }
                 }
                 else if (ev.Position.Y < 0 && _topRow > 0)
                 else if (ev.Position.Y < 0 && _topRow > 0)
                 {
                 {
                     ScrollTo (0);
                     ScrollTo (0);
                 }
                 }
 
 
-                if (CurrentColumn - _leftColumn + RightOffset >= Frame.Width - 1 && line.Count + RightOffset > _leftColumn + CurrentColumn)
+                if (CurrentColumn - _leftColumn >= Viewport.Width - 1 && line.Count > _leftColumn + CurrentColumn)
                 {
                 {
-                    ScrollTo (_leftColumn + Frame.Width, false);
+                    ScrollTo (_leftColumn + Viewport.Width, false);
                 }
                 }
                 else if (_leftColumn > 0 && CurrentColumn <= _leftColumn)
                 else if (_leftColumn > 0 && CurrentColumn <= _leftColumn)
                 {
                 {
-                    ScrollTo (_leftColumn - Frame.Width, false);
+                    ScrollTo (_leftColumn - Viewport.Width, false);
                 }
                 }
-                else if (ev.Position.X >= Frame.Width)
+                else if (ev.Position.X >= Viewport.Width)
                 {
                 {
-                    ScrollTo (line.Count + RightOffset, false);
+                    ScrollTo (line.Count, false);
                 }
                 }
                 else if (ev.Position.X < 0 && _leftColumn > 0)
                 else if (ev.Position.X < 0 && _leftColumn > 0)
                 {
                 {
@@ -3585,8 +3547,8 @@ public class TextView : View
         SetNormalColor ();
         SetNormalColor ();
 
 
         (int width, int height) offB = OffSetBackground ();
         (int width, int height) offB = OffSetBackground ();
-        int right = Frame.Width + offB.width + RightOffset;
-        int bottom = Frame.Height + offB.height + BottomOffset;
+        int right = Viewport.Width + offB.width;
+        int bottom = Viewport.Height + offB.height;
         var row = 0;
         var row = 0;
 
 
         for (int idxRow = _topRow; idxRow < _model.Count; idxRow++)
         for (int idxRow = _topRow; idxRow < _model.Count; idxRow++)
@@ -3826,9 +3788,9 @@ public class TextView : View
         if (Application.MouseGrabView == this && Selecting)
         if (Application.MouseGrabView == this && Selecting)
         {
         {
             // BUGBUG: customized rect aren't supported now because the Redraw isn't using the Intersect method.
             // BUGBUG: customized rect aren't supported now because the Redraw isn't using the Intersect method.
-            //var minRow = Math.Min (Math.Max (Math.Min (selectionStartRow, currentRow) - topRow, 0), Frame.Height);
-            //var maxRow = Math.Min (Math.Max (Math.Max (selectionStartRow, currentRow) - topRow, 0), Frame.Height);
-            //SetNeedsDisplay (new (0, minRow, Frame.Width, maxRow));
+            //var minRow = Math.Min (Math.Max (Math.Min (selectionStartRow, currentRow) - topRow, 0), Viewport.Height);
+            //var maxRow = Math.Min (Math.Max (Math.Max (selectionStartRow, currentRow) - topRow, 0), Viewport.Height);
+            //SetNeedsDisplay (new (0, minRow, Viewport.Width, maxRow));
             SetNeedsDisplay ();
             SetNeedsDisplay ();
         }
         }
 
 
@@ -3851,7 +3813,7 @@ public class TextView : View
                     cols += TabWidth + 1;
                     cols += TabWidth + 1;
                 }
                 }
 
 
-                if (!TextModel.SetCol (ref col, Frame.Width, cols))
+                if (!TextModel.SetCol (ref col, Viewport.Width, cols))
                 {
                 {
                     col = CurrentColumn;
                     col = CurrentColumn;
 
 
@@ -3863,7 +3825,7 @@ public class TextView : View
         int posX = CurrentColumn - _leftColumn;
         int posX = CurrentColumn - _leftColumn;
         int posY = CurrentRow - _topRow;
         int posY = CurrentRow - _topRow;
 
 
-        if (posX > -1 && col >= posX && posX < Frame.Width - RightOffset && _topRow <= CurrentRow && posY < Frame.Height - BottomOffset)
+        if (posX > -1 && col >= posX && posX < Viewport.Width && _topRow <= CurrentRow && posY < Viewport.Height)
         {
         {
             Move (col, CurrentRow - _topRow);
             Move (col, CurrentRow - _topRow);
             return new (col, CurrentRow - _topRow);
             return new (col, CurrentRow - _topRow);
@@ -3934,7 +3896,7 @@ public class TextView : View
         else if (!_wordWrap)
         else if (!_wordWrap)
         {
         {
             int maxlength =
             int maxlength =
-                _model.GetMaxVisibleLine (_topRow, _topRow + Frame.Height + RightOffset, TabWidth);
+                _model.GetMaxVisibleLine (_topRow, _topRow + Viewport.Height, TabWidth);
             _leftColumn = Math.Max (!_wordWrap && idx > maxlength - 1 ? maxlength - 1 : idx, 0);
             _leftColumn = Math.Max (!_wordWrap && idx > maxlength - 1 ? maxlength - 1 : idx, 0);
         }
         }
 
 
@@ -4113,18 +4075,18 @@ public class TextView : View
             need = true;
             need = true;
         }
         }
         else if (!_wordWrap
         else if (!_wordWrap
-                 && (CurrentColumn - _leftColumn + RightOffset > Frame.Width + offB.width || dSize.size + RightOffset >= Frame.Width + offB.width))
+                 && (CurrentColumn - _leftColumn + 1 > Viewport.Width + offB.width || dSize.size + 1 >= Viewport.Width + offB.width))
         {
         {
             _leftColumn = TextModel.CalculateLeftColumn (
             _leftColumn = TextModel.CalculateLeftColumn (
                                                          line,
                                                          line,
                                                          _leftColumn,
                                                          _leftColumn,
                                                          CurrentColumn,
                                                          CurrentColumn,
-                                                         Frame.Width + offB.width - RightOffset,
+                                                         Viewport.Width + offB.width,
                                                          TabWidth
                                                          TabWidth
                                                         );
                                                         );
             need = true;
             need = true;
         }
         }
-        else if ((_wordWrap && _leftColumn > 0) || (dSize.size + RightOffset < Frame.Width + offB.width && tSize.size + RightOffset < Frame.Width + offB.width))
+        else if ((_wordWrap && _leftColumn > 0) || (dSize.size < Viewport.Width + offB.width && tSize.size < Viewport.Width + offB.width))
         {
         {
             if (_leftColumn > 0)
             if (_leftColumn > 0)
             {
             {
@@ -4138,9 +4100,9 @@ public class TextView : View
             _topRow = CurrentRow;
             _topRow = CurrentRow;
             need = true;
             need = true;
         }
         }
-        else if (CurrentRow - _topRow + BottomOffset >= Frame.Height + offB.height)
+        else if (CurrentRow - _topRow >= Viewport.Height + offB.height)
         {
         {
-            _topRow = Math.Min (Math.Max (CurrentRow - Frame.Height + 1 + BottomOffset, 0), CurrentRow);
+            _topRow = Math.Min (Math.Max (CurrentRow - Viewport.Height + 1, 0), CurrentRow);
             need = true;
             need = true;
         }
         }
         else if (_topRow > 0 && CurrentRow < _topRow)
         else if (_topRow > 0 && CurrentRow < _topRow)
@@ -4285,7 +4247,7 @@ public class TextView : View
             {
             {
                 //QUESTION: Is the below comment still relevant?
                 //QUESTION: Is the below comment still relevant?
                 // BUGBUG: customized rect aren't supported now because the Redraw isn't using the Intersect method.
                 // BUGBUG: customized rect aren't supported now because the Redraw isn't using the Intersect method.
-                //SetNeedsDisplay (new (0, startRow - topRow, Frame.Width, startRow - topRow + 1));
+                //SetNeedsDisplay (new (0, startRow - topRow, Viewport.Width, startRow - topRow + 1));
                 SetNeedsDisplay ();
                 SetNeedsDisplay ();
             }
             }
 
 
@@ -4381,7 +4343,7 @@ public class TextView : View
             else
             else
             {
             {
                 // BUGBUG: customized rect aren't supported now because the Redraw isn't using the Intersect method.
                 // BUGBUG: customized rect aren't supported now because the Redraw isn't using the Intersect method.
-                //SetNeedsDisplay (new (0, currentRow - topRow, 1, Frame.Width));
+                //SetNeedsDisplay (new (0, currentRow - topRow, 1, Viewport.Width));
                 SetNeedsDisplay ();
                 SetNeedsDisplay ();
             }
             }
         }
         }
@@ -4473,7 +4435,7 @@ public class TextView : View
                 _wrapNeeded = true;
                 _wrapNeeded = true;
             }
             }
 
 
-            DoSetNeedsDisplay (new (0, CurrentRow - _topRow, Frame.Width, CurrentRow - _topRow + 1));
+            DoSetNeedsDisplay (new (0, CurrentRow - _topRow, Viewport.Width, CurrentRow - _topRow + 1));
         }
         }
         else
         else
         {
         {
@@ -4496,8 +4458,8 @@ public class TextView : View
                                new (
                                new (
                                     CurrentColumn - _leftColumn,
                                     CurrentColumn - _leftColumn,
                                     CurrentRow - _topRow,
                                     CurrentRow - _topRow,
-                                    Frame.Width,
-                                    CurrentRow - _topRow + 1
+                                    Viewport.Width,
+                                    Math.Max (CurrentRow - _topRow + 1, 0)
                                    )
                                    )
                               );
                               );
         }
         }
@@ -4791,7 +4753,7 @@ public class TextView : View
         if (!_wrapNeeded)
         if (!_wrapNeeded)
         {
         {
             // BUGBUG: customized rect aren't supported now because the Redraw isn't using the Intersect method.
             // BUGBUG: customized rect aren't supported now because the Redraw isn't using the Intersect method.
-            //SetNeedsDisplay (new (0, prow, Math.Max (Frame.Width, 0), Math.Max (prow + 1, 0)));
+            //SetNeedsDisplay (new (0, prow, Math.Max (Viewport.Width, 0), Math.Max (prow + 1, 0)));
             SetNeedsDisplay ();
             SetNeedsDisplay ();
         }
         }
     }
     }
@@ -4828,9 +4790,9 @@ public class TextView : View
                               HistoryText.LineStatus.Replaced
                               HistoryText.LineStatus.Replaced
                              );
                              );
 
 
-            if (!_wordWrap && CurrentColumn - _leftColumn > Frame.Width)
+            if (!_wordWrap && CurrentColumn - _leftColumn > Viewport.Width)
             {
             {
-                _leftColumn = Math.Max (CurrentColumn - Frame.Width + 1, 0);
+                _leftColumn = Math.Max (CurrentColumn - Viewport.Width + 1, 0);
             }
             }
 
 
             if (_wordWrap)
             if (_wordWrap)
@@ -4840,7 +4802,7 @@ public class TextView : View
             else
             else
             {
             {
                 // BUGBUG: customized rect aren't supported now because the Redraw isn't using the Intersect method.
                 // BUGBUG: customized rect aren't supported now because the Redraw isn't using the Intersect method.
-                //SetNeedsDisplay (new (0, currentRow - topRow, Frame.Width, Math.Max (currentRow - topRow + 1, 0)));
+                //SetNeedsDisplay (new (0, currentRow - topRow, Viewport.Width, Math.Max (currentRow - topRow + 1, 0)));
                 SetNeedsDisplay ();
                 SetNeedsDisplay ();
             }
             }
 
 
@@ -4936,7 +4898,7 @@ public class TextView : View
                 Insert (new () { Rune = a.AsRune, ColorScheme = colorScheme });
                 Insert (new () { Rune = a.AsRune, ColorScheme = colorScheme });
                 CurrentColumn++;
                 CurrentColumn++;
 
 
-                if (CurrentColumn >= _leftColumn + Frame.Width)
+                if (CurrentColumn >= _leftColumn + Viewport.Width)
                 {
                 {
                     _leftColumn++;
                     _leftColumn++;
                     SetNeedsDisplay ();
                     SetNeedsDisplay ();
@@ -5054,7 +5016,7 @@ public class TextView : View
 
 
         UpdateWrapModel ();
         UpdateWrapModel ();
 
 
-        DoSetNeedsDisplay (new (0, CurrentRow - _topRow, Frame.Width, Frame.Height));
+        DoSetNeedsDisplay (new (0, CurrentRow - _topRow, Viewport.Width, Viewport.Height));
 
 
         _lastWasKill = setLastWasKill;
         _lastWasKill = setLastWasKill;
         DoNeededAction ();
         DoNeededAction ();
@@ -5161,7 +5123,7 @@ public class TextView : View
 
 
         UpdateWrapModel ();
         UpdateWrapModel ();
 
 
-        DoSetNeedsDisplay (new (0, CurrentRow - _topRow, Frame.Width, Frame.Height));
+        DoSetNeedsDisplay (new (0, CurrentRow - _topRow, Viewport.Width, Viewport.Height));
 
 
         _lastWasKill = setLastWasKill;
         _lastWasKill = setLastWasKill;
         DoNeededAction ();
         DoNeededAction ();
@@ -5231,7 +5193,7 @@ public class TextView : View
 
 
         UpdateWrapModel ();
         UpdateWrapModel ();
 
 
-        DoSetNeedsDisplay (new (0, CurrentRow - _topRow, Frame.Width, Frame.Height));
+        DoSetNeedsDisplay (new (0, CurrentRow - _topRow, Viewport.Width, Viewport.Height));
         DoNeededAction ();
         DoNeededAction ();
     }
     }
 
 
@@ -5290,7 +5252,7 @@ public class TextView : View
 
 
         UpdateWrapModel ();
         UpdateWrapModel ();
 
 
-        DoSetNeedsDisplay (new (0, CurrentRow - _topRow, Frame.Width, Frame.Height));
+        DoSetNeedsDisplay (new (0, CurrentRow - _topRow, Viewport.Width, Viewport.Height));
         DoNeededAction ();
         DoNeededAction ();
     }
     }
 
 
@@ -5306,7 +5268,7 @@ public class TextView : View
         if (!_multiline && !IsInitialized)
         if (!_multiline && !IsInitialized)
         {
         {
             CurrentColumn = Text.GetRuneCount ();
             CurrentColumn = Text.GetRuneCount ();
-            _leftColumn = CurrentColumn > Frame.Width + 1 ? CurrentColumn - Frame.Width + 1 : 0;
+            _leftColumn = CurrentColumn > Viewport.Width + 1 ? CurrentColumn - Viewport.Width + 1 : 0;
         }
         }
     }
     }
 
 
@@ -5340,7 +5302,7 @@ public class TextView : View
 
 
             CurrentRow++;
             CurrentRow++;
 
 
-            if (CurrentRow + BottomOffset >= _topRow + Frame.Height)
+            if (CurrentRow >= _topRow + Viewport.Height)
             {
             {
                 _topRow++;
                 _topRow++;
                 SetNeedsDisplay ();
                 SetNeedsDisplay ();
@@ -5349,7 +5311,7 @@ public class TextView : View
             TrackColumn ();
             TrackColumn ();
             PositionCursor ();
             PositionCursor ();
         }
         }
-        else if (CurrentRow > Frame.Height)
+        else if (CurrentRow > Viewport.Height)
         {
         {
             Adjust ();
             Adjust ();
         }
         }
@@ -5360,7 +5322,7 @@ public class TextView : View
     private void MoveEndOfLine ()
     private void MoveEndOfLine ()
     {
     {
         List<RuneCell> currentLine = GetCurrentLine ();
         List<RuneCell> currentLine = GetCurrentLine ();
-        CurrentColumn = currentLine.Count;
+        CurrentColumn = Math.Max (currentLine.Count - (ReadOnly ? 1 : 0), 0);
         Adjust ();
         Adjust ();
         DoNeededAction ();
         DoNeededAction ();
     }
     }
@@ -5384,7 +5346,7 @@ public class TextView : View
                 }
                 }
 
 
                 List<RuneCell> currentLine = GetCurrentLine ();
                 List<RuneCell> currentLine = GetCurrentLine ();
-                CurrentColumn = currentLine.Count;
+                CurrentColumn = Math.Max (currentLine.Count - (ReadOnly ? 1 : 0), 0);
             }
             }
         }
         }
 
 
@@ -5404,7 +5366,7 @@ public class TextView : View
 
 
     private void MovePageDown ()
     private void MovePageDown ()
     {
     {
-        int nPageDnShift = Frame.Height - 1;
+        int nPageDnShift = Viewport.Height - 1;
 
 
         if (CurrentRow >= 0 && CurrentRow < _model.Count)
         if (CurrentRow >= 0 && CurrentRow < _model.Count)
         {
         {
@@ -5434,7 +5396,7 @@ public class TextView : View
 
 
     private void MovePageUp ()
     private void MovePageUp ()
     {
     {
-        int nPageUpShift = Frame.Height - 1;
+        int nPageUpShift = Viewport.Height - 1;
 
 
         if (CurrentRow > 0)
         if (CurrentRow > 0)
         {
         {
@@ -5472,7 +5434,7 @@ public class TextView : View
     {
     {
         List<RuneCell> currentLine = GetCurrentLine ();
         List<RuneCell> currentLine = GetCurrentLine ();
 
 
-        if (CurrentColumn < currentLine.Count)
+        if ((ReadOnly ? CurrentColumn + 1 : CurrentColumn) < currentLine.Count)
         {
         {
             CurrentColumn++;
             CurrentColumn++;
         }
         }
@@ -5483,7 +5445,7 @@ public class TextView : View
                 CurrentRow++;
                 CurrentRow++;
                 CurrentColumn = 0;
                 CurrentColumn = 0;
 
 
-                if (CurrentRow >= _topRow + Frame.Height)
+                if (CurrentRow >= _topRow + Viewport.Height)
                 {
                 {
                     _topRow++;
                     _topRow++;
                     SetNeedsDisplay ();
                     SetNeedsDisplay ();
@@ -5584,14 +5546,14 @@ public class TextView : View
         var w = 0;
         var w = 0;
         var h = 0;
         var h = 0;
 
 
-        if (SuperView?.Frame.Right - Frame.Right < 0)
+        if (SuperView?.Viewport.Right - Viewport.Right < 0)
         {
         {
-            w = SuperView!.Frame.Right - Frame.Right - 1;
+            w = SuperView!.Viewport.Right - Viewport.Right - 1;
         }
         }
 
 
-        if (SuperView?.Frame.Bottom - Frame.Bottom < 0)
+        if (SuperView?.Viewport.Bottom - Viewport.Bottom < 0)
         {
         {
-            h = SuperView!.Frame.Bottom - Frame.Bottom - 1;
+            h = SuperView!.Viewport.Bottom - Viewport.Bottom - 1;
         }
         }
 
 
         return (w, h);
         return (w, h);
@@ -5838,9 +5800,9 @@ public class TextView : View
             r = GetCurrentLine ();
             r = GetCurrentLine ();
             int idx = TextModel.GetColFromX (r, _leftColumn, Math.Max (ev.Position.X, 0), TabWidth);
             int idx = TextModel.GetColFromX (r, _leftColumn, Math.Max (ev.Position.X, 0), TabWidth);
 
 
-            if (idx - _leftColumn >= r.Count + RightOffset)
+            if (idx - _leftColumn >= r.Count)
             {
             {
-                CurrentColumn = Math.Max (r.Count - _leftColumn + RightOffset, 0);
+                CurrentColumn = Math.Max (r.Count - _leftColumn - (ReadOnly ? 1 : 0), 0);
             }
             }
             else
             else
             {
             {
@@ -6126,7 +6088,7 @@ public class TextView : View
 
 
         var fullNeedsDisplay = false;
         var fullNeedsDisplay = false;
 
 
-        if (CurrentRow >= _topRow + Frame.Height)
+        if (CurrentRow >= _topRow + Viewport.Height)
         {
         {
             _topRow++;
             _topRow++;
             fullNeedsDisplay = true;
             fullNeedsDisplay = true;
@@ -6153,7 +6115,7 @@ public class TextView : View
         else
         else
         {
         {
             // BUGBUG: customized rect aren't supported now because the Redraw isn't using the Intersect method.
             // BUGBUG: customized rect aren't supported now because the Redraw isn't using the Intersect method.
-            //SetNeedsDisplay (new (0, currentRow - topRow, 2, Frame.Height));
+            //SetNeedsDisplay (new (0, currentRow - topRow, 2, Viewport.Height));
             SetNeedsDisplay ();
             SetNeedsDisplay ();
         }
         }
 
 
@@ -6484,7 +6446,7 @@ public class TextView : View
         if (_wordWrap && _wrapManager is { })
         if (_wordWrap && _wrapManager is { })
         {
         {
             _model = _wrapManager.WrapModel (
             _model = _wrapManager.WrapModel (
-                                             _frameWidth,
+                                             Math.Max (Viewport.Width - (ReadOnly ? 0 : 1), 0), // For the cursor on the last column of a line
                                              out int nRow,
                                              out int nRow,
                                              out int nCol,
                                              out int nCol,
                                              out int nStartRow,
                                              out int nStartRow,

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

@@ -21,7 +21,7 @@ public class TimeField : TextField
     private bool _isShort;
     private bool _isShort;
     private TimeSpan _time;
     private TimeSpan _time;
 
 
-    /// <summary>Initializes a new instance of <see cref="TimeField"/> using <see cref="LayoutStyle.Computed"/> positioning.</summary>
+    /// <summary>Initializes a new instance of <see cref="TimeField"/>.</summary>
     public TimeField ()
     public TimeField ()
     {
     {
         CultureInfo cultureInfo = CultureInfo.CurrentCulture;
         CultureInfo cultureInfo = CultureInfo.CurrentCulture;

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

@@ -23,7 +23,7 @@ namespace Terminal.Gui;
 public partial class Toplevel : View
 public partial class Toplevel : View
 {
 {
     /// <summary>
     /// <summary>
-    ///     Initializes a new instance of the <see cref="Toplevel"/> class with <see cref="LayoutStyle.Computed"/> layout,
+    ///     Initializes a new instance of the <see cref="Toplevel"/> class,
     ///     defaulting to full screen. The <see cref="View.Width"/> and <see cref="View.Height"/> properties will be set to the
     ///     defaulting to full screen. The <see cref="View.Width"/> and <see cref="View.Height"/> properties will be set to the
     ///     dimensions of the terminal using <see cref="Dim.Fill"/>.
     ///     dimensions of the terminal using <see cref="Dim.Fill"/>.
     /// </summary>
     /// </summary>
@@ -397,9 +397,7 @@ public partial class Toplevel : View
         }
         }
 
 
         if ((superView != top || top?.SuperView is { } || (top != Application.Top && top.Modal) || (top?.SuperView is null && top.IsOverlapped))
         if ((superView != top || top?.SuperView is { } || (top != Application.Top && top.Modal) || (top?.SuperView is null && top.IsOverlapped))
-
-            // BUGBUG: Prevously PositionToplevel required LayotuStyle.Computed
-            && (top.Frame.X + top.Frame.Width > maxWidth || ny > top.Frame.Y) /*&& top.LayoutStyle == LayoutStyle.Computed*/)
+            && (top.Frame.X + top.Frame.Width > maxWidth || ny > top.Frame.Y))
         {
         {
             if ((top.X is null || top.X is PosAbsolute) && top.Frame.X != nx)
             if ((top.X is null || top.X is PosAbsolute) && top.Frame.X != nx)
             {
             {

+ 1 - 2
Terminal.Gui/Views/Window.cs

@@ -15,8 +15,7 @@ namespace Terminal.Gui;
 public class Window : Toplevel
 public class Window : Toplevel
 {
 {
     /// <summary>
     /// <summary>
-    ///     Initializes a new instance of the <see cref="Window"/> class using <see cref="LayoutStyle.Computed"/>
-    ///     positioning.
+    ///     Initializes a new instance of the <see cref="Window"/> class.
     /// </summary>
     /// </summary>
     public Window ()
     public Window ()
     {
     {

+ 1 - 2
Terminal.Gui/Views/Wizard/Wizard.cs

@@ -57,8 +57,7 @@ public class Wizard : Dialog
     private string _wizardTitle = string.Empty;
     private string _wizardTitle = string.Empty;
 
 
     /// <summary>
     /// <summary>
-    ///     Initializes a new instance of the <see cref="Wizard"/> class using <see cref="LayoutStyle.Computed"/>
-    ///     positioning.
+    ///     Initializes a new instance of the <see cref="Wizard"/> class.
     /// </summary>
     /// </summary>
     /// <remarks>
     /// <remarks>
     ///     The Wizard will be vertically and horizontally centered in the container. After initialization use <c>X</c>,
     ///     The Wizard will be vertically and horizontally centered in the container. After initialization use <c>X</c>,

+ 1 - 2
Terminal.Gui/Views/Wizard/WizardStep.cs

@@ -40,8 +40,7 @@ public class WizardStep : FrameView
     private readonly TextView _helpTextView = new ();
     private readonly TextView _helpTextView = new ();
 
 
     /// <summary>
     /// <summary>
-    ///     Initializes a new instance of the <see cref="Wizard"/> class using <see cref="LayoutStyle.Computed"/>
-    ///     positioning.
+    ///     Initializes a new instance of the <see cref="Wizard"/> class.
     /// </summary>
     /// </summary>
     public WizardStep ()
     public WizardStep ()
     {
     {

+ 3 - 2
UICatalog/Scenarios/ASCIICustomButton.cs

@@ -235,6 +235,7 @@ public class ASCIICustomButtonTest : Scenario
                 pages++;
                 pages++;
             }
             }
 
 
+            // BUGBUG: set_ContentSize is supposed to be `protected`. 
             _scrollView.SetContentSize (new (25, pages * BUTTONS_ON_PAGE * BUTTON_HEIGHT));
             _scrollView.SetContentSize (new (25, pages * BUTTONS_ON_PAGE * BUTTON_HEIGHT));
 
 
             if (_smallerWindow)
             if (_smallerWindow)
@@ -269,7 +270,7 @@ public class ASCIICustomButtonTest : Scenario
                 case KeyCode.End:
                 case KeyCode.End:
                     _scrollView.ContentOffset = new Point (
                     _scrollView.ContentOffset = new Point (
                                                            _scrollView.ContentOffset.X,
                                                            _scrollView.ContentOffset.X,
-                                                           -(_scrollView.ContentSize.Height
+                                                           -(_scrollView.GetContentSize ().Height
                                                              - _scrollView.Frame.Height
                                                              - _scrollView.Frame.Height
                                                              + (_scrollView.ShowHorizontalScrollIndicator ? 1 : 0))
                                                              + (_scrollView.ShowHorizontalScrollIndicator ? 1 : 0))
                                                           );
                                                           );
@@ -287,7 +288,7 @@ public class ASCIICustomButtonTest : Scenario
                                                            Math.Max (
                                                            Math.Max (
                                                                      _scrollView.ContentOffset.Y
                                                                      _scrollView.ContentOffset.Y
                                                                      - _scrollView.Frame.Height,
                                                                      - _scrollView.Frame.Height,
-                                                                     -(_scrollView.ContentSize.Height
+                                                                     -(_scrollView.GetContentSize ().Height
                                                                        - _scrollView.Frame.Height
                                                                        - _scrollView.Frame.Height
                                                                        + (_scrollView.ShowHorizontalScrollIndicator
                                                                        + (_scrollView.ShowHorizontalScrollIndicator
                                                                               ? 1
                                                                               ? 1

+ 0 - 4
UICatalog/Scenarios/AllViewsTester.cs

@@ -417,12 +417,8 @@ public class AllViewsTester : Scenario
             return;
             return;
         }
         }
 
 
-        LayoutStyle layout = view.LayoutStyle;
-
         try
         try
         {
         {
-            //view.LayoutStyle = LayoutStyle.Absolute;
-
             view.X = _xRadioGroup.SelectedItem switch
             view.X = _xRadioGroup.SelectedItem switch
                      {
                      {
                          0 => Pos.Percent (_xVal),
                          0 => Pos.Percent (_xVal),

+ 2 - 1
UICatalog/Scenarios/Clipping.cs

@@ -23,12 +23,13 @@ public class Clipping : Scenario
         //Win.Height = Dim.Fill () - 2;
         //Win.Height = Dim.Fill () - 2;
         var label = new Label
         var label = new Label
         {
         {
-            X = 0, Y = 0, Text = "ScrollView (new Rectangle (3, 3, 50, 20)) with a 200, 100 ContentSize..."
+            X = 0, Y = 0, Text = "ScrollView (new Rectangle (3, 3, 50, 20)) with a 200, 100 GetContentSize ()..."
         };
         };
         Top.Add (label);
         Top.Add (label);
 
 
         var scrollView = new ScrollView { X = 3, Y = 3, Width = 50, Height = 20 };
         var scrollView = new ScrollView { X = 3, Y = 3, Width = 50, Height = 20 };
         scrollView.ColorScheme = Colors.ColorSchemes ["Menu"];
         scrollView.ColorScheme = Colors.ColorSchemes ["Menu"];
+        // BUGBUG: set_ContentSize is supposed to be `protected`. 
         scrollView.SetContentSize (new (200, 100));
         scrollView.SetContentSize (new (200, 100));
 
 
         //ContentOffset = Point.Empty,
         //ContentOffset = Point.Empty,

+ 12 - 11
UICatalog/Scenarios/ContentScrolling.cs

@@ -1,10 +1,11 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 using Terminal.Gui;
 using Terminal.Gui;
 
 
 namespace UICatalog.Scenarios;
 namespace UICatalog.Scenarios;
 
 
-[ScenarioMetadata ("Content Scrolling", "Demonstrates using View.Viewport and View.ContentSize to scroll content.")]
+[ScenarioMetadata ("Content Scrolling", "Demonstrates using View.Viewport and View.GetContentSize () to scroll content.")]
 [ScenarioCategory ("Layout")]
 [ScenarioCategory ("Layout")]
 [ScenarioCategory ("Drawing")]
 [ScenarioCategory ("Drawing")]
 [ScenarioCategory ("Scrolling")]
 [ScenarioCategory ("Scrolling")]
@@ -86,7 +87,7 @@ public class ContentScrolling : Scenario
 
 
             if (status is { })
             if (status is { })
             {
             {
-                status.Title = $"Frame: {Frame}\n\nViewport: {Viewport}, ContentSize = {ContentSize}";
+                status.Title = $"Frame: {Frame}\n\nViewport: {Viewport}, ContentSize = {GetContentSize ()}";
                 status.Width = Border.Frame.Width - status.Frame.X - Border.Thickness.Right;
                 status.Width = Border.Frame.Width - status.Frame.X - Border.Thickness.Right;
                 status.Height = Border.Thickness.Top;
                 status.Height = Border.Thickness.Top;
             }
             }
@@ -230,7 +231,7 @@ public class ContentScrolling : Scenario
 
 
         Buttons.NumericUpDown<int> contentSizeWidth = new Buttons.NumericUpDown<int>
         Buttons.NumericUpDown<int> contentSizeWidth = new Buttons.NumericUpDown<int>
         {
         {
-            Value = view.ContentSize.Width,
+            Value = view.GetContentSize ().Width,
             X = Pos.Right (labelContentSize) + 1,
             X = Pos.Right (labelContentSize) + 1,
             Y = Pos.Top (labelContentSize)
             Y = Pos.Top (labelContentSize)
         };
         };
@@ -244,8 +245,8 @@ public class ContentScrolling : Scenario
 
 
                 return;
                 return;
             }
             }
-
-            view.SetContentSize (view.ContentSize with { Width = e.NewValue });
+            // BUGBUG: set_ContentSize is supposed to be `protected`. 
+            view.SetContentSize (view.GetContentSize () with { Width = e.NewValue });
         }
         }
 
 
         var labelComma = new Label
         var labelComma = new Label
@@ -257,7 +258,7 @@ public class ContentScrolling : Scenario
 
 
         Buttons.NumericUpDown<int> contentSizeHeight = new Buttons.NumericUpDown<int>
         Buttons.NumericUpDown<int> contentSizeHeight = new Buttons.NumericUpDown<int>
         {
         {
-            Value = view.ContentSize.Height,
+            Value = view.GetContentSize ().Height,
             X = Pos.Right (labelComma) + 1,
             X = Pos.Right (labelComma) + 1,
             Y = Pos.Top (labelContentSize),
             Y = Pos.Top (labelContentSize),
             CanFocus = false
             CanFocus = false
@@ -272,8 +273,8 @@ public class ContentScrolling : Scenario
 
 
                 return;
                 return;
             }
             }
-
-            view.SetContentSize (view.ContentSize with { Height = e.NewValue });
+            // BUGBUG: set_ContentSize is supposed to be `protected`. 
+            view.SetContentSize (view.GetContentSize () with { Height = e.NewValue });
         }
         }
 
 
         var cbClearOnlyVisible = new CheckBox
         var cbClearOnlyVisible = new CheckBox
@@ -355,8 +356,8 @@ public class ContentScrolling : Scenario
         {
         {
             X = Pos.Center (),
             X = Pos.Center (),
             Y = Pos.Bottom (textView) + 1,
             Y = Pos.Bottom (textView) + 1,
-            Width = Dim.Auto(DimAutoStyle.Content, maximumContentDim: Dim.Func (() => view.ContentSize.Width)),
-            Height = Dim.Auto (DimAutoStyle.Content, maximumContentDim: Dim.Percent(20)),
+            Width = Dim.Auto (DimAutoStyle.Content, maximumContentDim: Dim.Func (() => view.GetContentSize ().Width)),
+            Height = Dim.Auto (DimAutoStyle.Content, maximumContentDim: Dim.Percent (20)),
         };
         };
 
 
         charMap.Accept += (s, e) =>
         charMap.Accept += (s, e) =>

+ 1 - 32
UICatalog/Scenarios/Editor.cs

@@ -60,9 +60,7 @@ public class Editor : Scenario
             X = 0,
             X = 0,
             Y = 0,
             Y = 0,
             Width = Dim.Fill (),
             Width = Dim.Fill (),
-            Height = Dim.Fill (),
-            BottomOffset = 1,
-            RightOffset = 1
+            Height = Dim.Fill ()
         };
         };
 
 
         CreateDemoFile (_fileName);
         CreateDemoFile (_fileName);
@@ -297,30 +295,6 @@ public class Editor : Scenario
                                                              _textView.SetNeedsDisplay ();
                                                              _textView.SetNeedsDisplay ();
                                                          };
                                                          };
 
 
-        _scrollBar.VisibleChanged += (s, e) =>
-                                     {
-                                         if (_scrollBar.Visible && _textView.RightOffset == 0)
-                                         {
-                                             _textView.RightOffset = 1;
-                                         }
-                                         else if (!_scrollBar.Visible && _textView.RightOffset == 1)
-                                         {
-                                             _textView.RightOffset = 0;
-                                         }
-                                     };
-
-        _scrollBar.OtherScrollBarView.VisibleChanged += (s, e) =>
-                                                        {
-                                                            if (_scrollBar.OtherScrollBarView.Visible && _textView.BottomOffset == 0)
-                                                            {
-                                                                _textView.BottomOffset = 1;
-                                                            }
-                                                            else if (!_scrollBar.OtherScrollBarView.Visible && _textView.BottomOffset == 1)
-                                                            {
-                                                                _textView.BottomOffset = 0;
-                                                            }
-                                                        };
-
         _textView.DrawContent += (s, e) =>
         _textView.DrawContent += (s, e) =>
                                  {
                                  {
                                      _scrollBar.Size = _textView.Lines;
                                      _scrollBar.Size = _textView.Lines;
@@ -834,11 +808,6 @@ public class Editor : Scenario
                            if (_textView.WordWrap)
                            if (_textView.WordWrap)
                            {
                            {
                                _scrollBar.OtherScrollBarView.ShowScrollIndicator = false;
                                _scrollBar.OtherScrollBarView.ShowScrollIndicator = false;
-                               _textView.BottomOffset = 0;
-                           }
-                           else
-                           {
-                               _textView.BottomOffset = 1;
                            }
                            }
                        };
                        };
 
 

+ 2 - 1
UICatalog/Scenarios/Scrolling.cs

@@ -44,10 +44,11 @@ public class Scrolling : Scenario
             ShowVerticalScrollIndicator = true,
             ShowVerticalScrollIndicator = true,
             ShowHorizontalScrollIndicator = true
             ShowHorizontalScrollIndicator = true
         };
         };
+        // BUGBUG: set_ContentSize is supposed to be `protected`. 
         scrollView.SetContentSize (new (120, 40));
         scrollView.SetContentSize (new (120, 40));
         scrollView.Padding.Thickness = new (1);
         scrollView.Padding.Thickness = new (1);
 
 
-        label.Text = $"{scrollView}\nContentSize: {scrollView.ContentSize}\nContentOffset: {scrollView.ContentOffset}";
+        label.Text = $"{scrollView}\nContentSize: {scrollView.GetContentSize ()}\nContentOffset: {scrollView.ContentOffset}";
 
 
         const string rule = "0123456789";
         const string rule = "0123456789";
 
 

+ 0 - 12
UICatalog/Scenarios/Wizards.cs

@@ -296,18 +296,6 @@ public class Wizards : Scenario
                                                                             someText.SetNeedsDisplay ();
                                                                             someText.SetNeedsDisplay ();
                                                                         };
                                                                         };
 
 
-                                           scrollBar.VisibleChanged += (s, e) =>
-                                                                       {
-                                                                           if (scrollBar.Visible && someText.RightOffset == 0)
-                                                                           {
-                                                                               someText.RightOffset = 1;
-                                                                           }
-                                                                           else if (!scrollBar.Visible && someText.RightOffset == 1)
-                                                                           {
-                                                                               someText.RightOffset = 0;
-                                                                           }
-                                                                       };
-
                                            someText.DrawContent += (s, e) =>
                                            someText.DrawContent += (s, e) =>
                                                                    {
                                                                    {
                                                                        scrollBar.Size = someText.Lines;
                                                                        scrollBar.Size = someText.Lines;

+ 4 - 4
UnitTests/Application/ApplicationTests.cs

@@ -40,10 +40,12 @@ public class ApplicationTests
     public void Begin_Sets_Application_Top_To_Console_Size ()
     public void Begin_Sets_Application_Top_To_Console_Size ()
     {
     {
         Assert.Null (Application.Top);
         Assert.Null (Application.Top);
-        Application.Begin (new ());
+        Toplevel top = new ();
+        Application.Begin (top);
         Assert.Equal (new (0, 0, 80, 25), Application.Top.Frame);
         Assert.Equal (new (0, 0, 80, 25), Application.Top.Frame);
         ((FakeDriver)Application.Driver).SetBufferSize (5, 5);
         ((FakeDriver)Application.Driver).SetBufferSize (5, 5);
         Assert.Equal (new (0, 0, 5, 5), Application.Top.Frame);
         Assert.Equal (new (0, 0, 5, 5), Application.Top.Frame);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -265,8 +267,6 @@ public class ApplicationTests
     {
     {
         Application.Init (new FakeDriver ());
         Application.Init (new FakeDriver ());
 
 
-        Toplevel topLevel = null;
-
         Assert.Throws<InvalidOperationException> (
         Assert.Throws<InvalidOperationException> (
                                                   () =>
                                                   () =>
                                                       Application.InternalInit (
                                                       Application.InternalInit (
@@ -280,7 +280,6 @@ public class ApplicationTests
         Assert.Null (Application.Driver);
         Assert.Null (Application.Driver);
 
 
         // Now try the other way
         // Now try the other way
-        topLevel = null;
         Application.InternalInit (new FakeDriver ());
         Application.InternalInit (new FakeDriver ());
 
 
         Assert.Throws<InvalidOperationException> (() => Application.Init (new FakeDriver ()));
         Assert.Throws<InvalidOperationException> (() => Application.Init (new FakeDriver ()));
@@ -347,6 +346,7 @@ public class ApplicationTests
         Assert.Null (Application.MouseGrabView); // public
         Assert.Null (Application.MouseGrabView); // public
         Assert.Null (Application.WantContinuousButtonPressedView); // public
         Assert.Null (Application.WantContinuousButtonPressedView); // public
         Assert.False (Application.MoveToOverlappedChild (Application.Top));
         Assert.False (Application.MoveToOverlappedChild (Application.Top));
+        Application.Top.Dispose ();
     }
     }
 
 
     // Invoke Tests
     // Invoke Tests

+ 5 - 0
UnitTests/Application/KeyboardTests.cs

@@ -172,6 +172,7 @@ public class KeyboardTests
         Assert.True (win2.CanFocus);
         Assert.True (win2.CanFocus);
         Assert.True (win2.HasFocus);
         Assert.True (win2.HasFocus);
         Assert.Equal ("win2", ((Window)top.Subviews [^1]).Title);
         Assert.Equal ("win2", ((Window)top.Subviews [^1]).Title);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -224,6 +225,7 @@ public class KeyboardTests
         Assert.True (win2.CanFocus);
         Assert.True (win2.CanFocus);
         Assert.False (win2.HasFocus);
         Assert.False (win2.HasFocus);
         Assert.Equal ("win", ((Window)top.Subviews [^1]).Title);
         Assert.Equal ("win", ((Window)top.Subviews [^1]).Title);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -358,6 +360,7 @@ public class KeyboardTests
         Assert.True (view.ApplicationCommand);
         Assert.True (view.ApplicationCommand);
         Assert.True (view.HotKeyCommand);
         Assert.True (view.HotKeyCommand);
         Assert.False (view.FocusedCommand);
         Assert.False (view.FocusedCommand);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -385,6 +388,7 @@ public class KeyboardTests
         Assert.False (view.ApplicationCommand);
         Assert.False (view.ApplicationCommand);
         Assert.False (view.HotKeyCommand);
         Assert.False (view.HotKeyCommand);
         Assert.False (view.FocusedCommand);
         Assert.False (view.FocusedCommand);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -423,6 +427,7 @@ public class KeyboardTests
 
 
         // Reset the QuitKey to avoid throws errors on another tests
         // Reset the QuitKey to avoid throws errors on another tests
         Application.QuitKey = Key.Q.WithCtrl;
         Application.QuitKey = Key.Q.WithCtrl;
+        top.Dispose ();
     }
     }
 
 
     // test Application key Bindings
     // test Application key Bindings

+ 2 - 0
UnitTests/Application/MainLoopTests.cs

@@ -640,6 +640,7 @@ public class MainLoopTests
         await task; // Propagate exception if any occurred
         await task; // Propagate exception if any occurred
 
 
         Assert.Equal (numIncrements * numPasses, tbCounter);
         Assert.Equal (numIncrements * numPasses, tbCounter);
+        top.Dispose ();
     }
     }
 
 
     [Theory]
     [Theory]
@@ -714,6 +715,7 @@ public class MainLoopTests
                                  };
                                  };
 
 
         Application.Run (top);
         Application.Run (top);
+        top.Dispose ();
 
 
         Assert.True (taskCompleted);
         Assert.True (taskCompleted);
         Assert.Equal (clickMe, btn.Text);
         Assert.Equal (clickMe, btn.Text);

+ 4 - 0
UnitTests/Application/MouseTests.cs

@@ -130,6 +130,7 @@ public class MouseTests
 
 
         Application.OnMouseEvent (mouseEvent);
         Application.OnMouseEvent (mouseEvent);
         Assert.Equal (expectedClicked, clicked);
         Assert.Equal (expectedClicked, clicked);
+        top.Dispose ();
     }
     }
 
 
     /// <summary>
     /// <summary>
@@ -224,6 +225,7 @@ public class MouseTests
 
 
         Application.OnMouseEvent (mouseEvent);
         Application.OnMouseEvent (mouseEvent);
         Assert.Equal (expectedClicked, clicked);
         Assert.Equal (expectedClicked, clicked);
+        top.Dispose ();
     }
     }
 
 
     #endregion mouse coordinate tests
     #endregion mouse coordinate tests
@@ -290,6 +292,7 @@ public class MouseTests
                                  };
                                  };
 
 
         Application.Run (top);
         Application.Run (top);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -396,6 +399,7 @@ public class MouseTests
         Application.OnMouseEvent (new () { Position = new (0, 0), Flags = MouseFlags.Button1Pressed });
         Application.OnMouseEvent (new () { Position = new (0, 0), Flags = MouseFlags.Button1Pressed });
         Assert.Null (Application.MouseGrabView);
         Assert.Null (Application.MouseGrabView);
         Assert.Equal (0, count);
         Assert.Equal (0, count);
+        top.Dispose ();
     }
     }
     #endregion
     #endregion
 }
 }

+ 10 - 1
UnitTests/Dialogs/DialogTests.cs

@@ -906,8 +906,10 @@ public class DialogTests
                                         };
                                         };
 
 
                           Run (dlg);
                           Run (dlg);
+                          dlg.Dispose ();
                       };
                       };
         Run (win);
         Run (win);
+        win.Dispose ();
     }
     }
 
 
     [Theory]
     [Theory]
@@ -988,6 +990,7 @@ public class DialogTests
                                  Height = Dim.Percent (85)
                                  Height = Dim.Percent (85)
                              };
                              };
                              Run (dlg);
                              Run (dlg);
+                             dlg.Dispose ();
                          }
                          }
                          else if (iterations == 1)
                          else if (iterations == 1)
                          {
                          {
@@ -1001,6 +1004,7 @@ public class DialogTests
                      };
                      };
 
 
         Run (win);
         Run (win);
+        win.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -1134,6 +1138,7 @@ public class DialogTests
         // Default location is centered, so 100 / 2 - 85 / 2 = 7
         // Default location is centered, so 100 / 2 - 85 / 2 = 7
         var expected = 7;
         var expected = 7;
         Assert.Equal (new (expected, expected), d.Frame.Location);
         Assert.Equal (new (expected, expected), d.Frame.Location);
+        d.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -1147,6 +1152,7 @@ public class DialogTests
         // Default location is centered, so 100 / 2 - 85 / 2 = 7
         // Default location is centered, so 100 / 2 - 85 / 2 = 7
         var expected = 1;
         var expected = 1;
         Assert.Equal (new (expected, expected), d.Frame.Location);
         Assert.Equal (new (expected, expected), d.Frame.Location);
+        d.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -1170,6 +1176,7 @@ public class DialogTests
      └───┘",
      └───┘",
                                                       _output
                                                       _output
                                                      );
                                                      );
+        d.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -1263,6 +1270,7 @@ public class DialogTests
 
 
         ((FakeDriver)Driver).SetBufferSize (20, 10);
         ((FakeDriver)Driver).SetBufferSize (20, 10);
         Run (top);
         Run (top);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -1282,7 +1290,7 @@ public class DialogTests
         int width = buttonRow.Length;
         int width = buttonRow.Length;
         d.SetBufferSize (buttonRow.Length, 10);
         d.SetBufferSize (buttonRow.Length, 10);
 
 
-        (runstate, Dialog _) = RunButtonTestDialog (
+        (runstate, Dialog dlg) = RunButtonTestDialog (
                                                     title,
                                                     title,
                                                     width,
                                                     width,
                                                     Alignment.Center,
                                                     Alignment.Center,
@@ -1290,6 +1298,7 @@ public class DialogTests
                                                    );
                                                    );
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         End (runstate);
+        dlg.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]

+ 32 - 41
UnitTests/Dialogs/WizardTests.cs

@@ -2,21 +2,16 @@
 
 
 namespace Terminal.Gui.DialogTests;
 namespace Terminal.Gui.DialogTests;
 
 
-public class WizardTests
+public class WizardTests ()
 {
 {
-    private readonly ITestOutputHelper _output;
-    public WizardTests (ITestOutputHelper output) { _output = output; }
-
     // =========== Wizard Tests
     // =========== Wizard Tests
     [Fact]
     [Fact]
-    [AutoInitShutdown]
     public void DefaultConstructor_SizedProperly ()
     public void DefaultConstructor_SizedProperly ()
     {
     {
-        var d = (FakeDriver)Application.Driver;
-
         var wizard = new Wizard ();
         var wizard = new Wizard ();
         Assert.NotEqual (0, wizard.Width);
         Assert.NotEqual (0, wizard.Width);
         Assert.NotEqual (0, wizard.Height);
         Assert.NotEqual (0, wizard.Height);
+        wizard.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -47,9 +42,9 @@ public class WizardTests
         wizard.Dispose ();
         wizard.Dispose ();
 
 
         // Same test, but with two steps
         // Same test, but with two steps
-        wizard = new Wizard ();
+        wizard = new ();
         firstIteration = false;
         firstIteration = false;
-        step1 = new WizardStep { Title = "step1" };
+        step1 = new() { Title = "step1" };
         wizard.AddStep (step1);
         wizard.AddStep (step1);
         var step2 = new WizardStep { Title = "step2" };
         var step2 = new WizardStep { Title = "step2" };
         wizard.AddStep (step2);
         wizard.AddStep (step2);
@@ -80,11 +75,11 @@ public class WizardTests
         wizard.Dispose ();
         wizard.Dispose ();
 
 
         // Same test, but with two steps but the 1st one disabled
         // Same test, but with two steps but the 1st one disabled
-        wizard = new Wizard ();
+        wizard = new ();
         firstIteration = false;
         firstIteration = false;
-        step1 = new WizardStep { Title = "step1" };
+        step1 = new() { Title = "step1" };
         wizard.AddStep (step1);
         wizard.AddStep (step1);
-        step2 = new WizardStep { Title = "step2" };
+        step2 = new() { Title = "step2" };
         wizard.AddStep (step2);
         wizard.AddStep (step2);
         step1.Enabled = false;
         step1.Enabled = false;
 
 
@@ -103,10 +98,10 @@ public class WizardTests
         Application.End (runstate);
         Application.End (runstate);
         Assert.True (finishedFired);
         Assert.True (finishedFired);
         Assert.True (closedFired);
         Assert.True (closedFired);
+        wizard.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown]
     public void Navigate_GetFirstStep_Works ()
     public void Navigate_GetFirstStep_Works ()
     {
     {
         var wizard = new Wizard ();
         var wizard = new Wizard ();
@@ -134,10 +129,10 @@ public class WizardTests
         step1.Enabled = false;
         step1.Enabled = false;
         step2.Enabled = false;
         step2.Enabled = false;
         Assert.Equal (step3.Title, wizard.GetFirstStep ().Title);
         Assert.Equal (step3.Title, wizard.GetFirstStep ().Title);
+        wizard.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown]
     public void Navigate_GetLastStep_Works ()
     public void Navigate_GetLastStep_Works ()
     {
     {
         var wizard = new Wizard ();
         var wizard = new Wizard ();
@@ -165,6 +160,7 @@ public class WizardTests
         step3.Enabled = false;
         step3.Enabled = false;
         step2.Enabled = false;
         step2.Enabled = false;
         Assert.Equal (step1.Title, wizard.GetLastStep ().Title);
         Assert.Equal (step1.Title, wizard.GetLastStep ().Title);
+        wizard.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -263,6 +259,7 @@ public class WizardTests
         step2.Enabled = false;
         step2.Enabled = false;
         step3.Enabled = false;
         step3.Enabled = false;
         Assert.Equal (step1.Title, wizard.GetNextStep ().Title);
         Assert.Equal (step1.Title, wizard.GetNextStep ().Title);
+        wizard.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -356,10 +353,10 @@ public class WizardTests
         step2.Enabled = false;
         step2.Enabled = false;
         step3.Enabled = false;
         step3.Enabled = false;
         Assert.Equal (step1.Title, wizard.GetPreviousStep ().Title);
         Assert.Equal (step1.Title, wizard.GetPreviousStep ().Title);
+        wizard.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown]
     public void Navigate_GoBack_Works ()
     public void Navigate_GoBack_Works ()
     {
     {
         // If zero steps do nothing
         // If zero steps do nothing
@@ -374,7 +371,6 @@ public class WizardTests
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown]
     public void Navigate_GoNext_Works ()
     public void Navigate_GoNext_Works ()
     {
     {
         // If zero steps do nothing
         // If zero steps do nothing
@@ -429,16 +425,16 @@ public class WizardTests
             } - {
             } - {
                 stepTitle
                 stepTitle
             }╞{
             }╞{
-                new string (CM.Glyphs.HLineDbl.ToString () [0], width - title.Length - stepTitle.Length - 7)
+                new (CM.Glyphs.HLineDbl.ToString () [0], width - title.Length - stepTitle.Length - 7)
             }{
             }{
                 CM.Glyphs.URCornerDbl
                 CM.Glyphs.URCornerDbl
             }";
             }";
-        var row2 = $"{CM.Glyphs.VLineDbl}{new string (' ', width - 2)}{CM.Glyphs.VLineDbl}";
+        var row2 = $"{CM.Glyphs.VLineDbl}{new (' ', width - 2)}{CM.Glyphs.VLineDbl}";
         string row3 = row2;
         string row3 = row2;
         string row4 = row3;
         string row4 = row3;
 
 
         var separatorRow =
         var separatorRow =
-            $"{CM.Glyphs.VLineDbl}{new string (CM.Glyphs.HLine.ToString () [0], width - 2)}{CM.Glyphs.VLineDbl}";
+            $"{CM.Glyphs.VLineDbl}{new (CM.Glyphs.HLine.ToString () [0], width - 2)}{CM.Glyphs.VLineDbl}";
 
 
         var buttonRow =
         var buttonRow =
             $"{
             $"{
@@ -446,7 +442,7 @@ public class WizardTests
             }{
             }{
                 btnBack
                 btnBack
             }{
             }{
-                new string (' ', width - btnBack.Length - btnNext.Length - 2)
+                new (' ', width - btnBack.Length - btnNext.Length - 2)
             }{
             }{
                 btnNext
                 btnNext
             }{
             }{
@@ -457,13 +453,13 @@ public class WizardTests
             $"{
             $"{
                 CM.Glyphs.LLCornerDbl
                 CM.Glyphs.LLCornerDbl
             }{
             }{
-                new string (CM.Glyphs.HLineDbl.ToString () [0], width - 2)
+                new (CM.Glyphs.HLineDbl.ToString () [0], width - 2)
             }{
             }{
                 CM.Glyphs.LRCornerDbl
                 CM.Glyphs.LRCornerDbl
             }";
             }";
 
 
         var wizard = new Wizard { Title = title, Width = width, Height = height };
         var wizard = new Wizard { Title = title, Width = width, Height = height };
-        wizard.AddStep (new WizardStep { Title = stepTitle });
+        wizard.AddStep (new() { Title = stepTitle });
 
 
         //wizard.LayoutSubviews ();
         //wizard.LayoutSubviews ();
         var firstIteration = false;
         var firstIteration = false;
@@ -476,6 +472,7 @@ public class WizardTests
         //                                              _output
         //                                              _output
         //                                             );
         //                                             );
         Application.End (runstate);
         Application.End (runstate);
+        wizard.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -516,36 +513,36 @@ public class WizardTests
             }{
             }{
                 stepTitle
                 stepTitle
             }╞{
             }╞{
-                new string (CM.Glyphs.HLineDbl.ToString () [0], width - title.Length - stepTitle.Length - 4)
+                new (CM.Glyphs.HLineDbl.ToString () [0], width - title.Length - stepTitle.Length - 4)
             }{
             }{
                 CM.Glyphs.URCornerDbl
                 CM.Glyphs.URCornerDbl
             }";
             }";
 
 
         var separatorRow =
         var separatorRow =
-            $"{CM.Glyphs.VLineDbl}{new string (CM.Glyphs.HLine.ToString () [0], width - 2)}{CM.Glyphs.VLineDbl}";
+            $"{CM.Glyphs.VLineDbl}{new (CM.Glyphs.HLine.ToString () [0], width - 2)}{CM.Glyphs.VLineDbl}";
 
 
         // Once this is fixed, revert to commented out line: https://github.com/gui-cs/Terminal.Gui/issues/1791
         // Once this is fixed, revert to commented out line: https://github.com/gui-cs/Terminal.Gui/issues/1791
         var buttonRow =
         var buttonRow =
-            $"{CM.Glyphs.VLineDbl}{new string (' ', width - btnNext.Length - 2)}{btnNext}{CM.Glyphs.VLineDbl}";
+            $"{CM.Glyphs.VLineDbl}{new (' ', width - btnNext.Length - 2)}{btnNext}{CM.Glyphs.VLineDbl}";
 
 
         //var buttonRow = $"{CM.Glyphs.VDLine}{new String (' ', width - btnNext.Length - 2)}{btnNext}{CM.Glyphs.VDLine}";
         //var buttonRow = $"{CM.Glyphs.VDLine}{new String (' ', width - btnNext.Length - 2)}{btnNext}{CM.Glyphs.VDLine}";
         var bottomRow =
         var bottomRow =
             $"{
             $"{
                 CM.Glyphs.LLCornerDbl
                 CM.Glyphs.LLCornerDbl
             }{
             }{
-                new string (CM.Glyphs.HLineDbl.ToString () [0], width - 2)
+                new (CM.Glyphs.HLineDbl.ToString () [0], width - 2)
             }{
             }{
                 CM.Glyphs.LRCornerDbl
                 CM.Glyphs.LRCornerDbl
             }";
             }";
 
 
         var wizard = new Wizard { Title = title, Width = width, Height = height };
         var wizard = new Wizard { Title = title, Width = width, Height = height };
-        wizard.AddStep (new WizardStep { Title = "ABCD" });
+        wizard.AddStep (new() { Title = "ABCD" });
 
 
         Application.End (Application.Begin (wizard));
         Application.End (Application.Begin (wizard));
+        wizard.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown]
 
 
     // This test verifies that the 2nd step in a wizard with more than 2 steps 
     // This test verifies that the 2nd step in a wizard with more than 2 steps 
     // shows the correct buttons on all steps
     // shows the correct buttons on all steps
@@ -564,7 +561,6 @@ public class WizardTests
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown]
 
 
     // This test verifies that the 2nd step in a wizard with 2 steps 
     // This test verifies that the 2nd step in a wizard with 2 steps 
     // shows the correct buttons on both steps
     // shows the correct buttons on both steps
@@ -585,7 +581,6 @@ public class WizardTests
     // =========== WizardStep Tests
     // =========== WizardStep Tests
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown]
     public void WizardStep_ButtonText ()
     public void WizardStep_ButtonText ()
     {
     {
         // Verify default button text
         // Verify default button text
@@ -684,15 +679,15 @@ public class WizardTests
             }{
             }{
                 stepTitle
                 stepTitle
             }╞{
             }╞{
-                new string (CM.Glyphs.HLineDbl.ToString () [0], width - title.Length - stepTitle.Length - 4)
+                new (CM.Glyphs.HLineDbl.ToString () [0], width - title.Length - stepTitle.Length - 4)
             }{
             }{
                 CM.Glyphs.URCornerDbl
                 CM.Glyphs.URCornerDbl
             }";
             }";
-        var row2 = $"{CM.Glyphs.VLineDbl}{new string (' ', width - 2)}{CM.Glyphs.VLineDbl}";
+        var row2 = $"{CM.Glyphs.VLineDbl}{new (' ', width - 2)}{CM.Glyphs.VLineDbl}";
         string row3 = row2;
         string row3 = row2;
 
 
         var separatorRow =
         var separatorRow =
-            $"{CM.Glyphs.VLineDbl}{new string (CM.Glyphs.HLine.ToString () [0], width - 2)}{CM.Glyphs.VLineDbl}";
+            $"{CM.Glyphs.VLineDbl}{new (CM.Glyphs.HLine.ToString () [0], width - 2)}{CM.Glyphs.VLineDbl}";
 
 
         var buttonRow =
         var buttonRow =
             $"{
             $"{
@@ -700,7 +695,7 @@ public class WizardTests
             }{
             }{
                 btnBack
                 btnBack
             }{
             }{
-                new string (' ', width - btnBack.Length - btnNext.Length - 2)
+                new (' ', width - btnBack.Length - btnNext.Length - 2)
             }{
             }{
                 btnNext
                 btnNext
             }{
             }{
@@ -711,24 +706,20 @@ public class WizardTests
             $"{
             $"{
                 CM.Glyphs.LLCornerDbl
                 CM.Glyphs.LLCornerDbl
             }{
             }{
-                new string (CM.Glyphs.HLineDbl.ToString () [0], width - 2)
+                new (CM.Glyphs.HLineDbl.ToString () [0], width - 2)
             }{
             }{
                 CM.Glyphs.LRCornerDbl
                 CM.Glyphs.LRCornerDbl
             }";
             }";
 
 
         var wizard = new Wizard { Title = title, Width = width, Height = height };
         var wizard = new Wizard { Title = title, Width = width, Height = height };
         RunState runstate = Application.Begin (wizard);
         RunState runstate = Application.Begin (wizard);
+
         // TODO: Disabled until Dim.Auto is used in Dialog
         // TODO: Disabled until Dim.Auto is used in Dialog
         //TestHelpers.AssertDriverContentsWithFrameAre (
         //TestHelpers.AssertDriverContentsWithFrameAre (
         //                                              $"{topRow}\n{row2}\n{row3}\n{separatorRow}\n{buttonRow}\n{bottomRow}",
         //                                              $"{topRow}\n{row2}\n{row3}\n{separatorRow}\n{buttonRow}\n{bottomRow}",
         //                                              _output
         //                                              _output
         //                                             );
         //                                             );
         Application.End (runstate);
         Application.End (runstate);
-    }
-
-    private void RunButtonTestWizard (string title, int width, int height)
-    {
-        var wizard = new Wizard { Title = title, Width = width, Height = height };
-        Application.End (Application.Begin (wizard));
+        wizard.Dispose ();
     }
     }
 }
 }

+ 0 - 6
UnitTests/Drawing/AttributeTests.cs

@@ -12,7 +12,6 @@ public class AttributeTests
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown]
     public void ColorAndColorNamesConstructor ()
     public void ColorAndColorNamesConstructor ()
     {
     {
         // Arrange & Act
         // Arrange & Act
@@ -26,7 +25,6 @@ public class AttributeTests
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown]
     public void ColorConstructor ()
     public void ColorConstructor ()
     {
     {
         // Arrange & Act
         // Arrange & Act
@@ -143,11 +141,8 @@ public class AttributeTests
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown]
     public void Equals_Initialized ()
     public void Equals_Initialized ()
     {
     {
-        Assert.NotNull (Application.Driver);
-
         var attr1 = new Attribute (Color.Red, Color.Green);
         var attr1 = new Attribute (Color.Red, Color.Green);
         var attr2 = new Attribute (Color.Red, Color.Green);
         var attr2 = new Attribute (Color.Red, Color.Green);
 
 
@@ -324,7 +319,6 @@ public class AttributeTests
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown]
     public void NotEquals_Initialized ()
     public void NotEquals_Initialized ()
     {
     {
         var attr1 = new Attribute (Color.Red, Color.Green);
         var attr1 = new Attribute (Color.Red, Color.Green);

+ 3 - 3
UnitTests/Drawing/ColorTests.ParsingAndFormatting.cs

@@ -84,7 +84,7 @@ public partial class ColorTests
                 )]
                 )]
     public void TryParse_string_Returns_False_For_Invalid_Inputs (string? input)
     public void TryParse_string_Returns_False_For_Invalid_Inputs (string? input)
     {
     {
-        bool tryParseStatus = Color.TryParse (input, out Color? color);
+        bool tryParseStatus = Color.TryParse (input ?? string.Empty, out Color? color);
         Assert.False (tryParseStatus);
         Assert.False (tryParseStatus);
         Assert.Null (color);
         Assert.Null (color);
     }
     }
@@ -94,9 +94,9 @@ public partial class ColorTests
                     nameof (ColorTestsTheoryDataGenerators.TryParse_string_Returns_True_For_Valid_Inputs),
                     nameof (ColorTestsTheoryDataGenerators.TryParse_string_Returns_True_For_Valid_Inputs),
                     MemberType = typeof (ColorTestsTheoryDataGenerators)
                     MemberType = typeof (ColorTestsTheoryDataGenerators)
                 )]
                 )]
-    public void TryParse_string_Returns_True_For_Valid_Inputs (string input, int expectedColorArgb)
+    public void TryParse_string_Returns_True_For_Valid_Inputs (string? input, int expectedColorArgb)
     {
     {
-        bool tryParseStatus = Color.TryParse (input, out Color? color);
+        bool tryParseStatus = Color.TryParse (input ?? string.Empty, out Color? color);
         Assert.True (tryParseStatus);
         Assert.True (tryParseStatus);
         Assert.NotNull (color);
         Assert.NotNull (color);
         Assert.IsType<Color> (color);
         Assert.IsType<Color> (color);

+ 121 - 114
UnitTests/Drawing/LineCanvasTests.cs

@@ -3,13 +3,9 @@ using Xunit.Abstractions;
 
 
 namespace Terminal.Gui.DrawingTests;
 namespace Terminal.Gui.DrawingTests;
 
 
-public class LineCanvasTests
+public class LineCanvasTests (ITestOutputHelper output)
 {
 {
-    private readonly ITestOutputHelper output;
-    public LineCanvasTests (ITestOutputHelper output) { this.output = output; }
-
     [Theory]
     [Theory]
-    [AutoInitShutdown]
 
 
     // Horizontal lines with a vertical zero-length
     // Horizontal lines with a vertical zero-length
     [InlineData (
     [InlineData (
@@ -293,12 +289,13 @@ public class LineCanvasTests
         View v = GetCanvas (out LineCanvas lc);
         View v = GetCanvas (out LineCanvas lc);
         v.Width = 10;
         v.Width = 10;
         v.Height = 10;
         v.Height = 10;
-        v.Viewport = new Rectangle (0, 0, 10, 10);
+        v.Viewport = new (0, 0, 10, 10);
 
 
-        lc.AddLine (new Point (x1, y1), len1, o1, s1);
-        lc.AddLine (new Point (x2, y2), len2, o2, s2);
+        lc.AddLine (new (x1, y1), len1, o1, s1);
+        lc.AddLine (new (x2, y2), len2, o2, s2);
 
 
         TestHelpers.AssertEqual (output, expected, lc.ToString ());
         TestHelpers.AssertEqual (output, expected, lc.ToString ());
+        v.Dispose ();
     }
     }
 
 
     [InlineData (
     [InlineData (
@@ -377,10 +374,10 @@ public class LineCanvasTests
     )
     )
     {
     {
         var canvas = new LineCanvas ();
         var canvas = new LineCanvas ();
-        canvas.AddLine (new Point (x, y), length, Orientation.Horizontal, LineStyle.Single);
-        canvas.AddLine (new Point (x, y), length, Orientation.Vertical, LineStyle.Single);
+        canvas.AddLine (new (x, y), length, Orientation.Horizontal, LineStyle.Single);
+        canvas.AddLine (new (x, y), length, Orientation.Vertical, LineStyle.Single);
 
 
-        Assert.Equal (new Rectangle (expectedX, expectedY, expectedWidth, expectedHeight), canvas.Viewport);
+        Assert.Equal (new (expectedX, expectedY, expectedWidth, expectedHeight), canvas.Viewport);
     }
     }
 
 
     [InlineData (
     [InlineData (
@@ -459,9 +456,9 @@ public class LineCanvasTests
     )
     )
     {
     {
         var canvas = new LineCanvas ();
         var canvas = new LineCanvas ();
-        canvas.AddLine (new Point (x, y), length, Orientation.Horizontal, LineStyle.Single);
+        canvas.AddLine (new (x, y), length, Orientation.Horizontal, LineStyle.Single);
 
 
-        Assert.Equal (new Rectangle (expectedX, expectedY, expectedWidth, expectedHeight), canvas.Viewport);
+        Assert.Equal (new (expectedX, expectedY, expectedWidth, expectedHeight), canvas.Viewport);
     }
     }
 
 
     [Fact]
     [Fact]
@@ -482,28 +479,28 @@ public class LineCanvasTests
         // ║  ║2
         // ║  ║2
 
 
         // Add a short horiz line for ╔╡
         // Add a short horiz line for ╔╡
-        lc.AddLine (new Point (x, y), 2, Orientation.Horizontal, LineStyle.Double);
-        Assert.Equal (new Rectangle (x, y, 2, 1), lc.Viewport);
+        lc.AddLine (new (x, y), 2, Orientation.Horizontal, LineStyle.Double);
+        Assert.Equal (new (x, y, 2, 1), lc.Viewport);
 
 
         //LHS line down
         //LHS line down
-        lc.AddLine (new Point (x, y), height, Orientation.Vertical, LineStyle.Double);
-        Assert.Equal (new Rectangle (x, y, 2, 2), lc.Viewport);
+        lc.AddLine (new (x, y), height, Orientation.Vertical, LineStyle.Double);
+        Assert.Equal (new (x, y, 2, 2), lc.Viewport);
 
 
         //Vertical line before Title, results in a ╡
         //Vertical line before Title, results in a ╡
-        lc.AddLine (new Point (x + 1, y), 0, Orientation.Vertical, LineStyle.Single);
-        Assert.Equal (new Rectangle (x, y, 2, 2), lc.Viewport);
+        lc.AddLine (new (x + 1, y), 0, Orientation.Vertical, LineStyle.Single);
+        Assert.Equal (new (x, y, 2, 2), lc.Viewport);
 
 
         //Vertical line after Title, results in a ╞
         //Vertical line after Title, results in a ╞
-        lc.AddLine (new Point (x + 2, y), 0, Orientation.Vertical, LineStyle.Single);
-        Assert.Equal (new Rectangle (x, y, 3, 2), lc.Viewport);
+        lc.AddLine (new (x + 2, y), 0, Orientation.Vertical, LineStyle.Single);
+        Assert.Equal (new (x, y, 3, 2), lc.Viewport);
 
 
         // remainder of top line
         // remainder of top line
-        lc.AddLine (new Point (x + 2, y), width - 1, Orientation.Horizontal, LineStyle.Double);
-        Assert.Equal (new Rectangle (x, y, 4, 2), lc.Viewport);
+        lc.AddLine (new (x + 2, y), width - 1, Orientation.Horizontal, LineStyle.Double);
+        Assert.Equal (new (x, y, 4, 2), lc.Viewport);
 
 
         //RHS line down
         //RHS line down
-        lc.AddLine (new Point (x + width, y), height, Orientation.Vertical, LineStyle.Double);
-        Assert.Equal (new Rectangle (x, y, 4, 2), lc.Viewport);
+        lc.AddLine (new (x + width, y), height, Orientation.Vertical, LineStyle.Double);
+        Assert.Equal (new (x, y, 4, 2), lc.Viewport);
 
 
         TestHelpers.AssertEqual (
         TestHelpers.AssertEqual (
                                  output,
                                  output,
@@ -532,28 +529,28 @@ public class LineCanvasTests
         // ║  ║2
         // ║  ║2
 
 
         // Add a short horiz line for ╔╡
         // Add a short horiz line for ╔╡
-        lc.AddLine (new Point (x, y), 2, Orientation.Horizontal, LineStyle.Double);
-        Assert.Equal (new Rectangle (x, y, 2, 1), lc.Viewport);
+        lc.AddLine (new (x, y), 2, Orientation.Horizontal, LineStyle.Double);
+        Assert.Equal (new (x, y, 2, 1), lc.Viewport);
 
 
         //LHS line down
         //LHS line down
-        lc.AddLine (new Point (x, y), height, Orientation.Vertical, LineStyle.Double);
-        Assert.Equal (new Rectangle (x, y, 2, 2), lc.Viewport);
+        lc.AddLine (new (x, y), height, Orientation.Vertical, LineStyle.Double);
+        Assert.Equal (new (x, y, 2, 2), lc.Viewport);
 
 
         //Vertical line before Title, results in a ╡
         //Vertical line before Title, results in a ╡
-        lc.AddLine (new Point (x + 1, y), 0, Orientation.Vertical, LineStyle.Single);
-        Assert.Equal (new Rectangle (x, y, 2, 2), lc.Viewport);
+        lc.AddLine (new (x + 1, y), 0, Orientation.Vertical, LineStyle.Single);
+        Assert.Equal (new (x, y, 2, 2), lc.Viewport);
 
 
         //Vertical line after Title, results in a ╞
         //Vertical line after Title, results in a ╞
-        lc.AddLine (new Point (x + 2, y), 0, Orientation.Vertical, LineStyle.Single);
-        Assert.Equal (new Rectangle (x, y, 3, 2), lc.Viewport);
+        lc.AddLine (new (x + 2, y), 0, Orientation.Vertical, LineStyle.Single);
+        Assert.Equal (new (x, y, 3, 2), lc.Viewport);
 
 
         // remainder of top line
         // remainder of top line
-        lc.AddLine (new Point (x + 2, y), width - 1, Orientation.Horizontal, LineStyle.Double);
-        Assert.Equal (new Rectangle (x, y, 4, 2), lc.Viewport);
+        lc.AddLine (new (x + 2, y), width - 1, Orientation.Horizontal, LineStyle.Double);
+        Assert.Equal (new (x, y, 4, 2), lc.Viewport);
 
 
         //RHS line down
         //RHS line down
-        lc.AddLine (new Point (x + width, y), height, Orientation.Vertical, LineStyle.Double);
-        Assert.Equal (new Rectangle (x, y, 4, 2), lc.Viewport);
+        lc.AddLine (new (x + width, y), height, Orientation.Vertical, LineStyle.Double);
+        Assert.Equal (new (x, y, 4, 2), lc.Viewport);
 
 
         TestHelpers.AssertEqual (
         TestHelpers.AssertEqual (
                                  output,
                                  output,
@@ -598,7 +595,7 @@ public class LineCanvasTests
         var canvas = new LineCanvas ();
         var canvas = new LineCanvas ();
 
 
         // Add a line at 5, 5 that's has length of 1
         // Add a line at 5, 5 that's has length of 1
-        canvas.AddLine (new Point (x, y), 1, orientation, LineStyle.Single);
+        canvas.AddLine (new (x, y), 1, orientation, LineStyle.Single);
         TestHelpers.AssertEqual (output, $"{expected}", $"{canvas}");
         TestHelpers.AssertEqual (output, $"{expected}", $"{canvas}");
     }
     }
 
 
@@ -653,7 +650,7 @@ public class LineCanvasTests
     public void Length_n_Is_n_Long (int x, int y, int length, Orientation orientation, string expected)
     public void Length_n_Is_n_Long (int x, int y, int length, Orientation orientation, string expected)
     {
     {
         var canvas = new LineCanvas ();
         var canvas = new LineCanvas ();
-        canvas.AddLine (new Point (x, y), length, orientation, LineStyle.Single);
+        canvas.AddLine (new (x, y), length, orientation, LineStyle.Single);
 
 
         var result = canvas.ToString ();
         var result = canvas.ToString ();
         TestHelpers.AssertEqual (output, expected, result);
         TestHelpers.AssertEqual (output, expected, result);
@@ -731,7 +728,6 @@ public class LineCanvasTests
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown]
     public void TestLineCanvas_LeaveMargin_Top1_Left1 ()
     public void TestLineCanvas_LeaveMargin_Top1_Left1 ()
     {
     {
         var canvas = new LineCanvas ();
         var canvas = new LineCanvas ();
@@ -748,19 +744,19 @@ public class LineCanvasTests
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown]
+    [SetupFakeDriver]
     public void TestLineCanvas_Window_Heavy ()
     public void TestLineCanvas_Window_Heavy ()
     {
     {
         View v = GetCanvas (out LineCanvas canvas);
         View v = GetCanvas (out LineCanvas canvas);
 
 
         // outer box
         // outer box
         canvas.AddLine (Point.Empty, 10, Orientation.Horizontal, LineStyle.Heavy);
         canvas.AddLine (Point.Empty, 10, Orientation.Horizontal, LineStyle.Heavy);
-        canvas.AddLine (new Point (9, 0), 5, Orientation.Vertical, LineStyle.Heavy);
-        canvas.AddLine (new Point (9, 4), -10, Orientation.Horizontal, LineStyle.Heavy);
-        canvas.AddLine (new Point (0, 4), -5, Orientation.Vertical, LineStyle.Heavy);
+        canvas.AddLine (new (9, 0), 5, Orientation.Vertical, LineStyle.Heavy);
+        canvas.AddLine (new (9, 4), -10, Orientation.Horizontal, LineStyle.Heavy);
+        canvas.AddLine (new (0, 4), -5, Orientation.Vertical, LineStyle.Heavy);
 
 
-        canvas.AddLine (new Point (5, 0), 5, Orientation.Vertical, LineStyle.Heavy);
-        canvas.AddLine (new Point (0, 2), 10, Orientation.Horizontal, LineStyle.Heavy);
+        canvas.AddLine (new (5, 0), 5, Orientation.Vertical, LineStyle.Heavy);
+        canvas.AddLine (new (0, 2), 10, Orientation.Horizontal, LineStyle.Heavy);
 
 
         v.Draw ();
         v.Draw ();
 
 
@@ -772,10 +768,11 @@ public class LineCanvasTests
 ┃    ┃   ┃
 ┃    ┃   ┃
 ┗━━━━┻━━━┛";
 ┗━━━━┻━━━┛";
         TestHelpers.AssertDriverContentsAre (looksLike, output);
         TestHelpers.AssertDriverContentsAre (looksLike, output);
+        v.Dispose ();
     }
     }
 
 
     [Theory]
     [Theory]
-    [AutoInitShutdown]
+    [SetupFakeDriver]
     [InlineData (LineStyle.Single)]
     [InlineData (LineStyle.Single)]
     [InlineData (LineStyle.Rounded)]
     [InlineData (LineStyle.Rounded)]
     public void TestLineCanvas_Window_HeavyTop_ThinSides (LineStyle thinStyle)
     public void TestLineCanvas_Window_HeavyTop_ThinSides (LineStyle thinStyle)
@@ -784,12 +781,12 @@ public class LineCanvasTests
 
 
         // outer box
         // outer box
         canvas.AddLine (Point.Empty, 10, Orientation.Horizontal, LineStyle.Heavy);
         canvas.AddLine (Point.Empty, 10, Orientation.Horizontal, LineStyle.Heavy);
-        canvas.AddLine (new Point (9, 0), 5, Orientation.Vertical, thinStyle);
-        canvas.AddLine (new Point (9, 4), -10, Orientation.Horizontal, LineStyle.Heavy);
-        canvas.AddLine (new Point (0, 4), -5, Orientation.Vertical, thinStyle);
+        canvas.AddLine (new (9, 0), 5, Orientation.Vertical, thinStyle);
+        canvas.AddLine (new (9, 4), -10, Orientation.Horizontal, LineStyle.Heavy);
+        canvas.AddLine (new (0, 4), -5, Orientation.Vertical, thinStyle);
 
 
-        canvas.AddLine (new Point (5, 0), 5, Orientation.Vertical, thinStyle);
-        canvas.AddLine (new Point (0, 2), 10, Orientation.Horizontal, LineStyle.Heavy);
+        canvas.AddLine (new (5, 0), 5, Orientation.Vertical, thinStyle);
+        canvas.AddLine (new (0, 2), 10, Orientation.Horizontal, LineStyle.Heavy);
 
 
         v.Draw ();
         v.Draw ();
 
 
@@ -802,10 +799,11 @@ public class LineCanvasTests
 ┕━━━━┷━━━┙
 ┕━━━━┷━━━┙
 ";
 ";
         TestHelpers.AssertDriverContentsAre (looksLike, output);
         TestHelpers.AssertDriverContentsAre (looksLike, output);
+        v.Dispose ();
     }
     }
 
 
     [Theory]
     [Theory]
-    [AutoInitShutdown]
+    [SetupFakeDriver]
     [InlineData (LineStyle.Single)]
     [InlineData (LineStyle.Single)]
     [InlineData (LineStyle.Rounded)]
     [InlineData (LineStyle.Rounded)]
     public void TestLineCanvas_Window_ThinTop_HeavySides (LineStyle thinStyle)
     public void TestLineCanvas_Window_ThinTop_HeavySides (LineStyle thinStyle)
@@ -814,12 +812,12 @@ public class LineCanvasTests
 
 
         // outer box
         // outer box
         canvas.AddLine (Point.Empty, 10, Orientation.Horizontal, thinStyle);
         canvas.AddLine (Point.Empty, 10, Orientation.Horizontal, thinStyle);
-        canvas.AddLine (new Point (9, 0), 5, Orientation.Vertical, LineStyle.Heavy);
-        canvas.AddLine (new Point (9, 4), -10, Orientation.Horizontal, thinStyle);
-        canvas.AddLine (new Point (0, 4), -5, Orientation.Vertical, LineStyle.Heavy);
+        canvas.AddLine (new (9, 0), 5, Orientation.Vertical, LineStyle.Heavy);
+        canvas.AddLine (new (9, 4), -10, Orientation.Horizontal, thinStyle);
+        canvas.AddLine (new (0, 4), -5, Orientation.Vertical, LineStyle.Heavy);
 
 
-        canvas.AddLine (new Point (5, 0), 5, Orientation.Vertical, LineStyle.Heavy);
-        canvas.AddLine (new Point (0, 2), 10, Orientation.Horizontal, thinStyle);
+        canvas.AddLine (new (5, 0), 5, Orientation.Vertical, LineStyle.Heavy);
+        canvas.AddLine (new (0, 2), 10, Orientation.Horizontal, thinStyle);
 
 
         v.Draw ();
         v.Draw ();
 
 
@@ -833,6 +831,7 @@ public class LineCanvasTests
 
 
 ";
 ";
         TestHelpers.AssertDriverContentsAre (looksLike, output);
         TestHelpers.AssertDriverContentsAre (looksLike, output);
+        v.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -843,7 +842,7 @@ public class LineCanvasTests
 
 
         // Upper box
         // Upper box
         canvas.AddLine (Point.Empty, 2, Orientation.Horizontal, LineStyle.Single);
         canvas.AddLine (Point.Empty, 2, Orientation.Horizontal, LineStyle.Single);
-        canvas.AddLine (new Point (0, 1), -2, Orientation.Vertical, LineStyle.Single);
+        canvas.AddLine (new (0, 1), -2, Orientation.Vertical, LineStyle.Single);
 
 
         var looksLike =
         var looksLike =
             @"
             @"
@@ -862,7 +861,7 @@ public class LineCanvasTests
         canvas.AddLine (Point.Empty, 1, Orientation.Horizontal, LineStyle.Single);
         canvas.AddLine (Point.Empty, 1, Orientation.Horizontal, LineStyle.Single);
 
 
         // Bottom   ─
         // Bottom   ─
-        canvas.AddLine (new Point (1, 1), -1, Orientation.Horizontal, LineStyle.Single);
+        canvas.AddLine (new (1, 1), -1, Orientation.Horizontal, LineStyle.Single);
 
 
         //// Right down
         //// Right down
         //canvas.AddLine (new Point (9, 0), 3, Orientation.Vertical, LineStyle.Single);
         //canvas.AddLine (new Point (9, 0), 3, Orientation.Vertical, LineStyle.Single);
@@ -873,7 +872,7 @@ public class LineCanvasTests
         //// Left Up
         //// Left Up
         //canvas.AddLine (new Point (0, 3), -3, Orientation.Vertical, LineStyle.Single);
         //canvas.AddLine (new Point (0, 3), -3, Orientation.Vertical, LineStyle.Single);
 
 
-        Assert.Equal (new Rectangle (0, 0, 2, 2), canvas.Viewport);
+        Assert.Equal (new (0, 0, 2, 2), canvas.Viewport);
 
 
         Dictionary<Point, Rune> map = canvas.GetMap ();
         Dictionary<Point, Rune> map = canvas.GetMap ();
         Assert.Equal (2, map.Count);
         Assert.Equal (2, map.Count);
@@ -910,7 +909,7 @@ public class LineCanvasTests
     public void ToString_Positive_Horizontal_1Line_Offset (int x, int y, string expected)
     public void ToString_Positive_Horizontal_1Line_Offset (int x, int y, string expected)
     {
     {
         var lc = new LineCanvas ();
         var lc = new LineCanvas ();
-        lc.AddLine (new Point (x, y), 3, Orientation.Horizontal, LineStyle.Double);
+        lc.AddLine (new (x, y), 3, Orientation.Horizontal, LineStyle.Double);
         TestHelpers.AssertEqual (output, expected, $"{lc}");
         TestHelpers.AssertEqual (output, expected, $"{lc}");
     }
     }
 
 
@@ -933,8 +932,8 @@ public class LineCanvasTests
     public void ToString_Positive_Horizontal_2Line_Offset (int x1, int y1, int x2, int y2, string expected)
     public void ToString_Positive_Horizontal_2Line_Offset (int x1, int y1, int x2, int y2, string expected)
     {
     {
         var lc = new LineCanvas ();
         var lc = new LineCanvas ();
-        lc.AddLine (new Point (x1, y1), 3, Orientation.Horizontal, LineStyle.Double);
-        lc.AddLine (new Point (x2, y2), 3, Orientation.Horizontal, LineStyle.Double);
+        lc.AddLine (new (x1, y1), 3, Orientation.Horizontal, LineStyle.Double);
+        lc.AddLine (new (x2, y2), 3, Orientation.Horizontal, LineStyle.Double);
 
 
         TestHelpers.AssertEqual (output, expected, $"{lc}");
         TestHelpers.AssertEqual (output, expected, $"{lc}");
     }
     }
@@ -976,7 +975,7 @@ public class LineCanvasTests
     [InlineData (0, 0, 2, Orientation.Vertical, LineStyle.Double, "║\n║")]
     [InlineData (0, 0, 2, Orientation.Vertical, LineStyle.Double, "║\n║")]
     [InlineData (0, 0, 2, Orientation.Horizontal, LineStyle.Single, "──")]
     [InlineData (0, 0, 2, Orientation.Horizontal, LineStyle.Single, "──")]
     [InlineData (0, 0, 2, Orientation.Vertical, LineStyle.Single, "│\n│")]
     [InlineData (0, 0, 2, Orientation.Vertical, LineStyle.Single, "│\n│")]
-    [AutoInitShutdown]
+    [SetupFakeDriver]
     [Theory]
     [Theory]
     public void View_Draws_1LineTests (
     public void View_Draws_1LineTests (
         int x1,
         int x1,
@@ -990,18 +989,19 @@ public class LineCanvasTests
         View v = GetCanvas (out LineCanvas lc);
         View v = GetCanvas (out LineCanvas lc);
         v.Width = 10;
         v.Width = 10;
         v.Height = 10;
         v.Height = 10;
-        v.Viewport = new Rectangle (0, 0, 10, 10);
+        v.Viewport = new (0, 0, 10, 10);
 
 
-        lc.AddLine (new Point (x1, y1), length, o1, s1);
+        lc.AddLine (new (x1, y1), length, o1, s1);
 
 
         v.Draw ();
         v.Draw ();
 
 
         TestHelpers.AssertDriverContentsAre (expected, output);
         TestHelpers.AssertDriverContentsAre (expected, output);
+        v.Dispose ();
     }
     }
 
 
     /// <summary>This test demonstrates how to correctly trigger a corner.  By overlapping the lines in the same cell</summary>
     /// <summary>This test demonstrates how to correctly trigger a corner.  By overlapping the lines in the same cell</summary>
     [Fact]
     [Fact]
-    [AutoInitShutdown]
+    [SetupFakeDriver]
     public void View_Draws_Corner_Correct ()
     public void View_Draws_Corner_Correct ()
     {
     {
         View v = GetCanvas (out LineCanvas canvas);
         View v = GetCanvas (out LineCanvas canvas);
@@ -1015,6 +1015,7 @@ public class LineCanvasTests
 ┌─
 ┌─
 │";
 │";
         TestHelpers.AssertDriverContentsAre (looksLike, output);
         TestHelpers.AssertDriverContentsAre (looksLike, output);
+        v.Dispose ();
     }
     }
 
 
     /// <summary>
     /// <summary>
@@ -1022,12 +1023,12 @@ public class LineCanvasTests
     ///     another.
     ///     another.
     /// </summary>
     /// </summary>
     [Fact]
     [Fact]
-    [AutoInitShutdown]
+    [SetupFakeDriver]
     public void View_Draws_Corner_NoOverlap ()
     public void View_Draws_Corner_NoOverlap ()
     {
     {
         View v = GetCanvas (out LineCanvas canvas);
         View v = GetCanvas (out LineCanvas canvas);
         canvas.AddLine (Point.Empty, 2, Orientation.Horizontal, LineStyle.Single);
         canvas.AddLine (Point.Empty, 2, Orientation.Horizontal, LineStyle.Single);
-        canvas.AddLine (new Point (0, 1), 2, Orientation.Vertical, LineStyle.Single);
+        canvas.AddLine (new (0, 1), 2, Orientation.Vertical, LineStyle.Single);
 
 
         v.Draw ();
         v.Draw ();
 
 
@@ -1037,12 +1038,13 @@ public class LineCanvasTests
 │";
 │";
         TestHelpers.AssertDriverContentsAre (looksLike, output);
         TestHelpers.AssertDriverContentsAre (looksLike, output);
+        v.Dispose ();
     }
     }
 
 
     [InlineData (LineStyle.Single)]
     [InlineData (LineStyle.Single)]
     [InlineData (LineStyle.Rounded)]
     [InlineData (LineStyle.Rounded)]
     [Theory]
     [Theory]
-    [AutoInitShutdown]
+    [SetupFakeDriver]
     public void View_Draws_Horizontal (LineStyle style)
     public void View_Draws_Horizontal (LineStyle style)
     {
     {
         View v = GetCanvas (out LineCanvas canvas);
         View v = GetCanvas (out LineCanvas canvas);
@@ -1054,10 +1056,11 @@ public class LineCanvasTests
             @"    
             @"    
 ──";
 ──";
         TestHelpers.AssertDriverContentsAre (looksLike, output);
         TestHelpers.AssertDriverContentsAre (looksLike, output);
+        v.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown]
+    [SetupFakeDriver]
     public void View_Draws_Horizontal_Double ()
     public void View_Draws_Horizontal_Double ()
     {
     {
         View v = GetCanvas (out LineCanvas canvas);
         View v = GetCanvas (out LineCanvas canvas);
@@ -1069,12 +1072,13 @@ public class LineCanvasTests
             @" 
             @" 
 ══";
 ══";
         TestHelpers.AssertDriverContentsAre (looksLike, output);
         TestHelpers.AssertDriverContentsAre (looksLike, output);
+        v.Dispose ();
     }
     }
 
 
     [InlineData (LineStyle.Single)]
     [InlineData (LineStyle.Single)]
     [InlineData (LineStyle.Rounded)]
     [InlineData (LineStyle.Rounded)]
     [Theory]
     [Theory]
-    [AutoInitShutdown]
+    [SetupFakeDriver]
     public void View_Draws_Vertical (LineStyle style)
     public void View_Draws_Vertical (LineStyle style)
     {
     {
         View v = GetCanvas (out LineCanvas canvas);
         View v = GetCanvas (out LineCanvas canvas);
@@ -1087,10 +1091,11 @@ public class LineCanvasTests
 │";
 │";
         TestHelpers.AssertDriverContentsAre (looksLike, output);
         TestHelpers.AssertDriverContentsAre (looksLike, output);
+        v.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown]
+    [SetupFakeDriver]
     public void View_Draws_Vertical_Double ()
     public void View_Draws_Vertical_Double ()
     {
     {
         View v = GetCanvas (out LineCanvas canvas);
         View v = GetCanvas (out LineCanvas canvas);
@@ -1103,22 +1108,23 @@ public class LineCanvasTests
 ║";
 ║";
         TestHelpers.AssertDriverContentsAre (looksLike, output);
         TestHelpers.AssertDriverContentsAre (looksLike, output);
+        v.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown]
+    [SetupFakeDriver]
     public void View_Draws_Window_Double ()
     public void View_Draws_Window_Double ()
     {
     {
         View v = GetCanvas (out LineCanvas canvas);
         View v = GetCanvas (out LineCanvas canvas);
 
 
         // outer box
         // outer box
         canvas.AddLine (Point.Empty, 10, Orientation.Horizontal, LineStyle.Double);
         canvas.AddLine (Point.Empty, 10, Orientation.Horizontal, LineStyle.Double);
-        canvas.AddLine (new Point (9, 0), 5, Orientation.Vertical, LineStyle.Double);
-        canvas.AddLine (new Point (9, 4), -10, Orientation.Horizontal, LineStyle.Double);
-        canvas.AddLine (new Point (0, 4), -5, Orientation.Vertical, LineStyle.Double);
+        canvas.AddLine (new (9, 0), 5, Orientation.Vertical, LineStyle.Double);
+        canvas.AddLine (new (9, 4), -10, Orientation.Horizontal, LineStyle.Double);
+        canvas.AddLine (new (0, 4), -5, Orientation.Vertical, LineStyle.Double);
 
 
-        canvas.AddLine (new Point (5, 0), 5, Orientation.Vertical, LineStyle.Double);
-        canvas.AddLine (new Point (0, 2), 10, Orientation.Horizontal, LineStyle.Double);
+        canvas.AddLine (new (5, 0), 5, Orientation.Vertical, LineStyle.Double);
+        canvas.AddLine (new (0, 2), 10, Orientation.Horizontal, LineStyle.Double);
 
 
         v.Draw ();
         v.Draw ();
 
 
@@ -1130,10 +1136,11 @@ public class LineCanvasTests
 ║    ║   ║
 ║    ║   ║
 ╚════╩═══╝";
 ╚════╩═══╝";
         TestHelpers.AssertDriverContentsAre (looksLike, output);
         TestHelpers.AssertDriverContentsAre (looksLike, output);
+        v.Dispose ();
     }
     }
 
 
     [Theory]
     [Theory]
-    [AutoInitShutdown]
+    [SetupFakeDriver]
     [InlineData (LineStyle.Single)]
     [InlineData (LineStyle.Single)]
     [InlineData (LineStyle.Rounded)]
     [InlineData (LineStyle.Rounded)]
     public void View_Draws_Window_DoubleTop_SingleSides (LineStyle thinStyle)
     public void View_Draws_Window_DoubleTop_SingleSides (LineStyle thinStyle)
@@ -1142,12 +1149,12 @@ public class LineCanvasTests
 
 
         // outer box
         // outer box
         canvas.AddLine (Point.Empty, 10, Orientation.Horizontal, LineStyle.Double);
         canvas.AddLine (Point.Empty, 10, Orientation.Horizontal, LineStyle.Double);
-        canvas.AddLine (new Point (9, 0), 5, Orientation.Vertical, thinStyle);
-        canvas.AddLine (new Point (9, 4), -10, Orientation.Horizontal, LineStyle.Double);
-        canvas.AddLine (new Point (0, 4), -5, Orientation.Vertical, thinStyle);
+        canvas.AddLine (new (9, 0), 5, Orientation.Vertical, thinStyle);
+        canvas.AddLine (new (9, 4), -10, Orientation.Horizontal, LineStyle.Double);
+        canvas.AddLine (new (0, 4), -5, Orientation.Vertical, thinStyle);
 
 
-        canvas.AddLine (new Point (5, 0), 5, Orientation.Vertical, thinStyle);
-        canvas.AddLine (new Point (0, 2), 10, Orientation.Horizontal, LineStyle.Double);
+        canvas.AddLine (new (5, 0), 5, Orientation.Vertical, thinStyle);
+        canvas.AddLine (new (0, 2), 10, Orientation.Horizontal, LineStyle.Double);
 
 
         v.Draw ();
         v.Draw ();
 
 
@@ -1160,6 +1167,7 @@ public class LineCanvasTests
 ╘════╧═══╛
 ╘════╧═══╛
 ";
 ";
         TestHelpers.AssertDriverContentsAre (looksLike, output);
         TestHelpers.AssertDriverContentsAre (looksLike, output);
+        v.Dispose ();
     }
     }
 
 
     /// <summary>
     /// <summary>
@@ -1168,7 +1176,7 @@ public class LineCanvasTests
     ///     used.
     ///     used.
     /// </summary>
     /// </summary>
     [Fact]
     [Fact]
-    [AutoInitShutdown]
+    [SetupFakeDriver]
     public void View_Draws_Window_Rounded ()
     public void View_Draws_Window_Rounded ()
     {
     {
         View v = GetCanvas (out LineCanvas canvas);
         View v = GetCanvas (out LineCanvas canvas);
@@ -1178,13 +1186,13 @@ public class LineCanvasTests
 
 
         // LineStyle.Single is ignored because corner overlaps with the above line which is Rounded
         // LineStyle.Single is ignored because corner overlaps with the above line which is Rounded
         // this results in a rounded corner being used.
         // this results in a rounded corner being used.
-        canvas.AddLine (new Point (9, 0), 5, Orientation.Vertical, LineStyle.Single);
-        canvas.AddLine (new Point (9, 4), -10, Orientation.Horizontal, LineStyle.Rounded);
-        canvas.AddLine (new Point (0, 4), -5, Orientation.Vertical, LineStyle.Single);
+        canvas.AddLine (new (9, 0), 5, Orientation.Vertical, LineStyle.Single);
+        canvas.AddLine (new (9, 4), -10, Orientation.Horizontal, LineStyle.Rounded);
+        canvas.AddLine (new (0, 4), -5, Orientation.Vertical, LineStyle.Single);
 
 
         // These lines say rounded but they will result in the T sections which are never rounded.
         // These lines say rounded but they will result in the T sections which are never rounded.
-        canvas.AddLine (new Point (5, 0), 5, Orientation.Vertical, LineStyle.Rounded);
-        canvas.AddLine (new Point (0, 2), 10, Orientation.Horizontal, LineStyle.Rounded);
+        canvas.AddLine (new (5, 0), 5, Orientation.Vertical, LineStyle.Rounded);
+        canvas.AddLine (new (0, 2), 10, Orientation.Horizontal, LineStyle.Rounded);
 
 
         v.Draw ();
         v.Draw ();
 
 
@@ -1196,24 +1204,25 @@ public class LineCanvasTests
 │    │   │
 │    │   │
 ╰────┴───╯";
 ╰────┴───╯";
         TestHelpers.AssertDriverContentsAre (looksLike, output);
         TestHelpers.AssertDriverContentsAre (looksLike, output);
+        v.Dispose ();
     }
     }
 
 
     [Theory]
     [Theory]
-    [AutoInitShutdown]
     [InlineData (LineStyle.Single)]
     [InlineData (LineStyle.Single)]
     [InlineData (LineStyle.Rounded)]
     [InlineData (LineStyle.Rounded)]
+    [SetupFakeDriver]
     public void View_Draws_Window_SingleTop_DoubleSides (LineStyle thinStyle)
     public void View_Draws_Window_SingleTop_DoubleSides (LineStyle thinStyle)
     {
     {
         View v = GetCanvas (out LineCanvas canvas);
         View v = GetCanvas (out LineCanvas canvas);
 
 
         // outer box
         // outer box
         canvas.AddLine (Point.Empty, 10, Orientation.Horizontal, thinStyle);
         canvas.AddLine (Point.Empty, 10, Orientation.Horizontal, thinStyle);
-        canvas.AddLine (new Point (9, 0), 5, Orientation.Vertical, LineStyle.Double);
-        canvas.AddLine (new Point (9, 4), -10, Orientation.Horizontal, thinStyle);
-        canvas.AddLine (new Point (0, 4), -5, Orientation.Vertical, LineStyle.Double);
+        canvas.AddLine (new (9, 0), 5, Orientation.Vertical, LineStyle.Double);
+        canvas.AddLine (new (9, 4), -10, Orientation.Horizontal, thinStyle);
+        canvas.AddLine (new (0, 4), -5, Orientation.Vertical, LineStyle.Double);
 
 
-        canvas.AddLine (new Point (5, 0), 5, Orientation.Vertical, LineStyle.Double);
-        canvas.AddLine (new Point (0, 2), 10, Orientation.Horizontal, thinStyle);
+        canvas.AddLine (new (5, 0), 5, Orientation.Vertical, LineStyle.Double);
+        canvas.AddLine (new (0, 2), 10, Orientation.Horizontal, thinStyle);
 
 
         v.Draw ();
         v.Draw ();
 
 
@@ -1227,6 +1236,7 @@ public class LineCanvasTests
 
 
 ";
 ";
         TestHelpers.AssertDriverContentsAre (looksLike, output);
         TestHelpers.AssertDriverContentsAre (looksLike, output);
+        v.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -1237,13 +1247,13 @@ public class LineCanvasTests
 
 
         // Frame
         // Frame
         canvas.AddLine (Point.Empty, 10, Orientation.Horizontal, LineStyle.Single);
         canvas.AddLine (Point.Empty, 10, Orientation.Horizontal, LineStyle.Single);
-        canvas.AddLine (new Point (9, 0), 5, Orientation.Vertical, LineStyle.Single);
-        canvas.AddLine (new Point (9, 4), -10, Orientation.Horizontal, LineStyle.Single);
-        canvas.AddLine (new Point (0, 4), -5, Orientation.Vertical, LineStyle.Single);
+        canvas.AddLine (new (9, 0), 5, Orientation.Vertical, LineStyle.Single);
+        canvas.AddLine (new (9, 4), -10, Orientation.Horizontal, LineStyle.Single);
+        canvas.AddLine (new (0, 4), -5, Orientation.Vertical, LineStyle.Single);
 
 
         // Cross
         // Cross
-        canvas.AddLine (new Point (5, 0), 5, Orientation.Vertical, LineStyle.Single);
-        canvas.AddLine (new Point (0, 2), 10, Orientation.Horizontal, LineStyle.Single);
+        canvas.AddLine (new (5, 0), 5, Orientation.Vertical, LineStyle.Single);
+        canvas.AddLine (new (0, 2), 10, Orientation.Horizontal, LineStyle.Single);
 
 
         var looksLike =
         var looksLike =
             @"
             @"
@@ -1270,22 +1280,22 @@ public class LineCanvasTests
 
 
         // ╔╡╞═════╗
         // ╔╡╞═════╗
         // Add a short horiz line for ╔╡
         // Add a short horiz line for ╔╡
-        lc.AddLine (new Point (x, y), 2, Orientation.Horizontal, LineStyle.Double);
+        lc.AddLine (new (x, y), 2, Orientation.Horizontal, LineStyle.Double);
 
 
         //LHS line down
         //LHS line down
-        lc.AddLine (new Point (x, y), height, Orientation.Vertical, LineStyle.Double);
+        lc.AddLine (new (x, y), height, Orientation.Vertical, LineStyle.Double);
 
 
         //Vertical line before Title, results in a ╡
         //Vertical line before Title, results in a ╡
-        lc.AddLine (new Point (x + 1, y), 0, Orientation.Vertical, LineStyle.Single);
+        lc.AddLine (new (x + 1, y), 0, Orientation.Vertical, LineStyle.Single);
 
 
         //Vertical line after Title, results in a ╞
         //Vertical line after Title, results in a ╞
-        lc.AddLine (new Point (x + 2, y), 0, Orientation.Vertical, LineStyle.Single);
+        lc.AddLine (new (x + 2, y), 0, Orientation.Vertical, LineStyle.Single);
 
 
         // remainder of top line
         // remainder of top line
-        lc.AddLine (new Point (x + 2, y), width - 1, Orientation.Horizontal, LineStyle.Double);
+        lc.AddLine (new (x + 2, y), width - 1, Orientation.Horizontal, LineStyle.Double);
 
 
         //RHS line down
         //RHS line down
-        lc.AddLine (new Point (x + width, y), height, Orientation.Vertical, LineStyle.Double);
+        lc.AddLine (new (x + width, y), height, Orientation.Vertical, LineStyle.Double);
 
 
         var looksLike = @"
         var looksLike = @"
 ╔╡╞══╗
 ╔╡╞══╗
@@ -1304,12 +1314,9 @@ public class LineCanvasTests
     /// <returns></returns>
     /// <returns></returns>
     private View GetCanvas (out LineCanvas canvas, int offsetX = 0, int offsetY = 0)
     private View GetCanvas (out LineCanvas canvas, int offsetX = 0, int offsetY = 0)
     {
     {
-        var v = new View { Width = 10, Height = 5, Viewport = new Rectangle (0, 0, 10, 5) };
-        var top = new Toplevel ();
-        top.Add (v);
-        Application.Begin (top);
+        var v = new View { Width = 10, Height = 5, Viewport = new (0, 0, 10, 5) };
 
 
-        LineCanvas canvasCopy = canvas = new LineCanvas ();
+        LineCanvas canvasCopy = canvas = new ();
 
 
         v.DrawContentComplete += (s, e) =>
         v.DrawContentComplete += (s, e) =>
                                  {
                                  {

+ 16 - 16
UnitTests/Drawing/RulerTests.cs

@@ -1,9 +1,5 @@
 using Xunit.Abstractions;
 using Xunit.Abstractions;
 
 
-//using GraphViewTests = Terminal.Gui.Views.GraphViewTests;
-
-// Alias Console to MockConsole so we don't accidentally use Console
-
 namespace Terminal.Gui.DrawingTests;
 namespace Terminal.Gui.DrawingTests;
 
 
 public class RulerTests
 public class RulerTests
@@ -52,7 +48,7 @@ public class RulerTests
         top.Add (f);
         top.Add (f);
         Application.Begin (top);
         Application.Begin (top);
         ((FakeDriver)Application.Driver).SetBufferSize (len + 5, 5);
         ((FakeDriver)Application.Driver).SetBufferSize (len + 5, 5);
-        Assert.Equal (new Rectangle (0, 0, len + 5, 5), f.Frame);
+        Assert.Equal (new (0, 0, len + 5, 5), f.Frame);
 
 
         var r = new Ruler ();
         var r = new Ruler ();
         Assert.Equal (Orientation.Horizontal, r.Orientation);
         Assert.Equal (Orientation.Horizontal, r.Orientation);
@@ -72,7 +68,7 @@ public class RulerTests
 
 
         // Postive offset
         // Postive offset
         Application.Refresh ();
         Application.Refresh ();
-        r.Draw (new Point (1, 1));
+        r.Draw (new (1, 1));
 
 
         TestHelpers.AssertDriverContentsWithFrameAre (
         TestHelpers.AssertDriverContentsWithFrameAre (
                                                       @"
                                                       @"
@@ -86,7 +82,7 @@ public class RulerTests
 
 
         // Negative offset
         // Negative offset
         Application.Refresh ();
         Application.Refresh ();
-        r.Draw (new Point (-1, 1));
+        r.Draw (new (-1, 1));
 
 
         TestHelpers.AssertDriverContentsWithFrameAre (
         TestHelpers.AssertDriverContentsWithFrameAre (
                                                       @"
                                                       @"
@@ -100,7 +96,7 @@ public class RulerTests
 
 
         // Clip
         // Clip
         Application.Refresh ();
         Application.Refresh ();
-        r.Draw (new Point (10, 1));
+        r.Draw (new (10, 1));
 
 
         TestHelpers.AssertDriverContentsWithFrameAre (
         TestHelpers.AssertDriverContentsWithFrameAre (
                                                       @"
                                                       @"
@@ -111,6 +107,7 @@ public class RulerTests
 └──────────────────┘",
 └──────────────────┘",
                                                       _output
                                                       _output
                                                      );
                                                      );
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -125,7 +122,7 @@ public class RulerTests
         top.Add (f);
         top.Add (f);
         Application.Begin (top);
         Application.Begin (top);
         ((FakeDriver)Application.Driver).SetBufferSize (len + 5, 5);
         ((FakeDriver)Application.Driver).SetBufferSize (len + 5, 5);
-        Assert.Equal (new Rectangle (0, 0, len + 5, 5), f.Frame);
+        Assert.Equal (new (0, 0, len + 5, 5), f.Frame);
 
 
         var r = new Ruler ();
         var r = new Ruler ();
         Assert.Equal (Orientation.Horizontal, r.Orientation);
         Assert.Equal (Orientation.Horizontal, r.Orientation);
@@ -145,7 +142,7 @@ public class RulerTests
 
 
         Application.Refresh ();
         Application.Refresh ();
         r.Length = len;
         r.Length = len;
-        r.Draw (new Point (1, 0), 1);
+        r.Draw (new (1, 0), 1);
 
 
         TestHelpers.AssertDriverContentsWithFrameAre (
         TestHelpers.AssertDriverContentsWithFrameAre (
                                                       @"
                                                       @"
@@ -156,6 +153,7 @@ public class RulerTests
 └──────────────────┘",
 └──────────────────┘",
                                                       _output
                                                       _output
                                                      );
                                                      );
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -171,7 +169,7 @@ public class RulerTests
         top.Add (f);
         top.Add (f);
         Application.Begin (top);
         Application.Begin (top);
         ((FakeDriver)Application.Driver).SetBufferSize (5, len + 5);
         ((FakeDriver)Application.Driver).SetBufferSize (5, len + 5);
-        Assert.Equal (new Rectangle (0, 0, 5, len + 5), f.Frame);
+        Assert.Equal (new (0, 0, 5, len + 5), f.Frame);
 
 
         var r = new Ruler ();
         var r = new Ruler ();
         r.Orientation = Orientation.Vertical;
         r.Orientation = Orientation.Vertical;
@@ -205,7 +203,7 @@ public class RulerTests
 
 
         // Postive offset
         // Postive offset
         Application.Refresh ();
         Application.Refresh ();
-        r.Draw (new Point (1, 1));
+        r.Draw (new (1, 1));
 
 
         TestHelpers.AssertDriverContentsWithFrameAre (
         TestHelpers.AssertDriverContentsWithFrameAre (
                                                       @"
                                                       @"
@@ -234,7 +232,7 @@ public class RulerTests
 
 
         // Negative offset
         // Negative offset
         Application.Refresh ();
         Application.Refresh ();
-        r.Draw (new Point (1, -1));
+        r.Draw (new (1, -1));
 
 
         TestHelpers.AssertDriverContentsWithFrameAre (
         TestHelpers.AssertDriverContentsWithFrameAre (
                                                       @"
                                                       @"
@@ -263,7 +261,7 @@ public class RulerTests
 
 
         // Clip
         // Clip
         Application.Refresh ();
         Application.Refresh ();
-        r.Draw (new Point (1, 10));
+        r.Draw (new (1, 10));
 
 
         TestHelpers.AssertDriverContentsWithFrameAre (
         TestHelpers.AssertDriverContentsWithFrameAre (
                                                       @"
                                                       @"
@@ -289,6 +287,7 @@ public class RulerTests
 └9──┘",
 └9──┘",
                                                       _output
                                                       _output
                                                      );
                                                      );
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -304,7 +303,7 @@ public class RulerTests
         top.Add (f);
         top.Add (f);
         Application.Begin (top);
         Application.Begin (top);
         ((FakeDriver)Application.Driver).SetBufferSize (5, len + 5);
         ((FakeDriver)Application.Driver).SetBufferSize (5, len + 5);
-        Assert.Equal (new Rectangle (0, 0, 5, len + 5), f.Frame);
+        Assert.Equal (new (0, 0, 5, len + 5), f.Frame);
 
 
         var r = new Ruler ();
         var r = new Ruler ();
         r.Orientation = Orientation.Vertical;
         r.Orientation = Orientation.Vertical;
@@ -338,7 +337,7 @@ public class RulerTests
 
 
         Application.Refresh ();
         Application.Refresh ();
         r.Length = len;
         r.Length = len;
-        r.Draw (new Point (0, 1), 1);
+        r.Draw (new (0, 1), 1);
 
 
         TestHelpers.AssertDriverContentsWithFrameAre (
         TestHelpers.AssertDriverContentsWithFrameAre (
                                                       @"
                                                       @"
@@ -364,6 +363,7 @@ public class RulerTests
 └───┘",
 └───┘",
                                                       _output
                                                       _output
                                                      );
                                                      );
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]

+ 10 - 16
UnitTests/Drawing/ThicknessTests.cs

@@ -1,17 +1,10 @@
 using System.Text;
 using System.Text;
 using Xunit.Abstractions;
 using Xunit.Abstractions;
 
 
-//using GraphViewTests = Terminal.Gui.Views.GraphViewTests;
-
-// Alias Console to MockConsole so we don't accidentally use Console
-
 namespace Terminal.Gui.DrawingTests;
 namespace Terminal.Gui.DrawingTests;
 
 
-public class ThicknessTests
+public class ThicknessTests (ITestOutputHelper output)
 {
 {
-    private readonly ITestOutputHelper _output;
-    public ThicknessTests (ITestOutputHelper output) { _output = output; }
-
     [Fact]
     [Fact]
     public void Constructor_Defaults ()
     public void Constructor_Defaults ()
     {
     {
@@ -73,7 +66,7 @@ public class ThicknessTests
         TestHelpers.AssertDriverContentsWithFrameAre (
         TestHelpers.AssertDriverContentsWithFrameAre (
                                                       @"
                                                       @"
        Test (Left=0,Top=0,Right=0,Bottom=0)",
        Test (Left=0,Top=0,Right=0,Bottom=0)",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         t = new Thickness (1, 1, 1, 1);
         t = new Thickness (1, 1, 1, 1);
@@ -104,7 +97,7 @@ public class ThicknessTests
      T                                      T
      T                                      T
      T                                      T
      T                                      T
      TTTest (Left=1,Top=1,Right=1,Bottom=1)TT",
      TTTest (Left=1,Top=1,Right=1,Bottom=1)TT",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         t = new Thickness (1, 2, 3, 4);
         t = new Thickness (1, 2, 3, 4);
@@ -135,7 +128,7 @@ public class ThicknessTests
      TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
      TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
      TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
      TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
      TTTest (Left=1,Top=2,Right=3,Bottom=4)TT",
      TTTest (Left=1,Top=2,Right=3,Bottom=4)TT",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         t = new Thickness (-1, 1, 1, 1);
         t = new Thickness (-1, 1, 1, 1);
@@ -166,7 +159,7 @@ public class ThicknessTests
                                             T
                                             T
                                             T
                                             T
      TTest (Left=-1,Top=1,Right=1,Bottom=1)TT",
      TTest (Left=-1,Top=1,Right=1,Bottom=1)TT",
-                                                      _output
+                                                      output
                                                      );
                                                      );
     }
     }
 
 
@@ -211,7 +204,7 @@ public class ThicknessTests
 │                                           │
 │                                           │
 │                                           │
 │                                           │
 └───────────────────────────────────────────┘",
 └───────────────────────────────────────────┘",
-                                             _output
+                                             output
                                             );
                                             );
 
 
         t = new Thickness (1, 1, 1, 1);
         t = new Thickness (1, 1, 1, 1);
@@ -243,7 +236,7 @@ public class ThicknessTests
 │                                           │
 │                                           │
 │                                           │
 │                                           │
 └───────────────────────────────────────────┘",
 └───────────────────────────────────────────┘",
-                                             _output
+                                             output
                                             );
                                             );
 
 
         t = new Thickness (1, 2, 3, 4);
         t = new Thickness (1, 2, 3, 4);
@@ -275,7 +268,7 @@ public class ThicknessTests
 │                                           │
 │                                           │
 │                                           │
 │                                           │
 └───────────────────────────────────────────┘",
 └───────────────────────────────────────────┘",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         t = new Thickness (-1, 1, 1, 1);
         t = new Thickness (-1, 1, 1, 1);
@@ -307,8 +300,9 @@ public class ThicknessTests
 │                                           2
 │                                           2
 │                                           3
 │                                           3
 └────|123456789|123456789|123456789|123456789",
 └────|123456789|123456789|123456789|123456789",
-                                                      _output
+                                                      output
                                                      );
                                                      );
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]

+ 30 - 21
UnitTests/FileServices/FileDialogTests.cs

@@ -1,19 +1,15 @@
-using System.Globalization;
 using System.IO.Abstractions.TestingHelpers;
 using System.IO.Abstractions.TestingHelpers;
 using System.Runtime.InteropServices;
 using System.Runtime.InteropServices;
 using Xunit.Abstractions;
 using Xunit.Abstractions;
 
 
 namespace Terminal.Gui.FileServicesTests;
 namespace Terminal.Gui.FileServicesTests;
 
 
-public class FileDialogTests
+public class FileDialogTests (ITestOutputHelper output)
 {
 {
-    private readonly ITestOutputHelper output;
-    public FileDialogTests (ITestOutputHelper output) { this.output = output; }
-
     [Theory]
     [Theory]
-    [AutoInitShutdown]
     [InlineData (true)]
     [InlineData (true)]
     [InlineData (false)]
     [InlineData (false)]
+    [AutoInitShutdown]
     public void CancelSelection (bool cancel)
     public void CancelSelection (bool cancel)
     {
     {
         FileDialog dlg = GetInitializedFileDialog ();
         FileDialog dlg = GetInitializedFileDialog ();
@@ -28,6 +24,7 @@ public class FileDialogTests
         Send ('\n', ConsoleKey.Enter);
         Send ('\n', ConsoleKey.Enter);
 
 
         Assert.Equal (cancel, dlg.Canceled);
         Assert.Equal (cancel, dlg.Canceled);
+        dlg.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -57,6 +54,7 @@ public class FileDialogTests
         Send ('\n', ConsoleKey.Enter);
         Send ('\n', ConsoleKey.Enter);
         Assert.False (dlg.Canceled);
         Assert.False (dlg.Canceled);
         Assert.Equal ("bob.csv", Path.GetFileName (dlg.Path));
         Assert.Equal ("bob.csv", Path.GetFileName (dlg.Path));
+        dlg.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -90,6 +88,7 @@ public class FileDialogTests
         Send ('\n', ConsoleKey.Enter);
         Send ('\n', ConsoleKey.Enter);
         Assert.False (dlg.Canceled);
         Assert.False (dlg.Canceled);
         Assert.EndsWith ("xx" + Path.DirectorySeparatorChar, dlg.Path);
         Assert.EndsWith ("xx" + Path.DirectorySeparatorChar, dlg.Path);
+        dlg.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -128,6 +127,7 @@ public class FileDialogTests
 
 
         // Dialog has not yet been confirmed with a choice
         // Dialog has not yet been confirmed with a choice
         Assert.False (dlg.Canceled);
         Assert.False (dlg.Canceled);
+        dlg.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -166,6 +166,7 @@ public class FileDialogTests
 
 
         Assert.True (dlg.Canceled);
         Assert.True (dlg.Canceled);
         Assert.False (selected);
         Assert.False (selected);
+        dlg.Dispose ();
     }
     }
 
 
     [Theory]
     [Theory]
@@ -220,6 +221,7 @@ public class FileDialogTests
                              AssertIsTheSubfolder (eventMultiSelected.Single ());
                              AssertIsTheSubfolder (eventMultiSelected.Single ());
                          }
                          }
                         );
                         );
+        dlg.Dispose ();
     }
     }
 
 
     [Theory]
     [Theory]
@@ -273,6 +275,7 @@ public class FileDialogTests
                              AssertIsTheSubfolder (eventMultiSelected.Single ());
                              AssertIsTheSubfolder (eventMultiSelected.Single ());
                          }
                          }
                         );
                         );
+        dlg.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -301,6 +304,7 @@ public class FileDialogTests
         Assert.True (dlg.Canceled);
         Assert.True (dlg.Canceled);
         Assert.Empty (dlg.MultiSelected);
         Assert.Empty (dlg.MultiSelected);
         Assert.Null (eventMultiSelected);
         Assert.Null (eventMultiSelected);
+        dlg.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -312,6 +316,7 @@ public class FileDialogTests
         View tf = dlg.Subviews.FirstOrDefault (t => t.HasFocus);
         View tf = dlg.Subviews.FirstOrDefault (t => t.HasFocus);
         Assert.NotNull (tf);
         Assert.NotNull (tf);
         Assert.IsType<TextField> (tf);
         Assert.IsType<TextField> (tf);
+        dlg.Dispose ();
     }
     }
 
 
     [Theory]
     [Theory]
@@ -341,6 +346,7 @@ public class FileDialogTests
         Assert.False (dlg.Canceled);
         Assert.False (dlg.Canceled);
 
 
         AssertIsTheSubfolder (dlg.Path);
         AssertIsTheSubfolder (dlg.Path);
+        dlg.Dispose ();
     }
     }
 
 
     [Theory]
     [Theory]
@@ -368,6 +374,7 @@ public class FileDialogTests
         Send ('\n', ConsoleKey.Enter);
         Send ('\n', ConsoleKey.Enter);
         Assert.False (dlg.Canceled);
         Assert.False (dlg.Canceled);
         AssertIsTheSubfolder (dlg.Path);
         AssertIsTheSubfolder (dlg.Path);
+        dlg.Dispose ();
     }
     }
 
 
     [Theory]
     [Theory]
@@ -413,7 +420,7 @@ public class FileDialogTests
         FileDialog fd = GetLinuxDialog ();
         FileDialog fd = GetLinuxDialog ();
         fd.Title = string.Empty;
         fd.Title = string.Empty;
 
 
-        fd.Style.Culture = new CultureInfo ("en-US");
+        fd.Style.Culture = new ("en-US");
 
 
         fd.Draw ();
         fd.Draw ();
 
 
@@ -456,6 +463,7 @@ public class FileDialogTests
 └─────────────────────────────────────────────────────────────────────────┘
 └─────────────────────────────────────────────────────────────────────────┘
 ";
 ";
         TestHelpers.AssertDriverContentsAre (expected, output, ignoreLeadingWhitespace: true);
         TestHelpers.AssertDriverContentsAre (expected, output, ignoreLeadingWhitespace: true);
+        fd.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -470,7 +478,7 @@ public class FileDialogTests
         FileDialog fd = GetWindowsDialog ();
         FileDialog fd = GetWindowsDialog ();
         fd.Title = string.Empty;
         fd.Title = string.Empty;
 
 
-        fd.Style.Culture = new CultureInfo ("en-US");
+        fd.Style.Culture = new ("en-US");
 
 
         fd.Draw ();
         fd.Draw ();
 
 
@@ -513,6 +521,7 @@ public class FileDialogTests
 └─────────────────────────────────────────────────────────────────────────┘
 └─────────────────────────────────────────────────────────────────────────┘
 ";
 ";
         TestHelpers.AssertDriverContentsAre (expected, output, ignoreLeadingWhitespace: true);
         TestHelpers.AssertDriverContentsAre (expected, output, ignoreLeadingWhitespace: true);
+        fd.Dispose ();
     }
     }
 
 
     private void AssertIsTheRootDirectory (string path)
     private void AssertIsTheRootDirectory (string path)
@@ -572,21 +581,21 @@ public class FileDialogTests
     {
     {
         // Arrange
         // Arrange
         var fileSystem = new MockFileSystem (new Dictionary<string, MockFileData> (), "/");
         var fileSystem = new MockFileSystem (new Dictionary<string, MockFileData> (), "/");
-        fileSystem.MockTime (() => new DateTime (2010, 01, 01, 11, 12, 43));
+        fileSystem.MockTime (() => new (2010, 01, 01, 11, 12, 43));
 
 
         fileSystem.AddFile (
         fileSystem.AddFile (
                             @"/myfile.txt",
                             @"/myfile.txt",
-                            new MockFileData ("Testing is meh.") { LastWriteTime = new DateTime (2001, 01, 01, 11, 12, 11) }
+                            new ("Testing is meh.") { LastWriteTime = new DateTime (2001, 01, 01, 11, 12, 11) }
                            );
                            );
 
 
         fileSystem.AddFile (
         fileSystem.AddFile (
                             @"/demo/jQuery.js",
                             @"/demo/jQuery.js",
-                            new MockFileData ("some js") { LastWriteTime = new DateTime (2001, 01, 01, 11, 44, 42) }
+                            new ("some js") { LastWriteTime = new DateTime (2001, 01, 01, 11, 44, 42) }
                            );
                            );
 
 
         fileSystem.AddFile (
         fileSystem.AddFile (
                             @"/demo/image.gif",
                             @"/demo/image.gif",
-                            new MockFileData (new byte [] { 0x12, 0x34, 0x56, 0xd2 })
+                            new (new byte [] { 0x12, 0x34, 0x56, 0xd2 })
                             {
                             {
                                 LastWriteTime = new DateTime (2002, 01, 01, 22, 42, 10)
                                 LastWriteTime = new DateTime (2002, 01, 01, 22, 42, 10)
                             }
                             }
@@ -594,11 +603,11 @@ public class FileDialogTests
 
 
         var m = (MockDirectoryInfo)fileSystem.DirectoryInfo.New (@"/demo/subfolder");
         var m = (MockDirectoryInfo)fileSystem.DirectoryInfo.New (@"/demo/subfolder");
         m.Create ();
         m.Create ();
-        m.LastWriteTime = new DateTime (2002, 01, 01, 22, 42, 10);
+        m.LastWriteTime = new (2002, 01, 01, 22, 42, 10);
 
 
         fileSystem.AddFile (
         fileSystem.AddFile (
                             @"/demo/subfolder/image2.gif",
                             @"/demo/subfolder/image2.gif",
-                            new MockFileData (new byte [] { 0x12, 0x34, 0x56, 0xd2 })
+                            new (new byte [] { 0x12, 0x34, 0x56, 0xd2 })
                             {
                             {
                                 LastWriteTime = new DateTime (2002, 01, 01, 22, 42, 10)
                                 LastWriteTime = new DateTime (2002, 01, 01, 22, 42, 10)
                             }
                             }
@@ -615,26 +624,26 @@ public class FileDialogTests
     {
     {
         // Arrange
         // Arrange
         var fileSystem = new MockFileSystem (new Dictionary<string, MockFileData> (), @"c:\");
         var fileSystem = new MockFileSystem (new Dictionary<string, MockFileData> (), @"c:\");
-        fileSystem.MockTime (() => new DateTime (2010, 01, 01, 11, 12, 43));
+        fileSystem.MockTime (() => new (2010, 01, 01, 11, 12, 43));
 
 
         fileSystem.AddFile (
         fileSystem.AddFile (
                             @"c:\myfile.txt",
                             @"c:\myfile.txt",
-                            new MockFileData ("Testing is meh.") { LastWriteTime = new DateTime (2001, 01, 01, 11, 12, 11) }
+                            new ("Testing is meh.") { LastWriteTime = new DateTime (2001, 01, 01, 11, 12, 11) }
                            );
                            );
 
 
         fileSystem.AddFile (
         fileSystem.AddFile (
                             @"c:\demo\jQuery.js",
                             @"c:\demo\jQuery.js",
-                            new MockFileData ("some js") { LastWriteTime = new DateTime (2001, 01, 01, 11, 44, 42) }
+                            new ("some js") { LastWriteTime = new DateTime (2001, 01, 01, 11, 44, 42) }
                            );
                            );
 
 
         fileSystem.AddFile (
         fileSystem.AddFile (
                             @"c:\demo\mybinary.exe",
                             @"c:\demo\mybinary.exe",
-                            new MockFileData ("some js") { LastWriteTime = new DateTime (2001, 01, 01, 11, 44, 42) }
+                            new ("some js") { LastWriteTime = new DateTime (2001, 01, 01, 11, 44, 42) }
                            );
                            );
 
 
         fileSystem.AddFile (
         fileSystem.AddFile (
                             @"c:\demo\image.gif",
                             @"c:\demo\image.gif",
-                            new MockFileData (new byte [] { 0x12, 0x34, 0x56, 0xd2 })
+                            new (new byte [] { 0x12, 0x34, 0x56, 0xd2 })
                             {
                             {
                                 LastWriteTime = new DateTime (2002, 01, 01, 22, 42, 10)
                                 LastWriteTime = new DateTime (2002, 01, 01, 22, 42, 10)
                             }
                             }
@@ -642,11 +651,11 @@ public class FileDialogTests
 
 
         var m = (MockDirectoryInfo)fileSystem.DirectoryInfo.New (@"c:\demo\subfolder");
         var m = (MockDirectoryInfo)fileSystem.DirectoryInfo.New (@"c:\demo\subfolder");
         m.Create ();
         m.Create ();
-        m.LastWriteTime = new DateTime (2002, 01, 01, 22, 42, 10);
+        m.LastWriteTime = new (2002, 01, 01, 22, 42, 10);
 
 
         fileSystem.AddFile (
         fileSystem.AddFile (
                             @"c:\demo\subfolder\image2.gif",
                             @"c:\demo\subfolder\image2.gif",
-                            new MockFileData (new byte [] { 0x12, 0x34, 0x56, 0xd2 })
+                            new (new byte [] { 0x12, 0x34, 0x56, 0xd2 })
                             {
                             {
                                 LastWriteTime = new DateTime (2002, 01, 01, 22, 42, 10)
                                 LastWriteTime = new DateTime (2002, 01, 01, 22, 42, 10)
                             }
                             }

+ 72 - 74
UnitTests/Input/EscSeqUtilsTests.cs

@@ -1,7 +1,4 @@
-using System.Diagnostics;
-using System.Runtime.InteropServices;
-
-namespace Terminal.Gui.InputTests;
+namespace Terminal.Gui.InputTests;
 
 
 public class EscSeqUtilsTests
 public class EscSeqUtilsTests
 {
 {
@@ -53,7 +50,7 @@ public class EscSeqUtilsTests
         Assert.Null (_values);
         Assert.Null (_values);
         Assert.Null (_terminating);
         Assert.Null (_terminating);
         Assert.False (_isKeyMouse);
         Assert.False (_isKeyMouse);
-        Assert.Equal (new List<MouseFlags> { 0 }, _mouseFlags);
+        Assert.Equal (new() { 0 }, _mouseFlags);
         Assert.Equal (Point.Empty, _pos);
         Assert.Equal (Point.Empty, _pos);
         Assert.False (_isReq);
         Assert.False (_isReq);
         Assert.Equal (0, (int)_arg1);
         Assert.Equal (0, (int)_arg1);
@@ -61,7 +58,7 @@ public class EscSeqUtilsTests
 
 
         ClearAll ();
         ClearAll ();
         _cki = new ConsoleKeyInfo [] { new ('\u001b', 0, false, false, false), new ('\u0012', 0, false, false, false) };
         _cki = new ConsoleKeyInfo [] { new ('\u001b', 0, false, false, false), new ('\u0012', 0, false, false, false) };
-        expectedCki = new ConsoleKeyInfo ('\u0012', ConsoleKey.R, false, true, true);
+        expectedCki = new ('\u0012', ConsoleKey.R, false, true, true);
 
 
         EscSeqUtils.DecodeEscSeq (
         EscSeqUtils.DecodeEscSeq (
                                   _escSeqReqProc,
                                   _escSeqReqProc,
@@ -88,7 +85,7 @@ public class EscSeqUtilsTests
         Assert.Null (_values);
         Assert.Null (_values);
         Assert.Equal ("\u0012", _terminating);
         Assert.Equal ("\u0012", _terminating);
         Assert.False (_isKeyMouse);
         Assert.False (_isKeyMouse);
-        Assert.Equal (new List<MouseFlags> { 0 }, _mouseFlags);
+        Assert.Equal (new() { 0 }, _mouseFlags);
         Assert.Equal (Point.Empty, _pos);
         Assert.Equal (Point.Empty, _pos);
         Assert.False (_isReq);
         Assert.False (_isReq);
         Assert.Equal (0, (int)_arg1);
         Assert.Equal (0, (int)_arg1);
@@ -96,7 +93,7 @@ public class EscSeqUtilsTests
 
 
         ClearAll ();
         ClearAll ();
         _cki = new ConsoleKeyInfo [] { new ('\u001b', 0, false, false, false), new ('r', 0, false, false, false) };
         _cki = new ConsoleKeyInfo [] { new ('\u001b', 0, false, false, false), new ('r', 0, false, false, false) };
-        expectedCki = new ConsoleKeyInfo ('R', ConsoleKey.R, false, true, false);
+        expectedCki = new ('R', ConsoleKey.R, false, true, false);
 
 
         EscSeqUtils.DecodeEscSeq (
         EscSeqUtils.DecodeEscSeq (
                                   _escSeqReqProc,
                                   _escSeqReqProc,
@@ -123,7 +120,7 @@ public class EscSeqUtilsTests
         Assert.Null (_values);
         Assert.Null (_values);
         Assert.Equal ("r", _terminating);
         Assert.Equal ("r", _terminating);
         Assert.False (_isKeyMouse);
         Assert.False (_isKeyMouse);
-        Assert.Equal (new List<MouseFlags> { 0 }, _mouseFlags);
+        Assert.Equal (new() { 0 }, _mouseFlags);
         Assert.Equal (Point.Empty, _pos);
         Assert.Equal (Point.Empty, _pos);
         Assert.False (_isReq);
         Assert.False (_isReq);
         Assert.Equal (0, (int)_arg1);
         Assert.Equal (0, (int)_arg1);
@@ -136,7 +133,7 @@ public class EscSeqUtilsTests
         {
         {
             new ('\u001b', 0, false, false, false), new ('O', 0, false, false, false), new ('R', 0, false, false, false)
             new ('\u001b', 0, false, false, false), new ('O', 0, false, false, false), new ('R', 0, false, false, false)
         };
         };
-        expectedCki = new ConsoleKeyInfo ('\0', ConsoleKey.F3, false, false, false);
+        expectedCki = new ('\0', ConsoleKey.F3, false, false, false);
 
 
         EscSeqUtils.DecodeEscSeq (
         EscSeqUtils.DecodeEscSeq (
                                   _escSeqReqProc,
                                   _escSeqReqProc,
@@ -164,7 +161,7 @@ public class EscSeqUtilsTests
         Assert.Null (_values [0]);
         Assert.Null (_values [0]);
         Assert.Equal ("R", _terminating);
         Assert.Equal ("R", _terminating);
         Assert.False (_isKeyMouse);
         Assert.False (_isKeyMouse);
-        Assert.Equal (new List<MouseFlags> { 0 }, _mouseFlags);
+        Assert.Equal (new() { 0 }, _mouseFlags);
         Assert.Equal (Point.Empty, _pos);
         Assert.Equal (Point.Empty, _pos);
         Assert.False (_isReq);
         Assert.False (_isReq);
         Assert.Equal (0, (int)_arg1);
         Assert.Equal (0, (int)_arg1);
@@ -182,7 +179,7 @@ public class EscSeqUtilsTests
             new ('2', 0, false, false, false),
             new ('2', 0, false, false, false),
             new ('R', 0, false, false, false)
             new ('R', 0, false, false, false)
         };
         };
-        expectedCki = new ConsoleKeyInfo ('\0', ConsoleKey.F3, true, false, false);
+        expectedCki = new ('\0', ConsoleKey.F3, true, false, false);
 
 
         EscSeqUtils.DecodeEscSeq (
         EscSeqUtils.DecodeEscSeq (
                                   _escSeqReqProc,
                                   _escSeqReqProc,
@@ -211,7 +208,7 @@ public class EscSeqUtilsTests
         Assert.Equal ("2", _values [^1]);
         Assert.Equal ("2", _values [^1]);
         Assert.Equal ("R", _terminating);
         Assert.Equal ("R", _terminating);
         Assert.False (_isKeyMouse);
         Assert.False (_isKeyMouse);
-        Assert.Equal (new List<MouseFlags> { 0 }, _mouseFlags);
+        Assert.Equal (new() { 0 }, _mouseFlags);
         Assert.Equal (Point.Empty, _pos);
         Assert.Equal (Point.Empty, _pos);
         Assert.False (_isReq);
         Assert.False (_isReq);
         Assert.Equal (0, (int)_arg1);
         Assert.Equal (0, (int)_arg1);
@@ -228,7 +225,7 @@ public class EscSeqUtilsTests
             new ('3', 0, false, false, false),
             new ('3', 0, false, false, false),
             new ('R', 0, false, false, false)
             new ('R', 0, false, false, false)
         };
         };
-        expectedCki = new ConsoleKeyInfo ('\0', ConsoleKey.F3, false, true, false);
+        expectedCki = new ('\0', ConsoleKey.F3, false, true, false);
 
 
         EscSeqUtils.DecodeEscSeq (
         EscSeqUtils.DecodeEscSeq (
                                   _escSeqReqProc,
                                   _escSeqReqProc,
@@ -257,7 +254,7 @@ public class EscSeqUtilsTests
         Assert.Equal ("3", _values [^1]);
         Assert.Equal ("3", _values [^1]);
         Assert.Equal ("R", _terminating);
         Assert.Equal ("R", _terminating);
         Assert.False (_isKeyMouse);
         Assert.False (_isKeyMouse);
-        Assert.Equal (new List<MouseFlags> { 0 }, _mouseFlags);
+        Assert.Equal (new() { 0 }, _mouseFlags);
         Assert.Equal (Point.Empty, _pos);
         Assert.Equal (Point.Empty, _pos);
         Assert.False (_isReq);
         Assert.False (_isReq);
         Assert.Equal (0, (int)_arg1);
         Assert.Equal (0, (int)_arg1);
@@ -274,7 +271,7 @@ public class EscSeqUtilsTests
             new ('4', 0, false, false, false),
             new ('4', 0, false, false, false),
             new ('R', 0, false, false, false)
             new ('R', 0, false, false, false)
         };
         };
-        expectedCki = new ConsoleKeyInfo ('\0', ConsoleKey.F3, true, true, false);
+        expectedCki = new ('\0', ConsoleKey.F3, true, true, false);
 
 
         EscSeqUtils.DecodeEscSeq (
         EscSeqUtils.DecodeEscSeq (
                                   _escSeqReqProc,
                                   _escSeqReqProc,
@@ -303,7 +300,7 @@ public class EscSeqUtilsTests
         Assert.Equal ("4", _values [^1]);
         Assert.Equal ("4", _values [^1]);
         Assert.Equal ("R", _terminating);
         Assert.Equal ("R", _terminating);
         Assert.False (_isKeyMouse);
         Assert.False (_isKeyMouse);
-        Assert.Equal (new List<MouseFlags> { 0 }, _mouseFlags);
+        Assert.Equal (new() { 0 }, _mouseFlags);
         Assert.Equal (Point.Empty, _pos);
         Assert.Equal (Point.Empty, _pos);
         Assert.False (_isReq);
         Assert.False (_isReq);
         Assert.Equal (0, (int)_arg1);
         Assert.Equal (0, (int)_arg1);
@@ -320,7 +317,7 @@ public class EscSeqUtilsTests
             new ('5', 0, false, false, false),
             new ('5', 0, false, false, false),
             new ('R', 0, false, false, false)
             new ('R', 0, false, false, false)
         };
         };
-        expectedCki = new ConsoleKeyInfo ('\0', ConsoleKey.F3, false, false, true);
+        expectedCki = new ('\0', ConsoleKey.F3, false, false, true);
 
 
         EscSeqUtils.DecodeEscSeq (
         EscSeqUtils.DecodeEscSeq (
                                   _escSeqReqProc,
                                   _escSeqReqProc,
@@ -349,7 +346,7 @@ public class EscSeqUtilsTests
         Assert.Equal ("5", _values [^1]);
         Assert.Equal ("5", _values [^1]);
         Assert.Equal ("R", _terminating);
         Assert.Equal ("R", _terminating);
         Assert.False (_isKeyMouse);
         Assert.False (_isKeyMouse);
-        Assert.Equal (new List<MouseFlags> { 0 }, _mouseFlags);
+        Assert.Equal (new() { 0 }, _mouseFlags);
         Assert.Equal (Point.Empty, _pos);
         Assert.Equal (Point.Empty, _pos);
         Assert.False (_isReq);
         Assert.False (_isReq);
         Assert.Equal (0, (int)_arg1);
         Assert.Equal (0, (int)_arg1);
@@ -366,7 +363,7 @@ public class EscSeqUtilsTests
             new ('6', 0, false, false, false),
             new ('6', 0, false, false, false),
             new ('R', 0, false, false, false)
             new ('R', 0, false, false, false)
         };
         };
-        expectedCki = new ConsoleKeyInfo ('\0', ConsoleKey.F3, true, false, true);
+        expectedCki = new ('\0', ConsoleKey.F3, true, false, true);
 
 
         EscSeqUtils.DecodeEscSeq (
         EscSeqUtils.DecodeEscSeq (
                                   _escSeqReqProc,
                                   _escSeqReqProc,
@@ -395,7 +392,7 @@ public class EscSeqUtilsTests
         Assert.Equal ("6", _values [^1]);
         Assert.Equal ("6", _values [^1]);
         Assert.Equal ("R", _terminating);
         Assert.Equal ("R", _terminating);
         Assert.False (_isKeyMouse);
         Assert.False (_isKeyMouse);
-        Assert.Equal (new List<MouseFlags> { 0 }, _mouseFlags);
+        Assert.Equal (new() { 0 }, _mouseFlags);
         Assert.Equal (Point.Empty, _pos);
         Assert.Equal (Point.Empty, _pos);
         Assert.False (_isReq);
         Assert.False (_isReq);
         Assert.Equal (0, (int)_arg1);
         Assert.Equal (0, (int)_arg1);
@@ -412,7 +409,7 @@ public class EscSeqUtilsTests
             new ('7', 0, false, false, false),
             new ('7', 0, false, false, false),
             new ('R', 0, false, false, false)
             new ('R', 0, false, false, false)
         };
         };
-        expectedCki = new ConsoleKeyInfo ('\0', ConsoleKey.F3, false, true, true);
+        expectedCki = new ('\0', ConsoleKey.F3, false, true, true);
 
 
         EscSeqUtils.DecodeEscSeq (
         EscSeqUtils.DecodeEscSeq (
                                   _escSeqReqProc,
                                   _escSeqReqProc,
@@ -441,7 +438,7 @@ public class EscSeqUtilsTests
         Assert.Equal ("7", _values [^1]);
         Assert.Equal ("7", _values [^1]);
         Assert.Equal ("R", _terminating);
         Assert.Equal ("R", _terminating);
         Assert.False (_isKeyMouse);
         Assert.False (_isKeyMouse);
-        Assert.Equal (new List<MouseFlags> { 0 }, _mouseFlags);
+        Assert.Equal (new() { 0 }, _mouseFlags);
         Assert.Equal (Point.Empty, _pos);
         Assert.Equal (Point.Empty, _pos);
         Assert.False (_isReq);
         Assert.False (_isReq);
         Assert.Equal (0, (int)_arg1);
         Assert.Equal (0, (int)_arg1);
@@ -458,7 +455,7 @@ public class EscSeqUtilsTests
             new ('8', 0, false, false, false),
             new ('8', 0, false, false, false),
             new ('R', 0, false, false, false)
             new ('R', 0, false, false, false)
         };
         };
-        expectedCki = new ConsoleKeyInfo ('\0', ConsoleKey.F3, true, true, true);
+        expectedCki = new ('\0', ConsoleKey.F3, true, true, true);
 
 
         EscSeqUtils.DecodeEscSeq (
         EscSeqUtils.DecodeEscSeq (
                                   _escSeqReqProc,
                                   _escSeqReqProc,
@@ -487,7 +484,7 @@ public class EscSeqUtilsTests
         Assert.Equal ("8", _values [^1]);
         Assert.Equal ("8", _values [^1]);
         Assert.Equal ("R", _terminating);
         Assert.Equal ("R", _terminating);
         Assert.False (_isKeyMouse);
         Assert.False (_isKeyMouse);
-        Assert.Equal (new List<MouseFlags> { 0 }, _mouseFlags);
+        Assert.Equal (new() { 0 }, _mouseFlags);
         Assert.Equal (Point.Empty, _pos);
         Assert.Equal (Point.Empty, _pos);
         Assert.False (_isReq);
         Assert.False (_isReq);
         Assert.Equal (0, (int)_arg1);
         Assert.Equal (0, (int)_arg1);
@@ -537,8 +534,8 @@ public class EscSeqUtilsTests
         Assert.Equal ("3", _values [^1]);
         Assert.Equal ("3", _values [^1]);
         Assert.Equal ("M", _terminating);
         Assert.Equal ("M", _terminating);
         Assert.True (_isKeyMouse);
         Assert.True (_isKeyMouse);
-        Assert.Equal (new List<MouseFlags> { MouseFlags.Button1Pressed }, _mouseFlags);
-        Assert.Equal (new Point (1, 2), _pos);
+        Assert.Equal (new() { MouseFlags.Button1Pressed }, _mouseFlags);
+        Assert.Equal (new (1, 2), _pos);
         Assert.False (_isReq);
         Assert.False (_isReq);
         Assert.Equal (0, (int)_arg1);
         Assert.Equal (0, (int)_arg1);
         Assert.Equal (Point.Empty, _arg2);
         Assert.Equal (Point.Empty, _arg2);
@@ -590,10 +587,10 @@ public class EscSeqUtilsTests
         Assert.Equal (2, _mouseFlags.Count);
         Assert.Equal (2, _mouseFlags.Count);
 
 
         Assert.Equal (
         Assert.Equal (
-                      new List<MouseFlags> { MouseFlags.Button1Released, MouseFlags.Button1Clicked },
+                      new() { MouseFlags.Button1Released, MouseFlags.Button1Clicked },
                       _mouseFlags
                       _mouseFlags
                      );
                      );
-        Assert.Equal (new Point (1, 2), _pos);
+        Assert.Equal (new (1, 2), _pos);
         Assert.False (_isReq);
         Assert.False (_isReq);
         Assert.Equal (0, (int)_arg1);
         Assert.Equal (0, (int)_arg1);
         Assert.Equal (Point.Empty, _arg2);
         Assert.Equal (Point.Empty, _arg2);
@@ -642,8 +639,8 @@ public class EscSeqUtilsTests
         Assert.Equal ("3", _values [^1]);
         Assert.Equal ("3", _values [^1]);
         Assert.Equal ("M", _terminating);
         Assert.Equal ("M", _terminating);
         Assert.True (_isKeyMouse);
         Assert.True (_isKeyMouse);
-        Assert.Equal (new List<MouseFlags> { MouseFlags.Button1DoubleClicked }, _mouseFlags);
-        Assert.Equal (new Point (1, 2), _pos);
+        Assert.Equal (new() { MouseFlags.Button1DoubleClicked }, _mouseFlags);
+        Assert.Equal (new (1, 2), _pos);
         Assert.False (_isReq);
         Assert.False (_isReq);
 
 
         ClearAll ();
         ClearAll ();
@@ -690,8 +687,8 @@ public class EscSeqUtilsTests
         Assert.Equal ("3", _values [^1]);
         Assert.Equal ("3", _values [^1]);
         Assert.Equal ("M", _terminating);
         Assert.Equal ("M", _terminating);
         Assert.True (_isKeyMouse);
         Assert.True (_isKeyMouse);
-        Assert.Equal (new List<MouseFlags> { MouseFlags.Button1TripleClicked }, _mouseFlags);
-        Assert.Equal (new Point (1, 2), _pos);
+        Assert.Equal (new() { MouseFlags.Button1TripleClicked }, _mouseFlags);
+        Assert.Equal (new (1, 2), _pos);
         Assert.False (_isReq);
         Assert.False (_isReq);
 
 
         var view = new View { Width = Dim.Fill (), Height = Dim.Fill (), WantContinuousButtonPressed = true };
         var view = new View { Width = Dim.Fill (), Height = Dim.Fill (), WantContinuousButtonPressed = true };
@@ -699,7 +696,7 @@ public class EscSeqUtilsTests
         top.Add (view);
         top.Add (view);
         Application.Begin (top);
         Application.Begin (top);
 
 
-        Application.OnMouseEvent (new MouseEvent { Position = new (0, 0), Flags = 0 });
+        Application.OnMouseEvent (new() { Position = new (0, 0), Flags = 0 });
 
 
         ClearAll ();
         ClearAll ();
 
 
@@ -745,8 +742,8 @@ public class EscSeqUtilsTests
         Assert.Equal ("3", _values [^1]);
         Assert.Equal ("3", _values [^1]);
         Assert.Equal ("M", _terminating);
         Assert.Equal ("M", _terminating);
         Assert.True (_isKeyMouse);
         Assert.True (_isKeyMouse);
-        Assert.Equal (new List<MouseFlags> { MouseFlags.Button1Pressed }, _mouseFlags);
-        Assert.Equal (new Point (1, 2), _pos);
+        Assert.Equal (new() { MouseFlags.Button1Pressed }, _mouseFlags);
+        Assert.Equal (new (1, 2), _pos);
         Assert.False (_isReq);
         Assert.False (_isReq);
 
 
         Application.Iteration += (s, a) =>
         Application.Iteration += (s, a) =>
@@ -756,18 +753,19 @@ public class EscSeqUtilsTests
                                          // set Application.WantContinuousButtonPressedView to null
                                          // set Application.WantContinuousButtonPressedView to null
                                          view.WantContinuousButtonPressed = false;
                                          view.WantContinuousButtonPressed = false;
 
 
-                                         Application.OnMouseEvent (new MouseEvent { Position = new (0, 0), Flags = 0 });
+                                         Application.OnMouseEvent (new() { Position = new (0, 0), Flags = 0 });
 
 
                                          Application.RequestStop ();
                                          Application.RequestStop ();
                                      }
                                      }
                                  };
                                  };
 
 
         Application.Run (top);
         Application.Run (top);
+        top.Dispose ();
 
 
         Assert.Null (Application.WantContinuousButtonPressedView);
         Assert.Null (Application.WantContinuousButtonPressedView);
 
 
         Assert.Equal (MouseFlags.Button1Pressed, _arg1);
         Assert.Equal (MouseFlags.Button1Pressed, _arg1);
-        Assert.Equal (new Point (1, 2), _arg2);
+        Assert.Equal (new (1, 2), _arg2);
 
 
         ClearAll ();
         ClearAll ();
 
 
@@ -813,8 +811,8 @@ public class EscSeqUtilsTests
         Assert.Equal ("3", _values [^1]);
         Assert.Equal ("3", _values [^1]);
         Assert.Equal ("m", _terminating);
         Assert.Equal ("m", _terminating);
         Assert.True (_isKeyMouse);
         Assert.True (_isKeyMouse);
-        Assert.Equal (new List<MouseFlags> { MouseFlags.Button1Released }, _mouseFlags);
-        Assert.Equal (new Point (1, 2), _pos);
+        Assert.Equal (new() { MouseFlags.Button1Released }, _mouseFlags);
+        Assert.Equal (new (1, 2), _pos);
         Assert.False (_isReq);
         Assert.False (_isReq);
         Assert.Equal (0, (int)_arg1);
         Assert.Equal (0, (int)_arg1);
         Assert.Equal (Point.Empty, _arg2);
         Assert.Equal (Point.Empty, _arg2);
@@ -822,7 +820,7 @@ public class EscSeqUtilsTests
         ClearAll ();
         ClearAll ();
 
 
         Assert.Null (_escSeqReqProc);
         Assert.Null (_escSeqReqProc);
-        _escSeqReqProc = new EscSeqRequests ();
+        _escSeqReqProc = new ();
         _escSeqReqProc.Add ("t");
         _escSeqReqProc.Add ("t");
 
 
         _cki = new ConsoleKeyInfo []
         _cki = new ConsoleKeyInfo []
@@ -870,7 +868,7 @@ public class EscSeqUtilsTests
         Assert.Equal ("20", _values [^1]);
         Assert.Equal ("20", _values [^1]);
         Assert.Equal ("t", _terminating);
         Assert.Equal ("t", _terminating);
         Assert.False (_isKeyMouse);
         Assert.False (_isKeyMouse);
-        Assert.Equal (new List<MouseFlags> { 0 }, _mouseFlags);
+        Assert.Equal (new() { 0 }, _mouseFlags);
         Assert.Equal (Point.Empty, _pos);
         Assert.Equal (Point.Empty, _pos);
         Assert.True (_isReq);
         Assert.True (_isReq);
         Assert.Equal (0, (int)_arg1);
         Assert.Equal (0, (int)_arg1);
@@ -921,48 +919,48 @@ public class EscSeqUtilsTests
         var expectedCki = new ConsoleKeyInfo ('r', 0, false, false, false);
         var expectedCki = new ConsoleKeyInfo ('r', 0, false, false, false);
         Assert.Equal (expectedCki, EscSeqUtils.MapConsoleKeyInfo (cki));
         Assert.Equal (expectedCki, EscSeqUtils.MapConsoleKeyInfo (cki));
 
 
-        cki = new ConsoleKeyInfo ('r', 0, true, false, false);
-        expectedCki = new ConsoleKeyInfo ('r', 0, true, false, false);
+        cki = new ('r', 0, true, false, false);
+        expectedCki = new ('r', 0, true, false, false);
         Assert.Equal (expectedCki, EscSeqUtils.MapConsoleKeyInfo (cki));
         Assert.Equal (expectedCki, EscSeqUtils.MapConsoleKeyInfo (cki));
 
 
-        cki = new ConsoleKeyInfo ('r', 0, false, true, false);
-        expectedCki = new ConsoleKeyInfo ('r', 0, false, true, false);
+        cki = new ('r', 0, false, true, false);
+        expectedCki = new ('r', 0, false, true, false);
         Assert.Equal (expectedCki, EscSeqUtils.MapConsoleKeyInfo (cki));
         Assert.Equal (expectedCki, EscSeqUtils.MapConsoleKeyInfo (cki));
 
 
-        cki = new ConsoleKeyInfo ('r', 0, false, false, true);
-        expectedCki = new ConsoleKeyInfo ('r', 0, false, false, true);
+        cki = new ('r', 0, false, false, true);
+        expectedCki = new ('r', 0, false, false, true);
         Assert.Equal (expectedCki, EscSeqUtils.MapConsoleKeyInfo (cki));
         Assert.Equal (expectedCki, EscSeqUtils.MapConsoleKeyInfo (cki));
 
 
-        cki = new ConsoleKeyInfo ('r', 0, true, true, false);
-        expectedCki = new ConsoleKeyInfo ('r', 0, true, true, false);
+        cki = new ('r', 0, true, true, false);
+        expectedCki = new ('r', 0, true, true, false);
         Assert.Equal (expectedCki, EscSeqUtils.MapConsoleKeyInfo (cki));
         Assert.Equal (expectedCki, EscSeqUtils.MapConsoleKeyInfo (cki));
 
 
-        cki = new ConsoleKeyInfo ('r', 0, false, true, true);
-        expectedCki = new ConsoleKeyInfo ('r', 0, false, true, true);
+        cki = new ('r', 0, false, true, true);
+        expectedCki = new ('r', 0, false, true, true);
         Assert.Equal (expectedCki, EscSeqUtils.MapConsoleKeyInfo (cki));
         Assert.Equal (expectedCki, EscSeqUtils.MapConsoleKeyInfo (cki));
 
 
-        cki = new ConsoleKeyInfo ('r', 0, true, true, true);
-        expectedCki = new ConsoleKeyInfo ('r', 0, true, true, true);
+        cki = new ('r', 0, true, true, true);
+        expectedCki = new ('r', 0, true, true, true);
         Assert.Equal (expectedCki, EscSeqUtils.MapConsoleKeyInfo (cki));
         Assert.Equal (expectedCki, EscSeqUtils.MapConsoleKeyInfo (cki));
 
 
-        cki = new ConsoleKeyInfo ('\u0012', 0, false, false, false);
-        expectedCki = new ConsoleKeyInfo ('R', ConsoleKey.R, false, false, true);
+        cki = new ('\u0012', 0, false, false, false);
+        expectedCki = new ('R', ConsoleKey.R, false, false, true);
         Assert.Equal (expectedCki, EscSeqUtils.MapConsoleKeyInfo (cki));
         Assert.Equal (expectedCki, EscSeqUtils.MapConsoleKeyInfo (cki));
 
 
-        cki = new ConsoleKeyInfo ('\0', (ConsoleKey)64, false, false, true);
-        expectedCki = new ConsoleKeyInfo (' ', ConsoleKey.Spacebar, false, false, true);
+        cki = new ('\0', (ConsoleKey)64, false, false, true);
+        expectedCki = new (' ', ConsoleKey.Spacebar, false, false, true);
         Assert.Equal (expectedCki, EscSeqUtils.MapConsoleKeyInfo (cki));
         Assert.Equal (expectedCki, EscSeqUtils.MapConsoleKeyInfo (cki));
 
 
-        cki = new ConsoleKeyInfo ('\r', 0, false, false, false);
-        expectedCki = new ConsoleKeyInfo ('\r', ConsoleKey.Enter, false, false, false);
+        cki = new ('\r', 0, false, false, false);
+        expectedCki = new ('\r', ConsoleKey.Enter, false, false, false);
         Assert.Equal (expectedCki, EscSeqUtils.MapConsoleKeyInfo (cki));
         Assert.Equal (expectedCki, EscSeqUtils.MapConsoleKeyInfo (cki));
 
 
-        cki = new ConsoleKeyInfo ('\u007f', 0, false, false, false);
-        expectedCki = new ConsoleKeyInfo ('\u007f', ConsoleKey.Backspace, false, false, false);
+        cki = new ('\u007f', 0, false, false, false);
+        expectedCki = new ('\u007f', ConsoleKey.Backspace, false, false, false);
         Assert.Equal (expectedCki, EscSeqUtils.MapConsoleKeyInfo (cki));
         Assert.Equal (expectedCki, EscSeqUtils.MapConsoleKeyInfo (cki));
 
 
-        cki = new ConsoleKeyInfo ('R', 0, false, false, false);
-        expectedCki = new ConsoleKeyInfo ('R', 0, false, false, false);
+        cki = new ('R', 0, false, false, false);
+        expectedCki = new ('R', 0, false, false, false);
         Assert.Equal (expectedCki, EscSeqUtils.MapConsoleKeyInfo (cki));
         Assert.Equal (expectedCki, EscSeqUtils.MapConsoleKeyInfo (cki));
     }
     }
 
 
@@ -1062,8 +1060,8 @@ public class EscSeqUtilsTests
             new ('M', 0, false, false, false)
             new ('M', 0, false, false, false)
         };
         };
         EscSeqUtils.GetMouse (cki, out List<MouseFlags> mouseFlags, out Point pos, ProcessContinuousButtonPressed);
         EscSeqUtils.GetMouse (cki, out List<MouseFlags> mouseFlags, out Point pos, ProcessContinuousButtonPressed);
-        Assert.Equal (new List<MouseFlags> { MouseFlags.Button1Pressed }, mouseFlags);
-        Assert.Equal (new Point (1, 2), pos);
+        Assert.Equal (new() { MouseFlags.Button1Pressed }, mouseFlags);
+        Assert.Equal (new (1, 2), pos);
 
 
         cki = new ConsoleKeyInfo []
         cki = new ConsoleKeyInfo []
         {
         {
@@ -1081,10 +1079,10 @@ public class EscSeqUtilsTests
         Assert.Equal (2, mouseFlags.Count);
         Assert.Equal (2, mouseFlags.Count);
 
 
         Assert.Equal (
         Assert.Equal (
-                      new List<MouseFlags> { MouseFlags.Button1Released, MouseFlags.Button1Clicked },
+                      new() { MouseFlags.Button1Released, MouseFlags.Button1Clicked },
                       mouseFlags
                       mouseFlags
                      );
                      );
-        Assert.Equal (new Point (1, 2), pos);
+        Assert.Equal (new (1, 2), pos);
 
 
         cki = new ConsoleKeyInfo []
         cki = new ConsoleKeyInfo []
         {
         {
@@ -1099,8 +1097,8 @@ public class EscSeqUtilsTests
             new ('M', 0, false, false, false)
             new ('M', 0, false, false, false)
         };
         };
         EscSeqUtils.GetMouse (cki, out mouseFlags, out pos, ProcessContinuousButtonPressed);
         EscSeqUtils.GetMouse (cki, out mouseFlags, out pos, ProcessContinuousButtonPressed);
-        Assert.Equal (new List<MouseFlags> { MouseFlags.Button1DoubleClicked }, mouseFlags);
-        Assert.Equal (new Point (1, 2), pos);
+        Assert.Equal (new() { MouseFlags.Button1DoubleClicked }, mouseFlags);
+        Assert.Equal (new (1, 2), pos);
 
 
         cki = new ConsoleKeyInfo []
         cki = new ConsoleKeyInfo []
         {
         {
@@ -1115,8 +1113,8 @@ public class EscSeqUtilsTests
             new ('M', 0, false, false, false)
             new ('M', 0, false, false, false)
         };
         };
         EscSeqUtils.GetMouse (cki, out mouseFlags, out pos, ProcessContinuousButtonPressed);
         EscSeqUtils.GetMouse (cki, out mouseFlags, out pos, ProcessContinuousButtonPressed);
-        Assert.Equal (new List<MouseFlags> { MouseFlags.Button1TripleClicked }, mouseFlags);
-        Assert.Equal (new Point (1, 2), pos);
+        Assert.Equal (new() { MouseFlags.Button1TripleClicked }, mouseFlags);
+        Assert.Equal (new (1, 2), pos);
 
 
         cki = new ConsoleKeyInfo []
         cki = new ConsoleKeyInfo []
         {
         {
@@ -1131,8 +1129,8 @@ public class EscSeqUtilsTests
             new ('m', 0, false, false, false)
             new ('m', 0, false, false, false)
         };
         };
         EscSeqUtils.GetMouse (cki, out mouseFlags, out pos, ProcessContinuousButtonPressed);
         EscSeqUtils.GetMouse (cki, out mouseFlags, out pos, ProcessContinuousButtonPressed);
-        Assert.Equal (new List<MouseFlags> { MouseFlags.Button1Released }, mouseFlags);
-        Assert.Equal (new Point (1, 2), pos);
+        Assert.Equal (new() { MouseFlags.Button1Released }, mouseFlags);
+        Assert.Equal (new (1, 2), pos);
     }
     }
 
 
     [Fact]
     [Fact]

+ 3 - 1
UnitTests/TestHelpers.cs

@@ -77,7 +77,7 @@ public class AutoInitShutdownAttribute : BeforeAfterTestAttribute
         if (AutoInit)
         if (AutoInit)
         {
         {
             // TODO: This Dispose call is here until all unit tests that don't correctly dispose Toplevel's they create are fixed.
             // TODO: This Dispose call is here until all unit tests that don't correctly dispose Toplevel's they create are fixed.
-            Application.Top?.Dispose ();
+            //Application.Top?.Dispose ();
             Application.Shutdown ();
             Application.Shutdown ();
 #if DEBUG_IDISPOSABLE
 #if DEBUG_IDISPOSABLE
             if (Responder.Instances.Count == 0)
             if (Responder.Instances.Count == 0)
@@ -171,6 +171,8 @@ public class SetupFakeDriverAttribute : BeforeAfterTestAttribute
         Debug.WriteLine ($"Before: {methodUnderTest.Name}");
         Debug.WriteLine ($"Before: {methodUnderTest.Name}");
         Assert.Null (Application.Driver);
         Assert.Null (Application.Driver);
         Application.Driver = new FakeDriver { Rows = 25, Cols = 25 };
         Application.Driver = new FakeDriver { Rows = 25, Cols = 25 };
+        Assert.Equal (FakeConsole.BufferWidth, Application.Driver.Cols);
+        Assert.Equal (FakeConsole.BufferHeight, Application.Driver.Rows);
         base.Before (methodUnderTest);
         base.Before (methodUnderTest);
     }
     }
 }
 }

+ 38 - 40
UnitTests/Text/AutocompleteTests.cs

@@ -3,11 +3,8 @@ using Xunit.Abstractions;
 
 
 namespace Terminal.Gui.TextTests;
 namespace Terminal.Gui.TextTests;
 
 
-public class AutocompleteTests
+public class AutocompleteTests (ITestOutputHelper output)
 {
 {
-    private readonly ITestOutputHelper _output;
-    public AutocompleteTests (ITestOutputHelper output) { _output = output; }
-
     [Fact]
     [Fact]
     [AutoInitShutdown]
     [AutoInitShutdown]
     public void CursorLeft_CursorRight_Mouse_Button_Pressed_Does_Not_Show_Popup ()
     public void CursorLeft_CursorRight_Mouse_Button_Pressed_Does_Not_Show_Popup ()
@@ -34,7 +31,7 @@ public class AutocompleteTests
                 TestHelpers.AssertDriverContentsWithFrameAre (
                 TestHelpers.AssertDriverContentsWithFrameAre (
                                                               @"
                                                               @"
 This a long line and against TextView.",
 This a long line and against TextView.",
-                                                              _output
+                                                              output
                                                              );
                                                              );
             }
             }
             else
             else
@@ -44,15 +41,15 @@ This a long line and against TextView.",
 This a long line and against TextView.
 This a long line and against TextView.
      and                              
      and                              
      against                          ",
      against                          ",
-                                                              _output
+                                                              output
                                                              );
                                                              );
             }
             }
         }
         }
 
 
         Assert.True (
         Assert.True (
                      tv.NewMouseEvent (
                      tv.NewMouseEvent (
-                                    new MouseEvent { Position = new (6, 0), Flags = MouseFlags.Button1Pressed }
-                                   )
+                                       new() { Position = new (6, 0), Flags = MouseFlags.Button1Pressed }
+                                      )
                     );
                     );
         Application.Refresh ();
         Application.Refresh ();
 
 
@@ -61,7 +58,7 @@ This a long line and against TextView.
 This a long line and against TextView.
 This a long line and against TextView.
      and                              
      and                              
      against                          ",
      against                          ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Assert.True (tv.NewKeyDownEvent (Key.G));
         Assert.True (tv.NewKeyDownEvent (Key.G));
@@ -71,7 +68,7 @@ This a long line and against TextView.
                                                       @"
                                                       @"
 This ag long line and against TextView.
 This ag long line and against TextView.
      against                           ",
      against                           ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Assert.True (tv.NewKeyDownEvent (Key.CursorLeft));
         Assert.True (tv.NewKeyDownEvent (Key.CursorLeft));
@@ -81,7 +78,7 @@ This ag long line and against TextView.
                                                       @"
                                                       @"
 This ag long line and against TextView.
 This ag long line and against TextView.
      against                           ",
      against                           ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Assert.True (tv.NewKeyDownEvent (Key.CursorLeft));
         Assert.True (tv.NewKeyDownEvent (Key.CursorLeft));
@@ -91,7 +88,7 @@ This ag long line and against TextView.
                                                       @"
                                                       @"
 This ag long line and against TextView.
 This ag long line and against TextView.
      against                           ",
      against                           ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Assert.True (tv.NewKeyDownEvent (Key.CursorLeft));
         Assert.True (tv.NewKeyDownEvent (Key.CursorLeft));
@@ -100,7 +97,7 @@ This ag long line and against TextView.
         TestHelpers.AssertDriverContentsWithFrameAre (
         TestHelpers.AssertDriverContentsWithFrameAre (
                                                       @"
                                                       @"
 This ag long line and against TextView.",
 This ag long line and against TextView.",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         for (var i = 0; i < 3; i++)
         for (var i = 0; i < 3; i++)
@@ -112,7 +109,7 @@ This ag long line and against TextView.",
                                                           @"
                                                           @"
 This ag long line and against TextView.
 This ag long line and against TextView.
      against                           ",
      against                           ",
-                                                          _output
+                                                          output
                                                          );
                                                          );
         }
         }
 
 
@@ -124,7 +121,7 @@ This ag long line and against TextView.
 This a long line and against TextView.
 This a long line and against TextView.
      and                              
      and                              
      against                          ",
      against                          ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Assert.True (tv.NewKeyDownEvent (Key.N));
         Assert.True (tv.NewKeyDownEvent (Key.N));
@@ -134,7 +131,7 @@ This a long line and against TextView.
                                                       @"
                                                       @"
 This an long line and against TextView.
 This an long line and against TextView.
      and                               ",
      and                               ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Assert.True (tv.NewKeyDownEvent (Key.CursorRight));
         Assert.True (tv.NewKeyDownEvent (Key.CursorRight));
@@ -143,8 +140,9 @@ This an long line and against TextView.
         TestHelpers.AssertDriverContentsWithFrameAre (
         TestHelpers.AssertDriverContentsWithFrameAre (
                                                       @"
                                                       @"
 This an long line and against TextView.",
 This an long line and against TextView.",
-                                                      _output
+                                                      output
                                                      );
                                                      );
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -175,7 +173,7 @@ This an long line and against TextView.",
         Assert.True (tv.NewKeyDownEvent (Key.F.WithShift));
         Assert.True (tv.NewKeyDownEvent (Key.F.WithShift));
         top.Draw ();
         top.Draw ();
         Assert.Equal ("F Fortunately super feature.", tv.Text);
         Assert.Equal ("F Fortunately super feature.", tv.Text);
-        Assert.Equal (new Point (1, 0), tv.CursorPosition);
+        Assert.Equal (new (1, 0), tv.CursorPosition);
         Assert.Equal (2, tv.Autocomplete.Suggestions.Count);
         Assert.Equal (2, tv.Autocomplete.Suggestions.Count);
         Assert.Equal ("Fortunately", tv.Autocomplete.Suggestions [0].Replacement);
         Assert.Equal ("Fortunately", tv.Autocomplete.Suggestions [0].Replacement);
         Assert.Equal ("feature", tv.Autocomplete.Suggestions [^1].Replacement);
         Assert.Equal ("feature", tv.Autocomplete.Suggestions [^1].Replacement);
@@ -184,7 +182,7 @@ This an long line and against TextView.",
         Assert.True (tv.NewKeyDownEvent (Key.CursorDown));
         Assert.True (tv.NewKeyDownEvent (Key.CursorDown));
         top.Draw ();
         top.Draw ();
         Assert.Equal ("F Fortunately super feature.", tv.Text);
         Assert.Equal ("F Fortunately super feature.", tv.Text);
-        Assert.Equal (new Point (1, 0), tv.CursorPosition);
+        Assert.Equal (new (1, 0), tv.CursorPosition);
         Assert.Equal (2, tv.Autocomplete.Suggestions.Count);
         Assert.Equal (2, tv.Autocomplete.Suggestions.Count);
         Assert.Equal ("Fortunately", tv.Autocomplete.Suggestions [0].Replacement);
         Assert.Equal ("Fortunately", tv.Autocomplete.Suggestions [0].Replacement);
         Assert.Equal ("feature", tv.Autocomplete.Suggestions [^1].Replacement);
         Assert.Equal ("feature", tv.Autocomplete.Suggestions [^1].Replacement);
@@ -193,7 +191,7 @@ This an long line and against TextView.",
         Assert.True (tv.NewKeyDownEvent (Key.CursorDown));
         Assert.True (tv.NewKeyDownEvent (Key.CursorDown));
         top.Draw ();
         top.Draw ();
         Assert.Equal ("F Fortunately super feature.", tv.Text);
         Assert.Equal ("F Fortunately super feature.", tv.Text);
-        Assert.Equal (new Point (1, 0), tv.CursorPosition);
+        Assert.Equal (new (1, 0), tv.CursorPosition);
         Assert.Equal (2, tv.Autocomplete.Suggestions.Count);
         Assert.Equal (2, tv.Autocomplete.Suggestions.Count);
         Assert.Equal ("Fortunately", tv.Autocomplete.Suggestions [0].Replacement);
         Assert.Equal ("Fortunately", tv.Autocomplete.Suggestions [0].Replacement);
         Assert.Equal ("feature", tv.Autocomplete.Suggestions [^1].Replacement);
         Assert.Equal ("feature", tv.Autocomplete.Suggestions [^1].Replacement);
@@ -202,7 +200,7 @@ This an long line and against TextView.",
         Assert.True (tv.NewKeyDownEvent (Key.CursorUp));
         Assert.True (tv.NewKeyDownEvent (Key.CursorUp));
         top.Draw ();
         top.Draw ();
         Assert.Equal ("F Fortunately super feature.", tv.Text);
         Assert.Equal ("F Fortunately super feature.", tv.Text);
-        Assert.Equal (new Point (1, 0), tv.CursorPosition);
+        Assert.Equal (new (1, 0), tv.CursorPosition);
         Assert.Equal (2, tv.Autocomplete.Suggestions.Count);
         Assert.Equal (2, tv.Autocomplete.Suggestions.Count);
         Assert.Equal ("Fortunately", tv.Autocomplete.Suggestions [0].Replacement);
         Assert.Equal ("Fortunately", tv.Autocomplete.Suggestions [0].Replacement);
         Assert.Equal ("feature", tv.Autocomplete.Suggestions [^1].Replacement);
         Assert.Equal ("feature", tv.Autocomplete.Suggestions [^1].Replacement);
@@ -211,7 +209,7 @@ This an long line and against TextView.",
         Assert.True (tv.NewKeyDownEvent (Key.CursorUp));
         Assert.True (tv.NewKeyDownEvent (Key.CursorUp));
         top.Draw ();
         top.Draw ();
         Assert.Equal ("F Fortunately super feature.", tv.Text);
         Assert.Equal ("F Fortunately super feature.", tv.Text);
-        Assert.Equal (new Point (1, 0), tv.CursorPosition);
+        Assert.Equal (new (1, 0), tv.CursorPosition);
         Assert.Equal (2, tv.Autocomplete.Suggestions.Count);
         Assert.Equal (2, tv.Autocomplete.Suggestions.Count);
         Assert.Equal ("Fortunately", tv.Autocomplete.Suggestions [0].Replacement);
         Assert.Equal ("Fortunately", tv.Autocomplete.Suggestions [0].Replacement);
         Assert.Equal ("feature", tv.Autocomplete.Suggestions [^1].Replacement);
         Assert.Equal ("feature", tv.Autocomplete.Suggestions [^1].Replacement);
@@ -219,25 +217,26 @@ This an long line and against TextView.",
         Assert.Equal ("Fortunately", tv.Autocomplete.Suggestions [tv.Autocomplete.SelectedIdx].Replacement);
         Assert.Equal ("Fortunately", tv.Autocomplete.Suggestions [tv.Autocomplete.SelectedIdx].Replacement);
         Assert.True (tv.Autocomplete.Visible);
         Assert.True (tv.Autocomplete.Visible);
         top.Draw ();
         top.Draw ();
-        Assert.True (tv.NewKeyDownEvent (new Key (tv.Autocomplete.CloseKey)));
+        Assert.True (tv.NewKeyDownEvent (new (tv.Autocomplete.CloseKey)));
         Assert.Equal ("F Fortunately super feature.", tv.Text);
         Assert.Equal ("F Fortunately super feature.", tv.Text);
-        Assert.Equal (new Point (1, 0), tv.CursorPosition);
+        Assert.Equal (new (1, 0), tv.CursorPosition);
         Assert.Empty (tv.Autocomplete.Suggestions);
         Assert.Empty (tv.Autocomplete.Suggestions);
         Assert.Equal (3, g.AllSuggestions.Count);
         Assert.Equal (3, g.AllSuggestions.Count);
         Assert.False (tv.Autocomplete.Visible);
         Assert.False (tv.Autocomplete.Visible);
         tv.PositionCursor ();
         tv.PositionCursor ();
-        Assert.True (tv.NewKeyDownEvent (new Key (tv.Autocomplete.Reopen)));
+        Assert.True (tv.NewKeyDownEvent (new (tv.Autocomplete.Reopen)));
         Assert.Equal ("F Fortunately super feature.", tv.Text);
         Assert.Equal ("F Fortunately super feature.", tv.Text);
-        Assert.Equal (new Point (1, 0), tv.CursorPosition);
+        Assert.Equal (new (1, 0), tv.CursorPosition);
         Assert.Equal (2, tv.Autocomplete.Suggestions.Count);
         Assert.Equal (2, tv.Autocomplete.Suggestions.Count);
         Assert.Equal (3, g.AllSuggestions.Count);
         Assert.Equal (3, g.AllSuggestions.Count);
-        Assert.True (tv.NewKeyDownEvent (new Key (tv.Autocomplete.SelectionKey)));
+        Assert.True (tv.NewKeyDownEvent (new (tv.Autocomplete.SelectionKey)));
         tv.PositionCursor ();
         tv.PositionCursor ();
         Assert.Equal ("Fortunately Fortunately super feature.", tv.Text);
         Assert.Equal ("Fortunately Fortunately super feature.", tv.Text);
-        Assert.Equal (new Point (11, 0), tv.CursorPosition);
+        Assert.Equal (new (11, 0), tv.CursorPosition);
         Assert.Empty (tv.Autocomplete.Suggestions);
         Assert.Empty (tv.Autocomplete.Suggestions);
         Assert.Equal (3, g.AllSuggestions.Count);
         Assert.Equal (3, g.AllSuggestions.Count);
         Assert.False (tv.Autocomplete.Visible);
         Assert.False (tv.Autocomplete.Visible);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -246,7 +245,7 @@ This an long line and against TextView.",
         var ac = new TextViewAutocomplete ();
         var ac = new TextViewAutocomplete ();
 
 
         ((SingleWordSuggestionGenerator)ac.SuggestionGenerator).AllSuggestions =
         ((SingleWordSuggestionGenerator)ac.SuggestionGenerator).AllSuggestions =
-            new List<string> { "fish", "const", "Cobble" };
+            new() { "fish", "const", "Cobble" };
 
 
         var tv = new TextView ();
         var tv = new TextView ();
         tv.InsertText ("co");
         tv.InsertText ("co");
@@ -254,10 +253,10 @@ This an long line and against TextView.",
         ac.HostControl = tv;
         ac.HostControl = tv;
 
 
         ac.GenerateSuggestions (
         ac.GenerateSuggestions (
-                                new AutocompleteContext (
-                                                         TextModel.ToRuneCellList (tv.Text),
-                                                         2
-                                                        )
+                                new (
+                                     TextModel.ToRuneCellList (tv.Text),
+                                     2
+                                    )
                                );
                                );
 
 
         Assert.Equal (2, ac.Suggestions.Count);
         Assert.Equal (2, ac.Suggestions.Count);
@@ -266,7 +265,6 @@ This an long line and against TextView.",
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown]
     public void TestSettingColorSchemeOnAutocomplete ()
     public void TestSettingColorSchemeOnAutocomplete ()
     {
     {
         var tv = new TextView ();
         var tv = new TextView ();
@@ -275,19 +273,19 @@ This an long line and against TextView.",
         Assert.Same (Colors.ColorSchemes ["Menu"], tv.Autocomplete.ColorScheme);
         Assert.Same (Colors.ColorSchemes ["Menu"], tv.Autocomplete.ColorScheme);
 
 
         // allocate a new custom scheme
         // allocate a new custom scheme
-        tv.Autocomplete.ColorScheme = new ColorScheme
+        tv.Autocomplete.ColorScheme = new()
         {
         {
-            Normal = new Attribute (Color.Black, Color.Blue), Focus = new Attribute (Color.Black, Color.Cyan)
+            Normal = new (Color.Black, Color.Blue), Focus = new (Color.Black, Color.Cyan)
         };
         };
 
 
         // should be separate instance
         // should be separate instance
         Assert.NotSame (Colors.ColorSchemes ["Menu"], tv.Autocomplete.ColorScheme);
         Assert.NotSame (Colors.ColorSchemes ["Menu"], tv.Autocomplete.ColorScheme);
 
 
         // with the values we set on it
         // with the values we set on it
-        Assert.Equal (new Color (Color.Black), tv.Autocomplete.ColorScheme.Normal.Foreground);
-        Assert.Equal (new Color (Color.Blue), tv.Autocomplete.ColorScheme.Normal.Background);
+        Assert.Equal (new (Color.Black), tv.Autocomplete.ColorScheme.Normal.Foreground);
+        Assert.Equal (new (Color.Blue), tv.Autocomplete.ColorScheme.Normal.Background);
 
 
-        Assert.Equal (new Color (Color.Black), tv.Autocomplete.ColorScheme.Focus.Foreground);
-        Assert.Equal (new Color (Color.Cyan), tv.Autocomplete.ColorScheme.Focus.Background);
+        Assert.Equal (new (Color.Black), tv.Autocomplete.ColorScheme.Focus.Foreground);
+        Assert.Equal (new (Color.Cyan), tv.Autocomplete.ColorScheme.Focus.Background);
     }
     }
 }
 }

+ 2 - 21
UnitTests/UICatalog/ScenarioTests.cs

@@ -107,7 +107,6 @@ public class ScenarioTests : TestsAllViews
 
 
         // Settings
         // Settings
         FrameView _settingsPane;
         FrameView _settingsPane;
-        CheckBox _computedCheckBox;
         FrameView _locationFrame;
         FrameView _locationFrame;
         RadioGroup _xRadioGroup;
         RadioGroup _xRadioGroup;
         TextField _xText;
         TextField _xText;
@@ -165,15 +164,13 @@ public class ScenarioTests : TestsAllViews
             ColorScheme = Colors.ColorSchemes ["TopLevel"],
             ColorScheme = Colors.ColorSchemes ["TopLevel"],
             Title = "Settings"
             Title = "Settings"
         };
         };
-        _computedCheckBox = new () { X = 0, Y = 0, Text = "Computed Layout", Checked = true };
-        _settingsPane.Add (_computedCheckBox);
 
 
         var radioItems = new [] { "Percent(x)", "AnchorEnd(x)", "Center", "Absolute(x)" };
         var radioItems = new [] { "Percent(x)", "AnchorEnd(x)", "Center", "Absolute(x)" };
 
 
         _locationFrame = new ()
         _locationFrame = new ()
         {
         {
-            X = Pos.Left (_computedCheckBox),
-            Y = Pos.Bottom (_computedCheckBox),
+            X = 0,
+            Y = 0,
             Height = 3 + radioItems.Length,
             Height = 3 + radioItems.Length,
             Width = 36,
             Width = 36,
             Title = "Location (Pos)"
             Title = "Location (Pos)"
@@ -250,15 +247,6 @@ public class ScenarioTests : TestsAllViews
                                                   _curView = CreateClass (_viewClasses.Values.ToArray () [_classListView.SelectedItem]);
                                                   _curView = CreateClass (_viewClasses.Values.ToArray () [_classListView.SelectedItem]);
                                               };
                                               };
 
 
-        _computedCheckBox.Toggled += (s, e) =>
-                                     {
-                                         if (_curView != null)
-                                         {
-                                             //_curView.LayoutStyle = e.OldValue == true ? LayoutStyle.Absolute : LayoutStyle.Computed;
-                                             _hostPane.LayoutSubviews ();
-                                         }
-                                     };
-
         _xRadioGroup.SelectedItemChanged += (s, selected) => DimPosChanged (_curView);
         _xRadioGroup.SelectedItemChanged += (s, selected) => DimPosChanged (_curView);
 
 
         _xText.TextChanged += (s, args) =>
         _xText.TextChanged += (s, args) =>
@@ -352,12 +340,8 @@ public class ScenarioTests : TestsAllViews
                 return;
                 return;
             }
             }
 
 
-            LayoutStyle layout = view.LayoutStyle;
-
             try
             try
             {
             {
-                //view.LayoutStyle = LayoutStyle.Absolute;
-
                 switch (_xRadioGroup.SelectedItem)
                 switch (_xRadioGroup.SelectedItem)
                 {
                 {
                     case 0:
                     case 0:
@@ -532,9 +516,6 @@ public class ScenarioTests : TestsAllViews
                 view?.GetType ().GetProperty ("Source")?.GetSetMethod ()?.Invoke (view, new [] { source });
                 view?.GetType ().GetProperty ("Source")?.GetSetMethod ()?.Invoke (view, new [] { source });
             }
             }
 
 
-            // Set Settings
-            _computedCheckBox.Checked = view.LayoutStyle == LayoutStyle.Computed;
-
             // Add
             // Add
             _hostPane.Add (view);
             _hostPane.Add (view);
 
 

+ 58 - 53
UnitTests/View/Adornment/BorderTests.cs

@@ -2,11 +2,8 @@
 
 
 namespace Terminal.Gui.ViewTests;
 namespace Terminal.Gui.ViewTests;
 
 
-public class BorderTests
+public class BorderTests (ITestOutputHelper output)
 {
 {
-    private readonly ITestOutputHelper _output;
-    public BorderTests (ITestOutputHelper output) { _output = output; }
-
     [Fact]
     [Fact]
     [SetupFakeDriver]
     [SetupFakeDriver]
     public void Border_Parent_HasFocus_Title_Uses_FocusAttribute ()
     public void Border_Parent_HasFocus_Title_Uses_FocusAttribute ()
@@ -18,13 +15,13 @@ public class BorderTests
         var view = new View { Title = "A", Height = 2, Width = 5 };
         var view = new View { Title = "A", Height = 2, Width = 5 };
         superView.Add (view);
         superView.Add (view);
 
 
-        view.Border.Thickness = new Thickness (0, 1, 0, 0);
+        view.Border.Thickness = new (0, 1, 0, 0);
         view.Border.LineStyle = LineStyle.Single;
         view.Border.LineStyle = LineStyle.Single;
 
 
-        view.ColorScheme = new ColorScheme
+        view.ColorScheme = new()
         {
         {
-            Normal = new Attribute (Color.Red, Color.Green), 
-            Focus = new Attribute (Color.Green, Color.Red)
+            Normal = new (Color.Red, Color.Green),
+            Focus = new (Color.Green, Color.Red)
         };
         };
         Assert.NotEqual (view.ColorScheme.Normal.Foreground, view.ColorScheme.Focus.Foreground);
         Assert.NotEqual (view.ColorScheme.Normal.Foreground, view.ColorScheme.Focus.Foreground);
         Assert.Equal (ColorName.Red, view.Border.GetNormalColor ().Foreground.GetClosestNamedColor ());
         Assert.Equal (ColorName.Red, view.Border.GetNormalColor ().Foreground.GetClosestNamedColor ());
@@ -36,7 +33,7 @@ public class BorderTests
         superView.Draw ();
         superView.Draw ();
 
 
         var expected = @"─┤A├─";
         var expected = @"─┤A├─";
-        TestHelpers.AssertDriverContentsAre (expected, _output);
+        TestHelpers.AssertDriverContentsAre (expected, output);
         TestHelpers.AssertDriverAttributesAre ("00000", null, view.ColorScheme.Normal);
         TestHelpers.AssertDriverAttributesAre ("00000", null, view.ColorScheme.Normal);
 
 
         view.CanFocus = true;
         view.CanFocus = true;
@@ -53,12 +50,12 @@ public class BorderTests
     public void Border_Uses_Parent_ColorScheme ()
     public void Border_Uses_Parent_ColorScheme ()
     {
     {
         var view = new View { Title = "A", Height = 2, Width = 5 };
         var view = new View { Title = "A", Height = 2, Width = 5 };
-        view.Border.Thickness = new Thickness (0, 1, 0, 0);
+        view.Border.Thickness = new (0, 1, 0, 0);
         view.Border.LineStyle = LineStyle.Single;
         view.Border.LineStyle = LineStyle.Single;
 
 
-        view.ColorScheme = new ColorScheme
+        view.ColorScheme = new()
         {
         {
-            Normal = new Attribute (Color.Red, Color.Green), Focus = new Attribute (Color.Green, Color.Red)
+            Normal = new (Color.Red, Color.Green), Focus = new (Color.Green, Color.Red)
         };
         };
         Assert.Equal (ColorName.Red, view.Border.GetNormalColor ().Foreground.GetClosestNamedColor ());
         Assert.Equal (ColorName.Red, view.Border.GetNormalColor ().Foreground.GetClosestNamedColor ());
         Assert.Equal (ColorName.Green, view.Border.GetFocusColor ().Foreground.GetClosestNamedColor ());
         Assert.Equal (ColorName.Green, view.Border.GetFocusColor ().Foreground.GetClosestNamedColor ());
@@ -70,7 +67,7 @@ public class BorderTests
         view.Draw ();
         view.Draw ();
 
 
         var expected = @"─┤A├─";
         var expected = @"─┤A├─";
-        TestHelpers.AssertDriverContentsAre (expected, _output);
+        TestHelpers.AssertDriverContentsAre (expected, output);
         TestHelpers.AssertDriverAttributesAre ("00000", null, view.ColorScheme.Normal);
         TestHelpers.AssertDriverAttributesAre ("00000", null, view.ColorScheme.Normal);
     }
     }
 
 
@@ -105,7 +102,7 @@ public class BorderTests
         switch (width)
         switch (width)
         {
         {
             case 1:
             case 1:
-                Assert.Equal (new Rectangle (0, 0, 1, 5), win.Frame);
+                Assert.Equal (new (0, 0, 1, 5), win.Frame);
 
 
                 expected = @"
                 expected = @"
@@ -114,7 +111,7 @@ public class BorderTests
 
 
                 break;
                 break;
             case 2:
             case 2:
-                Assert.Equal (new Rectangle (0, 0, 2, 5), win.Frame);
+                Assert.Equal (new (0, 0, 2, 5), win.Frame);
 
 
                 expected = @"
                 expected = @"
 ╔╗
 ╔╗
@@ -123,7 +120,7 @@ public class BorderTests
 
 
                 break;
                 break;
             case 3:
             case 3:
-                Assert.Equal (new Rectangle (0, 0, 3, 5), win.Frame);
+                Assert.Equal (new (0, 0, 3, 5), win.Frame);
 
 
                 expected = @"
                 expected = @"
 ╔═╗
 ╔═╗
@@ -132,7 +129,7 @@ public class BorderTests
 
 
                 break;
                 break;
             case 4:
             case 4:
-                Assert.Equal (new Rectangle (0, 0, 4, 5), win.Frame);
+                Assert.Equal (new (0, 0, 4, 5), win.Frame);
 
 
                 expected = @"
                 expected = @"
  ╒╕ 
  ╒╕ 
@@ -142,7 +139,7 @@ public class BorderTests
 
 
                 break;
                 break;
             case 5:
             case 5:
-                Assert.Equal (new Rectangle (0, 0, 5, 5), win.Frame);
+                Assert.Equal (new (0, 0, 5, 5), win.Frame);
 
 
                 expected = @"
                 expected = @"
  ╒═╕ 
  ╒═╕ 
@@ -152,7 +149,7 @@ public class BorderTests
 
 
                 break;
                 break;
             case 6:
             case 6:
-                Assert.Equal (new Rectangle (0, 0, 6, 5), win.Frame);
+                Assert.Equal (new (0, 0, 6, 5), win.Frame);
 
 
                 expected = @"
                 expected = @"
  ╒══╕ 
  ╒══╕ 
@@ -162,7 +159,7 @@ public class BorderTests
 
 
                 break;
                 break;
             case 7:
             case 7:
-                Assert.Equal (new Rectangle (0, 0, 7, 5), win.Frame);
+                Assert.Equal (new (0, 0, 7, 5), win.Frame);
 
 
                 expected = @"
                 expected = @"
  ╒═══╕ 
  ╒═══╕ 
@@ -172,7 +169,7 @@ public class BorderTests
 
 
                 break;
                 break;
             case 8:
             case 8:
-                Assert.Equal (new Rectangle (0, 0, 8, 5), win.Frame);
+                Assert.Equal (new (0, 0, 8, 5), win.Frame);
 
 
                 expected = @"
                 expected = @"
  ╒════╕ 
  ╒════╕ 
@@ -182,7 +179,7 @@ public class BorderTests
 
 
                 break;
                 break;
             case 9:
             case 9:
-                Assert.Equal (new Rectangle (0, 0, 9, 5), win.Frame);
+                Assert.Equal (new (0, 0, 9, 5), win.Frame);
 
 
                 expected = @"
                 expected = @"
  ╒════╕  
  ╒════╕  
@@ -192,7 +189,7 @@ public class BorderTests
 
 
                 break;
                 break;
             case 10:
             case 10:
-                Assert.Equal (new Rectangle (0, 0, 10, 5), win.Frame);
+                Assert.Equal (new (0, 0, 10, 5), win.Frame);
 
 
                 expected = @"
                 expected = @"
  ╒════╕   
  ╒════╕   
@@ -203,8 +200,9 @@ public class BorderTests
                 break;
                 break;
         }
         }
 
 
-        _ = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        _ = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Application.End (rs);
         Application.End (rs);
+        win.Dispose ();
     }
     }
 
 
     [Theory]
     [Theory]
@@ -238,7 +236,7 @@ public class BorderTests
         switch (width)
         switch (width)
         {
         {
             case 1:
             case 1:
-                Assert.Equal (new Rectangle (0, 0, 1, 4), win.Frame);
+                Assert.Equal (new (0, 0, 1, 4), win.Frame);
 
 
                 expected = @"
                 expected = @"
@@ -247,7 +245,7 @@ public class BorderTests
 
 
                 break;
                 break;
             case 2:
             case 2:
-                Assert.Equal (new Rectangle (0, 0, 2, 4), win.Frame);
+                Assert.Equal (new (0, 0, 2, 4), win.Frame);
 
 
                 expected = @"
                 expected = @"
 ╔╗
 ╔╗
@@ -256,7 +254,7 @@ public class BorderTests
 
 
                 break;
                 break;
             case 3:
             case 3:
-                Assert.Equal (new Rectangle (0, 0, 3, 4), win.Frame);
+                Assert.Equal (new (0, 0, 3, 4), win.Frame);
 
 
                 expected = @"
                 expected = @"
 ╔═╗
 ╔═╗
@@ -265,7 +263,7 @@ public class BorderTests
 
 
                 break;
                 break;
             case 4:
             case 4:
-                Assert.Equal (new Rectangle (0, 0, 4, 4), win.Frame);
+                Assert.Equal (new (0, 0, 4, 4), win.Frame);
 
 
                 expected = @"
                 expected = @"
  ╒╕ 
  ╒╕ 
@@ -275,7 +273,7 @@ public class BorderTests
 
 
                 break;
                 break;
             case 5:
             case 5:
-                Assert.Equal (new Rectangle (0, 0, 5, 4), win.Frame);
+                Assert.Equal (new (0, 0, 5, 4), win.Frame);
 
 
                 expected = @"
                 expected = @"
  ╒═╕ 
  ╒═╕ 
@@ -285,7 +283,7 @@ public class BorderTests
 
 
                 break;
                 break;
             case 6:
             case 6:
-                Assert.Equal (new Rectangle (0, 0, 6, 4), win.Frame);
+                Assert.Equal (new (0, 0, 6, 4), win.Frame);
 
 
                 expected = @"
                 expected = @"
  ╒══╕ 
  ╒══╕ 
@@ -295,7 +293,7 @@ public class BorderTests
 
 
                 break;
                 break;
             case 7:
             case 7:
-                Assert.Equal (new Rectangle (0, 0, 7, 4), win.Frame);
+                Assert.Equal (new (0, 0, 7, 4), win.Frame);
 
 
                 expected = @"
                 expected = @"
  ╒═══╕ 
  ╒═══╕ 
@@ -305,7 +303,7 @@ public class BorderTests
 
 
                 break;
                 break;
             case 8:
             case 8:
-                Assert.Equal (new Rectangle (0, 0, 8, 4), win.Frame);
+                Assert.Equal (new (0, 0, 8, 4), win.Frame);
 
 
                 expected = @"
                 expected = @"
  ╒════╕ 
  ╒════╕ 
@@ -315,7 +313,7 @@ public class BorderTests
 
 
                 break;
                 break;
             case 9:
             case 9:
-                Assert.Equal (new Rectangle (0, 0, 9, 4), win.Frame);
+                Assert.Equal (new (0, 0, 9, 4), win.Frame);
 
 
                 expected = @"
                 expected = @"
  ╒════╕  
  ╒════╕  
@@ -325,7 +323,7 @@ public class BorderTests
 
 
                 break;
                 break;
             case 10:
             case 10:
-                Assert.Equal (new Rectangle (0, 0, 10, 4), win.Frame);
+                Assert.Equal (new (0, 0, 10, 4), win.Frame);
 
 
                 expected = @"
                 expected = @"
  ╒════╕   
  ╒════╕   
@@ -336,8 +334,9 @@ public class BorderTests
                 break;
                 break;
         }
         }
 
 
-        _ = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        _ = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Application.End (rs);
         Application.End (rs);
+        win.Dispose ();
     }
     }
 
 
     [Theory]
     [Theory]
@@ -371,7 +370,7 @@ public class BorderTests
         switch (width)
         switch (width)
         {
         {
             case 1:
             case 1:
-                Assert.Equal (new Rectangle (0, 0, 1, 4), win.Frame);
+                Assert.Equal (new (0, 0, 1, 4), win.Frame);
 
 
                 expected = @"
                 expected = @"
@@ -380,7 +379,7 @@ public class BorderTests
 
 
                 break;
                 break;
             case 2:
             case 2:
-                Assert.Equal (new Rectangle (0, 0, 2, 4), win.Frame);
+                Assert.Equal (new (0, 0, 2, 4), win.Frame);
 
 
                 expected = @"
                 expected = @"
 ╔╗
 ╔╗
@@ -389,7 +388,7 @@ public class BorderTests
 
 
                 break;
                 break;
             case 3:
             case 3:
-                Assert.Equal (new Rectangle (0, 0, 3, 4), win.Frame);
+                Assert.Equal (new (0, 0, 3, 4), win.Frame);
 
 
                 expected = @"
                 expected = @"
 ╔═╗
 ╔═╗
@@ -398,7 +397,7 @@ public class BorderTests
 
 
                 break;
                 break;
             case 4:
             case 4:
-                Assert.Equal (new Rectangle (0, 0, 4, 4), win.Frame);
+                Assert.Equal (new (0, 0, 4, 4), win.Frame);
 
 
                 expected = @"
                 expected = @"
  ╒╕ 
  ╒╕ 
@@ -408,7 +407,7 @@ public class BorderTests
 
 
                 break;
                 break;
             case 5:
             case 5:
-                Assert.Equal (new Rectangle (0, 0, 5, 4), win.Frame);
+                Assert.Equal (new (0, 0, 5, 4), win.Frame);
 
 
                 expected = @"
                 expected = @"
  ╒═╕ 
  ╒═╕ 
@@ -418,7 +417,7 @@ public class BorderTests
 
 
                 break;
                 break;
             case 6:
             case 6:
-                Assert.Equal (new Rectangle (0, 0, 6, 4), win.Frame);
+                Assert.Equal (new (0, 0, 6, 4), win.Frame);
 
 
                 expected = @"
                 expected = @"
  ╒══╕ 
  ╒══╕ 
@@ -428,7 +427,7 @@ public class BorderTests
 
 
                 break;
                 break;
             case 7:
             case 7:
-                Assert.Equal (new Rectangle (0, 0, 7, 4), win.Frame);
+                Assert.Equal (new (0, 0, 7, 4), win.Frame);
 
 
                 expected = @"
                 expected = @"
  ╒═══╕ 
  ╒═══╕ 
@@ -438,7 +437,7 @@ public class BorderTests
 
 
                 break;
                 break;
             case 8:
             case 8:
-                Assert.Equal (new Rectangle (0, 0, 8, 4), win.Frame);
+                Assert.Equal (new (0, 0, 8, 4), win.Frame);
 
 
                 expected = @"
                 expected = @"
  ╒════╕ 
  ╒════╕ 
@@ -448,7 +447,7 @@ public class BorderTests
 
 
                 break;
                 break;
             case 9:
             case 9:
-                Assert.Equal (new Rectangle (0, 0, 9, 4), win.Frame);
+                Assert.Equal (new (0, 0, 9, 4), win.Frame);
 
 
                 expected = @"
                 expected = @"
  ╒════╕  
  ╒════╕  
@@ -458,7 +457,7 @@ public class BorderTests
 
 
                 break;
                 break;
             case 10:
             case 10:
-                Assert.Equal (new Rectangle (0, 0, 10, 4), win.Frame);
+                Assert.Equal (new (0, 0, 10, 4), win.Frame);
 
 
                 expected = @"
                 expected = @"
  ╒════╕   
  ╒════╕   
@@ -469,8 +468,9 @@ public class BorderTests
                 break;
                 break;
         }
         }
 
 
-        _ = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        _ = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Application.End (rs);
         Application.End (rs);
+        win.Dispose ();
     }
     }
 
 
     [Theory]
     [Theory]
@@ -523,8 +523,9 @@ public class BorderTests
                 break;
                 break;
         }
         }
 
 
-        _ = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        _ = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Application.End (rs);
         Application.End (rs);
+        win.Dispose ();
     }
     }
 
 
     [Theory]
     [Theory]
@@ -636,7 +637,8 @@ public class BorderTests
                 break;
                 break;
         }
         }
 
 
-        _ = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        _ = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+        win.Dispose ();
     }
     }
 
 
     [Theory]
     [Theory]
@@ -736,8 +738,9 @@ public class BorderTests
 ║└─┘║
 ║└─┘║
 ╚═══╝";
 ╚═══╝";
 
 
-        _ = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        _ = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Application.End (rs);
         Application.End (rs);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -762,8 +765,9 @@ public class BorderTests
 ║└──────┘║
 ║└──────┘║
 ╚════════╝";
 ╚════════╝";
 
 
-        _ = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        _ = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Application.End (rs);
         Application.End (rs);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -783,7 +787,8 @@ public class BorderTests
 │ │
 │ │
 └─┘";
 └─┘";
 
 
-        _ = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        _ = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+        win.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -801,11 +806,11 @@ public class BorderTests
         var view = new View ();
         var view = new View ();
         view.BorderStyle = LineStyle.Single;
         view.BorderStyle = LineStyle.Single;
         Assert.Equal (LineStyle.Single, view.BorderStyle);
         Assert.Equal (LineStyle.Single, view.BorderStyle);
-        Assert.Equal (new Thickness (1), view.Border.Thickness);
+        Assert.Equal (new (1), view.Border.Thickness);
 
 
         view.BorderStyle = LineStyle.Double;
         view.BorderStyle = LineStyle.Double;
         Assert.Equal (LineStyle.Double, view.BorderStyle);
         Assert.Equal (LineStyle.Double, view.BorderStyle);
-        Assert.Equal (new Thickness (1), view.Border.Thickness);
+        Assert.Equal (new (1), view.Border.Thickness);
 
 
         view.BorderStyle = LineStyle.None;
         view.BorderStyle = LineStyle.None;
         Assert.Equal (LineStyle.None, view.BorderStyle);
         Assert.Equal (LineStyle.None, view.BorderStyle);

+ 2 - 5
UnitTests/View/Adornment/MarginTests.cs

@@ -2,11 +2,8 @@
 
 
 namespace Terminal.Gui.ViewTests;
 namespace Terminal.Gui.ViewTests;
 
 
-public class MarginTests
+public class MarginTests (ITestOutputHelper output)
 {
 {
-    private readonly ITestOutputHelper _output;
-    public MarginTests (ITestOutputHelper output) { _output = output; }
-
     [Fact]
     [Fact]
     [SetupFakeDriver]
     [SetupFakeDriver]
     public void Margin_Uses_SuperView_ColorScheme ()
     public void Margin_Uses_SuperView_ColorScheme ()
@@ -39,7 +36,7 @@ public class MarginTests
 MMM
 MMM
 M M
 M M
 MMM",
 MMM",
-                                             _output
+                                             output
                                             );
                                             );
         TestHelpers.AssertDriverAttributesAre ("0", null, superView.GetNormalColor ());
         TestHelpers.AssertDriverAttributesAre ("0", null, superView.GetNormalColor ());
     }
     }

+ 5 - 8
UnitTests/View/Adornment/PaddingTests.cs

@@ -2,22 +2,19 @@
 
 
 namespace Terminal.Gui.ViewTests;
 namespace Terminal.Gui.ViewTests;
 
 
-public class PaddingTests
+public class PaddingTests (ITestOutputHelper output)
 {
 {
-    private readonly ITestOutputHelper _output;
-    public PaddingTests (ITestOutputHelper output) { _output = output; }
-
     [Fact]
     [Fact]
     [SetupFakeDriver]
     [SetupFakeDriver]
     public void Padding_Uses_Parent_ColorScheme ()
     public void Padding_Uses_Parent_ColorScheme ()
     {
     {
         ((FakeDriver)Application.Driver).SetBufferSize (5, 5);
         ((FakeDriver)Application.Driver).SetBufferSize (5, 5);
         var view = new View { Height = 3, Width = 3 };
         var view = new View { Height = 3, Width = 3 };
-        view.Padding.Thickness = new Thickness (1);
+        view.Padding.Thickness = new (1);
 
 
-        view.ColorScheme = new ColorScheme
+        view.ColorScheme = new()
         {
         {
-            Normal = new Attribute (Color.Red, Color.Green), Focus = new Attribute (Color.Green, Color.Red)
+            Normal = new (Color.Red, Color.Green), Focus = new (Color.Green, Color.Red)
         };
         };
 
 
         Assert.Equal (ColorName.Red, view.Padding.GetNormalColor ().Foreground.GetClosestNamedColor ());
         Assert.Equal (ColorName.Red, view.Padding.GetNormalColor ().Foreground.GetClosestNamedColor ());
@@ -34,7 +31,7 @@ public class PaddingTests
 PPP
 PPP
 P P
 P P
 PPP",
 PPP",
-                                             _output
+                                             output
                                             );
                                             );
         TestHelpers.AssertDriverAttributesAre ("0", null, view.GetNormalColor ());
         TestHelpers.AssertDriverAttributesAre ("0", null, view.GetNormalColor ());
     }
     }

+ 7 - 6
UnitTests/View/DiagnosticsTests.cs

@@ -4,21 +4,22 @@ using Xunit.Abstractions;
 namespace Terminal.Gui.ViewTests;
 namespace Terminal.Gui.ViewTests;
 
 
 /// <summary>
 /// <summary>
-/// Tests <see cref="View.Diagnostics"/> static property and <see cref="ViewDiagnosticFlags"/> enum.
+///     Tests <see cref="View.Diagnostics"/> static property and <see cref="ViewDiagnosticFlags"/> enum.
 /// </summary>
 /// </summary>
 /// <param name="output"></param>
 /// <param name="output"></param>
-[Trait("Category","Output")]
-public class DiagnosticTests (ITestOutputHelper output)
+[Trait ("Category", "Output")]
+public class DiagnosticTests ()
 {
 {
     /// <summary>
     /// <summary>
-    ///    /// Tests <see cref="View.Diagnostics"/> static property and <see cref="ViewDiagnosticFlags"/> enum.
-    ///    /// </summary>
+    ///     /// Tests <see cref="View.Diagnostics"/> static property and <see cref="ViewDiagnosticFlags"/> enum.
+    ///     ///
+    /// </summary>
     [Fact]
     [Fact]
     public void Diagnostics_Sets ()
     public void Diagnostics_Sets ()
     {
     {
         // View.Diagnostics is a static property that returns the current diagnostic flags.
         // View.Diagnostics is a static property that returns the current diagnostic flags.
         Assert.Equal (ViewDiagnosticFlags.Off, View.Diagnostics);
         Assert.Equal (ViewDiagnosticFlags.Off, View.Diagnostics);
-    
+
         // View.Diagnostics can be set to a new value.
         // View.Diagnostics can be set to a new value.
         View.Diagnostics = ViewDiagnosticFlags.Padding;
         View.Diagnostics = ViewDiagnosticFlags.Padding;
         Assert.Equal (ViewDiagnosticFlags.Padding, View.Diagnostics);
         Assert.Equal (ViewDiagnosticFlags.Padding, View.Diagnostics);

+ 17 - 14
UnitTests/View/DrawTests.cs

@@ -155,12 +155,9 @@ public class DrawTests (ITestOutputHelper _output)
                                                       _output);
                                                       _output);
     }
     }
 
 
-    [Theory]
-    [InlineData (0, 0, 1, 1)]
-    [InlineData (0, 0, 2, 2)]
-    [InlineData (-1, -1, 2, 2)]
+    [Fact]
     [SetupFakeDriver]
     [SetupFakeDriver]
-    public void Clear_ClearsEntireViewport (int x, int y, int width, int height)
+    public void Clear_ClearsEntireViewport ()
     {
     {
         var superView = new View { Width = Dim.Fill (), Height = Dim.Fill () };
         var superView = new View { Width = Dim.Fill (), Height = Dim.Fill () };
 
 
@@ -193,12 +190,9 @@ public class DrawTests (ITestOutputHelper _output)
                                                       _output);
                                                       _output);
     }
     }
 
 
-    [Theory]
-    [InlineData (0, 0, 1, 1)]
-    [InlineData (0, 0, 2, 2)]
-    [InlineData (-1, -1, 2, 2)]
+    [Fact]
     [SetupFakeDriver]
     [SetupFakeDriver]
-    public void Clear_WithClearVisibleContentOnly_ClearsVisibleContentOnly (int x, int y, int width, int height)
+    public void Clear_WithClearVisibleContentOnly_ClearsVisibleContentOnly ()
     {
     {
         var superView = new View { Width = Dim.Fill (), Height = Dim.Fill () };
         var superView = new View { Width = Dim.Fill (), Height = Dim.Fill () };
 
 
@@ -270,6 +264,7 @@ public class DrawTests (ITestOutputHelper _output)
         TestHelpers.AssertDriverContentsAre (expectedOutput, _output);
         TestHelpers.AssertDriverContentsAre (expectedOutput, _output);
 
 
         // This test has nothing to do with color - removing as it is not relevant and fragile
         // This test has nothing to do with color - removing as it is not relevant and fragile
+        top.Dispose ();
     }
     }
 
 
     // TODO: Refactor this test to not depend on TextView etc... Make it as primitive as possible
     // TODO: Refactor this test to not depend on TextView etc... Make it as primitive as possible
@@ -326,7 +321,9 @@ public class DrawTests (ITestOutputHelper _output)
         Assert.Equal (new Rectangle (0, 0, 30, 10), pos);
         Assert.Equal (new Rectangle (0, 0, 30, 10), pos);
 
 
         Application.End (rsDiag);
         Application.End (rsDiag);
+        dg.Dispose ();
         Application.End (rsTop);
         Application.End (rsTop);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -385,8 +382,9 @@ public class DrawTests (ITestOutputHelper _output)
                                                0
                                                0
                                                """,
                                                """,
                                                Application.Driver,
                                                Application.Driver,
-                                               Colors.ColorSchemes ["Base"].Normal
+                                               Colors.ColorSchemes ["Base"]!.Normal
                                               );
                                               );
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -647,6 +645,7 @@ public class DrawTests (ITestOutputHelper _output)
         content.Y = 0;
         content.Y = 0;
         Application.Refresh ();
         Application.Refresh ();
         TestHelpers.AssertDriverContentsWithFrameAre ("", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ("", _output);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -681,8 +680,6 @@ public class DrawTests (ITestOutputHelper _output)
 
 
         // BUGBUG: v2 - it's bogus to reference .Frame before BeginInit. And why is the clip being set anyway???
         // BUGBUG: v2 - it's bogus to reference .Frame before BeginInit. And why is the clip being set anyway???
 
 
-        void Top_LayoutComplete (object sender, LayoutEventArgs e) { Application.Driver.Clip = container.Frame; }
-
         top.LayoutComplete += Top_LayoutComplete;
         top.LayoutComplete += Top_LayoutComplete;
         Application.Begin (top);
         Application.Begin (top);
 
 
@@ -726,6 +723,11 @@ public class DrawTests (ITestOutputHelper _output)
         content.Y = 0;
         content.Y = 0;
         Application.Refresh ();
         Application.Refresh ();
         TestHelpers.AssertDriverContentsWithFrameAre ("", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ("", _output);
+        top.Dispose ();
+
+        return;
+
+        void Top_LayoutComplete (object? sender, LayoutEventArgs e) { Application.Driver.Clip = container.Frame; }
     }
     }
 
 
     [Fact]
     [Fact]
@@ -849,6 +851,7 @@ public class DrawTests (ITestOutputHelper _output)
         content.Y = 0;
         content.Y = 0;
         Application.Refresh ();
         Application.Refresh ();
         TestHelpers.AssertDriverContentsWithFrameAre ("", _output);
         TestHelpers.AssertDriverContentsWithFrameAre ("", _output);
+        top.Dispose ();
     }
     }
 
 
     [Theory]
     [Theory]
@@ -898,7 +901,7 @@ public class DrawTests (ITestOutputHelper _output)
         TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
         TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
 
 
         TestHelpers.AssertDriverContentsAre (expected, _output);
         TestHelpers.AssertDriverContentsAre (expected, _output);
-
+        top.Dispose ();
         // This test has nothing to do with color - removing as it is not relevant and fragile
         // This test has nothing to do with color - removing as it is not relevant and fragile
     }
     }
 
 

+ 4 - 4
UnitTests/View/InitTests.cs

@@ -125,11 +125,11 @@ public class InitTests
         var superView = new View ();
         var superView = new View ();
         superView.Add (view);
         superView.Add (view);
 
 
-        var initialized = false;
-        view.Initialized += (s, e) => initialized = true;
+        //var initialized = false;
+        //view.Initialized += (s, e) => initialized = true;
 
 
-        var superViewInitialized = false;
-        superView.Initialized += (s, e) => superViewInitialized = true;
+        //var superViewInitialized = false;
+        //superView.Initialized += (s, e) => superViewInitialized = true;
 
 
         Assert.False (view.IsInitialized, "View should not be initialized");
         Assert.False (view.IsInitialized, "View should not be initialized");
         Assert.False (superView.IsInitialized, "SuperView should not be initialized");
         Assert.False (superView.IsInitialized, "SuperView should not be initialized");

+ 28 - 65
UnitTests/View/Layout/AbsoluteLayoutTests.cs

@@ -1,16 +1,10 @@
 using Xunit.Abstractions;
 using Xunit.Abstractions;
 
 
-//using GraphViewTests = Terminal.Gui.Views.GraphViewTests;
-
-// Alias Console to MockConsole so we don't accidentally use Console
-
 namespace Terminal.Gui.LayoutTests;
 namespace Terminal.Gui.LayoutTests;
 
 
-public class AbsoluteLayoutTests
+public class AbsoluteLayoutTests (ITestOutputHelper output)
 {
 {
-    private readonly ITestOutputHelper _output;
-    public AbsoluteLayoutTests (ITestOutputHelper output) { _output = output; }
-
+    private readonly ITestOutputHelper _output = output;
 
 
     [Fact]
     [Fact]
     [TestRespondersDisposed]
     [TestRespondersDisposed]
@@ -22,11 +16,10 @@ public class AbsoluteLayoutTests
         var v = new View { Frame = frame };
         var v = new View { Frame = frame };
         v.Height = newFrame.Height;
         v.Height = newFrame.Height;
         v.Width = newFrame.Width;
         v.Width = newFrame.Width;
-        Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
         Assert.Equal (newFrame, v.Frame);
         Assert.Equal (newFrame, v.Frame);
 
 
         Assert.Equal (
         Assert.Equal (
-                      new Rectangle (0, 0, newFrame.Width, newFrame.Height),
+                      new (0, 0, newFrame.Width, newFrame.Height),
                       v.Viewport
                       v.Viewport
                      ); // With Absolute Viewport *is* deterministic before Layout
                      ); // With Absolute Viewport *is* deterministic before Layout
         Assert.Equal (Pos.Absolute (1), v.X);
         Assert.Equal (Pos.Absolute (1), v.X);
@@ -43,7 +36,6 @@ public class AbsoluteLayoutTests
         var v = new View { Frame = Rectangle.Empty };
         var v = new View { Frame = Rectangle.Empty };
         v.Height = Dim.Fill ();
         v.Height = Dim.Fill ();
         v.Width = Dim.Fill ();
         v.Width = Dim.Fill ();
-        Assert.True (v.LayoutStyle == LayoutStyle.Computed);
         v.Dispose ();
         v.Dispose ();
     }
     }
 
 
@@ -57,11 +49,10 @@ public class AbsoluteLayoutTests
         var v = new View { Frame = frame };
         var v = new View { Frame = frame };
         v.X = newFrame.X;
         v.X = newFrame.X;
         v.Y = newFrame.Y;
         v.Y = newFrame.Y;
-        Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
         Assert.Equal (newFrame, v.Frame);
         Assert.Equal (newFrame, v.Frame);
 
 
         Assert.Equal (
         Assert.Equal (
-                      new Rectangle (0, 0, newFrame.Width, newFrame.Height),
+                      new (0, 0, newFrame.Width, newFrame.Height),
                       v.Viewport
                       v.Viewport
                      ); // With Absolute Viewport *is* deterministic before Layout
                      ); // With Absolute Viewport *is* deterministic before Layout
         Assert.Equal ($"Absolute({newFrame.X})", v.X.ToString ());
         Assert.Equal ($"Absolute({newFrame.X})", v.X.ToString ());
@@ -78,7 +69,6 @@ public class AbsoluteLayoutTests
         var v = new View { Frame = Rectangle.Empty };
         var v = new View { Frame = Rectangle.Empty };
         v.X = Pos.Center ();
         v.X = Pos.Center ();
         v.Y = Pos.Center ();
         v.Y = Pos.Center ();
-        Assert.True (v.LayoutStyle == LayoutStyle.Computed);
         v.Dispose ();
         v.Dispose ();
     }
     }
 
 
@@ -91,73 +81,61 @@ public class AbsoluteLayoutTests
         v.Y = 2;
         v.Y = 2;
         v.Height = 3;
         v.Height = 3;
         v.Width = 4;
         v.Width = 4;
-        Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
         v.Dispose ();
         v.Dispose ();
 
 
-        v = new View { Frame = Rectangle.Empty };
+        v = new() { Frame = Rectangle.Empty };
         v.X = Pos.Center ();
         v.X = Pos.Center ();
         v.Y = Pos.Center ();
         v.Y = Pos.Center ();
         v.Width = Dim.Fill ();
         v.Width = Dim.Fill ();
         v.Height = Dim.Fill ();
         v.Height = Dim.Fill ();
-        Assert.True (v.LayoutStyle == LayoutStyle.Computed);
         v.Dispose ();
         v.Dispose ();
 
 
-        v = new View { Frame = Rectangle.Empty };
+        v = new() { Frame = Rectangle.Empty };
         v.X = Pos.Center ();
         v.X = Pos.Center ();
         v.Y = Pos.Center ();
         v.Y = Pos.Center ();
         v.Width = Dim.Fill ();
         v.Width = Dim.Fill ();
         v.Height = Dim.Fill ();
         v.Height = Dim.Fill ();
-        Assert.True (v.LayoutStyle == LayoutStyle.Computed);
 
 
         v.X = 1;
         v.X = 1;
-        Assert.True (v.LayoutStyle == LayoutStyle.Computed);
         v.Dispose ();
         v.Dispose ();
 
 
-        v = new View { Frame = Rectangle.Empty };
+        v = new() { Frame = Rectangle.Empty };
         v.X = Pos.Center ();
         v.X = Pos.Center ();
         v.Y = Pos.Center ();
         v.Y = Pos.Center ();
         v.Width = Dim.Fill ();
         v.Width = Dim.Fill ();
         v.Height = Dim.Fill ();
         v.Height = Dim.Fill ();
-        Assert.True (v.LayoutStyle == LayoutStyle.Computed);
 
 
         v.Y = 2;
         v.Y = 2;
-        Assert.True (v.LayoutStyle == LayoutStyle.Computed);
         v.Dispose ();
         v.Dispose ();
 
 
-        v = new View { Frame = Rectangle.Empty };
+        v = new() { Frame = Rectangle.Empty };
         v.X = Pos.Center ();
         v.X = Pos.Center ();
         v.Y = Pos.Center ();
         v.Y = Pos.Center ();
         v.Width = Dim.Fill ();
         v.Width = Dim.Fill ();
         v.Height = Dim.Fill ();
         v.Height = Dim.Fill ();
-        Assert.True (v.LayoutStyle == LayoutStyle.Computed);
 
 
         v.Width = 3;
         v.Width = 3;
-        Assert.True (v.LayoutStyle == LayoutStyle.Computed);
         v.Dispose ();
         v.Dispose ();
 
 
-        v = new View { Frame = Rectangle.Empty };
+        v = new() { Frame = Rectangle.Empty };
         v.X = Pos.Center ();
         v.X = Pos.Center ();
         v.Y = Pos.Center ();
         v.Y = Pos.Center ();
         v.Width = Dim.Fill ();
         v.Width = Dim.Fill ();
         v.Height = Dim.Fill ();
         v.Height = Dim.Fill ();
-        Assert.True (v.LayoutStyle == LayoutStyle.Computed);
 
 
         v.Height = 3;
         v.Height = 3;
-        Assert.True (v.LayoutStyle == LayoutStyle.Computed);
         v.Dispose ();
         v.Dispose ();
 
 
-        v = new View { Frame = Rectangle.Empty };
+        v = new() { Frame = Rectangle.Empty };
         v.X = Pos.Center ();
         v.X = Pos.Center ();
         v.Y = Pos.Center ();
         v.Y = Pos.Center ();
         v.Width = Dim.Fill ();
         v.Width = Dim.Fill ();
         v.Height = Dim.Fill ();
         v.Height = Dim.Fill ();
-        Assert.True (v.LayoutStyle == LayoutStyle.Computed);
 
 
         v.X = 1;
         v.X = 1;
         v.Y = 2;
         v.Y = 2;
         v.Height = 3;
         v.Height = 3;
         v.Width = 4;
         v.Width = 4;
-        Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
         v.Dispose ();
         v.Dispose ();
     }
     }
 
 
@@ -166,16 +144,14 @@ public class AbsoluteLayoutTests
     public void AbsoluteLayout_Constructor ()
     public void AbsoluteLayout_Constructor ()
     {
     {
         var v = new View ();
         var v = new View ();
-        Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
         v.Dispose ();
         v.Dispose ();
 
 
         var frame = Rectangle.Empty;
         var frame = Rectangle.Empty;
-        v = new View { Frame = frame };
-        Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
+        v = new() { Frame = frame };
         Assert.Equal (frame, v.Frame);
         Assert.Equal (frame, v.Frame);
 
 
         Assert.Equal (
         Assert.Equal (
-                      new Rectangle (0, 0, frame.Width, frame.Height),
+                      new (0, 0, frame.Width, frame.Height),
                       v.Viewport
                       v.Viewport
                      ); // With Absolute Viewport *is* deterministic before Layout
                      ); // With Absolute Viewport *is* deterministic before Layout
         Assert.Equal (Pos.Absolute (0), v.X);
         Assert.Equal (Pos.Absolute (0), v.X);
@@ -184,13 +160,12 @@ public class AbsoluteLayoutTests
         Assert.Equal (Dim.Absolute (0), v.Height);
         Assert.Equal (Dim.Absolute (0), v.Height);
         v.Dispose ();
         v.Dispose ();
 
 
-        frame = new Rectangle (1, 2, 3, 4);
-        v = new View { Frame = frame };
-        Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
+        frame = new (1, 2, 3, 4);
+        v = new() { Frame = frame };
         Assert.Equal (frame, v.Frame);
         Assert.Equal (frame, v.Frame);
 
 
         Assert.Equal (
         Assert.Equal (
-                      new Rectangle (0, 0, frame.Width, frame.Height),
+                      new (0, 0, frame.Width, frame.Height),
                       v.Viewport
                       v.Viewport
                      ); // With Absolute Viewport *is* deterministic before Layout
                      ); // With Absolute Viewport *is* deterministic before Layout
         Assert.Equal (Pos.Absolute (1), v.X);
         Assert.Equal (Pos.Absolute (1), v.X);
@@ -199,12 +174,11 @@ public class AbsoluteLayoutTests
         Assert.Equal (Dim.Absolute (4), v.Height);
         Assert.Equal (Dim.Absolute (4), v.Height);
         v.Dispose ();
         v.Dispose ();
 
 
-        v = new View { Frame = frame, Text = "v" };
-        Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
+        v = new() { Frame = frame, Text = "v" };
         Assert.Equal (frame, v.Frame);
         Assert.Equal (frame, v.Frame);
 
 
         Assert.Equal (
         Assert.Equal (
-                      new Rectangle (0, 0, frame.Width, frame.Height),
+                      new (0, 0, frame.Width, frame.Height),
                       v.Viewport
                       v.Viewport
                      ); // With Absolute Viewport *is* deterministic before Layout
                      ); // With Absolute Viewport *is* deterministic before Layout
         Assert.Equal (Pos.Absolute (1), v.X);
         Assert.Equal (Pos.Absolute (1), v.X);
@@ -213,34 +187,28 @@ public class AbsoluteLayoutTests
         Assert.Equal (Dim.Absolute (4), v.Height);
         Assert.Equal (Dim.Absolute (4), v.Height);
         v.Dispose ();
         v.Dispose ();
 
 
-        v = new View { X = frame.X, Y = frame.Y, Text = "v" };
-        Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
+        v = new() { X = frame.X, Y = frame.Y, Text = "v" };
 
 
-        // BUGBUG: v2 - I think the default size should be 0,0 not 1,1
-        // That is correct it should be 0,0 because AutoSize is false
-        // and the size wasn't set on the initializer
-        Assert.Equal (new Rectangle (frame.X, frame.Y, 0, 0), v.Frame);
-        Assert.Equal (new Rectangle (0, 0, 0, 0), v.Viewport); // With Absolute Viewport *is* deterministic before Layout
+        Assert.Equal (new (frame.X, frame.Y, 0, 0), v.Frame);
+        Assert.Equal (new (0, 0, 0, 0), v.Viewport); // With Absolute Viewport *is* deterministic before Layout
         Assert.Equal (Pos.Absolute (1), v.X);
         Assert.Equal (Pos.Absolute (1), v.X);
         Assert.Equal (Pos.Absolute (2), v.Y);
         Assert.Equal (Pos.Absolute (2), v.Y);
         Assert.Equal (Dim.Absolute (0), v.Width);
         Assert.Equal (Dim.Absolute (0), v.Width);
         Assert.Equal (Dim.Absolute (0), v.Height);
         Assert.Equal (Dim.Absolute (0), v.Height);
         v.Dispose ();
         v.Dispose ();
 
 
-        v = new View ();
-        Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
-        Assert.Equal (new Rectangle (0, 0, 0, 0), v.Frame);
-        Assert.Equal (new Rectangle (0, 0, 0, 0), v.Viewport); // With Absolute Viewport *is* deterministic before Layout
+        v = new ();
+        Assert.Equal (new (0, 0, 0, 0), v.Frame);
+        Assert.Equal (new (0, 0, 0, 0), v.Viewport); // With Absolute Viewport *is* deterministic before Layout
         Assert.Equal (Pos.Absolute (0), v.X);
         Assert.Equal (Pos.Absolute (0), v.X);
         Assert.Equal (Pos.Absolute (0), v.Y);
         Assert.Equal (Pos.Absolute (0), v.Y);
         Assert.Equal (Dim.Absolute (0), v.Width);
         Assert.Equal (Dim.Absolute (0), v.Width);
         Assert.Equal (Dim.Absolute (0), v.Height);
         Assert.Equal (Dim.Absolute (0), v.Height);
         v.Dispose ();
         v.Dispose ();
 
 
-        v = new View { X = frame.X, Y = frame.Y, Width = frame.Width, Height = frame.Height };
-        Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
-        Assert.Equal (new Rectangle (frame.X, frame.Y, 3, 4), v.Frame);
-        Assert.Equal (new Rectangle (0, 0, 3, 4), v.Viewport); // With Absolute Viewport *is* deterministic before Layout
+        v = new() { X = frame.X, Y = frame.Y, Width = frame.Width, Height = frame.Height };
+        Assert.Equal (new (frame.X, frame.Y, 3, 4), v.Frame);
+        Assert.Equal (new (0, 0, 3, 4), v.Viewport); // With Absolute Viewport *is* deterministic before Layout
         Assert.Equal (Pos.Absolute (1), v.X);
         Assert.Equal (Pos.Absolute (1), v.X);
         Assert.Equal (Pos.Absolute (2), v.Y);
         Assert.Equal (Pos.Absolute (2), v.Y);
         Assert.Equal (Dim.Absolute (3), v.Width);
         Assert.Equal (Dim.Absolute (3), v.Width);
@@ -254,20 +222,15 @@ public class AbsoluteLayoutTests
     {
     {
         var superRect = new Rectangle (0, 0, 100, 100);
         var superRect = new Rectangle (0, 0, 100, 100);
         var super = new View { Frame = superRect, Text = "super" };
         var super = new View { Frame = superRect, Text = "super" };
-        Assert.True (super.LayoutStyle == LayoutStyle.Absolute);
         var v1 = new View { X = 0, Y = 0, Width = 10, Height = 10 };
         var v1 = new View { X = 0, Y = 0, Width = 10, Height = 10 };
-        Assert.True (v1.LayoutStyle == LayoutStyle.Absolute);
 
 
         var v2 = new View { X = 10, Y = 10, Width = 10, Height = 10 };
         var v2 = new View { X = 10, Y = 10, Width = 10, Height = 10 };
-        Assert.True (v2.LayoutStyle == LayoutStyle.Absolute);
 
 
         super.Add (v1, v2);
         super.Add (v1, v2);
-        Assert.True (v1.LayoutStyle == LayoutStyle.Absolute);
-        Assert.True (v2.LayoutStyle == LayoutStyle.Absolute);
 
 
         super.LayoutSubviews ();
         super.LayoutSubviews ();
-        Assert.Equal (new Rectangle (0, 0, 10, 10), v1.Frame);
-        Assert.Equal (new Rectangle (10, 10, 10, 10), v2.Frame);
+        Assert.Equal (new (0, 0, 10, 10), v1.Frame);
+        Assert.Equal (new (10, 10, 10, 10), v2.Frame);
         super.Dispose ();
         super.Dispose ();
     }
     }
 }
 }

+ 22 - 6
UnitTests/View/Layout/Dim.AutoTests.cs

@@ -671,7 +671,7 @@ public class DimAutoTests (ITestOutputHelper output)
 
 
         superView.BeginInit ();
         superView.BeginInit ();
         superView.EndInit ();
         superView.EndInit ();
-        superView.SetRelativeLayout (superView.ContentSize);
+        superView.SetRelativeLayout (superView.GetContentSize ());
 
 
         superView.LayoutSubviews ();
         superView.LayoutSubviews ();
         Assert.Equal (expectedSubWidth, subView.Frame.Width);
         Assert.Equal (expectedSubWidth, subView.Frame.Width);
@@ -720,7 +720,7 @@ public class DimAutoTests (ITestOutputHelper output)
 
 
         superView.BeginInit ();
         superView.BeginInit ();
         superView.EndInit ();
         superView.EndInit ();
-        superView.SetRelativeLayout (superView.ContentSize);
+        superView.SetRelativeLayout (superView.GetContentSize ());
 
 
         superView.LayoutSubviews ();
         superView.LayoutSubviews ();
         Assert.Equal (expectedSubWidth, subView.Frame.Width);
         Assert.Equal (expectedSubWidth, subView.Frame.Width);
@@ -745,7 +745,7 @@ public class DimAutoTests (ITestOutputHelper output)
         super.Add (view);
         super.Add (view);
 
 
         Rectangle expectedViewport = new (0, 0, 8, 1);
         Rectangle expectedViewport = new (0, 0, 8, 1);
-        Assert.Equal (expectedViewport.Size, view.ContentSize);
+        Assert.Equal (expectedViewport.Size, view.GetContentSize ());
         Assert.Equal (expectedViewport, view.Frame);
         Assert.Equal (expectedViewport, view.Frame);
         Assert.Equal (expectedViewport, view.Viewport);
         Assert.Equal (expectedViewport, view.Viewport);
 
 
@@ -943,19 +943,19 @@ public class DimAutoTests (ITestOutputHelper output)
         };
         };
 
 
         Assert.Equal (new Rectangle (0, 0, 5, 1), view.Frame);
         Assert.Equal (new Rectangle (0, 0, 5, 1), view.Frame);
-        Assert.Equal (new Size (5, 1), view.ContentSize);
+        Assert.Equal (new Size (5, 1), view.GetContentSize ());
 
 
         // Change text to a longer string
         // Change text to a longer string
         view.Text = "0123456789";
         view.Text = "0123456789";
 
 
         Assert.Equal (new Rectangle (0, 0, 10, 1), view.Frame);
         Assert.Equal (new Rectangle (0, 0, 10, 1), view.Frame);
-        Assert.Equal (new Size (10, 1), view.ContentSize);
+        Assert.Equal (new Size (10, 1), view.GetContentSize ());
 
 
         // If ContentSize was reset, these should cause it to update
         // If ContentSize was reset, these should cause it to update
         view.Width = 5;
         view.Width = 5;
         view.Height = 1;
         view.Height = 1;
 
 
-        Assert.Equal (new Size (5, 1), view.ContentSize);
+        Assert.Equal (new Size (5, 1), view.GetContentSize ());
     }
     }
 
 
     // DimAutoStyle.Content tests
     // DimAutoStyle.Content tests
@@ -972,6 +972,22 @@ public class DimAutoTests (ITestOutputHelper output)
         Assert.Equal (10, calculatedWidth);
         Assert.Equal (10, calculatedWidth);
     }
     }
 
 
+    [Fact]
+    public void DimAutoStyle_Content_IgnoresSubviews_When_ContentSize_Is_Set ()
+    {
+        var view = new View ();
+        var subview = new View () {
+                Frame = new Rectangle (50, 50, 1, 1)
+        };
+        view.SetContentSize (new (10, 5));
+
+        var dim = Dim.Auto (DimAutoStyle.Content);
+
+        int calculatedWidth = dim.Calculate (0, 100, view, Dimension.Width);
+
+        Assert.Equal (10, calculatedWidth);
+    }
+
     [Fact]
     [Fact]
     public void DimAutoStyle_Content_IgnoresText_WhenContentSizeNotSet ()
     public void DimAutoStyle_Content_IgnoresText_WhenContentSizeNotSet ()
     {
     {

+ 1 - 0
UnitTests/View/Layout/Dim.FillTests.cs

@@ -22,6 +22,7 @@ public class DimFillTests (ITestOutputHelper output)
         //view.SetRelativeLayout (new (0, 0, 32, 5));
         //view.SetRelativeLayout (new (0, 0, 32, 5));
         Assert.Equal (32, view.Frame.Width);
         Assert.Equal (32, view.Frame.Width);
         Assert.Equal (5, view.Frame.Height);
         Assert.Equal (5, view.Frame.Height);
+        top.Dispose ();
     }
     }
 
 
 
 

+ 71 - 159
UnitTests/View/Layout/Dim.Tests.cs

@@ -3,10 +3,6 @@ using System.Text;
 using Xunit.Abstractions;
 using Xunit.Abstractions;
 using static Terminal.Gui.Dim;
 using static Terminal.Gui.Dim;
 
 
-
-// Alias Console to MockConsole so we don't accidentally use Console
-using Console = Terminal.Gui.FakeConsole;
-
 namespace Terminal.Gui.LayoutTests;
 namespace Terminal.Gui.LayoutTests;
 
 
 public class DimTests
 public class DimTests
@@ -28,7 +24,7 @@ public class DimTests
     public void DimAbsolute_Calculate_ReturnsCorrectValue ()
     public void DimAbsolute_Calculate_ReturnsCorrectValue ()
     {
     {
         var dim = new DimAbsolute (10);
         var dim = new DimAbsolute (10);
-        var result = dim.Calculate (0, 100, null, Dimension.None);
+        int result = dim.Calculate (0, 100, null, Dimension.None);
         Assert.Equal (10, result);
         Assert.Equal (10, result);
     }
     }
 
 
@@ -144,39 +140,7 @@ public class DimTests
         Application.Run (top);
         Application.Run (top);
 
 
         Assert.Equal (0, count);
         Assert.Equal (0, count);
-    }
-
-    // TODO: This actually a SetRelativeLayout/LayoutSubViews test and should be moved
-    // TODO: A new test that calls SetRelativeLayout directly is needed.
-    [Fact]
-    [TestRespondersDisposed]
-    public void
-        Dim_Validation_Do_Not_Throws_If_NewValue_Is_DimAbsolute_And_OldValue_Is_Another_Type_After_Sets_To_LayoutStyle_Absolute ()
-    {
-        var t = new View { Width = 80, Height = 25, Text = "top" };
-
-        var w = new Window { Width = Dim.Fill (), Height = Dim.Absolute (10) };
-        var v = new View { Width = Dim.Width (w) - 2, Height = Dim.Percent (10), Text = "v" };
-
-        w.Add (v);
-        t.Add (w);
-
-        Assert.Equal (LayoutStyle.Absolute, t.LayoutStyle);
-        Assert.Equal (LayoutStyle.Computed, w.LayoutStyle);
-        Assert.Equal (LayoutStyle.Computed, v.LayoutStyle);
-
-        t.LayoutSubviews ();
-        Assert.Equal (2, v.Width = 2);
-        Assert.Equal (2, v.Height = 2);
-
-        // Force v to be LayoutStyle.Absolute;
-        v.Frame = new Rectangle (0, 1, 3, 4);
-        Assert.Equal (LayoutStyle.Absolute, v.LayoutStyle);
-        t.LayoutSubviews ();
-
-        Assert.Equal (2, v.Width = 2);
-        Assert.Equal (2, v.Height = 2);
-        t.Dispose ();
+        top.Dispose ();
     }
     }
 
 
     // TODO: This actually a SetRelativeLayout/LayoutSubViews test and should be moved
     // TODO: This actually a SetRelativeLayout/LayoutSubViews test and should be moved
@@ -203,64 +167,10 @@ public class DimTests
         t.Dispose ();
         t.Dispose ();
     }
     }
 
 
-
-    // See #2461
-    //[Fact]
-    //public void Dim_Referencing_SuperView_Throws ()
-    //{
-    //	var super = new View ("super") {
-    //		Width = 10,
-    //		Height = 10
-    //	};
-    //	var view = new View ("view") {
-    //		Width = Dim.Width (super),	// this is not allowed
-    //		Height = Dim.Height (super),    // this is not allowed
-    //	};
-
-    //	super.Add (view);
-    //	super.BeginInit ();
-    //	super.EndInit ();
-    //	Assert.Throws<InvalidOperationException> (() => super.LayoutSubviews ());
-    //}
-
-    // TODO: This actually a SetRelativeLayout/LayoutSubViews test and should be moved
-    // TODO: A new test that calls SetRelativeLayout directly is needed.
-    [Fact]
-    [TestRespondersDisposed]
-    public void
-        Dim_Validation_Does_Not_Throw_If_NewValue_Is_DimAbsolute_And_OldValue_Is_Another_Type_After_Sets_To_LayoutStyle_Absolute ()
-    {
-        var t = new View { Width = 80, Height = 25, Text = "top" };
-
-        var w = new Window { Width = Dim.Fill (), Height = Dim.Absolute (10) };
-        var v = new View { Width = Dim.Width (w) - 2, Height = Dim.Percent (10), Text = "v" };
-
-        w.Add (v);
-        t.Add (w);
-
-        Assert.Equal (LayoutStyle.Absolute, t.LayoutStyle);
-        Assert.Equal (LayoutStyle.Computed, w.LayoutStyle);
-        Assert.Equal (LayoutStyle.Computed, v.LayoutStyle);
-
-        t.LayoutSubviews ();
-        Assert.Equal (2, v.Width = 2);
-        Assert.Equal (2, v.Height = 2);
-
-        // Force v to be LayoutStyle.Absolute;
-        v.Frame = new Rectangle (0, 1, 3, 4);
-        Assert.Equal (LayoutStyle.Absolute, v.LayoutStyle);
-        t.LayoutSubviews ();
-
-        Assert.Equal (2, v.Width = 2);
-        Assert.Equal (2, v.Height = 2);
-        t.Dispose ();
-    }
-
-
     [Fact]
     [Fact]
     public void DimHeight_Set_To_Null_Throws ()
     public void DimHeight_Set_To_Null_Throws ()
     {
     {
-        Dim dim = Dim.Height (null);
+        Dim dim = Height (null);
         Assert.Throws<NullReferenceException> (() => dim.ToString ());
         Assert.Throws<NullReferenceException> (() => dim.ToString ());
     }
     }
 
 
@@ -270,13 +180,13 @@ public class DimTests
     {
     {
         var testVal = Rectangle.Empty;
         var testVal = Rectangle.Empty;
         var testValview = new View { Frame = testVal };
         var testValview = new View { Frame = testVal };
-        Dim dim = Dim.Height (testValview);
+        Dim dim = Height (testValview);
         Assert.Equal ($"View(Height,View(){testVal})", dim.ToString ());
         Assert.Equal ($"View(Height,View(){testVal})", dim.ToString ());
         testValview.Dispose ();
         testValview.Dispose ();
 
 
-        testVal = new Rectangle (1, 2, 3, 4);
-        testValview = new View { Frame = testVal };
-        dim = Dim.Height (testValview);
+        testVal = new (1, 2, 3, 4);
+        testValview = new() { Frame = testVal };
+        dim = Height (testValview);
         Assert.Equal ($"View(Height,View(){testVal})", dim.ToString ());
         Assert.Equal ($"View(Height,View(){testVal})", dim.ToString ());
         testValview.Dispose ();
         testValview.Dispose ();
     }
     }
@@ -299,7 +209,7 @@ public class DimTests
         Assert.Equal (dimCombine.Right, dimAbsolute);
         Assert.Equal (dimCombine.Right, dimAbsolute);
         Assert.Equal (20, dimCombine.GetAnchor (100));
         Assert.Equal (20, dimCombine.GetAnchor (100));
 
 
-        var view = new View { Frame = new Rectangle (20, 10, 20, 1) };
+        var view = new View { Frame = new (20, 10, 20, 1) };
         var dimViewHeight = new DimView (view, Dimension.Height);
         var dimViewHeight = new DimView (view, Dimension.Height);
         Assert.Equal (1, dimViewHeight.GetAnchor (0));
         Assert.Equal (1, dimViewHeight.GetAnchor (0));
         var dimViewWidth = new DimView (view, Dimension.Width);
         var dimViewWidth = new DimView (view, Dimension.Width);
@@ -323,7 +233,7 @@ public class DimTests
         {
         {
             X = 0,
             X = 0,
             Y = 0,
             Y = 0,
-            Width = Dim.Percent (50),
+            Width = Percent (50),
             Height = 5,
             Height = 5,
             Title = "f1"
             Title = "f1"
         };
         };
@@ -332,7 +242,7 @@ public class DimTests
         {
         {
             X = Pos.Right (f1),
             X = Pos.Right (f1),
             Y = 0,
             Y = 0,
-            Width = Dim.Fill (),
+            Width = Fill (),
             Height = 5,
             Height = 5,
             Title = "f2"
             Title = "f2"
         };
         };
@@ -341,8 +251,8 @@ public class DimTests
         {
         {
             X = Pos.X (f1) + 2,
             X = Pos.X (f1) + 2,
             Y = Pos.Bottom (f1) + 2,
             Y = Pos.Bottom (f1) + 2,
-            Width = Dim.Width (f1) - 2,
-            Height = Dim.Fill () - 2,
+            Width = Width (f1) - 2,
+            Height = Fill () - 2,
             ValidatePosDim = true,
             ValidatePosDim = true,
             Text = "v1"
             Text = "v1"
         };
         };
@@ -351,32 +261,32 @@ public class DimTests
         {
         {
             X = Pos.X (f2) + 2,
             X = Pos.X (f2) + 2,
             Y = Pos.Bottom (f2) + 2,
             Y = Pos.Bottom (f2) + 2,
-            Width = Dim.Width (f2) - 2,
-            Height = Dim.Fill () - 2,
+            Width = Width (f2) - 2,
+            Height = Fill () - 2,
             ValidatePosDim = true,
             ValidatePosDim = true,
             Text = "v2"
             Text = "v2"
         };
         };
 
 
         var v3 = new Button
         var v3 = new Button
         {
         {
-            Width = Dim.Percent (10),
-            Height = Dim.Percent (10),
+            Width = Percent (10),
+            Height = Percent (10),
             ValidatePosDim = true,
             ValidatePosDim = true,
             Text = "v3"
             Text = "v3"
         };
         };
 
 
         var v4 = new Button
         var v4 = new Button
         {
         {
-            Width = Dim.Absolute (50),
-            Height = Dim.Absolute (50),
+            Width = Absolute (50),
+            Height = Absolute (50),
             ValidatePosDim = true,
             ValidatePosDim = true,
             Text = "v4"
             Text = "v4"
         };
         };
 
 
         var v5 = new Button
         var v5 = new Button
         {
         {
-            Width = Dim.Width (v1) - Dim.Width (v3),
-            Height = Dim.Height (v1) - Dim.Height (v3),
+            Width = Width (v1) - Width (v3),
+            Height = Height (v1) - Height (v3),
             ValidatePosDim = true,
             ValidatePosDim = true,
             Text = "v5"
             Text = "v5"
         };
         };
@@ -385,8 +295,8 @@ public class DimTests
         {
         {
             X = Pos.X (f2),
             X = Pos.X (f2),
             Y = Pos.Bottom (f2) + 2,
             Y = Pos.Bottom (f2) + 2,
-            Width = Dim.Percent (20, DimPercentMode.Position),
-            Height = Dim.Percent (20, DimPercentMode.Position),
+            Width = Percent (20, DimPercentMode.Position),
+            Height = Percent (20, DimPercentMode.Position),
             ValidatePosDim = true,
             ValidatePosDim = true,
             Text = "v6"
             Text = "v6"
         };
         };
@@ -449,10 +359,10 @@ public class DimTests
 #else
 #else
                        Assert.Equal ($"Combine(View(Height,Button(){v1.Frame})-View(Height,Button(){v3.Viewport}))", v5.Height.ToString ( ));
                        Assert.Equal ($"Combine(View(Height,Button(){v1.Frame})-View(Height,Button(){v3.Viewport}))", v5.Height.ToString ( ));
 #endif
 #endif
-                       Assert.Equal (38, v5.Frame.Width);  // 47-9=38
+                       Assert.Equal (38, v5.Frame.Width); // 47-9=38
                        Assert.Equal (80, v5.Frame.Height); // 89-9=80
                        Assert.Equal (80, v5.Frame.Height); // 89-9=80
 
 
-                       Assert.Equal (9, v6.Frame.Width);   // 47*20%=9
+                       Assert.Equal (9, v6.Frame.Width); // 47*20%=9
                        Assert.Equal (18, v6.Frame.Height); // 89*20%=18
                        Assert.Equal (18, v6.Frame.Height); // 89*20%=18
 
 
                        w.Width = 200;
                        w.Width = 200;
@@ -482,7 +392,7 @@ public class DimTests
                        Assert.Equal ($"Combine(View(Width,FrameView(){f1.Frame})-Absolute(2))", v1.Width.ToString ());
                        Assert.Equal ($"Combine(View(Width,FrameView(){f1.Frame})-Absolute(2))", v1.Width.ToString ());
 #endif
 #endif
                        Assert.Equal ("Combine(Fill(0)-Absolute(2))", v1.Height.ToString ());
                        Assert.Equal ("Combine(Fill(0)-Absolute(2))", v1.Height.ToString ());
-                       Assert.Equal (97, v1.Frame.Width);   // 99-2=97
+                       Assert.Equal (97, v1.Frame.Width); // 99-2=97
                        Assert.Equal (189, v1.Frame.Height); // 198-2-7=189
                        Assert.Equal (189, v1.Frame.Height); // 198-2-7=189
 
 
                        v2.Text = "Button2";
                        v2.Text = "Button2";
@@ -493,21 +403,22 @@ public class DimTests
                        Assert.Equal ($"Combine(View(Width,FrameView(){f2.Frame})-Absolute(2))", v2.Width.ToString ());
                        Assert.Equal ($"Combine(View(Width,FrameView(){f2.Frame})-Absolute(2))", v2.Width.ToString ());
 #endif
 #endif
                        Assert.Equal ("Combine(Fill(0)-Absolute(2))", v2.Height.ToString ());
                        Assert.Equal ("Combine(Fill(0)-Absolute(2))", v2.Height.ToString ());
-                       Assert.Equal (97, v2.Frame.Width);   // 99-2=97
+                       Assert.Equal (97, v2.Frame.Width); // 99-2=97
                        Assert.Equal (189, v2.Frame.Height); // 198-2-7=189
                        Assert.Equal (189, v2.Frame.Height); // 198-2-7=189
 
 
                        v3.Text = "Button3";
                        v3.Text = "Button3";
 
 
                        // 198*10%=19 * Percent is related to the super-view if it isn't null otherwise the view width
                        // 198*10%=19 * Percent is related to the super-view if it isn't null otherwise the view width
                        Assert.Equal (19, v3.Frame.Width);
                        Assert.Equal (19, v3.Frame.Width);
+
                        // 199*10%=19
                        // 199*10%=19
                        Assert.Equal (19, v3.Frame.Height);
                        Assert.Equal (19, v3.Frame.Height);
 
 
                        v4.Text = "Button4";
                        v4.Text = "Button4";
-                       v4.Width = Auto(DimAutoStyle.Text);
+                       v4.Width = Auto (DimAutoStyle.Text);
                        v4.Height = Auto (DimAutoStyle.Text);
                        v4.Height = Auto (DimAutoStyle.Text);
-                       Assert.Equal (Dim.Auto (DimAutoStyle.Text), v4.Width);
-                       Assert.Equal (Dim.Auto (DimAutoStyle.Text), v4.Height);
+                       Assert.Equal (Auto (DimAutoStyle.Text), v4.Width);
+                       Assert.Equal (Auto (DimAutoStyle.Text), v4.Height);
                        Assert.Equal (11, v4.Frame.Width); // 11 is the text length and because is DimAbsolute
                        Assert.Equal (11, v4.Frame.Width); // 11 is the text length and because is DimAbsolute
                        Assert.Equal (1, v4.Frame.Height); // 1 because is DimAbsolute
                        Assert.Equal (1, v4.Frame.Height); // 1 because is DimAbsolute
 
 
@@ -521,17 +432,18 @@ public class DimTests
                        Assert.Equal ($"Combine(View(Height,Button(){v1.Frame})-View(Height,Button(){v3.Frame}))", v5.Height.ToString ());
                        Assert.Equal ($"Combine(View(Height,Button(){v1.Frame})-View(Height,Button(){v3.Frame}))", v5.Height.ToString ());
 #endif
 #endif
 
 
-                       Assert.Equal (78, v5.Frame.Width);   // 97-9=78
+                       Assert.Equal (78, v5.Frame.Width); // 97-9=78
                        Assert.Equal (170, v5.Frame.Height); // 189-19=170
                        Assert.Equal (170, v5.Frame.Height); // 189-19=170
 
 
                        v6.Text = "Button6";
                        v6.Text = "Button6";
-                       Assert.Equal (19, v6.Frame.Width);  // 99*20%=19
+                       Assert.Equal (19, v6.Frame.Width); // 99*20%=19
                        Assert.Equal (38, v6.Frame.Height); // 198-7*20=18
                        Assert.Equal (38, v6.Frame.Height); // 198-7*20=18
                    };
                    };
 
 
         Application.Iteration += (s, a) => Application.RequestStop ();
         Application.Iteration += (s, a) => Application.RequestStop ();
 
 
         Application.Run (t);
         Application.Run (t);
+        t.Dispose ();
     }
     }
 
 
     // TODO: This actually a SetRelativeLayout/LayoutSubViews test and should be moved
     // TODO: This actually a SetRelativeLayout/LayoutSubViews test and should be moved
@@ -544,8 +456,8 @@ public class DimTests
 
 
         var view = new View
         var view = new View
         {
         {
-            Width = Dim.Width (super), // this is allowed
-            Height = Dim.Height (super), // this is allowed
+            Width = Width (super), // this is allowed
+            Height = Height (super), // this is allowed
             Text = "view"
             Text = "view"
         };
         };
 
 
@@ -563,39 +475,39 @@ public class DimTests
     {
     {
         var n1 = 0;
         var n1 = 0;
         var n2 = 0;
         var n2 = 0;
-        Dim dim1 = Dim.Absolute (n1);
-        Dim dim2 = Dim.Absolute (n2);
+        Dim dim1 = Absolute (n1);
+        Dim dim2 = Absolute (n2);
         Assert.Equal (dim1, dim2);
         Assert.Equal (dim1, dim2);
 
 
         n1 = n2 = 1;
         n1 = n2 = 1;
-        dim1 = Dim.Absolute (n1);
-        dim2 = Dim.Absolute (n2);
+        dim1 = Absolute (n1);
+        dim2 = Absolute (n2);
         Assert.Equal (dim1, dim2);
         Assert.Equal (dim1, dim2);
 
 
         n1 = n2 = -1;
         n1 = n2 = -1;
-        dim1 = Dim.Absolute (n1);
-        dim2 = Dim.Absolute (n2);
+        dim1 = Absolute (n1);
+        dim2 = Absolute (n2);
         Assert.Equal (dim1, dim2);
         Assert.Equal (dim1, dim2);
 
 
         n1 = 0;
         n1 = 0;
         n2 = 1;
         n2 = 1;
-        dim1 = Dim.Absolute (n1);
-        dim2 = Dim.Absolute (n2);
+        dim1 = Absolute (n1);
+        dim2 = Absolute (n2);
         Assert.NotEqual (dim1, dim2);
         Assert.NotEqual (dim1, dim2);
     }
     }
 
 
     [Fact]
     [Fact]
     public void DimSized_SetsValue ()
     public void DimSized_SetsValue ()
     {
     {
-        Dim dim = Dim.Absolute (0);
+        Dim dim = Absolute (0);
         Assert.Equal ("Absolute(0)", dim.ToString ());
         Assert.Equal ("Absolute(0)", dim.ToString ());
 
 
         var testVal = 5;
         var testVal = 5;
-        dim = Dim.Absolute (testVal);
+        dim = Absolute (testVal);
         Assert.Equal ($"Absolute({testVal})", dim.ToString ());
         Assert.Equal ($"Absolute({testVal})", dim.ToString ());
 
 
         testVal = -1;
         testVal = -1;
-        dim = Dim.Absolute (testVal);
+        dim = Absolute (testVal);
         Assert.Equal ($"Absolute({testVal})", dim.ToString ());
         Assert.Equal ($"Absolute({testVal})", dim.ToString ());
     }
     }
 
 
@@ -610,8 +522,8 @@ public class DimTests
 
 
         var view = new View
         var view = new View
         {
         {
-            Width = Dim.Width (view2), // this is not allowed
-            Height = Dim.Height (view2), // this is not allowed
+            Width = Width (view2), // this is not allowed
+            Height = Height (view2), // this is not allowed
             Text = "view"
             Text = "view"
         };
         };
 
 
@@ -657,39 +569,39 @@ public class DimTests
         var testRect2 = Rectangle.Empty;
         var testRect2 = Rectangle.Empty;
         var view2 = new View { Frame = testRect2 };
         var view2 = new View { Frame = testRect2 };
 
 
-        Dim dim1 = Dim.Width (view1);
-        Dim dim2 = Dim.Width (view1);
+        Dim dim1 = Width (view1);
+        Dim dim2 = Width (view1);
 
 
         // FIXED: Dim.Width should support Equals() and this should change to Equal.
         // FIXED: Dim.Width should support Equals() and this should change to Equal.
         Assert.Equal (dim1, dim2);
         Assert.Equal (dim1, dim2);
 
 
-        dim2 = Dim.Width (view2);
+        dim2 = Width (view2);
         Assert.NotEqual (dim1, dim2);
         Assert.NotEqual (dim1, dim2);
 
 
-        testRect1 = new Rectangle (0, 1, 2, 3);
-        view1 = new View { Frame = testRect1 };
-        testRect2 = new Rectangle (0, 1, 2, 3);
-        dim1 = Dim.Width (view1);
-        dim2 = Dim.Width (view1);
+        testRect1 = new (0, 1, 2, 3);
+        view1 = new() { Frame = testRect1 };
+        testRect2 = new (0, 1, 2, 3);
+        dim1 = Width (view1);
+        dim2 = Width (view1);
 
 
         // FIXED: Dim.Width should support Equals() and this should change to Equal.
         // FIXED: Dim.Width should support Equals() and this should change to Equal.
         Assert.Equal (dim1, dim2);
         Assert.Equal (dim1, dim2);
 
 
-        testRect1 = new Rectangle (0, -1, 2, 3);
-        view1 = new View { Frame = testRect1 };
-        testRect2 = new Rectangle (0, -1, 2, 3);
-        dim1 = Dim.Width (view1);
-        dim2 = Dim.Width (view1);
+        testRect1 = new (0, -1, 2, 3);
+        view1 = new() { Frame = testRect1 };
+        testRect2 = new (0, -1, 2, 3);
+        dim1 = Width (view1);
+        dim2 = Width (view1);
 
 
         // FIXED: Dim.Width should support Equals() and this should change to Equal.
         // FIXED: Dim.Width should support Equals() and this should change to Equal.
         Assert.Equal (dim1, dim2);
         Assert.Equal (dim1, dim2);
 
 
-        testRect1 = new Rectangle (0, -1, 2, 3);
-        view1 = new View { Frame = testRect1 };
+        testRect1 = new (0, -1, 2, 3);
+        view1 = new() { Frame = testRect1 };
         testRect2 = Rectangle.Empty;
         testRect2 = Rectangle.Empty;
-        view2 = new View { Frame = testRect2 };
-        dim1 = Dim.Width (view1);
-        dim2 = Dim.Width (view2);
+        view2 = new() { Frame = testRect2 };
+        dim1 = Width (view1);
+        dim2 = Width (view2);
         Assert.NotEqual (dim1, dim2);
         Assert.NotEqual (dim1, dim2);
 #if DEBUG_IDISPOSABLE
 #if DEBUG_IDISPOSABLE
 
 
@@ -702,7 +614,7 @@ public class DimTests
     [Fact]
     [Fact]
     public void DimWidth_Set_To_Null_Throws ()
     public void DimWidth_Set_To_Null_Throws ()
     {
     {
-        Dim dim = Dim.Width (null);
+        Dim dim = Width (null);
         Assert.Throws<NullReferenceException> (() => dim.ToString ());
         Assert.Throws<NullReferenceException> (() => dim.ToString ());
     }
     }
 
 
@@ -712,13 +624,13 @@ public class DimTests
     {
     {
         var testVal = Rectangle.Empty;
         var testVal = Rectangle.Empty;
         var testValView = new View { Frame = testVal };
         var testValView = new View { Frame = testVal };
-        Dim dim = Dim.Width (testValView);
+        Dim dim = Width (testValView);
         Assert.Equal ($"View(Width,View(){testVal})", dim.ToString ());
         Assert.Equal ($"View(Width,View(){testVal})", dim.ToString ());
         testValView.Dispose ();
         testValView.Dispose ();
 
 
-        testVal = new Rectangle (1, 2, 3, 4);
-        testValView = new View { Frame = testVal };
-        dim = Dim.Width (testValView);
+        testVal = new (1, 2, 3, 4);
+        testValView = new() { Frame = testVal };
+        dim = Width (testValView);
         Assert.Equal ($"View(Width,View(){testVal})", dim.ToString ());
         Assert.Equal ($"View(Width,View(){testVal})", dim.ToString ());
         testValView.Dispose ();
         testValView.Dispose ();
     }
     }

+ 0 - 6
UnitTests/View/Layout/FrameTests.cs

@@ -40,14 +40,11 @@ public class FrameTests (ITestOutputHelper output)
         var newFrame = new Rectangle (1, 2, 30, 40);
         var newFrame = new Rectangle (1, 2, 30, 40);
 
 
         var v = new View ();
         var v = new View ();
-        Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
         v.Dispose ();
         v.Dispose ();
 
 
         v = new View { Frame = frame };
         v = new View { Frame = frame };
-        Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
 
 
         v.Frame = newFrame;
         v.Frame = newFrame;
-        Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
         Assert.Equal (newFrame, v.Frame);
         Assert.Equal (newFrame, v.Frame);
 
 
         Assert.Equal (
         Assert.Equal (
@@ -62,7 +59,6 @@ public class FrameTests (ITestOutputHelper output)
 
 
         v = new View { X = frame.X, Y = frame.Y, Text = "v" };
         v = new View { X = frame.X, Y = frame.Y, Text = "v" };
         v.Frame = newFrame;
         v.Frame = newFrame;
-        Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
         Assert.Equal (newFrame, v.Frame);
         Assert.Equal (newFrame, v.Frame);
 
 
         Assert.Equal (
         Assert.Equal (
@@ -78,7 +74,6 @@ public class FrameTests (ITestOutputHelper output)
         newFrame = new Rectangle (10, 20, 30, 40);
         newFrame = new Rectangle (10, 20, 30, 40);
         v = new View { Frame = frame };
         v = new View { Frame = frame };
         v.Frame = newFrame;
         v.Frame = newFrame;
-        Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
         Assert.Equal (newFrame, v.Frame);
         Assert.Equal (newFrame, v.Frame);
 
 
         Assert.Equal (
         Assert.Equal (
@@ -93,7 +88,6 @@ public class FrameTests (ITestOutputHelper output)
 
 
         v = new View { X = frame.X, Y = frame.Y, Text = "v" };
         v = new View { X = frame.X, Y = frame.Y, Text = "v" };
         v.Frame = newFrame;
         v.Frame = newFrame;
-        Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
         Assert.Equal (newFrame, v.Frame);
         Assert.Equal (newFrame, v.Frame);
 
 
         Assert.Equal (
         Assert.Equal (

+ 2 - 0
UnitTests/View/Layout/Pos.AnchorEndTests.cs

@@ -260,6 +260,7 @@ public class PosAnchorEndTests (ITestOutputHelper output)
         Assert.Equal (new (0, 0, 80, 25), win.Frame);
         Assert.Equal (new (0, 0, 80, 25), win.Frame);
         Assert.Equal (new (68, 22, 10, 1), tv.Frame);
         Assert.Equal (new (68, 22, 10, 1), tv.Frame);
         Application.End (rs);
         Application.End (rs);
+        top.Dispose ();
     }
     }
 
 
     // TODO: This actually a SetRelativeLayout/LayoutSubViews test and should be moved
     // TODO: This actually a SetRelativeLayout/LayoutSubViews test and should be moved
@@ -293,6 +294,7 @@ public class PosAnchorEndTests (ITestOutputHelper output)
         Assert.Equal (new (68, 20, 10, 1), tv.Frame);
         Assert.Equal (new (68, 20, 10, 1), tv.Frame);
 
 
         Application.End (rs);
         Application.End (rs);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]

+ 24 - 24
UnitTests/View/Layout/Pos.CenterTests.cs

@@ -1,5 +1,4 @@
-using Microsoft.VisualStudio.TestPlatform.Utilities;
-using Xunit.Abstractions;
+using Xunit.Abstractions;
 using static Terminal.Gui.Dim;
 using static Terminal.Gui.Dim;
 using static Terminal.Gui.Pos;
 using static Terminal.Gui.Pos;
 
 
@@ -16,7 +15,6 @@ public class PosCenterTests (ITestOutputHelper output)
         Assert.NotNull (posCenter);
         Assert.NotNull (posCenter);
     }
     }
 
 
-
     [Fact]
     [Fact]
     public void PosCenter_Equals ()
     public void PosCenter_Equals ()
     {
     {
@@ -27,7 +25,6 @@ public class PosCenterTests (ITestOutputHelper output)
         Assert.False (posCenter2.Equals (posCenter1));
         Assert.False (posCenter2.Equals (posCenter1));
     }
     }
 
 
-
     [Fact]
     [Fact]
     public void PosCenter_ToString ()
     public void PosCenter_ToString ()
     {
     {
@@ -42,7 +39,7 @@ public class PosCenterTests (ITestOutputHelper output)
     {
     {
         var posCenter = new PosCenter ();
         var posCenter = new PosCenter ();
         var width = 50;
         var width = 50;
-        var expectedAnchor = width / 2;
+        int expectedAnchor = width / 2;
 
 
         Assert.Equal (expectedAnchor, posCenter.GetAnchor (width));
         Assert.Equal (expectedAnchor, posCenter.GetAnchor (width));
     }
     }
@@ -50,16 +47,15 @@ public class PosCenterTests (ITestOutputHelper output)
     [Fact]
     [Fact]
     public void PosCenter_CreatesCorrectInstance ()
     public void PosCenter_CreatesCorrectInstance ()
     {
     {
-        var pos = Pos.Center ();
+        Pos pos = Center ();
         Assert.IsType<PosCenter> (pos);
         Assert.IsType<PosCenter> (pos);
     }
     }
 
 
-
     [Fact]
     [Fact]
     public void PosCenter_Calculate_ReturnsExpectedValue ()
     public void PosCenter_Calculate_ReturnsExpectedValue ()
     {
     {
         var posCenter = new PosCenter ();
         var posCenter = new PosCenter ();
-        var result = posCenter.Calculate (10, new DimAbsolute (2), null, Dimension.None);
+        int result = posCenter.Calculate (10, new DimAbsolute (2), null, Dimension.None);
         Assert.Equal (4, result);
         Assert.Equal (4, result);
     }
     }
 
 
@@ -77,11 +73,11 @@ public class PosCenterTests (ITestOutputHelper output)
     [InlineData (10)]
     [InlineData (10)]
     public void PosCenter_SubView_85_Percent_Height (int height)
     public void PosCenter_SubView_85_Percent_Height (int height)
     {
     {
-        var win = new Window { Width = Dim.Fill (), Height = Dim.Fill () };
+        var win = new Window { Width = Fill (), Height = Fill () };
 
 
         var subview = new Window
         var subview = new Window
         {
         {
-            X = Pos.Center (), Y = Pos.Center (), Width = Dim.Percent (85), Height = Dim.Percent (85)
+            X = Center (), Y = Center (), Width = Dim.Percent (85), Height = Dim.Percent (85)
         };
         };
 
 
         win.Add (subview);
         win.Add (subview);
@@ -200,12 +196,14 @@ public class PosCenterTests (ITestOutputHelper output)
 │ └─────────────┘  │
 │ └─────────────┘  │
 │                  │
 │                  │
 └──────────────────┘"
 └──────────────────┘"
-                ;
+                    ;
+
                 break;
                 break;
         }
         }
 
 
         _ = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
         _ = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
         Application.End (rs);
         Application.End (rs);
+        win.Dispose ();
     }
     }
 
 
     [Theory]
     [Theory]
@@ -222,11 +220,11 @@ public class PosCenterTests (ITestOutputHelper output)
     [InlineData (10)]
     [InlineData (10)]
     public void PosCenter_SubView_85_Percent_Width (int width)
     public void PosCenter_SubView_85_Percent_Width (int width)
     {
     {
-        var win = new Window { Width = Dim.Fill (), Height = Dim.Fill () };
+        var win = new Window { Width = Fill (), Height = Fill () };
 
 
         var subview = new Window
         var subview = new Window
         {
         {
-            X = Pos.Center (), Y = Pos.Center (), Width = Dim.Percent (85), Height = Dim.Percent (85)
+            X = Center (), Y = Center (), Width = Dim.Percent (85), Height = Dim.Percent (85)
         };
         };
 
 
         win.Add (subview);
         win.Add (subview);
@@ -241,7 +239,7 @@ public class PosCenterTests (ITestOutputHelper output)
         switch (width)
         switch (width)
         {
         {
             case 1:
             case 1:
-                Assert.Equal (new Rectangle (0, 0, 0, 4), subview.Frame);
+                Assert.Equal (new (0, 0, 0, 4), subview.Frame);
 
 
                 expected = @"
                 expected = @"
@@ -254,7 +252,7 @@ public class PosCenterTests (ITestOutputHelper output)
 
 
                 break;
                 break;
             case 2:
             case 2:
-                Assert.Equal (new Rectangle (0, 0, 0, 4), subview.Frame);
+                Assert.Equal (new (0, 0, 0, 4), subview.Frame);
 
 
                 expected = @"
                 expected = @"
 ┌┐
 ┌┐
@@ -267,7 +265,7 @@ public class PosCenterTests (ITestOutputHelper output)
 
 
                 break;
                 break;
             case 3:
             case 3:
-                Assert.Equal (new Rectangle (0, 0, 0, 4), subview.Frame);
+                Assert.Equal (new (0, 0, 0, 4), subview.Frame);
 
 
                 expected = @"
                 expected = @"
 ┌─┐
 ┌─┐
@@ -280,7 +278,7 @@ public class PosCenterTests (ITestOutputHelper output)
 
 
                 break;
                 break;
             case 4:
             case 4:
-                Assert.Equal (new Rectangle (0, 0, 1, 4), subview.Frame);
+                Assert.Equal (new (0, 0, 1, 4), subview.Frame);
 
 
                 expected = @"
                 expected = @"
 ┌──┐
 ┌──┐
@@ -293,7 +291,7 @@ public class PosCenterTests (ITestOutputHelper output)
 
 
                 break;
                 break;
             case 5:
             case 5:
-                Assert.Equal (new Rectangle (0, 0, 2, 4), subview.Frame);
+                Assert.Equal (new (0, 0, 2, 4), subview.Frame);
 
 
                 expected = @"
                 expected = @"
 ┌───┐
 ┌───┐
@@ -306,7 +304,7 @@ public class PosCenterTests (ITestOutputHelper output)
 
 
                 break;
                 break;
             case 6:
             case 6:
-                Assert.Equal (new Rectangle (0, 0, 3, 4), subview.Frame);
+                Assert.Equal (new (0, 0, 3, 4), subview.Frame);
 
 
                 expected = @"
                 expected = @"
 ┌────┐
 ┌────┐
@@ -319,7 +317,7 @@ public class PosCenterTests (ITestOutputHelper output)
 
 
                 break;
                 break;
             case 7:
             case 7:
-                Assert.Equal (new Rectangle (0, 0, 4, 4), subview.Frame);
+                Assert.Equal (new (0, 0, 4, 4), subview.Frame);
 
 
                 expected = @"
                 expected = @"
 ┌─────┐
 ┌─────┐
@@ -332,7 +330,7 @@ public class PosCenterTests (ITestOutputHelper output)
 
 
                 break;
                 break;
             case 8:
             case 8:
-                Assert.Equal (new Rectangle (0, 0, 5, 4), subview.Frame);
+                Assert.Equal (new (0, 0, 5, 4), subview.Frame);
 
 
                 expected = @"
                 expected = @"
 ┌──────┐
 ┌──────┐
@@ -345,7 +343,7 @@ public class PosCenterTests (ITestOutputHelper output)
 
 
                 break;
                 break;
             case 9:
             case 9:
-                Assert.Equal (new Rectangle (1, 0, 5, 4), subview.Frame);
+                Assert.Equal (new (1, 0, 5, 4), subview.Frame);
 
 
                 expected = @"
                 expected = @"
 ┌───────┐
 ┌───────┐
@@ -358,7 +356,7 @@ public class PosCenterTests (ITestOutputHelper output)
 
 
                 break;
                 break;
             case 10:
             case 10:
-                Assert.Equal (new Rectangle (1, 0, 6, 4), subview.Frame);
+                Assert.Equal (new (1, 0, 6, 4), subview.Frame);
 
 
                 expected = @"
                 expected = @"
 ┌────────┐
 ┌────────┐
@@ -368,11 +366,13 @@ public class PosCenterTests (ITestOutputHelper output)
 │ └────┘ │
 │ └────┘ │
 │        │
 │        │
 └────────┘"
 └────────┘"
-                ;
+                    ;
+
                 break;
                 break;
         }
         }
 
 
         _ = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
         _ = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
         Application.End (rs);
         Application.End (rs);
+        win.Dispose ();
     }
     }
 }
 }

+ 3 - 2
UnitTests/View/Layout/Pos.CombineTests.cs

@@ -66,7 +66,6 @@ public class PosCombineTests (ITestOutputHelper output)
     [SetupFakeDriver]
     [SetupFakeDriver]
     public void PosCombine_DimCombine_View_With_SubViews ()
     public void PosCombine_DimCombine_View_With_SubViews ()
     {
     {
-        var clicked = false;
         Toplevel top = new Toplevel () { Width = 80, Height = 25 };
         Toplevel top = new Toplevel () { Width = 80, Height = 25 };
         var win1 = new Window { Id = "win1", Width = 20, Height = 10 };
         var win1 = new Window { Id = "win1", Width = 20, Height = 10 };
         var view1 = new View
         var view1 = new View
@@ -78,7 +77,9 @@ public class PosCombineTests (ITestOutputHelper output)
         };
         };
         var win2 = new Window { Id = "win2", Y = Pos.Bottom (view1) + 1, Width = 10, Height = 3 };
         var win2 = new Window { Id = "win2", Y = Pos.Bottom (view1) + 1, Width = 10, Height = 3 };
         var view2 = new View { Id = "view2", Width = Dim.Fill (), Height = 1, CanFocus = true };
         var view2 = new View { Id = "view2", Width = Dim.Fill (), Height = 1, CanFocus = true };
-        view2.MouseClick += (sender, e) => clicked = true;
+
+        //var clicked = false;
+        //view2.MouseClick += (sender, e) => clicked = true;
         var view3 = new View { Id = "view3", Width = Dim.Fill (1), Height = 1, CanFocus = true };
         var view3 = new View { Id = "view3", Width = Dim.Fill (1), Height = 1, CanFocus = true };
 
 
         view2.Add (view3);
         view2.Add (view3);

+ 12 - 13
UnitTests/View/Layout/Pos.PercentTests.cs

@@ -1,6 +1,4 @@
-using Microsoft.VisualStudio.TestPlatform.Utilities;
-using Xunit.Abstractions;
-using static Terminal.Gui.Dim;
+using Xunit.Abstractions;
 using static Terminal.Gui.Pos;
 using static Terminal.Gui.Pos;
 
 
 namespace Terminal.Gui.LayoutTests;
 namespace Terminal.Gui.LayoutTests;
@@ -12,7 +10,6 @@ public class PosPercentTests (ITestOutputHelper output)
     // TODO: This actually a SetRelativeLayout/LayoutSubViews test and should be moved
     // TODO: This actually a SetRelativeLayout/LayoutSubViews test and should be moved
     // TODO: A new test that calls SetRelativeLayout directly is needed.
     // TODO: A new test that calls SetRelativeLayout directly is needed.
     [Theory]
     [Theory]
-    [AutoInitShutdown]
     [InlineData (true)]
     [InlineData (true)]
     [InlineData (false)]
     [InlineData (false)]
     public void PosPercent_PlusOne (bool testHorizontal)
     public void PosPercent_PlusOne (bool testHorizontal)
@@ -21,8 +18,8 @@ public class PosPercentTests (ITestOutputHelper output)
 
 
         var view = new View
         var view = new View
         {
         {
-            X = testHorizontal ? Pos.Percent (50) + Pos.Percent (10) + 1 : 1,
-            Y = testHorizontal ? 1 : Pos.Percent (50) + Pos.Percent (10) + 1,
+            X = testHorizontal ? Percent (50) + Percent (10) + 1 : 1,
+            Y = testHorizontal ? 1 : Percent (50) + Percent (10) + 1,
             Width = 10,
             Width = 10,
             Height = 10
             Height = 10
         };
         };
@@ -45,29 +42,31 @@ public class PosPercentTests (ITestOutputHelper output)
             Assert.Equal (1, view.Frame.X);
             Assert.Equal (1, view.Frame.X);
             Assert.Equal (61, view.Frame.Y);
             Assert.Equal (61, view.Frame.Y);
         }
         }
+
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
     public void PosPercent_SetsValue ()
     public void PosPercent_SetsValue ()
     {
     {
-        int f = 0;
-        Pos pos = Pos.Percent (f);
+        var f = 0;
+        Pos pos = Percent (f);
         Assert.Equal ($"Percent({f})", pos.ToString ());
         Assert.Equal ($"Percent({f})", pos.ToString ());
         f = 50;
         f = 50;
-        pos = Pos.Percent (f);
+        pos = Percent (f);
         Assert.Equal ($"Percent({f})", pos.ToString ());
         Assert.Equal ($"Percent({f})", pos.ToString ());
         f = 100;
         f = 100;
-        pos = Pos.Percent (f);
+        pos = Percent (f);
         Assert.Equal ($"Percent({f})", pos.ToString ());
         Assert.Equal ($"Percent({f})", pos.ToString ());
     }
     }
 
 
     [Fact]
     [Fact]
     public void PosPercent_ThrowsOnIvalid ()
     public void PosPercent_ThrowsOnIvalid ()
     {
     {
-        Pos pos = Pos.Percent (0);
-        Assert.Throws<ArgumentException> (() => pos = Pos.Percent (-1));
+        Pos pos = Percent (0);
+        Assert.Throws<ArgumentException> (() => pos = Percent (-1));
+
         //Assert.Throws<ArgumentException> (() => pos = Pos.Percent (101));
         //Assert.Throws<ArgumentException> (() => pos = Pos.Percent (101));
         //Assert.Throws<ArgumentException> (() => pos = Pos.Percent (1000001));
         //Assert.Throws<ArgumentException> (() => pos = Pos.Percent (1000001));
     }
     }
-
 }
 }

+ 45 - 4
UnitTests/View/Layout/ViewportTests.cs

@@ -181,10 +181,8 @@ public class ViewportTests (ITestOutputHelper output)
         var newViewport = new Rectangle (0, 0, 30, 40);
         var newViewport = new Rectangle (0, 0, 30, 40);
 
 
         var v = new View { Frame = frame };
         var v = new View { Frame = frame };
-        Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
 
 
         v.Viewport = newViewport;
         v.Viewport = newViewport;
-        Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
         Assert.Equal (newViewport, v.Viewport);
         Assert.Equal (newViewport, v.Viewport);
         Assert.Equal (new Rectangle (1, 2, newViewport.Width, newViewport.Height), v.Frame);
         Assert.Equal (new Rectangle (1, 2, newViewport.Width, newViewport.Height), v.Frame);
         Assert.Equal (new Rectangle (0, 0, newViewport.Width, newViewport.Height), v.Viewport);
         Assert.Equal (new Rectangle (0, 0, newViewport.Width, newViewport.Height), v.Viewport);
@@ -340,14 +338,57 @@ public class ViewportTests (ITestOutputHelper output)
     }
     }
 
 
     [Fact]
     [Fact]
-    public void ContentSize_Matches_ViewportSize_If_Not_Set ()
+    public void ContentSize_Tracks_ViewportSize_If_Not_Set ()
     {
     {
         View view = new ()
         View view = new ()
         {
         {
             Width = 1,
             Width = 1,
             Height = 1
             Height = 1
         };
         };
-        Assert.Equal (view.Viewport.Size, view.ContentSize);
+        Assert.True (view.ContentSizeTracksViewport);
+        Assert.Equal (view.Viewport.Size, view.GetContentSize ());
+    }
+
+    [Fact]
+    public void ContentSize_Ignores_ViewportSize_If_Set ()
+    {
+        View view = new ()
+        {
+            Width = 1,
+            Height = 1,
+        };
+        view.SetContentSize (new Size (5, 5));
+        Assert.False (view.ContentSizeTracksViewport);
+        Assert.NotEqual (view.Viewport.Size, view.GetContentSize ());
+    }
+
+    [Fact]
+    public void ContentSize_Tracks_ViewportSize_If_ContentSizeTracksViewport_Is_True ()
+    {
+        View view = new ()
+        {
+            Width = 1,
+            Height = 1,
+        };
+        view.SetContentSize (new Size (5, 5));
+        view.Viewport = new (0, 0, 10, 10);
+        view.ContentSizeTracksViewport = true;
+        Assert.Equal (view.Viewport.Size, view.GetContentSize ());
+    }
+
+
+    [Fact]
+    public void ContentSize_Ignores_ViewportSize_If_ContentSizeTracksViewport_Is_False ()
+    {
+        View view = new ()
+        {
+            Width = 1,
+            Height = 1,
+        };
+        view.SetContentSize (new Size (5, 5));
+        view.Viewport = new (0, 0, 10, 10);
+        view.ContentSizeTracksViewport = false;
+        Assert.NotEqual (view.Viewport.Size, view.GetContentSize ());
     }
     }
 
 
     //[Theory]
     //[Theory]

+ 1 - 0
UnitTests/View/MouseTests.cs

@@ -78,6 +78,7 @@ public class MouseTests (ITestOutputHelper output) : TestsAllViews
         Application.OnMouseEvent (new () { Position = new (xy + 1, xy + 1), Flags = MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition });
         Application.OnMouseEvent (new () { Position = new (xy + 1, xy + 1), Flags = MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition });
 
 
         Assert.Equal (expectedMoved, new Point (5, 5) == testView.Frame.Location);
         Assert.Equal (expectedMoved, new Point (5, 5) == testView.Frame.Location);
+        top.Dispose ();
     }
     }
 
 
     [Theory]
     [Theory]

+ 17 - 12
UnitTests/View/NavigationTests.cs

@@ -1,15 +1,9 @@
 using Xunit.Abstractions;
 using Xunit.Abstractions;
 
 
-// Alias Console to MockConsole so we don't accidentally use Console
-using Console = Terminal.Gui.FakeConsole;
-
 namespace Terminal.Gui.ViewTests;
 namespace Terminal.Gui.ViewTests;
 
 
-public class NavigationTests
+public class NavigationTests (ITestOutputHelper output)
 {
 {
-    private readonly ITestOutputHelper _output;
-    public NavigationTests (ITestOutputHelper output) { _output = output; }
-
     [Fact]
     [Fact]
     public void BringSubviewForward_Subviews_vs_TabIndexes ()
     public void BringSubviewForward_Subviews_vs_TabIndexes ()
     {
     {
@@ -308,6 +302,7 @@ public class NavigationTests
         Assert.False (view.HasFocus);
         Assert.False (view.HasFocus);
         Assert.Null (Application.Current.Focused);
         Assert.Null (Application.Current.Focused);
         Assert.Null (Application.Current.MostFocused);
         Assert.Null (Application.Current.MostFocused);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -348,6 +343,7 @@ public class NavigationTests
         Assert.True (view2.HasFocus);
         Assert.True (view2.HasFocus);
         Assert.Equal (win2, Application.Current.Focused);
         Assert.Equal (win2, Application.Current.Focused);
         Assert.Equal (view2, Application.Current.MostFocused);
         Assert.Equal (view2, Application.Current.MostFocused);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -390,6 +386,7 @@ public class NavigationTests
         Assert.True (view2.HasFocus);
         Assert.True (view2.HasFocus);
         Assert.Equal (win2, Application.Current.Focused);
         Assert.Equal (win2, Application.Current.Focused);
         Assert.Equal (view2, Application.Current.MostFocused);
         Assert.Equal (view2, Application.Current.MostFocused);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -440,10 +437,10 @@ public class NavigationTests
         Assert.False (view2.HasFocus);
         Assert.False (view2.HasFocus);
         Assert.Equal (win1, Application.Current.Focused);
         Assert.Equal (win1, Application.Current.Focused);
         Assert.Equal (view12, Application.Current.MostFocused);
         Assert.Equal (view12, Application.Current.MostFocused);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown]
     public void Enabled_False_Sets_HasFocus_To_False ()
     public void Enabled_False_Sets_HasFocus_To_False ()
     {
     {
         var wasClicked = false;
         var wasClicked = false;
@@ -529,6 +526,7 @@ public class NavigationTests
         Application.Run (top);
         Application.Run (top);
 
 
         Assert.Equal (1, iterations);
         Assert.Equal (1, iterations);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -619,6 +617,7 @@ public class NavigationTests
         Assert.Null (exception);
         Assert.Null (exception);
         Assert.True (removed);
         Assert.True (removed);
         Assert.Null (view3);
         Assert.Null (view3);
+        top1.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -694,6 +693,7 @@ public class NavigationTests
 // This test is now invalid because `win` is focused, so it will receive the keypress
 // This test is now invalid because `win` is focused, so it will receive the keypress
         Assert.True (topQuiting);
         Assert.True (topQuiting);
 #endif
 #endif
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -745,9 +745,11 @@ public class NavigationTests
         Assert.True (sbQuiting);
         Assert.True (sbQuiting);
         Assert.False (tfQuiting);
         Assert.False (tfQuiting);
 #endif
 #endif
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
+    [SetupFakeDriver]
     public void Navigation_With_Null_Focused_View ()
     public void Navigation_With_Null_Focused_View ()
     {
     {
         // Non-regression test for #882 (NullReferenceException during keyboard navigation when Focused is null)
         // Non-regression test for #882 (NullReferenceException during keyboard navigation when Focused is null)
@@ -758,7 +760,7 @@ public class NavigationTests
         top.Ready += (s, e) => { Assert.Null (top.Focused); };
         top.Ready += (s, e) => { Assert.Null (top.Focused); };
 
 
         // Keyboard navigation with tab
         // Keyboard navigation with tab
-        Console.MockKeyPresses.Push (new ConsoleKeyInfo ('\t', ConsoleKey.Tab, false, false, false));
+        FakeConsole.MockKeyPresses.Push (new ConsoleKeyInfo ('\t', ConsoleKey.Tab, false, false, false));
 
 
         Application.Iteration += (s, a) => Application.RequestStop ();
         Application.Iteration += (s, a) => Application.RequestStop ();
 
 
@@ -805,6 +807,7 @@ public class NavigationTests
         Assert.True (container.HasFocus);
         Assert.True (container.HasFocus);
         Assert.Null (child);
         Assert.Null (child);
         Assert.False (leave);
         Assert.False (leave);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -847,7 +850,7 @@ public class NavigationTests
 │                  │
 │                  │
 │                  │
 │                  │
 └──────────────────┘",
 └──────────────────┘",
-                                                          _output
+                                                          output
                                                          );
                                                          );
 
 
         // top
         // top
@@ -948,6 +951,7 @@ public class NavigationTests
         Assert.Equal (4, screen.Y);
         Assert.Equal (4, screen.Y);
         found = View.FindDeepestView (top, new (15, 4));
         found = View.FindDeepestView (top, new (15, 4));
         Assert.Equal (top, found);
         Assert.Equal (top, found);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -997,7 +1001,7 @@ public class NavigationTests
    │                  │
    │                  │
    │                  │
    │                  │
    └──────────────────┘",
    └──────────────────┘",
-                                                                   _output
+                                                                   output
                                                                   );
                                                                   );
 
 
         // mean the output started at col 3 and line 2
         // mean the output started at col 3 and line 2
@@ -1083,6 +1087,7 @@ public class NavigationTests
         Assert.Equal (24, screen.X);
         Assert.Equal (24, screen.X);
         Assert.Equal (4, screen.Y);
         Assert.Equal (4, screen.Y);
         Assert.Null (View.FindDeepestView (top, new (24, 4)));
         Assert.Null (View.FindDeepestView (top, new (24, 4)));
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -1128,7 +1133,6 @@ public class NavigationTests
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown]
     public void SetFocus_View_With_Null_Superview_Does_Not_Throw_Exception ()
     public void SetFocus_View_With_Null_Superview_Does_Not_Throw_Exception ()
     {
     {
         var top = new Toplevel ();
         var top = new Toplevel ();
@@ -1177,6 +1181,7 @@ public class NavigationTests
         Assert.False (subView1subView1Leave);
         Assert.False (subView1subView1Leave);
         Application.End (rs);
         Application.End (rs);
         subView1subView1.Dispose ();
         subView1subView1.Dispose ();
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]

+ 42 - 1
UnitTests/View/SubviewTests.cs

@@ -75,7 +75,7 @@ public class SubviewTests
         w2.Dispose ();
         w2.Dispose ();
         top2.Dispose ();
         top2.Dispose ();
     }
     }
-    
+
     [Fact]
     [Fact]
     [TestRespondersDisposed]
     [TestRespondersDisposed]
     public void Initialized_Event_Comparing_With_Added_Event ()
     public void Initialized_Event_Comparing_With_Added_Event ()
@@ -332,4 +332,45 @@ public class SubviewTests
         top.Dispose ();
         top.Dispose ();
         view.Dispose ();
         view.Dispose ();
     }
     }
+
+    // TODO: Consider a feature that will change the ContentSize to fit the subviews.
+    [Fact]
+    public void Add_Does_Not_Impact_ContentSize ()
+    {
+        var view = new View ();
+        view.SetContentSize (new Size (1, 1));
+
+        var subview = new View ()
+        {
+            X = 10,
+            Y = 10
+        };
+
+        Assert.Equal (new Size (1, 1), view.GetContentSize ());
+        view.Add (subview);
+        Assert.Equal (new Size (1, 1), view.GetContentSize ());
+    }
+
+    [Fact]
+    public void Remove_Does_Not_Impact_ContentSize ()
+    {
+        var view = new View ();
+        view.SetContentSize (new Size (1, 1));
+
+        var subview = new View ()
+        {
+            X = 10,
+            Y = 10
+        };
+
+        Assert.Equal (new Size (1, 1), view.GetContentSize ());
+        view.Add (subview);
+        Assert.Equal (new Size (1, 1), view.GetContentSize ());
+
+        view.SetContentSize (new Size (5, 5));
+        Assert.Equal (new Size (5, 5), view.GetContentSize ());
+
+        view.Remove (subview);
+        Assert.Equal (new Size (5, 5), view.GetContentSize ());
+    }
 }
 }

+ 14 - 6
UnitTests/View/TextTests.cs

@@ -10,8 +10,6 @@ namespace Terminal.Gui.ViewTests;
 /// </summary>
 /// </summary>
 public class TextTests (ITestOutputHelper output)
 public class TextTests (ITestOutputHelper output)
 {
 {
-    private readonly ITestOutputHelper _output = output;
-
     // TextFormatter.Size should be empty unless DimAuto is set or ContentSize is set
     // TextFormatter.Size should be empty unless DimAuto is set or ContentSize is set
     [Theory]
     [Theory]
     [InlineData ("", 0, 0)]
     [InlineData ("", 0, 0)]
@@ -32,7 +30,7 @@ public class TextTests (ITestOutputHelper output)
     public void TextFormatter_Size_Tracks_ContentSize (string text, int expectedW, int expectedH)
     public void TextFormatter_Size_Tracks_ContentSize (string text, int expectedW, int expectedH)
     {
     {
         var view = new View ();
         var view = new View ();
-        view.SetContentSize(new (1,1));
+        view.SetContentSize (new (1, 1));
         view.Text = text;
         view.Text = text;
         Assert.Equal (new (expectedW, expectedH), view.TextFormatter.Size);
         Assert.Equal (new (expectedW, expectedH), view.TextFormatter.Size);
     }
     }
@@ -135,6 +133,7 @@ Y
 
 
         pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Application.End (rs);
         Application.End (rs);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -394,6 +393,7 @@ Y
 
 
         pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Application.End (rs);
         Application.End (rs);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -422,7 +422,7 @@ Y
 
 
         Assert.Equal (new (0, 0, 1, 5), view.Frame);
         Assert.Equal (new (0, 0, 1, 5), view.Frame);
         Assert.Equal (new (1, 5), view.TextFormatter.Size);
         Assert.Equal (new (1, 5), view.TextFormatter.Size);
-        Assert.Equal (new() { "Views" }, view.TextFormatter.GetLines ());
+        Assert.Equal (new () { "Views" }, view.TextFormatter.GetLines ());
         Assert.Equal (new (0, 0, 4, 10), win.Frame);
         Assert.Equal (new (0, 0, 4, 10), win.Frame);
         Assert.Equal (new (0, 0, 4, 10), Application.Top.Frame);
         Assert.Equal (new (0, 0, 4, 10), Application.Top.Frame);
 
 
@@ -468,6 +468,7 @@ Y
 
 
         pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Assert.Equal (new (0, 0, 4, 10), pos);
         Assert.Equal (new (0, 0, 4, 10), pos);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -493,7 +494,7 @@ Y
         Assert.Equal (5, text.Length);
         Assert.Equal (5, text.Length);
         Assert.Equal (new (0, 0, 2, 5), view.Frame);
         Assert.Equal (new (0, 0, 2, 5), view.Frame);
         Assert.Equal (new (2, 5), view.TextFormatter.Size);
         Assert.Equal (new (2, 5), view.TextFormatter.Size);
-        Assert.Equal (new() { "界View" }, view.TextFormatter.GetLines ());
+        Assert.Equal (new () { "界View" }, view.TextFormatter.GetLines ());
         Assert.Equal (new (0, 0, 4, 10), win.Frame);
         Assert.Equal (new (0, 0, 4, 10), win.Frame);
         Assert.Equal (new (0, 0, 4, 10), Application.Top.Frame);
         Assert.Equal (new (0, 0, 4, 10), Application.Top.Frame);
 
 
@@ -524,7 +525,7 @@ Y
 
 
         Exception exception = Record.Exception (
         Exception exception = Record.Exception (
                                                 () => Assert.Equal (
                                                 () => Assert.Equal (
-                                                                    new() { "界View" },
+                                                                    new () { "界View" },
                                                                     view.TextFormatter.GetLines ()
                                                                     view.TextFormatter.GetLines ()
                                                                    )
                                                                    )
                                                );
                                                );
@@ -545,6 +546,7 @@ Y
 
 
         pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Assert.Equal (new (0, 0, 4, 10), pos);
         Assert.Equal (new (0, 0, 4, 10), pos);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -641,6 +643,7 @@ Y
 
 
         pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Application.End (rs);
         Application.End (rs);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -737,6 +740,7 @@ Y
 
 
         pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Application.End (rs);
         Application.End (rs);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -772,6 +776,7 @@ Y
         }
         }
 
 
         Application.End (rs);
         Application.End (rs);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -820,6 +825,7 @@ Y
         Assert.Equal (new (0, 0, 2, 10), verticalView.Frame);
         Assert.Equal (new (0, 0, 2, 10), verticalView.Frame);
         Assert.Equal (new (2, 10), verticalView.GetSizeNeededForTextWithoutHotKey ());
         Assert.Equal (new (2, 10), verticalView.GetSizeNeededForTextWithoutHotKey ());
         Assert.Equal (verticalView.Frame.Size, verticalView.GetSizeNeededForTextWithoutHotKey ());
         Assert.Equal (verticalView.Frame.Size, verticalView.GetSizeNeededForTextWithoutHotKey ());
+        top.Dispose ();
     }
     }
 
 
     [Theory]
     [Theory]
@@ -942,6 +948,7 @@ Y
 
 
         Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Assert.Equal (new (0, 0, width + 2, 6), pos);
         Assert.Equal (new (0, 0, width + 2, 6), pos);
+        top.Dispose ();
     }
     }
 
 
     [Theory]
     [Theory]
@@ -1099,6 +1106,7 @@ Y
 
 
         Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Assert.Equal (new (0, 0, 9, height + 2), pos);
         Assert.Equal (new (0, 0, 9, height + 2), pos);
+        top.Dispose ();
     }
     }
 
 
     // Test that View.PreserveTrailingSpaces removes trailing spaces
     // Test that View.PreserveTrailingSpaces removes trailing spaces

+ 1 - 1
UnitTests/View/TitleTests.cs

@@ -102,7 +102,7 @@ public class TitleTests (ITestOutputHelper output)
         Assert.Equal (text, view.Text);
         Assert.Equal (text, view.Text);
 
 
         // SetupFakeDriver only create a screen with 25 cols and 25 rows
         // SetupFakeDriver only create a screen with 25 cols and 25 rows
-        Assert.Equal (new (text.Length, 1), view.ContentSize);
+        Assert.Equal (new (text.Length, 1), view.GetContentSize ());
 
 
         top.Dispose ();
         top.Dispose ();
     }
     }

+ 6 - 3
UnitTests/View/ViewKeyBindingTests.cs

@@ -2,10 +2,9 @@
 
 
 namespace Terminal.Gui.ViewTests;
 namespace Terminal.Gui.ViewTests;
 
 
-public class ViewKeyBindingTests
+public class ViewKeyBindingTests (ITestOutputHelper output)
 {
 {
-    private readonly ITestOutputHelper _output;
-    public ViewKeyBindingTests (ITestOutputHelper output) { _output = output; }
+    private readonly ITestOutputHelper _output = output;
 
 
     [Fact]
     [Fact]
     [AutoInitShutdown]
     [AutoInitShutdown]
@@ -42,6 +41,7 @@ public class ViewKeyBindingTests
         Assert.True (view.ApplicationCommand);
         Assert.True (view.ApplicationCommand);
         Assert.True (view.HotKeyCommand);
         Assert.True (view.HotKeyCommand);
         Assert.True (view.FocusedCommand);
         Assert.True (view.FocusedCommand);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -69,6 +69,7 @@ public class ViewKeyBindingTests
         Assert.False (view.ApplicationCommand);
         Assert.False (view.ApplicationCommand);
         Assert.False (view.HotKeyCommand);
         Assert.False (view.HotKeyCommand);
         Assert.False (view.FocusedCommand);
         Assert.False (view.FocusedCommand);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -98,6 +99,7 @@ public class ViewKeyBindingTests
         Application.OnKeyDown (Key.Z); // new hot key
         Application.OnKeyDown (Key.Z); // new hot key
         Assert.True (invoked);
         Assert.True (invoked);
         Assert.True (view.HotKeyCommand);
         Assert.True (view.HotKeyCommand);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -119,6 +121,7 @@ public class ViewKeyBindingTests
         invoked = false;
         invoked = false;
         Application.OnKeyDown (Key.F);
         Application.OnKeyDown (Key.F);
         Assert.False (view.HotKeyCommand);
         Assert.False (view.HotKeyCommand);
+        top.Dispose ();
     }
     }
 
 
     // tests that test KeyBindingScope.Focus and KeyBindingScope.HotKey (tests for KeyBindingScope.Application are in Application/KeyboardTests.cs)
     // tests that test KeyBindingScope.Focus and KeyBindingScope.HotKey (tests for KeyBindingScope.Application are in Application/KeyboardTests.cs)

+ 118 - 114
UnitTests/View/ViewTests.cs

@@ -4,11 +4,8 @@ using Xunit.Abstractions;
 
 
 namespace Terminal.Gui.ViewTests;
 namespace Terminal.Gui.ViewTests;
 
 
-public class ViewTests
+public class ViewTests (ITestOutputHelper output)
 {
 {
-    private readonly ITestOutputHelper _output;
-    public ViewTests (ITestOutputHelper output) { _output = output; }
-
     [Fact]
     [Fact]
     [AutoInitShutdown]
     [AutoInitShutdown]
     public void Clear_Viewport_Can_Use_Driver_AddRune_Or_AddStr_Methods ()
     public void Clear_Viewport_Can_Use_Driver_AddRune_Or_AddStr_Methods ()
@@ -18,7 +15,7 @@ public class ViewTests
         view.DrawContent += (s, e) =>
         view.DrawContent += (s, e) =>
                             {
                             {
                                 Rectangle savedClip = Application.Driver.Clip;
                                 Rectangle savedClip = Application.Driver.Clip;
-                                Application.Driver.Clip = new Rectangle (1, 1, view.Viewport.Width, view.Viewport.Height);
+                                Application.Driver.Clip = new (1, 1, view.Viewport.Width, view.Viewport.Height);
 
 
                                 for (var row = 0; row < view.Viewport.Height; row++)
                                 for (var row = 0; row < view.Viewport.Height; row++)
                                 {
                                 {
@@ -51,8 +48,8 @@ public class ViewTests
 └──────────────────┘
 └──────────────────┘
 ";
 ";
 
 
-        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
-        Assert.Equal (new Rectangle (0, 0, 20, 10), pos);
+        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+        Assert.Equal (new (0, 0, 20, 10), pos);
 
 
         view.FillRect (view.Viewport);
         view.FillRect (view.Viewport);
 
 
@@ -69,7 +66,7 @@ public class ViewTests
 └──────────────────┘
 └──────────────────┘
 ";
 ";
 
 
-        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         top.Dispose ();
         top.Dispose ();
     }
     }
 
 
@@ -82,7 +79,7 @@ public class ViewTests
         view.DrawContent += (s, e) =>
         view.DrawContent += (s, e) =>
                             {
                             {
                                 Rectangle savedClip = Application.Driver.Clip;
                                 Rectangle savedClip = Application.Driver.Clip;
-                                Application.Driver.Clip = new Rectangle (1, 1, view.Viewport.Width, view.Viewport.Height);
+                                Application.Driver.Clip = new (1, 1, view.Viewport.Width, view.Viewport.Height);
 
 
                                 for (var row = 0; row < view.Viewport.Height; row++)
                                 for (var row = 0; row < view.Viewport.Height; row++)
                                 {
                                 {
@@ -115,8 +112,8 @@ public class ViewTests
 └──────────────────┘
 └──────────────────┘
 ";
 ";
 
 
-        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
-        Assert.Equal (new Rectangle (0, 0, 20, 10), pos);
+        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+        Assert.Equal (new (0, 0, 20, 10), pos);
 
 
         view.FillRect (view.Viewport);
         view.FillRect (view.Viewport);
 
 
@@ -133,7 +130,7 @@ public class ViewTests
 └──────────────────┘
 └──────────────────┘
 ";
 ";
 
 
-        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
 
 
         top.Dispose ();
         top.Dispose ();
     }
     }
@@ -147,8 +144,8 @@ public class ViewTests
         var root = new View { Width = 20, Height = 10, ColorScheme = Colors.ColorSchemes ["Base"] };
         var root = new View { Width = 20, Height = 10, ColorScheme = Colors.ColorSchemes ["Base"] };
 
 
         View v = label
         View v = label
-                     ? new Label { Text = new string ('c', 100) }
-                     : new TextView { Height = 1, Text = new string ('c', 100), Width = Dim.Fill () };
+                     ? new Label { Text = new ('c', 100) }
+                     : new TextView { Height = 1, Text = new ('c', 100), Width = Dim.Fill () };
 
 
         root.Add (v);
         root.Add (v);
 
 
@@ -159,18 +156,19 @@ public class ViewTests
         if (label)
         if (label)
         {
         {
             Assert.False (v.CanFocus);
             Assert.False (v.CanFocus);
+
             //Assert.Equal (new Rectangle (0, 0, 20, 1), v.Frame);
             //Assert.Equal (new Rectangle (0, 0, 20, 1), v.Frame);
         }
         }
         else
         else
         {
         {
             Assert.True (v.CanFocus);
             Assert.True (v.CanFocus);
-            Assert.Equal (new Rectangle (0, 0, 20, 1), v.Frame);
+            Assert.Equal (new (0, 0, 20, 1), v.Frame);
         }
         }
 
 
         TestHelpers.AssertDriverContentsWithFrameAre (
         TestHelpers.AssertDriverContentsWithFrameAre (
                                                       @"
                                                       @"
 cccccccccccccccccccc",
 cccccccccccccccccccc",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Attribute [] attributes =
         Attribute [] attributes =
@@ -220,6 +218,7 @@ cccccccccccccccccccc",
         }
         }
 
 
         Application.End (runState);
         Application.End (runState);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -246,14 +245,13 @@ At 0,0
                              
                              
   A text with some long width
   A text with some long width
    and also with two lines.  ",
    and also with two lines.  ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
-        view.Frame = new Rectangle (3, 3, 10, 1);
-        Assert.Equal (new Rectangle (3, 3, 10, 1), view.Frame);
-        Assert.Equal (LayoutStyle.Absolute, view.LayoutStyle);
-        Assert.Equal (new Rectangle (0, 0, 10, 1), view.Viewport);
-        Assert.Equal (new Rectangle (0, 0, 10, 1), view._needsDisplayRect);
+        view.Frame = new (3, 3, 10, 1);
+        Assert.Equal (new (3, 3, 10, 1), view.Frame);
+        Assert.Equal (new (0, 0, 10, 1), view.Viewport);
+        Assert.Equal (new (0, 0, 10, 1), view._needsDisplayRect);
         top.Draw ();
         top.Draw ();
 
 
         TestHelpers.AssertDriverContentsWithFrameAre (
         TestHelpers.AssertDriverContentsWithFrameAre (
@@ -262,9 +260,10 @@ At 0,0
              
              
              
              
    A text wit",
    A text wit",
-                                                      _output
+                                                      output
                                                      );
                                                      );
         Application.End (runState);
         Application.End (runState);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -293,16 +292,16 @@ At 0,0
                              
                              
   A text with some long width
   A text with some long width
    and also with two lines.  ",
    and also with two lines.  ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         view.X = 3;
         view.X = 3;
         view.Y = 3;
         view.Y = 3;
         view.Width = 10;
         view.Width = 10;
         view.Height = 1;
         view.Height = 1;
-        Assert.Equal (new Rectangle (3, 3, 10, 1), view.Frame);
-        Assert.Equal (new Rectangle (0, 0, 10, 1), view.Viewport);
-        Assert.Equal (new Rectangle (0, 0, 30, 2), view._needsDisplayRect);
+        Assert.Equal (new (3, 3, 10, 1), view.Frame);
+        Assert.Equal (new (0, 0, 10, 1), view.Viewport);
+        Assert.Equal (new (0, 0, 30, 2), view._needsDisplayRect);
         top.Draw ();
         top.Draw ();
 
 
         TestHelpers.AssertDriverContentsWithFrameAre (
         TestHelpers.AssertDriverContentsWithFrameAre (
@@ -311,9 +310,10 @@ At 0,0
              
              
              
              
    A text wit",
    A text wit",
-                                                      _output
+                                                      output
                                                      );
                                                      );
         Application.End (runState);
         Application.End (runState);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -342,23 +342,23 @@ At 0,0
                              
                              
   A text with some long width
   A text with some long width
    and also with two lines.  ",
    and also with two lines.  ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
-        view.Frame = new Rectangle (1, 1, 10, 1);
-        Assert.Equal (new Rectangle (1, 1, 10, 1), view.Frame);
-        Assert.Equal (LayoutStyle.Absolute, view.LayoutStyle);
-        Assert.Equal (new Rectangle (0, 0, 10, 1), view.Viewport);
-        Assert.Equal (new Rectangle (0, 0, 10, 1), view._needsDisplayRect);
+        view.Frame = new (1, 1, 10, 1);
+        Assert.Equal (new (1, 1, 10, 1), view.Frame);
+        Assert.Equal (new (0, 0, 10, 1), view.Viewport);
+        Assert.Equal (new (0, 0, 10, 1), view._needsDisplayRect);
         top.Draw ();
         top.Draw ();
 
 
         TestHelpers.AssertDriverContentsWithFrameAre (
         TestHelpers.AssertDriverContentsWithFrameAre (
                                                       @"
                                                       @"
 At 0,0     
 At 0,0     
  A text wit",
  A text wit",
-                                                      _output
+                                                      output
                                                      );
                                                      );
         Application.End (runState);
         Application.End (runState);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -387,25 +387,26 @@ At 0,0
                              
                              
   A text with some long width
   A text with some long width
    and also with two lines.  ",
    and also with two lines.  ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         view.X = 1;
         view.X = 1;
         view.Y = 1;
         view.Y = 1;
         view.Width = 10;
         view.Width = 10;
         view.Height = 1;
         view.Height = 1;
-        Assert.Equal (new Rectangle (1, 1, 10, 1), view.Frame);
-        Assert.Equal (new Rectangle (0, 0, 10, 1), view.Viewport);
-        Assert.Equal (new Rectangle (0, 0, 30, 2), view._needsDisplayRect);
+        Assert.Equal (new (1, 1, 10, 1), view.Frame);
+        Assert.Equal (new (0, 0, 10, 1), view.Viewport);
+        Assert.Equal (new (0, 0, 30, 2), view._needsDisplayRect);
         top.Draw ();
         top.Draw ();
 
 
         TestHelpers.AssertDriverContentsWithFrameAre (
         TestHelpers.AssertDriverContentsWithFrameAre (
                                                       @"
                                                       @"
 At 0,0     
 At 0,0     
  A text wit",
  A text wit",
-                                                      _output
+                                                      output
                                                      );
                                                      );
         Application.End (runState);
         Application.End (runState);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -445,6 +446,7 @@ At 0,0
 
 
         Assert.True (viewCalled);
         Assert.True (viewCalled);
         Assert.True (tvCalled);
         Assert.True (tvCalled);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -478,33 +480,33 @@ At 0,0
 
 
         RunState runState = Application.Begin (top);
         RunState runState = Application.Begin (top);
 
 
-        top.LayoutComplete += (s, e) => { Assert.Equal (new Rectangle (0, 0, 80, 25), top._needsDisplayRect); };
+        top.LayoutComplete += (s, e) => { Assert.Equal (new (0, 0, 80, 25), top._needsDisplayRect); };
 
 
-        frame.LayoutComplete += (s, e) => { Assert.Equal (new Rectangle (0, 0, 40, 8), frame._needsDisplayRect); };
+        frame.LayoutComplete += (s, e) => { Assert.Equal (new (0, 0, 40, 8), frame._needsDisplayRect); };
 
 
-        label.LayoutComplete += (s, e) => { Assert.Equal (new Rectangle (0, 0, 38, 1), label._needsDisplayRect); };
+        label.LayoutComplete += (s, e) => { Assert.Equal (new (0, 0, 38, 1), label._needsDisplayRect); };
 
 
-        button.LayoutComplete += (s, e) => { Assert.Equal (new Rectangle (0, 0, 13, 1), button._needsDisplayRect); };
+        button.LayoutComplete += (s, e) => { Assert.Equal (new (0, 0, 13, 1), button._needsDisplayRect); };
 
 
-        Assert.Equal (new Rectangle (0, 0, 80, 25), top.Frame);
-        Assert.Equal (new Rectangle (20, 8, 40, 8), frame.Frame);
+        Assert.Equal (new (0, 0, 80, 25), top.Frame);
+        Assert.Equal (new (20, 8, 40, 8), frame.Frame);
 
 
         Assert.Equal (
         Assert.Equal (
-                      new Rectangle (20, 8, 60, 16),
+                      new (20, 8, 60, 16),
                       new Rectangle (
                       new Rectangle (
-                                frame.Frame.Left,
-                                frame.Frame.Top,
-                                frame.Frame.Right,
-                                frame.Frame.Bottom
-                               )
+                                     frame.Frame.Left,
+                                     frame.Frame.Top,
+                                     frame.Frame.Right,
+                                     frame.Frame.Bottom
+                                    )
                      );
                      );
-        Assert.Equal (new Rectangle (0, 0, 30, 1), label.Frame);
-        Assert.Equal (new Rectangle (0, 1, 13, 1), button.Frame); // this proves frame was set
+        Assert.Equal (new (0, 0, 30, 1), label.Frame);
+        Assert.Equal (new (0, 1, 13, 1), button.Frame); // this proves frame was set
         Application.End (runState);
         Application.End (runState);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown]
     public void GetHotNormalColor_ColorScheme ()
     public void GetHotNormalColor_ColorScheme ()
     {
     {
         var view = new View { ColorScheme = Colors.ColorSchemes ["Base"] };
         var view = new View { ColorScheme = Colors.ColorSchemes ["Base"] };
@@ -517,7 +519,6 @@ At 0,0
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown]
     public void GetNormalColor_ColorScheme ()
     public void GetNormalColor_ColorScheme ()
     {
     {
         var view = new View { ColorScheme = Colors.ColorSchemes ["Base"] };
         var view = new View { ColorScheme = Colors.ColorSchemes ["Base"] };
@@ -555,12 +556,12 @@ At 0,0
                              
                              
   A text with some long width
   A text with some long width
    and also with two lines.  ",
    and also with two lines.  ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
-        view.Frame = new Rectangle (3, 3, 10, 1);
-        Assert.Equal (new Rectangle (0, 0, 10, 1), view.Viewport);
-        Assert.Equal (new Rectangle (0, 0, 10, 1), view._needsDisplayRect);
+        view.Frame = new (3, 3, 10, 1);
+        Assert.Equal (new (0, 0, 10, 1), view.Viewport);
+        Assert.Equal (new (0, 0, 10, 1), view._needsDisplayRect);
         view.Draw ();
         view.Draw ();
 
 
         TestHelpers.AssertDriverContentsWithFrameAre (
         TestHelpers.AssertDriverContentsWithFrameAre (
@@ -569,9 +570,10 @@ At 0,0
                              
                              
   A text with some long width
   A text with some long width
    A text witith two lines.  ",
    A text witith two lines.  ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
         Application.End (runState);
         Application.End (runState);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -600,16 +602,16 @@ At 0,0
                              
                              
   A text with some long width
   A text with some long width
    and also with two lines.  ",
    and also with two lines.  ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         view.X = 3;
         view.X = 3;
         view.Y = 3;
         view.Y = 3;
         view.Width = 10;
         view.Width = 10;
         view.Height = 1;
         view.Height = 1;
-        Assert.Equal (new Rectangle (3, 3, 10, 1), view.Frame);
-        Assert.Equal (new Rectangle (0, 0, 10, 1), view.Viewport);
-        Assert.Equal (new Rectangle (0, 0, 30, 2), view._needsDisplayRect);
+        Assert.Equal (new (3, 3, 10, 1), view.Frame);
+        Assert.Equal (new (0, 0, 10, 1), view.Viewport);
+        Assert.Equal (new (0, 0, 30, 2), view._needsDisplayRect);
         view.Draw ();
         view.Draw ();
 
 
         TestHelpers.AssertDriverContentsWithFrameAre (
         TestHelpers.AssertDriverContentsWithFrameAre (
@@ -618,9 +620,10 @@ At 0,0
                              
                              
   A text with some long width
   A text with some long width
    A text witith two lines.  ",
    A text witith two lines.  ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
         Application.End (runState);
         Application.End (runState);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -649,14 +652,13 @@ At 0,0
                              
                              
   A text with some long width
   A text with some long width
    and also with two lines.  ",
    and also with two lines.  ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
-        view.Frame = new Rectangle (1, 1, 10, 1);
-        Assert.Equal (new Rectangle (1, 1, 10, 1), view.Frame);
-        Assert.Equal (LayoutStyle.Absolute, view.LayoutStyle);
-        Assert.Equal (new Rectangle (0, 0, 10, 1), view.Viewport);
-        Assert.Equal (new Rectangle (0, 0, 10, 1), view._needsDisplayRect);
+        view.Frame = new (1, 1, 10, 1);
+        Assert.Equal (new (1, 1, 10, 1), view.Frame);
+        Assert.Equal (new (0, 0, 10, 1), view.Viewport);
+        Assert.Equal (new (0, 0, 10, 1), view._needsDisplayRect);
         view.Draw ();
         view.Draw ();
 
 
         TestHelpers.AssertDriverContentsWithFrameAre (
         TestHelpers.AssertDriverContentsWithFrameAre (
@@ -665,9 +667,10 @@ At 0,0
  A text wit                  
  A text wit                  
   A text with some long width
   A text with some long width
    and also with two lines.  ",
    and also with two lines.  ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
         Application.End (runState);
         Application.End (runState);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -696,16 +699,16 @@ At 0,0
                              
                              
   A text with some long width
   A text with some long width
    and also with two lines.  ",
    and also with two lines.  ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         view.X = 1;
         view.X = 1;
         view.Y = 1;
         view.Y = 1;
         view.Width = 10;
         view.Width = 10;
         view.Height = 1;
         view.Height = 1;
-        Assert.Equal (new Rectangle (1, 1, 10, 1), view.Frame);
-        Assert.Equal (new Rectangle (0, 0, 10, 1), view.Viewport);
-        Assert.Equal (new Rectangle (0, 0, 30, 2), view._needsDisplayRect);
+        Assert.Equal (new (1, 1, 10, 1), view.Frame);
+        Assert.Equal (new (0, 0, 10, 1), view.Viewport);
+        Assert.Equal (new (0, 0, 30, 2), view._needsDisplayRect);
         view.Draw ();
         view.Draw ();
 
 
         TestHelpers.AssertDriverContentsWithFrameAre (
         TestHelpers.AssertDriverContentsWithFrameAre (
@@ -714,9 +717,10 @@ At 0,0
  A text wit                  
  A text wit                  
   A text with some long width
   A text with some long width
    and also with two lines.  ",
    and also with two lines.  ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
         Application.End (runState);
         Application.End (runState);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -738,7 +742,7 @@ At 0,0
         view.EndInit ();
         view.EndInit ();
         view.Draw ();
         view.Draw ();
 
 
-        TestHelpers.AssertDriverContentsWithFrameAre (text, _output);
+        TestHelpers.AssertDriverContentsWithFrameAre (text, output);
     }
     }
 
 
     [Fact]
     [Fact]
@@ -751,12 +755,11 @@ At 0,0
         Assert.True (r.Enabled);
         Assert.True (r.Enabled);
         Assert.True (r.Visible);
         Assert.True (r.Visible);
 
 
-        Assert.Equal (LayoutStyle.Absolute, r.LayoutStyle);
         Assert.Equal ($"View(){r.Viewport}", r.ToString ());
         Assert.Equal ($"View(){r.Viewport}", r.ToString ());
         Assert.False (r.CanFocus);
         Assert.False (r.CanFocus);
         Assert.False (r.HasFocus);
         Assert.False (r.HasFocus);
-        Assert.Equal (new Rectangle (0, 0, 0, 0), r.Viewport);
-        Assert.Equal (new Rectangle (0, 0, 0, 0), r.Frame);
+        Assert.Equal (new (0, 0, 0, 0), r.Viewport);
+        Assert.Equal (new (0, 0, 0, 0), r.Frame);
         Assert.Null (r.Focused);
         Assert.Null (r.Focused);
         Assert.Null (r.ColorScheme);
         Assert.Null (r.ColorScheme);
         Assert.Equal (0, r.Width);
         Assert.Equal (0, r.Width);
@@ -774,14 +777,13 @@ At 0,0
         r.Dispose ();
         r.Dispose ();
 
 
         // Empty Rect
         // Empty Rect
-        r = new View { Frame = Rectangle.Empty };
+        r = new() { Frame = Rectangle.Empty };
         Assert.NotNull (r);
         Assert.NotNull (r);
-        Assert.Equal (LayoutStyle.Absolute, r.LayoutStyle);
         Assert.Equal ($"View(){r.Viewport}", r.ToString ());
         Assert.Equal ($"View(){r.Viewport}", r.ToString ());
         Assert.False (r.CanFocus);
         Assert.False (r.CanFocus);
         Assert.False (r.HasFocus);
         Assert.False (r.HasFocus);
-        Assert.Equal (new Rectangle (0, 0, 0, 0), r.Viewport);
-        Assert.Equal (new Rectangle (0, 0, 0, 0), r.Frame);
+        Assert.Equal (new (0, 0, 0, 0), r.Viewport);
+        Assert.Equal (new (0, 0, 0, 0), r.Frame);
         Assert.Null (r.Focused);
         Assert.Null (r.Focused);
         Assert.Null (r.ColorScheme);
         Assert.Null (r.ColorScheme);
         Assert.Equal (0, r.Width);
         Assert.Equal (0, r.Width);
@@ -799,14 +801,13 @@ At 0,0
         r.Dispose ();
         r.Dispose ();
 
 
         // Rect with values
         // Rect with values
-        r = new View { Frame = new Rectangle (1, 2, 3, 4) };
+        r = new() { Frame = new (1, 2, 3, 4) };
         Assert.NotNull (r);
         Assert.NotNull (r);
-        Assert.Equal (LayoutStyle.Absolute, r.LayoutStyle);
         Assert.Equal ($"View(){r.Frame}", r.ToString ());
         Assert.Equal ($"View(){r.Frame}", r.ToString ());
         Assert.False (r.CanFocus);
         Assert.False (r.CanFocus);
         Assert.False (r.HasFocus);
         Assert.False (r.HasFocus);
-        Assert.Equal (new Rectangle (0, 0, 3, 4), r.Viewport);
-        Assert.Equal (new Rectangle (1, 2, 3, 4), r.Frame);
+        Assert.Equal (new (0, 0, 3, 4), r.Viewport);
+        Assert.Equal (new (1, 2, 3, 4), r.Frame);
         Assert.Null (r.Focused);
         Assert.Null (r.Focused);
         Assert.Null (r.ColorScheme);
         Assert.Null (r.ColorScheme);
         Assert.Equal (3, r.Width);
         Assert.Equal (3, r.Width);
@@ -824,7 +825,7 @@ At 0,0
         r.Dispose ();
         r.Dispose ();
 
 
         // Initializes a view with a vertical direction
         // Initializes a view with a vertical direction
-        r = new View
+        r = new()
         {
         {
             Text = "Vertical View",
             Text = "Vertical View",
             TextDirection = TextDirection.TopBottom_LeftRight,
             TextDirection = TextDirection.TopBottom_LeftRight,
@@ -832,15 +833,14 @@ At 0,0
             Height = Dim.Auto ()
             Height = Dim.Auto ()
         }; // BUGBUG: AutoSize or Height need be set
         }; // BUGBUG: AutoSize or Height need be set
         Assert.NotNull (r);
         Assert.NotNull (r);
-        Assert.Equal (LayoutStyle.Computed, r.LayoutStyle);
 
 
         // BUGBUG: IsInitialized must be true to process calculation
         // BUGBUG: IsInitialized must be true to process calculation
         r.BeginInit ();
         r.BeginInit ();
         r.EndInit ();
         r.EndInit ();
         Assert.False (r.CanFocus);
         Assert.False (r.CanFocus);
         Assert.False (r.HasFocus);
         Assert.False (r.HasFocus);
-        Assert.Equal (new Rectangle (0, 0, 1, 13), r.Viewport);
-        Assert.Equal (new Rectangle (0, 0, 1, 13), r.Frame);
+        Assert.Equal (new (0, 0, 1, 13), r.Viewport);
+        Assert.Equal (new (0, 0, 1, 13), r.Frame);
         Assert.Null (r.Focused);
         Assert.Null (r.Focused);
         Assert.Null (r.ColorScheme);
         Assert.Null (r.ColorScheme);
         Assert.False (r.IsCurrentTop);
         Assert.False (r.IsCurrentTop);
@@ -864,13 +864,13 @@ At 0,0
     {
     {
         var r = new View ();
         var r = new View ();
 
 
-        Assert.False (r.OnKeyDown (new Key { KeyCode = KeyCode.Null }));
+        Assert.False (r.OnKeyDown (new() { KeyCode = KeyCode.Null }));
 
 
         //Assert.False (r.OnKeyDown (new KeyEventArgs () { Key = Key.Unknown }));
         //Assert.False (r.OnKeyDown (new KeyEventArgs () { Key = Key.Unknown }));
-        Assert.False (r.OnKeyUp (new Key { KeyCode = KeyCode.Null }));
-        Assert.False (r.NewMouseEvent (new MouseEvent { Flags = MouseFlags.AllEvents }));
-        Assert.False (r.NewMouseEnterEvent (new MouseEvent { Flags = MouseFlags.AllEvents }));
-        Assert.False (r.NewMouseLeaveEvent (new MouseEvent { Flags = MouseFlags.AllEvents }));
+        Assert.False (r.OnKeyUp (new() { KeyCode = KeyCode.Null }));
+        Assert.False (r.NewMouseEvent (new() { Flags = MouseFlags.AllEvents }));
+        Assert.False (r.NewMouseEnterEvent (new() { Flags = MouseFlags.AllEvents }));
+        Assert.False (r.NewMouseLeaveEvent (new() { Flags = MouseFlags.AllEvents }));
 
 
         var v1 = new View ();
         var v1 = new View ();
         Assert.False (r.OnEnter (v1));
         Assert.False (r.OnEnter (v1));
@@ -889,7 +889,7 @@ At 0,0
     [AutoInitShutdown]
     [AutoInitShutdown]
     public void Test_Nested_Views_With_Height_Equal_To_One ()
     public void Test_Nested_Views_With_Height_Equal_To_One ()
     {
     {
-        var v = new View { Width = 11, Height = 3, ColorScheme = new ColorScheme () };
+        var v = new View { Width = 11, Height = 3, ColorScheme = new () };
 
 
         var top = new View { Width = Dim.Fill (), Height = 1 };
         var top = new View { Width = Dim.Fill (), Height = 1 };
         var bottom = new View { Width = Dim.Fill (), Height = 1, Y = 2 };
         var bottom = new View { Width = Dim.Fill (), Height = 1, Y = 2 };
@@ -910,7 +910,7 @@ At 0,0
 111
 111
 ───────────
 ───────────
 222";
 222";
-        TestHelpers.AssertDriverContentsAre (looksLike, _output);
+        TestHelpers.AssertDriverContentsAre (looksLike, output);
         v.Dispose ();
         v.Dispose ();
         top.Dispose ();
         top.Dispose ();
         bottom.Dispose ();
         bottom.Dispose ();
@@ -924,7 +924,7 @@ At 0,0
         var view = new View { X = 1, Y = 2, Width = 3, Height = 4 };
         var view = new View { X = 1, Y = 2, Width = 3, Height = 4 };
 
 
         // Object Initializer Absolute
         // Object Initializer Absolute
-        var super = new View { Frame = new Rectangle (0, 0, 10, 10) };
+        var super = new View { Frame = new (0, 0, 10, 10) };
         super.Add (view);
         super.Add (view);
         super.BeginInit ();
         super.BeginInit ();
         super.EndInit ();
         super.EndInit ();
@@ -935,9 +935,9 @@ At 0,0
         Assert.Equal (3, view.Width);
         Assert.Equal (3, view.Width);
         Assert.Equal (4, view.Height);
         Assert.Equal (4, view.Height);
         Assert.False (view.Frame.IsEmpty);
         Assert.False (view.Frame.IsEmpty);
-        Assert.Equal (new Rectangle (1, 2, 3, 4), view.Frame);
+        Assert.Equal (new (1, 2, 3, 4), view.Frame);
         Assert.False (view.Viewport.IsEmpty);
         Assert.False (view.Viewport.IsEmpty);
-        Assert.Equal (new Rectangle (0, 0, 3, 4), view.Viewport);
+        Assert.Equal (new (0, 0, 3, 4), view.Viewport);
 
 
         view.LayoutSubviews ();
         view.LayoutSubviews ();
 
 
@@ -954,7 +954,7 @@ At 0,0
 #endif
 #endif
 
 
         // Default Constructor
         // Default Constructor
-        view = new View ();
+        view = new ();
         Assert.Equal (0, view.X);
         Assert.Equal (0, view.X);
         Assert.Equal (0, view.Y);
         Assert.Equal (0, view.Y);
         Assert.Equal (0, view.Width);
         Assert.Equal (0, view.Width);
@@ -964,7 +964,7 @@ At 0,0
         view.Dispose ();
         view.Dispose ();
 
 
         // Object Initializer
         // Object Initializer
-        view = new View { X = 1, Y = 2, Text = "" };
+        view = new() { X = 1, Y = 2, Text = "" };
         Assert.Equal (1, view.X);
         Assert.Equal (1, view.X);
         Assert.Equal (2, view.Y);
         Assert.Equal (2, view.Y);
         Assert.Equal (0, view.Width);
         Assert.Equal (0, view.Width);
@@ -974,12 +974,12 @@ At 0,0
         view.Dispose ();
         view.Dispose ();
 
 
         // Default Constructor and post assignment equivalent to Object Initializer
         // Default Constructor and post assignment equivalent to Object Initializer
-        view = new View ();
+        view = new ();
         view.X = 1;
         view.X = 1;
         view.Y = 2;
         view.Y = 2;
         view.Width = 3;
         view.Width = 3;
         view.Height = 4;
         view.Height = 4;
-        super = new View { Frame = new Rectangle (0, 0, 10, 10) };
+        super = new() { Frame = new (0, 0, 10, 10) };
         super.Add (view);
         super.Add (view);
         super.BeginInit ();
         super.BeginInit ();
         super.EndInit ();
         super.EndInit ();
@@ -989,9 +989,9 @@ At 0,0
         Assert.Equal (3, view.Width);
         Assert.Equal (3, view.Width);
         Assert.Equal (4, view.Height);
         Assert.Equal (4, view.Height);
         Assert.False (view.Frame.IsEmpty);
         Assert.False (view.Frame.IsEmpty);
-        Assert.Equal (new Rectangle (1, 2, 3, 4), view.Frame);
+        Assert.Equal (new (1, 2, 3, 4), view.Frame);
         Assert.False (view.Viewport.IsEmpty);
         Assert.False (view.Viewport.IsEmpty);
-        Assert.Equal (new Rectangle (0, 0, 3, 4), view.Viewport);
+        Assert.Equal (new (0, 0, 3, 4), view.Viewport);
         super.Dispose ();
         super.Dispose ();
     }
     }
 
 
@@ -1024,7 +1024,7 @@ At 0,0
 │                            │
 │                            │
 └────────────────────────────┘
 └────────────────────────────┘
 ",
 ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         view.Visible = false;
         view.Visible = false;
@@ -1040,9 +1040,10 @@ At 0,0
 │                            │
 │                            │
 └────────────────────────────┘
 └────────────────────────────┘
 ",
 ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
         Application.End (rs);
         Application.End (rs);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -1096,7 +1097,7 @@ At 0,0
                                  };
                                  };
 
 
         Application.Run (top);
         Application.Run (top);
-
+        top.Dispose ();
         Assert.Equal (1, iterations);
         Assert.Equal (1, iterations);
 
 
         int RunesCount ()
         int RunesCount ()
@@ -1194,6 +1195,7 @@ At 0,0
         Assert.True (accepted);
         Assert.True (accepted);
 
 
         return;
         return;
+
         void ViewOnAccept (object sender, CancelEventArgs e) { accepted = true; }
         void ViewOnAccept (object sender, CancelEventArgs e) { accepted = true; }
     }
     }
 
 
@@ -1205,11 +1207,12 @@ At 0,0
 
 
         view.Accept += ViewOnAccept;
         view.Accept += ViewOnAccept;
 
 
-        var ret = view.InvokeCommand (Command.Accept);
+        bool? ret = view.InvokeCommand (Command.Accept);
         Assert.True (ret);
         Assert.True (ret);
         Assert.True (acceptInvoked);
         Assert.True (acceptInvoked);
 
 
         return;
         return;
+
         void ViewOnAccept (object sender, CancelEventArgs e)
         void ViewOnAccept (object sender, CancelEventArgs e)
         {
         {
             acceptInvoked = true;
             acceptInvoked = true;
@@ -1229,6 +1232,7 @@ At 0,0
         Assert.True (accepted);
         Assert.True (accepted);
 
 
         return;
         return;
+
         void ViewOnAccept (object sender, CancelEventArgs e) { accepted = true; }
         void ViewOnAccept (object sender, CancelEventArgs e) { accepted = true; }
     }
     }
 
 

+ 9 - 4
UnitTests/Views/AppendAutocompleteTests.cs

@@ -2,11 +2,8 @@ using Xunit.Abstractions;
 
 
 namespace Terminal.Gui.TextTests;
 namespace Terminal.Gui.TextTests;
 
 
-public class AppendAutocompleteTests
+public class AppendAutocompleteTests (ITestOutputHelper output)
 {
 {
-    private readonly ITestOutputHelper output;
-    public AppendAutocompleteTests (ITestOutputHelper output) { this.output = output; }
-
     [Fact]
     [Fact]
     [AutoInitShutdown]
     [AutoInitShutdown]
     public void TestAutoAppend_AfterCloseKey_NoAutocomplete ()
     public void TestAutoAppend_AfterCloseKey_NoAutocomplete ()
@@ -34,6 +31,7 @@ public class AppendAutocompleteTests
         // But can tab away
         // But can tab away
         Application.Driver.SendKeys ('\t', ConsoleKey.Tab, false, false, false);
         Application.Driver.SendKeys ('\t', ConsoleKey.Tab, false, false, false);
         Assert.NotSame (tf, Application.Top.Focused);
         Assert.NotSame (tf, Application.Top.Focused);
+        Application.Top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -63,6 +61,7 @@ public class AppendAutocompleteTests
         tf.PositionCursor ();
         tf.PositionCursor ();
         TestHelpers.AssertDriverContentsAre ("fish", output);
         TestHelpers.AssertDriverContentsAre ("fish", output);
         Assert.Equal ("fi", tf.Text);
         Assert.Equal ("fi", tf.Text);
+        Application.Top.Dispose ();
     }
     }
 
 
     [Theory]
     [Theory]
@@ -94,6 +93,7 @@ public class AppendAutocompleteTests
         tf.PositionCursor ();
         tf.PositionCursor ();
         TestHelpers.AssertDriverContentsAre ("fish", output);
         TestHelpers.AssertDriverContentsAre ("fish", output);
         Assert.Equal ("f", tf.Text);
         Assert.Equal ("f", tf.Text);
+        Application.Top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -116,6 +116,7 @@ public class AppendAutocompleteTests
         tf.Draw ();
         tf.Draw ();
         TestHelpers.AssertDriverContentsAre ("f", output);
         TestHelpers.AssertDriverContentsAre ("f", output);
         Assert.Equal ("f ", tf.Text);
         Assert.Equal ("f ", tf.Text);
+        Application.Top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -136,6 +137,7 @@ public class AppendAutocompleteTests
         tf.Draw ();
         tf.Draw ();
         TestHelpers.AssertDriverContentsAre ("fx", output);
         TestHelpers.AssertDriverContentsAre ("fx", output);
         Assert.Equal ("fx", tf.Text);
         Assert.Equal ("fx", tf.Text);
+        Application.Top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -168,6 +170,7 @@ public class AppendAutocompleteTests
         tf.Draw ();
         tf.Draw ();
         TestHelpers.AssertDriverContentsAre ("my FISH", output);
         TestHelpers.AssertDriverContentsAre ("my FISH", output);
         Assert.Equal ("my FISH", tf.Text);
         Assert.Equal ("my FISH", tf.Text);
+        Application.Top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -203,6 +206,7 @@ public class AppendAutocompleteTests
         // Second tab should move focus (nothing to autocomplete)
         // Second tab should move focus (nothing to autocomplete)
         Application.Driver.SendKeys ('\t', ConsoleKey.Tab, false, false, false);
         Application.Driver.SendKeys ('\t', ConsoleKey.Tab, false, false, false);
         Assert.NotSame (tf, Application.Top.Focused);
         Assert.NotSame (tf, Application.Top.Focused);
+        Application.Top.Dispose ();
     }
     }
 
 
     [Theory]
     [Theory]
@@ -220,6 +224,7 @@ public class AppendAutocompleteTests
         tf.PositionCursor ();
         tf.PositionCursor ();
         TestHelpers.AssertDriverContentsAre (expectRender, output);
         TestHelpers.AssertDriverContentsAre (expectRender, output);
         Assert.Equal ("f", tf.Text);
         Assert.Equal ("f", tf.Text);
+        Application.Top.Dispose ();
     }
     }
 
 
     private TextField GetTextFieldsInView ()
     private TextField GetTextFieldsInView ()

+ 7 - 14
UnitTests/Views/ButtonTests.cs

@@ -50,7 +50,6 @@ public class ButtonTests (ITestOutputHelper output)
     [InlineData ("0_12你", 0, 1, 0, 1)]
     [InlineData ("0_12你", 0, 1, 0, 1)]
     [InlineData ("0_12你", 1, 1, 1, 1)]
     [InlineData ("0_12你", 1, 1, 1, 1)]
     [InlineData ("0_12你", 10, 1, 10, 1)]
     [InlineData ("0_12你", 10, 1, 10, 1)]
-    [InlineData ("0_12你", 10, 3, 10, 3)]
     public void Button_AbsoluteSize_Text (string text, int width, int height, int expectedWidth, int expectedHeight)
     public void Button_AbsoluteSize_Text (string text, int width, int height, int expectedWidth, int expectedHeight)
     {
     {
         var btn1 = new Button
         var btn1 = new Button
@@ -62,7 +61,7 @@ public class ButtonTests (ITestOutputHelper output)
 
 
         Assert.Equal (new Size (expectedWidth, expectedHeight), btn1.Frame.Size);
         Assert.Equal (new Size (expectedWidth, expectedHeight), btn1.Frame.Size);
         Assert.Equal (new Size (expectedWidth, expectedHeight), btn1.Viewport.Size);
         Assert.Equal (new Size (expectedWidth, expectedHeight), btn1.Viewport.Size);
-        Assert.Equal (new Size (expectedWidth, expectedHeight), btn1.ContentSize);
+        Assert.Equal (new Size (expectedWidth, expectedHeight), btn1.GetContentSize ());
         Assert.Equal (new Size (expectedWidth, expectedHeight), btn1.TextFormatter.Size);
         Assert.Equal (new Size (expectedWidth, expectedHeight), btn1.TextFormatter.Size);
 
 
         btn1.Dispose ();
         btn1.Dispose ();
@@ -91,7 +90,6 @@ public class ButtonTests (ITestOutputHelper output)
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown]
     public void Button_HotKeyChanged_EventFires ()
     public void Button_HotKeyChanged_EventFires ()
     {
     {
         var btn = new Button { Text = "_Yar" };
         var btn = new Button { Text = "_Yar" };
@@ -204,7 +202,7 @@ public class ButtonTests (ITestOutputHelper output)
         Assert.Equal ('_', btn.HotKeySpecifier.Value);
         Assert.Equal ('_', btn.HotKeySpecifier.Value);
         Assert.Equal (10, btn.TextFormatter.Format ().Length);
         Assert.Equal (10, btn.TextFormatter.Format ().Length);
         Assert.Equal (new (10, 1), btn.TextFormatter.Size);
         Assert.Equal (new (10, 1), btn.TextFormatter.Size);
-        Assert.Equal (new (10, 1), btn.ContentSize);
+        Assert.Equal (new (10, 1), btn.GetContentSize ());
         Assert.Equal (new (0, 0, 10, 1), btn.Viewport);
         Assert.Equal (new (0, 0, 10, 1), btn.Viewport);
         Assert.Equal (new (0, 0, 10, 1), btn.Frame);
         Assert.Equal (new (0, 0, 10, 1), btn.Frame);
         Assert.Equal (KeyCode.T, btn.HotKey);
         Assert.Equal (KeyCode.T, btn.HotKey);
@@ -240,15 +238,11 @@ public class ButtonTests (ITestOutputHelper output)
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown]
     public void HotKeyChange_Works ()
     public void HotKeyChange_Works ()
     {
     {
         var clicked = false;
         var clicked = false;
         var btn = new Button { Text = "_Test" };
         var btn = new Button { Text = "_Test" };
         btn.Accept += (s, e) => clicked = true;
         btn.Accept += (s, e) => clicked = true;
-        var top = new Toplevel ();
-        top.Add (btn);
-        Application.Begin (top);
 
 
         Assert.Equal (KeyCode.T, btn.HotKey);
         Assert.Equal (KeyCode.T, btn.HotKey);
         Assert.True (btn.NewKeyDownEvent (Key.T));
         Assert.True (btn.NewKeyDownEvent (Key.T));
@@ -262,7 +256,6 @@ public class ButtonTests (ITestOutputHelper output)
         btn.HotKey = KeyCode.E;
         btn.HotKey = KeyCode.E;
         Assert.True (btn.NewKeyDownEvent (Key.E.WithAlt));
         Assert.True (btn.NewKeyDownEvent (Key.E.WithAlt));
         Assert.True (clicked);
         Assert.True (clicked);
-        top.Dispose ();
     }
     }
 
 
     /// <summary>
     /// <summary>
@@ -573,11 +566,11 @@ public class ButtonTests (ITestOutputHelper output)
     }
     }
 
 
     [Theory]
     [Theory]
-    [InlineData (MouseFlags.Button1Pressed, MouseFlags.Button1Released, MouseFlags.Button1Clicked)]
-    [InlineData (MouseFlags.Button2Pressed, MouseFlags.Button2Released, MouseFlags.Button2Clicked)]
-    [InlineData (MouseFlags.Button3Pressed, MouseFlags.Button3Released, MouseFlags.Button3Clicked)]
-    [InlineData (MouseFlags.Button4Pressed, MouseFlags.Button4Released, MouseFlags.Button4Clicked)]
-    public void WantContinuousButtonPressed_True_ButtonPressRelease_Accepts (MouseFlags pressed, MouseFlags released, MouseFlags clicked)
+    [InlineData (MouseFlags.Button1Pressed, MouseFlags.Button1Released)]
+    [InlineData (MouseFlags.Button2Pressed, MouseFlags.Button2Released)]
+    [InlineData (MouseFlags.Button3Pressed, MouseFlags.Button3Released)]
+    [InlineData (MouseFlags.Button4Pressed, MouseFlags.Button4Released)]
+    public void WantContinuousButtonPressed_True_ButtonPressRelease_Accepts (MouseFlags pressed, MouseFlags released)
     {
     {
         var me = new MouseEvent ();
         var me = new MouseEvent ();
 
 

+ 43 - 42
UnitTests/Views/CheckBoxTests.cs

@@ -3,12 +3,9 @@ using Xunit.Abstractions;
 
 
 namespace Terminal.Gui.ViewsTests;
 namespace Terminal.Gui.ViewsTests;
 
 
-public class CheckBoxTests
+public class CheckBoxTests (ITestOutputHelper output)
 {
 {
-    private readonly ITestOutputHelper _output;
     private static readonly Size _size25x1 = new (25, 1);
     private static readonly Size _size25x1 = new (25, 1);
-    public CheckBoxTests (ITestOutputHelper output) { _output = output; }
-
 
 
     [Theory]
     [Theory]
     [InlineData ("01234", 0, 0, 0, 0)]
     [InlineData ("01234", 0, 0, 0, 0)]
@@ -39,9 +36,9 @@ public class CheckBoxTests
             Text = text
             Text = text
         };
         };
 
 
-        Assert.Equal (new Size (expectedWidth, expectedHeight), checkBox.Frame.Size);
-        Assert.Equal (new Size (expectedWidth, expectedHeight), checkBox.Viewport.Size);
-        Assert.Equal (new Size (expectedWidth, expectedHeight), checkBox.TextFormatter.Size);
+        Assert.Equal (new (expectedWidth, expectedHeight), checkBox.Frame.Size);
+        Assert.Equal (new (expectedWidth, expectedHeight), checkBox.Viewport.Size);
+        Assert.Equal (new (expectedWidth, expectedHeight), checkBox.TextFormatter.Size);
 
 
         checkBox.Dispose ();
         checkBox.Dispose ();
     }
     }
@@ -60,12 +57,12 @@ public class CheckBoxTests
             X = 0,
             X = 0,
             Y = 0,
             Y = 0,
             Width = width,
             Width = width,
-            Height = height,
+            Height = height
         };
         };
 
 
-        Assert.Equal (new Size (expectedWidth, expectedHeight), checkBox.Frame.Size);
-        Assert.Equal (new Size (expectedWidth, expectedHeight), checkBox.Viewport.Size);
-        Assert.Equal (new Size (expectedWidth, expectedHeight), checkBox.TextFormatter.Size);
+        Assert.Equal (new (expectedWidth, expectedHeight), checkBox.Frame.Size);
+        Assert.Equal (new (expectedWidth, expectedHeight), checkBox.Viewport.Size);
+        Assert.Equal (new (expectedWidth, expectedHeight), checkBox.TextFormatter.Size);
 
 
         checkBox.Dispose ();
         checkBox.Dispose ();
     }
     }
@@ -77,7 +74,7 @@ public class CheckBoxTests
         var view = new CheckBox ();
         var view = new CheckBox ();
         view.Title = "Hello";
         view.Title = "Hello";
         Assert.Equal ("Hello", view.Title);
         Assert.Equal ("Hello", view.Title);
-        Assert.Equal ($"Hello", view.TitleTextFormatter.Text);
+        Assert.Equal ("Hello", view.TitleTextFormatter.Text);
 
 
         Assert.Equal ("Hello", view.Text);
         Assert.Equal ("Hello", view.Text);
         Assert.Equal ($"{CM.Glyphs.UnChecked} Hello", view.TextFormatter.Text);
         Assert.Equal ($"{CM.Glyphs.UnChecked} Hello", view.TextFormatter.Text);
@@ -92,39 +89,36 @@ public class CheckBoxTests
         Assert.Equal ($"{CM.Glyphs.UnChecked} Hello", view.TextFormatter.Text);
         Assert.Equal ($"{CM.Glyphs.UnChecked} Hello", view.TextFormatter.Text);
 
 
         Assert.Equal ("Hello", view.Title);
         Assert.Equal ("Hello", view.Title);
-        Assert.Equal ($"Hello", view.TitleTextFormatter.Text);
+        Assert.Equal ("Hello", view.TitleTextFormatter.Text);
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown]
+    [SetupFakeDriver]
     public void AllowNullChecked_Get_Set ()
     public void AllowNullChecked_Get_Set ()
     {
     {
         var checkBox = new CheckBox { Text = "Check this out 你" };
         var checkBox = new CheckBox { Text = "Check this out 你" };
-        Toplevel top = new ();
-        top.Add (checkBox);
-        Application.Begin (top);
 
 
         Assert.False (checkBox.Checked);
         Assert.False (checkBox.Checked);
         Assert.True (checkBox.NewKeyDownEvent (Key.Space));
         Assert.True (checkBox.NewKeyDownEvent (Key.Space));
         Assert.True (checkBox.Checked);
         Assert.True (checkBox.Checked);
-        Assert.True (checkBox.NewMouseEvent (new MouseEvent { Position = new (0, 0), Flags = MouseFlags.Button1Clicked }));
+        Assert.True (checkBox.NewMouseEvent (new() { Position = new (0, 0), Flags = MouseFlags.Button1Clicked }));
         Assert.False (checkBox.Checked);
         Assert.False (checkBox.Checked);
 
 
         checkBox.AllowNullChecked = true;
         checkBox.AllowNullChecked = true;
         Assert.True (checkBox.NewKeyDownEvent (Key.Space));
         Assert.True (checkBox.NewKeyDownEvent (Key.Space));
         Assert.Null (checkBox.Checked);
         Assert.Null (checkBox.Checked);
-        Application.Refresh ();
+        checkBox.Draw();
 
 
         TestHelpers.AssertDriverContentsWithFrameAre (
         TestHelpers.AssertDriverContentsWithFrameAre (
                                                       @$"
                                                       @$"
 {CM.Glyphs.NullChecked} Check this out 你",
 {CM.Glyphs.NullChecked} Check this out 你",
-                                                      _output
+                                                      output
                                                      );
                                                      );
-        Assert.True (checkBox.NewMouseEvent (new MouseEvent { Position = new (0, 0), Flags = MouseFlags.Button1Clicked }));
+        Assert.True (checkBox.NewMouseEvent (new() { Position = new (0, 0), Flags = MouseFlags.Button1Clicked }));
         Assert.True (checkBox.Checked);
         Assert.True (checkBox.Checked);
         Assert.True (checkBox.NewKeyDownEvent (Key.Space));
         Assert.True (checkBox.NewKeyDownEvent (Key.Space));
         Assert.False (checkBox.Checked);
         Assert.False (checkBox.Checked);
-        Assert.True (checkBox.NewMouseEvent (new MouseEvent { Position = new (0, 0), Flags = MouseFlags.Button1Clicked }));
+        Assert.True (checkBox.NewMouseEvent (new() { Position = new (0, 0), Flags = MouseFlags.Button1Clicked }));
         Assert.Null (checkBox.Checked);
         Assert.Null (checkBox.Checked);
 
 
         checkBox.AllowNullChecked = false;
         checkBox.AllowNullChecked = false;
@@ -142,9 +136,9 @@ public class CheckBoxTests
         Assert.Equal (string.Empty, ckb.Text);
         Assert.Equal (string.Empty, ckb.Text);
         Assert.Equal ($"{CM.Glyphs.UnChecked} ", ckb.TextFormatter.Text);
         Assert.Equal ($"{CM.Glyphs.UnChecked} ", ckb.TextFormatter.Text);
         Assert.True (ckb.CanFocus);
         Assert.True (ckb.CanFocus);
-        Assert.Equal (new Rectangle (0, 0, 2, 1), ckb.Frame);
+        Assert.Equal (new (0, 0, 2, 1), ckb.Frame);
 
 
-        ckb = new CheckBox { Text = "Test", Checked = true };
+        ckb = new() { Text = "Test", Checked = true };
         Assert.True (ckb.Width is DimAuto);
         Assert.True (ckb.Width is DimAuto);
         Assert.True (ckb.Height is DimAuto);
         Assert.True (ckb.Height is DimAuto);
         Assert.True (ckb.Checked);
         Assert.True (ckb.Checked);
@@ -152,9 +146,9 @@ public class CheckBoxTests
         Assert.Equal ("Test", ckb.Text);
         Assert.Equal ("Test", ckb.Text);
         Assert.Equal ($"{CM.Glyphs.Checked} Test", ckb.TextFormatter.Text);
         Assert.Equal ($"{CM.Glyphs.Checked} Test", ckb.TextFormatter.Text);
         Assert.True (ckb.CanFocus);
         Assert.True (ckb.CanFocus);
-        Assert.Equal (new Rectangle (0, 0, 6, 1), ckb.Frame);
+        Assert.Equal (new (0, 0, 6, 1), ckb.Frame);
 
 
-        ckb = new CheckBox { Text = "Test", X = 1, Y = 2 };
+        ckb = new() { Text = "Test", X = 1, Y = 2 };
         Assert.True (ckb.Width is DimAuto);
         Assert.True (ckb.Width is DimAuto);
         Assert.True (ckb.Height is DimAuto);
         Assert.True (ckb.Height is DimAuto);
         Assert.False (ckb.Checked);
         Assert.False (ckb.Checked);
@@ -162,9 +156,9 @@ public class CheckBoxTests
         Assert.Equal ("Test", ckb.Text);
         Assert.Equal ("Test", ckb.Text);
         Assert.Equal ($"{CM.Glyphs.UnChecked} Test", ckb.TextFormatter.Text);
         Assert.Equal ($"{CM.Glyphs.UnChecked} Test", ckb.TextFormatter.Text);
         Assert.True (ckb.CanFocus);
         Assert.True (ckb.CanFocus);
-        Assert.Equal (new Rectangle (1, 2, 6, 1), ckb.Frame);
+        Assert.Equal (new (1, 2, 6, 1), ckb.Frame);
 
 
-        ckb = new CheckBox { Text = "Test", X = 3, Y = 4, Checked = true };
+        ckb = new() { Text = "Test", X = 3, Y = 4, Checked = true };
         Assert.True (ckb.Width is DimAuto);
         Assert.True (ckb.Width is DimAuto);
         Assert.True (ckb.Height is DimAuto);
         Assert.True (ckb.Height is DimAuto);
         Assert.True (ckb.Checked);
         Assert.True (ckb.Checked);
@@ -172,7 +166,7 @@ public class CheckBoxTests
         Assert.Equal ("Test", ckb.Text);
         Assert.Equal ("Test", ckb.Text);
         Assert.Equal ($"{CM.Glyphs.Checked} Test", ckb.TextFormatter.Text);
         Assert.Equal ($"{CM.Glyphs.Checked} Test", ckb.TextFormatter.Text);
         Assert.True (ckb.CanFocus);
         Assert.True (ckb.CanFocus);
-        Assert.Equal (new Rectangle (3, 4, 6, 1), ckb.Frame);
+        Assert.Equal (new (3, 4, 6, 1), ckb.Frame);
     }
     }
 
 
     [Fact]
     [Fact]
@@ -229,11 +223,12 @@ public class CheckBoxTests
 
 
         ckb.Accept += ViewOnAccept;
         ckb.Accept += ViewOnAccept;
 
 
-        var ret = ckb.InvokeCommand (Command.Accept);
+        bool? ret = ckb.InvokeCommand (Command.Accept);
         Assert.True (ret);
         Assert.True (ret);
         Assert.True (acceptInvoked);
         Assert.True (acceptInvoked);
 
 
         return;
         return;
+
         void ViewOnAccept (object sender, CancelEventArgs e)
         void ViewOnAccept (object sender, CancelEventArgs e)
         {
         {
             acceptInvoked = true;
             acceptInvoked = true;
@@ -273,7 +268,7 @@ public class CheckBoxTests
 └────────────────────────────┘
 └────────────────────────────┘
 ";
 ";
 
 
-        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Assert.Equal (new (0, 0, 30, 5), pos);
         Assert.Equal (new (0, 0, 30, 5), pos);
 
 
         checkBox.Checked = true;
         checkBox.Checked = true;
@@ -287,8 +282,9 @@ public class CheckBoxTests
 └────────────────────────────┘
 └────────────────────────────┘
 ";
 ";
 
 
-        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Assert.Equal (new (0, 0, 30, 5), pos);
         Assert.Equal (new (0, 0, 30, 5), pos);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -324,7 +320,7 @@ public class CheckBoxTests
         Assert.Equal (new (1, 1, 25, 1), checkBox1.Frame);
         Assert.Equal (new (1, 1, 25, 1), checkBox1.Frame);
         Assert.Equal (Alignment.Fill, checkBox2.TextAlignment);
         Assert.Equal (Alignment.Fill, checkBox2.TextAlignment);
         Assert.Equal (new (1, 2, 25, 1), checkBox2.Frame);
         Assert.Equal (new (1, 2, 25, 1), checkBox2.Frame);
- 
+
         var expected = @$"
         var expected = @$"
 ┌┤Test Demo 你├──────────────┐
 ┌┤Test Demo 你├──────────────┐
 │                            │
 │                            │
@@ -334,7 +330,7 @@ public class CheckBoxTests
 └────────────────────────────┘
 └────────────────────────────┘
 ";
 ";
 
 
-        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Assert.Equal (new (0, 0, 30, 6), pos);
         Assert.Equal (new (0, 0, 30, 6), pos);
 
 
         checkBox1.Checked = true;
         checkBox1.Checked = true;
@@ -354,8 +350,9 @@ public class CheckBoxTests
 └────────────────────────────┘
 └────────────────────────────┘
 ";
 ";
 
 
-        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Assert.Equal (new (0, 0, 30, 6), pos);
         Assert.Equal (new (0, 0, 30, 6), pos);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -389,7 +386,7 @@ public class CheckBoxTests
 └────────────────────────────┘
 └────────────────────────────┘
 ";
 ";
 
 
-        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Assert.Equal (new (0, 0, 30, 5), pos);
         Assert.Equal (new (0, 0, 30, 5), pos);
 
 
         checkBox.Checked = true;
         checkBox.Checked = true;
@@ -403,8 +400,9 @@ public class CheckBoxTests
 └────────────────────────────┘
 └────────────────────────────┘
 ";
 ";
 
 
-        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Assert.Equal (new (0, 0, 30, 5), pos);
         Assert.Equal (new (0, 0, 30, 5), pos);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -439,7 +437,7 @@ public class CheckBoxTests
 └────────────────────────────┘
 └────────────────────────────┘
 ";
 ";
 
 
-        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Assert.Equal (new (0, 0, 30, 5), pos);
         Assert.Equal (new (0, 0, 30, 5), pos);
 
 
         checkBox.Checked = true;
         checkBox.Checked = true;
@@ -453,8 +451,9 @@ public class CheckBoxTests
 └────────────────────────────┘
 └────────────────────────────┘
 ";
 ";
 
 
-        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Assert.Equal (new (0, 0, 30, 5), pos);
         Assert.Equal (new (0, 0, 30, 5), pos);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -469,6 +468,7 @@ public class CheckBoxTests
         Assert.True (accepted);
         Assert.True (accepted);
 
 
         return;
         return;
+
         void CheckBoxOnAccept (object sender, CancelEventArgs e) { accepted = true; }
         void CheckBoxOnAccept (object sender, CancelEventArgs e) { accepted = true; }
     }
     }
 
 
@@ -478,19 +478,20 @@ public class CheckBoxTests
     [InlineData (null)]
     [InlineData (null)]
     public void Toggled_Cancel_Event_Prevents_Toggle (bool? initialState)
     public void Toggled_Cancel_Event_Prevents_Toggle (bool? initialState)
     {
     {
-        var ckb = new CheckBox () { AllowNullChecked = true };
+        var ckb = new CheckBox { AllowNullChecked = true };
         var checkedInvoked = false;
         var checkedInvoked = false;
 
 
         ckb.Toggled += CheckBoxToggled;
         ckb.Toggled += CheckBoxToggled;
 
 
         ckb.Checked = initialState;
         ckb.Checked = initialState;
-        Assert.Equal(initialState, ckb.Checked);
-        var ret = ckb.OnToggled ();
+        Assert.Equal (initialState, ckb.Checked);
+        bool? ret = ckb.OnToggled ();
         Assert.True (ret);
         Assert.True (ret);
         Assert.True (checkedInvoked);
         Assert.True (checkedInvoked);
         Assert.Equal (initialState, ckb.Checked);
         Assert.Equal (initialState, ckb.Checked);
 
 
         return;
         return;
+
         void CheckBoxToggled (object sender, CancelEventArgs e)
         void CheckBoxToggled (object sender, CancelEventArgs e)
         {
         {
             checkedInvoked = true;
             checkedInvoked = true;

+ 5 - 6
UnitTests/Views/ColorPickerTests.cs

@@ -13,11 +13,10 @@ public class ColorPickerTests
         colorPicker.BeginInit ();
         colorPicker.BeginInit ();
         colorPicker.EndInit ();
         colorPicker.EndInit ();
         colorPicker.LayoutSubviews ();
         colorPicker.LayoutSubviews ();
-        Assert.Equal (new Rectangle (0, 0, 32, 4), colorPicker.Frame);
+        Assert.Equal (new (0, 0, 32, 4), colorPicker.Frame);
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown]
     public void KeyBindings_Command ()
     public void KeyBindings_Command ()
     {
     {
         var colorPicker = new ColorPicker ();
         var colorPicker = new ColorPicker ();
@@ -52,14 +51,14 @@ public class ColorPickerTests
         top.Add (colorPicker);
         top.Add (colorPicker);
         Application.Begin (top);
         Application.Begin (top);
 
 
-        Assert.False (colorPicker.NewMouseEvent (new MouseEvent ()));
+        Assert.False (colorPicker.NewMouseEvent (new ()));
 
 
-        Assert.True (colorPicker.NewMouseEvent (new MouseEvent { Position = new (4, 1), Flags = MouseFlags.Button1Clicked }));
+        Assert.True (colorPicker.NewMouseEvent (new() { Position = new (4, 1), Flags = MouseFlags.Button1Clicked }));
         Assert.Equal (ColorName.Blue, colorPicker.SelectedColor);
         Assert.Equal (ColorName.Blue, colorPicker.SelectedColor);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown]
     public void SelectedColorAndCursor ()
     public void SelectedColorAndCursor ()
     {
     {
         var colorPicker = new ColorPicker ();
         var colorPicker = new ColorPicker ();
@@ -71,7 +70,7 @@ public class ColorPickerTests
         Assert.Equal (0, colorPicker.Cursor.X);
         Assert.Equal (0, colorPicker.Cursor.X);
         Assert.Equal (0, colorPicker.Cursor.Y);
         Assert.Equal (0, colorPicker.Cursor.Y);
 
 
-        colorPicker.Cursor = new Point (7, 1);
+        colorPicker.Cursor = new (7, 1);
         Assert.Equal (ColorName.White, colorPicker.SelectedColor);
         Assert.Equal (ColorName.White, colorPicker.SelectedColor);
 
 
         colorPicker.Cursor = Point.Empty;
         colorPicker.Cursor = Point.Empty;

+ 16 - 11
UnitTests/Views/ComboBoxTests.cs

@@ -3,13 +3,9 @@ using Xunit.Abstractions;
 
 
 namespace Terminal.Gui.ViewsTests;
 namespace Terminal.Gui.ViewsTests;
 
 
-public class ComboBoxTests
+public class ComboBoxTests (ITestOutputHelper output)
 {
 {
-    private readonly ITestOutputHelper _output;
-    public ComboBoxTests (ITestOutputHelper output) { _output = output; }
-
     [Fact]
     [Fact]
-    [AutoInitShutdown]
     public void Constructor_With_Source_Initialize_With_The_Passed_SelectedItem ()
     public void Constructor_With_Source_Initialize_With_The_Passed_SelectedItem ()
     {
     {
         var cb = new ComboBox
         var cb = new ComboBox
@@ -74,7 +70,6 @@ public class ComboBoxTests
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown]
     public void EnsureKeyEventsDoNotCauseExceptions ()
     public void EnsureKeyEventsDoNotCauseExceptions ()
     {
     {
         var comboBox = new ComboBox { Text = "0" };
         var comboBox = new ComboBox { Text = "0" };
@@ -121,6 +116,7 @@ public class ComboBoxTests
         Assert.False (cb.IsShow);
         Assert.False (cb.IsShow);
         Assert.Equal (-1, cb.SelectedItem);
         Assert.Equal (-1, cb.SelectedItem);
         Assert.Equal ("", cb.Text);
         Assert.Equal ("", cb.Text);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -175,6 +171,7 @@ public class ComboBoxTests
         Assert.False (cb.IsShow);
         Assert.False (cb.IsShow);
         Assert.Equal (1, cb.SelectedItem);
         Assert.Equal (1, cb.SelectedItem);
         Assert.Equal ("", cb.Text);
         Assert.Equal ("", cb.Text);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -210,6 +207,7 @@ public class ComboBoxTests
         Assert.False (cb.IsShow);
         Assert.False (cb.IsShow);
         Assert.Equal (1, cb.SelectedItem);
         Assert.Equal (1, cb.SelectedItem);
         Assert.Equal ("Two", cb.Text);
         Assert.Equal ("Two", cb.Text);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -269,6 +267,7 @@ public class ComboBoxTests
         Assert.False (cb.IsShow);
         Assert.False (cb.IsShow);
         Assert.Equal (1, cb.SelectedItem);
         Assert.Equal (1, cb.SelectedItem);
         Assert.Equal ("Two", cb.Text);
         Assert.Equal ("Two", cb.Text);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -370,6 +369,7 @@ public class ComboBoxTests
         Assert.False (cb.IsShow);
         Assert.False (cb.IsShow);
         Assert.Equal (0, cb.SelectedItem);
         Assert.Equal (0, cb.SelectedItem);
         Assert.Equal ("One", cb.Text);
         Assert.Equal ("One", cb.Text);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -488,6 +488,7 @@ public class ComboBoxTests
         Assert.False (cb.IsShow);
         Assert.False (cb.IsShow);
         Assert.Equal (-1, cb.SelectedItem);
         Assert.Equal (-1, cb.SelectedItem);
         Assert.Equal ("", cb.Text);
         Assert.Equal ("", cb.Text);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -524,7 +525,7 @@ public class ComboBoxTests
 One   
 One   
 Two   
 Two   
 Three ",
 Three ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Attribute [] attributes =
         Attribute [] attributes =
@@ -645,6 +646,7 @@ Three ",
         Assert.False (cb.IsShow);
         Assert.False (cb.IsShow);
         Assert.Equal (2, cb.SelectedItem);
         Assert.Equal (2, cb.SelectedItem);
         Assert.Equal ("Three", cb.Text);
         Assert.Equal ("Three", cb.Text);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -707,6 +709,7 @@ Three ",
         Assert.False (cb.IsShow);
         Assert.False (cb.IsShow);
         Assert.Equal (-1, cb.SelectedItem);
         Assert.Equal (-1, cb.SelectedItem);
         Assert.Equal ("", cb.Text);
         Assert.Equal ("", cb.Text);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -764,6 +767,7 @@ Three ",
         Assert.False (cb.IsShow);
         Assert.False (cb.IsShow);
         Assert.Equal (1, cb.SelectedItem);
         Assert.Equal (1, cb.SelectedItem);
         Assert.Equal ("Two", cb.Text);
         Assert.Equal ("Two", cb.Text);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -799,6 +803,7 @@ Three ",
         Assert.False (cb.IsShow);
         Assert.False (cb.IsShow);
         Assert.Equal (-1, cb.SelectedItem);
         Assert.Equal (-1, cb.SelectedItem);
         Assert.Equal ("", cb.Text);
         Assert.Equal ("", cb.Text);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -877,7 +882,7 @@ Three ",
 One      ▼
 One      ▼
 One       
 One       
 ",
 ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Assert.True (cb.NewKeyDownEvent (Key.PageDown));
         Assert.True (cb.NewKeyDownEvent (Key.PageDown));
@@ -891,7 +896,7 @@ One
 Two      ▼
 Two      ▼
 Two       
 Two       
 ",
 ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Assert.True (cb.NewKeyDownEvent (Key.PageDown));
         Assert.True (cb.NewKeyDownEvent (Key.PageDown));
@@ -905,7 +910,7 @@ Two
 Three    ▼
 Three    ▼
 Three     
 Three     
 ",
 ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
         Assert.True (cb.NewKeyDownEvent (Key.PageUp));
         Assert.True (cb.NewKeyDownEvent (Key.PageUp));
         Assert.True (cb.IsShow);
         Assert.True (cb.IsShow);
@@ -959,10 +964,10 @@ Three
         Assert.Equal (-1, cb.SelectedItem);
         Assert.Equal (-1, cb.SelectedItem);
         Assert.Equal ("", cb.Text);
         Assert.Equal ("", cb.Text);
         Assert.Equal (3, cb.Source.Count);
         Assert.Equal (3, cb.Source.Count);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown]
     public void Source_Equal_Null_Or_Count_Equal_Zero_Sets_SelectedItem_Equal_To_Minus_One ()
     public void Source_Equal_Null_Or_Count_Equal_Zero_Sets_SelectedItem_Equal_To_Minus_One ()
     {
     {
         var cb = new ComboBox ();
         var cb = new ComboBox ();

+ 86 - 63
UnitTests/Views/ContextMenuTests.cs

@@ -1,15 +1,10 @@
 using System.Globalization;
 using System.Globalization;
 using Xunit.Abstractions;
 using Xunit.Abstractions;
 
 
-//using GraphViewTests = Terminal.Gui.Views.GraphViewTests;
-
 namespace Terminal.Gui.ViewsTests;
 namespace Terminal.Gui.ViewsTests;
 
 
-public class ContextMenuTests
+public class ContextMenuTests (ITestOutputHelper output)
 {
 {
-    private readonly ITestOutputHelper _output;
-    public ContextMenuTests (ITestOutputHelper output) { _output = output; }
-
     [Fact]
     [Fact]
     [AutoInitShutdown]
     [AutoInitShutdown]
     public void ContextMenu_Constructors ()
     public void ContextMenu_Constructors ()
@@ -107,14 +102,15 @@ public class ContextMenuTests
         Assert.True (ContextMenu.IsShow);
         Assert.True (ContextMenu.IsShow);
         Assert.Equal (cm.MenuBar, Application.MouseGrabView);
         Assert.Equal (cm.MenuBar, Application.MouseGrabView);
         Assert.False (menu.IsMenuOpen);
         Assert.False (menu.IsMenuOpen);
-        Assert.False (menu.NewMouseEvent(new MouseEvent { Position = new (1, 0), Flags = MouseFlags.ReportMousePosition, View = menu }));
+        Assert.False (menu.NewMouseEvent (new MouseEvent { Position = new (1, 0), Flags = MouseFlags.ReportMousePosition, View = menu }));
         Assert.True (ContextMenu.IsShow);
         Assert.True (ContextMenu.IsShow);
         Assert.Equal (cm.MenuBar, Application.MouseGrabView);
         Assert.Equal (cm.MenuBar, Application.MouseGrabView);
         Assert.False (menu.IsMenuOpen);
         Assert.False (menu.IsMenuOpen);
-        Assert.True (menu.NewMouseEvent(new MouseEvent { Position = new (1, 0), Flags = MouseFlags.Button1Clicked, View = menu }));
+        Assert.True (menu.NewMouseEvent (new MouseEvent { Position = new (1, 0), Flags = MouseFlags.Button1Clicked, View = menu }));
         Assert.False (ContextMenu.IsShow);
         Assert.False (ContextMenu.IsShow);
         Assert.Equal (menu, Application.MouseGrabView);
         Assert.Equal (menu, Application.MouseGrabView);
         Assert.True (menu.IsMenuOpen);
         Assert.True (menu.IsMenuOpen);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -176,8 +172,9 @@ public class ContextMenuTests
  F1 Help │ ^Q Quit              
  F1 Help │ ^Q Quit              
 ";
 ";
 
 
-        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Assert.Equal (new Rectangle (1, 0, 32, 17), pos);
         Assert.Equal (new Rectangle (1, 0, 32, 17), pos);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -243,8 +240,9 @@ public class ContextMenuTests
  F1 Help │ ^Q Quit                          
  F1 Help │ ^Q Quit                          
 ";
 ";
 
 
-        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Assert.Equal (new Rectangle (1, 0, 44, 17), pos);
         Assert.Equal (new Rectangle (1, 0, 44, 17), pos);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -254,7 +252,7 @@ public class ContextMenuTests
         ((FakeDriver)Application.Driver).SetBufferSize (20, 15);
         ((FakeDriver)Application.Driver).SetBufferSize (20, 15);
 
 
         Assert.Equal (new Rectangle (0, 0, 20, 15), Application.Driver.Clip);
         Assert.Equal (new Rectangle (0, 0, 20, 15), Application.Driver.Clip);
-        TestHelpers.AssertDriverContentsWithFrameAre ("", _output);
+        TestHelpers.AssertDriverContentsWithFrameAre ("", output);
 
 
         var top = new Toplevel { X = 2, Y = 2, Width = 15, Height = 4 };
         var top = new Toplevel { X = 2, Y = 2, Width = 15, Height = 4 };
         top.Add (new TextField { X = Pos.Center (), Width = 10, Text = "Test" });
         top.Add (new TextField { X = Pos.Center (), Width = 10, Text = "Test" });
@@ -266,7 +264,7 @@ public class ContextMenuTests
         TestHelpers.AssertDriverContentsWithFrameAre (
         TestHelpers.AssertDriverContentsWithFrameAre (
                                                       @"
                                                       @"
     Test",
     Test",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Application.OnMouseEvent (new MouseEvent { Position = new (8, 2), Flags = MouseFlags.Button3Clicked });
         Application.OnMouseEvent (new MouseEvent { Position = new (8, 2), Flags = MouseFlags.Button3Clicked });
@@ -286,10 +284,11 @@ public class ContextMenuTests
 │ Undo         Ctrl+
 │ Undo         Ctrl+
 │ Redo         Ctrl+
 │ Redo         Ctrl+
 └───────────────────",
 └───────────────────",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Application.End (rs);
         Application.End (rs);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -321,7 +320,7 @@ public class ContextMenuTests
 │                  │
 │                  │
 │                  │
 │                  │
 └──────────────────┘",
 └──────────────────┘",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         // Don't use Dialog here as it has more layout logic. Use Window instead.
         // Don't use Dialog here as it has more layout logic. Use Window instead.
@@ -348,7 +347,7 @@ public class ContextMenuTests
 │                  │
 │                  │
 │                  │
 │                  │
 └──────────────────┘",
 └──────────────────┘",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Application.OnMouseEvent (new MouseEvent { Position = new (9, 3), Flags = MouseFlags.Button3Clicked });
         Application.OnMouseEvent (new MouseEvent { Position = new (9, 3), Flags = MouseFlags.Button3Clicked });
@@ -373,11 +372,12 @@ public class ContextMenuTests
 └───────────────────
 └───────────────────
 │                  │
 │                  │
 └──────────────────┘",
 └──────────────────┘",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Application.End (rsDialog);
         Application.End (rsDialog);
         Application.End (rsTop);
         Application.End (rsTop);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -387,7 +387,7 @@ public class ContextMenuTests
         ((FakeDriver)Application.Driver).SetBufferSize (20, 15);
         ((FakeDriver)Application.Driver).SetBufferSize (20, 15);
 
 
         Assert.Equal (new Rectangle (0, 0, 20, 15), Application.Driver.Clip);
         Assert.Equal (new Rectangle (0, 0, 20, 15), Application.Driver.Clip);
-        TestHelpers.AssertDriverContentsWithFrameAre ("", _output);
+        TestHelpers.AssertDriverContentsWithFrameAre ("", output);
 
 
         // Don't use Dialog here as it has more layout logic. Use Window instead.
         // Don't use Dialog here as it has more layout logic. Use Window instead.
         var dialog = new Window { X = 2, Y = 2, Width = 15, Height = 4 };
         var dialog = new Window { X = 2, Y = 2, Width = 15, Height = 4 };
@@ -403,7 +403,7 @@ public class ContextMenuTests
   │ Test        │
   │ Test        │
   │             │
   │             │
   └─────────────┘",
   └─────────────┘",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Application.OnMouseEvent (new MouseEvent { Position = new (9, 3), Flags = MouseFlags.Button3Clicked });
         Application.OnMouseEvent (new MouseEvent { Position = new (9, 3), Flags = MouseFlags.Button3Clicked });
@@ -424,10 +424,11 @@ public class ContextMenuTests
 │ Undo         Ctrl+
 │ Undo         Ctrl+
 │ Redo         Ctrl+
 │ Redo         Ctrl+
 └───────────────────",
 └───────────────────",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Application.End (rs);
         Application.End (rs);
+        dialog.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -446,8 +447,9 @@ public class ContextMenuTests
         };
         };
 
 
         Assert.Equal (new Point (-1, -2), cm.Position);
         Assert.Equal (new Point (-1, -2), cm.Position);
-
-        Application.Begin (new ());
+        
+        Toplevel top = new ();
+        Application.Begin (top);
 
 
         cm.Show ();
         cm.Show ();
         Assert.Equal (new Point (-1, -2), cm.Position);
         Assert.Equal (new Point (-1, -2), cm.Position);
@@ -460,7 +462,7 @@ public class ContextMenuTests
 └──────┘
 └──────┘
 ";
 ";
 
 
-        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Assert.Equal (new Rectangle (0, 1, 8, 4), pos);
         Assert.Equal (new Rectangle (0, 1, 8, 4), pos);
 
 
         cm.ForceMinimumPosToZero = false;
         cm.ForceMinimumPosToZero = false;
@@ -474,8 +476,9 @@ public class ContextMenuTests
 ──────┘
 ──────┘
 ";
 ";
 
 
-        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Assert.Equal (new Rectangle (1, 0, 7, 3), pos);
         Assert.Equal (new Rectangle (1, 0, 7, 3), pos);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -504,6 +507,7 @@ public class ContextMenuTests
 
 
         top.RequestStop ();
         top.RequestStop ();
         Assert.False (ContextMenu.IsShow);
         Assert.False (ContextMenu.IsShow);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -519,6 +523,7 @@ public class ContextMenuTests
         Assert.True (tf.ContextMenu.MenuBar.IsMenuOpen);
         Assert.True (tf.ContextMenu.MenuBar.IsMenuOpen);
         Assert.True (Application.OnKeyDown (ContextMenu.DefaultKey));
         Assert.True (Application.OnKeyDown (ContextMenu.DefaultKey));
         Assert.Null (tf.ContextMenu.MenuBar);
         Assert.Null (tf.ContextMenu.MenuBar);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -550,7 +555,8 @@ public class ContextMenuTests
                                         )
                                         )
         };
         };
 
 
-        Application.Begin (new ());
+        Toplevel top = new ();
+        Application.Begin (top);
         cm.Show ();
         cm.Show ();
         Application.Refresh ();
         Application.Refresh ();
 
 
@@ -561,7 +567,7 @@ public class ContextMenuTests
           └──────┘
           └──────┘
 ";
 ";
 
 
-        TestHelpers.AssertDriverContentsAre (expected, _output);
+        TestHelpers.AssertDriverContentsAre (expected, output);
 
 
         cm.MenuItems = new MenuBarItem (
         cm.MenuItems = new MenuBarItem (
                                         [
                                         [
@@ -582,7 +588,8 @@ public class ContextMenuTests
           └─────────┘
           └─────────┘
 ";
 ";
 
 
-        TestHelpers.AssertDriverContentsAre (expected, _output);
+        TestHelpers.AssertDriverContentsAre (expected, output);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -636,7 +643,7 @@ public class ContextMenuTests
 │ Six    │
 │ Six    │
 └────────┘
 └────────┘
 ",
 ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Assert.True (
         Assert.True (
@@ -664,7 +671,7 @@ public class ContextMenuTests
           │ SubMenu7  │
           │ SubMenu7  │
           └───────────┘
           └───────────┘
 ",
 ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         ((FakeDriver)Application.Driver).SetBufferSize (40, 20);
         ((FakeDriver)Application.Driver).SetBufferSize (40, 20);
@@ -684,7 +691,7 @@ public class ContextMenuTests
                               │ Six    │
                               │ Six    │
                               └────────┘
                               └────────┘
 ",
 ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Assert.True (
         Assert.True (
@@ -712,7 +719,7 @@ public class ContextMenuTests
                  │ SubMenu7  │          
                  │ SubMenu7  │          
                  └───────────┘          
                  └───────────┘          
 ",
 ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         cm.Position = new Point (41, 9);
         cm.Position = new Point (41, 9);
@@ -731,7 +738,7 @@ public class ContextMenuTests
                               │ Six    │
                               │ Six    │
                               └────────┘
                               └────────┘
 ",
 ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Assert.True (
         Assert.True (
@@ -756,7 +763,7 @@ public class ContextMenuTests
                  │ SubMenu7  │          
                  │ SubMenu7  │          
                  └───────────┘          
                  └───────────┘          
 ",
 ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         cm.Position = new Point (41, 22);
         cm.Position = new Point (41, 22);
@@ -775,7 +782,7 @@ public class ContextMenuTests
                               │ Six    │
                               │ Six    │
                               └────────┘
                               └────────┘
 ",
 ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Assert.True (
         Assert.True (
@@ -799,7 +806,7 @@ public class ContextMenuTests
                  │ SubMenu7  ││ Six    │
                  │ SubMenu7  ││ Six    │
                  └───────────┘└────────┘
                  └───────────┘└────────┘
 ",
 ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         ((FakeDriver)Application.Driver).SetBufferSize (18, 8);
         ((FakeDriver)Application.Driver).SetBufferSize (18, 8);
@@ -819,7 +826,7 @@ public class ContextMenuTests
         │ Six    │
         │ Six    │
         └────────┘
         └────────┘
 ",
 ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Assert.True (
         Assert.True (
@@ -842,8 +849,9 @@ public class ContextMenuTests
 │ SubMenu6  │    │
 │ SubMenu6  │    │
 │ SubMenu7  │────┘
 │ SubMenu7  │────┘
 ",
 ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -874,10 +882,10 @@ public class ContextMenuTests
         cm.MouseFlags = MouseFlags.Button2Clicked;
         cm.MouseFlags = MouseFlags.Button2Clicked;
         Assert.True (lbl.NewMouseEvent (new MouseEvent { Flags = cm.MouseFlags }));
         Assert.True (lbl.NewMouseEvent (new MouseEvent { Flags = cm.MouseFlags }));
         Assert.Equal ("Replaced", lbl.Text);
         Assert.Equal ("Replaced", lbl.Text);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown]
     public void MouseFlagsChanged_Event ()
     public void MouseFlagsChanged_Event ()
     {
     {
         var oldMouseFlags = new MouseFlags ();
         var oldMouseFlags = new MouseFlags ();
@@ -905,7 +913,8 @@ public class ContextMenuTests
                                         )
                                         )
         };
         };
 
 
-        Application.Begin (new ());
+        Toplevel top = new ();
+        Application.Begin (top);
         cm.Show ();
         cm.Show ();
         Application.Refresh ();
         Application.Refresh ();
 
 
@@ -916,7 +925,7 @@ public class ContextMenuTests
           └──────┘
           └──────┘
 ";
 ";
 
 
-        TestHelpers.AssertDriverContentsAre (expected, _output);
+        TestHelpers.AssertDriverContentsAre (expected, output);
 
 
         cm.Position = new Point (5, 10);
         cm.Position = new Point (5, 10);
 
 
@@ -930,7 +939,8 @@ public class ContextMenuTests
      └──────┘
      └──────┘
 ";
 ";
 
 
-        TestHelpers.AssertDriverContentsAre (expected, _output);
+        TestHelpers.AssertDriverContentsAre (expected, output);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -1006,6 +1016,7 @@ public class ContextMenuTests
         Assert.True (isTopClosed);
         Assert.True (isTopClosed);
         Assert.False (ContextMenu.IsShow);
         Assert.False (ContextMenu.IsShow);
         Assert.True (isMenuAllClosed);
         Assert.True (isMenuAllClosed);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -1027,7 +1038,8 @@ public class ContextMenuTests
 
 
         Assert.Equal (Point.Empty, cm.Position);
         Assert.Equal (Point.Empty, cm.Position);
 
 
-        Application.Begin (new ());
+        Toplevel top = new ();
+        Application.Begin (top);
         cm.Show ();
         cm.Show ();
         Assert.Equal (Point.Empty, cm.Position);
         Assert.Equal (Point.Empty, cm.Position);
         Application.Refresh ();
         Application.Refresh ();
@@ -1037,11 +1049,12 @@ public class ContextMenuTests
 │ One  │
 │ One  │
 │ Two  │";
 │ Two  │";
 
 
-        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Assert.Equal (new Rectangle (0, 0, 8, 3), pos);
         Assert.Equal (new Rectangle (0, 0, 8, 3), pos);
 
 
         cm.Hide ();
         cm.Hide ();
         Assert.Equal (Point.Empty, cm.Position);
         Assert.Equal (Point.Empty, cm.Position);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -1063,7 +1076,8 @@ public class ContextMenuTests
 
 
         Assert.Equal (Point.Empty, cm.Position);
         Assert.Equal (Point.Empty, cm.Position);
 
 
-        Application.Begin (new ());
+        Toplevel top = new ();
+        Application.Begin (top);
         cm.Show ();
         cm.Show ();
         Assert.Equal (Point.Empty, cm.Position);
         Assert.Equal (Point.Empty, cm.Position);
         Application.Refresh ();
         Application.Refresh ();
@@ -1074,11 +1088,12 @@ public class ContextMenuTests
 │ Two
 │ Two
 └────";
 └────";
 
 
-        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Assert.Equal (new Rectangle (0, 1, 5, 4), pos);
         Assert.Equal (new Rectangle (0, 1, 5, 4), pos);
 
 
         cm.Hide ();
         cm.Hide ();
         Assert.Equal (Point.Empty, cm.Position);
         Assert.Equal (Point.Empty, cm.Position);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -1124,7 +1139,7 @@ public class ContextMenuTests
           └──────┘
           └──────┘
 ";
 ";
 
 
-        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Assert.Equal (new Rectangle (10, 5, 18, 5), pos);
         Assert.Equal (new Rectangle (10, 5, 18, 5), pos);
 
 
         cm.Hide ();
         cm.Hide ();
@@ -1147,11 +1162,12 @@ public class ContextMenuTests
      └──────┘
      └──────┘
 ";
 ";
 
 
-        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Assert.Equal (new Rectangle (5, 10, 13, 7), pos);
         Assert.Equal (new Rectangle (5, 10, 13, 7), pos);
 
 
         cm.Hide ();
         cm.Hide ();
         Assert.Equal (new Point (5, 12), cm.Position);
         Assert.Equal (new Point (5, 12), cm.Position);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -1171,7 +1187,8 @@ public class ContextMenuTests
 
 
         Assert.Equal (new Point (80, 25), cm.Position);
         Assert.Equal (new Point (80, 25), cm.Position);
 
 
-        Application.Begin (new ());
+        Toplevel top = new ();
+        Application.Begin (top);
         cm.Show ();
         cm.Show ();
         Assert.Equal (new Point (80, 25), cm.Position);
         Assert.Equal (new Point (80, 25), cm.Position);
         Application.Refresh ();
         Application.Refresh ();
@@ -1183,11 +1200,12 @@ public class ContextMenuTests
                                                                         └──────┘
                                                                         └──────┘
 ";
 ";
 
 
-        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Assert.Equal (new Rectangle (72, 21, 80, 4), pos);
         Assert.Equal (new Rectangle (72, 21, 80, 4), pos);
 
 
         cm.Hide ();
         cm.Hide ();
         Assert.Equal (new Point (80, 25), cm.Position);
         Assert.Equal (new Point (80, 25), cm.Position);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -1233,11 +1251,12 @@ public class ContextMenuTests
                                                                       View    
                                                                       View    
 ";
 ";
 
 
-        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Assert.Equal (new Rectangle (70, 20, 78, 5), pos);
         Assert.Equal (new Rectangle (70, 20, 78, 5), pos);
 
 
         cm.Hide ();
         cm.Hide ();
         Assert.Equal (new Point (70, 24), cm.Position);
         Assert.Equal (new Point (70, 24), cm.Position);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -1246,7 +1265,8 @@ public class ContextMenuTests
     {
     {
         ContextMenu cm = Create_ContextMenu_With_Two_MenuItem (10, 5);
         ContextMenu cm = Create_ContextMenu_With_Two_MenuItem (10, 5);
 
 
-        Application.Begin (new ());
+        Toplevel top = new ();
+        Application.Begin (top);
         cm.Show ();
         cm.Show ();
         Assert.True (ContextMenu.IsShow);
         Assert.True (ContextMenu.IsShow);
         Application.Refresh ();
         Application.Refresh ();
@@ -1258,7 +1278,7 @@ public class ContextMenuTests
           └──────┘
           └──────┘
 ";
 ";
 
 
-        TestHelpers.AssertDriverContentsAre (expected, _output);
+        TestHelpers.AssertDriverContentsAre (expected, output);
 
 
         cm.Hide ();
         cm.Hide ();
         Assert.False (ContextMenu.IsShow);
         Assert.False (ContextMenu.IsShow);
@@ -1267,7 +1287,8 @@ public class ContextMenuTests
 
 
         expected = "";
         expected = "";
 
 
-        TestHelpers.AssertDriverContentsAre (expected, _output);
+        TestHelpers.AssertDriverContentsAre (expected, output);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -1297,8 +1318,8 @@ public class ContextMenuTests
                                         ),
                                         ),
             UseSubMenusSingleFrame = true
             UseSubMenusSingleFrame = true
         };
         };
-
-        RunState rs = Application.Begin (new ());
+        Toplevel top = new ();
+        RunState rs = Application.Begin (top);
         cm.Show ();
         cm.Show ();
         Assert.Equal (new Rectangle (5, 11, 10, 5), Application.Top.Subviews [0].Frame);
         Assert.Equal (new Rectangle (5, 11, 10, 5), Application.Top.Subviews [0].Frame);
         Application.Refresh ();
         Application.Refresh ();
@@ -1310,7 +1331,7 @@ public class ContextMenuTests
      │ Two   ►│
      │ Two   ►│
      │ Three  │
      │ Three  │
      └────────┘",
      └────────┘",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         // X=5 is the border and so need to use at least one more
         // X=5 is the border and so need to use at least one more
@@ -1329,7 +1350,7 @@ public class ContextMenuTests
      │ Sub-Menu 1  │
      │ Sub-Menu 1  │
      │ Sub-Menu 2  │
      │ Sub-Menu 2  │
      └─────────────┘",
      └─────────────┘",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Application.OnMouseEvent (new MouseEvent { Position = new (6, 12), Flags = MouseFlags.Button1Clicked });
         Application.OnMouseEvent (new MouseEvent { Position = new (6, 12), Flags = MouseFlags.Button1Clicked });
@@ -1345,10 +1366,11 @@ public class ContextMenuTests
      │ Two   ►│
      │ Two   ►│
      │ Three  │
      │ Three  │
      └────────┘",
      └────────┘",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Application.End (rs);
         Application.End (rs);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -1386,8 +1408,8 @@ public class ContextMenuTests
                                          ]
                                          ]
                                         )
                                         )
         };
         };
-
-        RunState rs = Application.Begin (new ());
+        Toplevel top = new ();
+        RunState rs = Application.Begin (top);
         cm.Show ();
         cm.Show ();
 
 
         Assert.Equal (new Rectangle (5, 11, 10, 5), Application.Top.Subviews [0].Frame);
         Assert.Equal (new Rectangle (5, 11, 10, 5), Application.Top.Subviews [0].Frame);
@@ -1400,7 +1422,7 @@ public class ContextMenuTests
      │ Two   ►│
      │ Two   ►│
      │ Three ►│
      │ Three ►│
      └────────┘",
      └────────┘",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Application.OnMouseEvent (new MouseEvent { Position = new (6, 13), Flags = MouseFlags.ReportMousePosition });
         Application.OnMouseEvent (new MouseEvent { Position = new (6, 13), Flags = MouseFlags.ReportMousePosition });
@@ -1417,7 +1439,7 @@ public class ContextMenuTests
      │ Three ►││ Two-Menu 1  │
      │ Three ►││ Two-Menu 1  │
      └────────┘│ Two-Menu 2  │
      └────────┘│ Two-Menu 2  │
                └─────────────┘",
                └─────────────┘",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Application.OnMouseEvent (new MouseEvent { Position = new (6, 14), Flags = MouseFlags.ReportMousePosition });
         Application.OnMouseEvent (new MouseEvent { Position = new (6, 14), Flags = MouseFlags.ReportMousePosition });
@@ -1435,7 +1457,7 @@ public class ContextMenuTests
      └────────┘│ Three-Menu 1  │
      └────────┘│ Three-Menu 1  │
                │ Three-Menu 2  │
                │ Three-Menu 2  │
                └───────────────┘",
                └───────────────┘",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Application.OnMouseEvent (new MouseEvent { Position = new (6, 13), Flags = MouseFlags.ReportMousePosition });
         Application.OnMouseEvent (new MouseEvent { Position = new (6, 13), Flags = MouseFlags.ReportMousePosition });
@@ -1452,10 +1474,11 @@ public class ContextMenuTests
      │ Three ►││ Two-Menu 1  │
      │ Three ►││ Two-Menu 1  │
      └────────┘│ Two-Menu 2  │
      └────────┘│ Two-Menu 2  │
                └─────────────┘",
                └─────────────┘",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Application.End (rs);
         Application.End (rs);
+        top.Dispose ();
     }
     }
 
 
     private ContextMenu Create_ContextMenu_With_Two_MenuItem (int x, int y)
     private ContextMenu Create_ContextMenu_With_Two_MenuItem (int x, int y)

+ 1 - 1
UnitTests/Views/DateFieldTests.cs

@@ -30,7 +30,7 @@ public class DateFieldTests
 
 
     [Fact]
     [Fact]
     [TestDate]
     [TestDate]
-    [AutoInitShutdown]
+    [SetupFakeDriver]
     public void Copy_Paste ()
     public void Copy_Paste ()
     {
     {
         var df1 = new DateField (DateTime.Parse ("12/12/1971"));
         var df1 = new DateField (DateTime.Parse ("12/12/1971"));

+ 3 - 1
UnitTests/Views/DatePickerTests.cs

@@ -50,7 +50,7 @@ public class DatePickerTests
         var datePicker = new DatePicker (date);
         var datePicker = new DatePicker (date);
 
 
         var top = new Toplevel ();
         var top = new Toplevel ();
-       top.Add (datePicker);
+        top.Add (datePicker);
         Application.Begin (top);
         Application.Begin (top);
 
 
         // Set focus to next month button
         // Set focus to next month button
@@ -65,6 +65,7 @@ public class DatePickerTests
         // Date should not change as next month button is disabled
         // Date should not change as next month button is disabled
         Assert.False (datePicker.NewKeyDownEvent (Key.Enter));
         Assert.False (datePicker.NewKeyDownEvent (Key.Enter));
         Assert.Equal (12, datePicker.Date.Month);
         Assert.Equal (12, datePicker.Date.Month);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -90,5 +91,6 @@ public class DatePickerTests
         // Date should not change as previous month button is disabled
         // Date should not change as previous month button is disabled
         Assert.False (datePicker.NewKeyDownEvent (Key.Enter));
         Assert.False (datePicker.NewKeyDownEvent (Key.Enter));
         Assert.Equal (1, datePicker.Date.Month);
         Assert.Equal (1, datePicker.Date.Month);
+        top.Dispose ();
     }
     }
 }
 }

+ 15 - 17
UnitTests/Views/FrameViewTests.cs

@@ -2,11 +2,8 @@
 
 
 namespace Terminal.Gui.ViewsTests;
 namespace Terminal.Gui.ViewsTests;
 
 
-public class FrameViewTests
+public class FrameViewTests (ITestOutputHelper output)
 {
 {
-    private readonly ITestOutputHelper _output;
-    public FrameViewTests (ITestOutputHelper output) { _output = output; }
-
     [Fact]
     [Fact]
     public void Constructors_Defaults ()
     public void Constructors_Defaults ()
     {
     {
@@ -15,12 +12,12 @@ public class FrameViewTests
         Assert.Equal (string.Empty, fv.Text);
         Assert.Equal (string.Empty, fv.Text);
         Assert.Equal (LineStyle.Single, fv.BorderStyle);
         Assert.Equal (LineStyle.Single, fv.BorderStyle);
 
 
-        fv = new FrameView { Title = "Test" };
+        fv = new() { Title = "Test" };
         Assert.Equal ("Test", fv.Title);
         Assert.Equal ("Test", fv.Title);
         Assert.Equal (string.Empty, fv.Text);
         Assert.Equal (string.Empty, fv.Text);
         Assert.Equal (LineStyle.Single, fv.BorderStyle);
         Assert.Equal (LineStyle.Single, fv.BorderStyle);
 
 
-        fv = new FrameView
+        fv = new()
         {
         {
             X = 1,
             X = 1,
             Y = 2,
             Y = 2,
@@ -33,7 +30,7 @@ public class FrameViewTests
         fv.BeginInit ();
         fv.BeginInit ();
         fv.EndInit ();
         fv.EndInit ();
         Assert.Equal (LineStyle.Single, fv.BorderStyle);
         Assert.Equal (LineStyle.Single, fv.BorderStyle);
-        Assert.Equal (new Rectangle (1, 2, 10, 20), fv.Frame);
+        Assert.Equal (new (1, 2, 10, 20), fv.Frame);
     }
     }
 
 
     [Fact]
     [Fact]
@@ -47,12 +44,12 @@ public class FrameViewTests
         var top = new Toplevel ();
         var top = new Toplevel ();
         top.Add (fv);
         top.Add (fv);
         Application.Begin (top);
         Application.Begin (top);
-        Assert.Equal (new Rectangle (0, 0, 0, 0), fv.Frame);
-        TestHelpers.AssertDriverContentsWithFrameAre (@"", _output);
+        Assert.Equal (new (0, 0, 0, 0), fv.Frame);
+        TestHelpers.AssertDriverContentsWithFrameAre (@"", output);
 
 
         fv.Height = 5;
         fv.Height = 5;
         fv.Width = 5;
         fv.Width = 5;
-        Assert.Equal (new Rectangle (0, 0, 5, 5), fv.Frame);
+        Assert.Equal (new (0, 0, 5, 5), fv.Frame);
         Application.Refresh ();
         Application.Refresh ();
 
 
         TestHelpers.AssertDriverContentsWithFrameAre (
         TestHelpers.AssertDriverContentsWithFrameAre (
@@ -62,12 +59,12 @@ public class FrameViewTests
 │   │
 │   │
 │   │
 │   │
 └───┘",
 └───┘",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         fv.X = 1;
         fv.X = 1;
         fv.Y = 2;
         fv.Y = 2;
-        Assert.Equal (new Rectangle (1, 2, 5, 5), fv.Frame);
+        Assert.Equal (new (1, 2, 5, 5), fv.Frame);
         Application.Refresh ();
         Application.Refresh ();
 
 
         TestHelpers.AssertDriverContentsWithFrameAre (
         TestHelpers.AssertDriverContentsWithFrameAre (
@@ -77,12 +74,12 @@ public class FrameViewTests
  │   │
  │   │
  │   │
  │   │
  └───┘",
  └───┘",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         fv.X = -1;
         fv.X = -1;
         fv.Y = -2;
         fv.Y = -2;
-        Assert.Equal (new Rectangle (-1, -2, 5, 5), fv.Frame);
+        Assert.Equal (new (-1, -2, 5, 5), fv.Frame);
         Application.Refresh ();
         Application.Refresh ();
 
 
         TestHelpers.AssertDriverContentsWithFrameAre (
         TestHelpers.AssertDriverContentsWithFrameAre (
@@ -90,19 +87,20 @@ public class FrameViewTests
 ───┘",
 ───┘",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         fv.X = 7;
         fv.X = 7;
         fv.Y = 8;
         fv.Y = 8;
-        Assert.Equal (new Rectangle (7, 8, 5, 5), fv.Frame);
+        Assert.Equal (new (7, 8, 5, 5), fv.Frame);
         Application.Refresh ();
         Application.Refresh ();
 
 
         TestHelpers.AssertDriverContentsWithFrameAre (
         TestHelpers.AssertDriverContentsWithFrameAre (
                                                       @"
                                                       @"
        ┌──
        ┌──
        │  ",
        │  ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
+        top.Dispose ();
     }
     }
 }
 }

+ 15 - 10
UnitTests/Views/HexViewTests.cs

@@ -86,7 +86,7 @@ public class HexViewTests
         Assert.True (hv.CanFocus);
         Assert.True (hv.CanFocus);
         Assert.True (hv.AllowEdits);
         Assert.True (hv.AllowEdits);
 
 
-        hv = new HexView (new MemoryStream ());
+        hv = new (new MemoryStream ());
         Assert.NotNull (hv.Source);
         Assert.NotNull (hv.Source);
         Assert.IsAssignableFrom<Stream> (hv.Source);
         Assert.IsAssignableFrom<Stream> (hv.Source);
         Assert.True (hv.CanFocus);
         Assert.True (hv.CanFocus);
@@ -102,7 +102,7 @@ public class HexViewTests
         top.Add (hv);
         top.Add (hv);
         Application.Begin (top);
         Application.Begin (top);
 
 
-        Assert.Equal (new Point (1, 1), hv.CursorPosition);
+        Assert.Equal (new (1, 1), hv.CursorPosition);
 
 
         Assert.True (hv.NewKeyDownEvent (Key.Enter));
         Assert.True (hv.NewKeyDownEvent (Key.Enter));
         Assert.True (hv.NewKeyDownEvent (Key.CursorRight.WithCtrl));
         Assert.True (hv.NewKeyDownEvent (Key.CursorRight.WithCtrl));
@@ -110,16 +110,17 @@ public class HexViewTests
         Assert.True (hv.NewKeyDownEvent (Key.Home));
         Assert.True (hv.NewKeyDownEvent (Key.Home));
 
 
         Assert.True (hv.NewKeyDownEvent (Key.CursorRight));
         Assert.True (hv.NewKeyDownEvent (Key.CursorRight));
-        Assert.Equal (new Point (2, 1), hv.CursorPosition);
+        Assert.Equal (new (2, 1), hv.CursorPosition);
 
 
         Assert.True (hv.NewKeyDownEvent (Key.CursorDown));
         Assert.True (hv.NewKeyDownEvent (Key.CursorDown));
-        Assert.Equal (new Point (2, 2), hv.CursorPosition);
+        Assert.Equal (new (2, 2), hv.CursorPosition);
 
 
         Assert.True (hv.NewKeyDownEvent (Key.End));
         Assert.True (hv.NewKeyDownEvent (Key.End));
         int col = hv.CursorPosition.X;
         int col = hv.CursorPosition.X;
         int line = hv.CursorPosition.Y;
         int line = hv.CursorPosition.Y;
         int offset = (line - 1) * (hv.BytesPerLine - col);
         int offset = (line - 1) * (hv.BytesPerLine - col);
         Assert.Equal (hv.Position, col * line + offset);
         Assert.Equal (hv.Position, col * line + offset);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -131,7 +132,7 @@ public class HexViewTests
         top.Add (hv);
         top.Add (hv);
         Application.Begin (top);
         Application.Begin (top);
 
 
-        Assert.Equal (new Point (1, 1), hv.CursorPosition);
+        Assert.Equal (new (1, 1), hv.CursorPosition);
 
 
         Assert.True (hv.NewKeyDownEvent (Key.Enter));
         Assert.True (hv.NewKeyDownEvent (Key.Enter));
         Assert.True (hv.NewKeyDownEvent (Key.CursorRight.WithCtrl));
         Assert.True (hv.NewKeyDownEvent (Key.CursorRight.WithCtrl));
@@ -139,16 +140,17 @@ public class HexViewTests
         Assert.True (hv.NewKeyDownEvent (Key.Home));
         Assert.True (hv.NewKeyDownEvent (Key.Home));
 
 
         Assert.True (hv.NewKeyDownEvent (Key.CursorRight));
         Assert.True (hv.NewKeyDownEvent (Key.CursorRight));
-        Assert.Equal (new Point (2, 1), hv.CursorPosition);
+        Assert.Equal (new (2, 1), hv.CursorPosition);
 
 
         Assert.True (hv.NewKeyDownEvent (Key.CursorDown));
         Assert.True (hv.NewKeyDownEvent (Key.CursorDown));
-        Assert.Equal (new Point (2, 2), hv.CursorPosition);
+        Assert.Equal (new (2, 2), hv.CursorPosition);
 
 
         Assert.True (hv.NewKeyDownEvent (Key.End));
         Assert.True (hv.NewKeyDownEvent (Key.End));
         int col = hv.CursorPosition.X;
         int col = hv.CursorPosition.X;
         int line = hv.CursorPosition.Y;
         int line = hv.CursorPosition.Y;
         int offset = (line - 1) * (hv.BytesPerLine - col);
         int offset = (line - 1) * (hv.BytesPerLine - col);
         Assert.Equal (hv.Position, col * line + offset);
         Assert.Equal (hv.Position, col * line + offset);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -200,7 +202,7 @@ public class HexViewTests
         hv.LayoutSubviews ();
         hv.LayoutSubviews ();
 
 
         KeyValuePair<long, byte> keyValuePair = default;
         KeyValuePair<long, byte> keyValuePair = default;
-        hv.Edited += (s, e) => keyValuePair = new KeyValuePair<long, byte> (e.Position, e.NewValue);
+        hv.Edited += (s, e) => keyValuePair = new (e.Position, e.NewValue);
 
 
         Assert.True (hv.NewKeyDownEvent (Key.D4));
         Assert.True (hv.NewKeyDownEvent (Key.D4));
         Assert.True (hv.NewKeyDownEvent (Key.D6));
         Assert.True (hv.NewKeyDownEvent (Key.D6));
@@ -248,7 +250,7 @@ public class HexViewTests
         Assert.True (hv.NewKeyDownEvent (Key.V.WithCtrl));
         Assert.True (hv.NewKeyDownEvent (Key.V.WithCtrl));
         Assert.Equal (41, hv.Position);
         Assert.Equal (41, hv.Position);
 
 
-        Assert.True (hv.NewKeyDownEvent (new Key (Key.V.WithAlt)));
+        Assert.True (hv.NewKeyDownEvent (new (Key.V.WithAlt)));
         Assert.Equal (1, hv.Position);
         Assert.Equal (1, hv.Position);
 
 
         Assert.True (hv.NewKeyDownEvent (Key.PageDown));
         Assert.True (hv.NewKeyDownEvent (Key.PageDown));
@@ -274,6 +276,7 @@ public class HexViewTests
 
 
         Assert.True (hv.NewKeyDownEvent (Key.CursorUp.WithCtrl));
         Assert.True (hv.NewKeyDownEvent (Key.CursorUp.WithCtrl));
         Assert.Equal (1, hv.Position);
         Assert.Equal (1, hv.Position);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -360,8 +363,9 @@ public class HexViewTests
         Assert.True (hv.NewKeyDownEvent (Key.CursorDown));
         Assert.True (hv.NewKeyDownEvent (Key.CursorDown));
 
 
         Assert.Equal (12, hexViewEventArgs.BytesPerLine);
         Assert.Equal (12, hexViewEventArgs.BytesPerLine);
-        Assert.Equal (new Point (2, 2), hexViewEventArgs.CursorPosition);
+        Assert.Equal (new (2, 2), hexViewEventArgs.CursorPosition);
         Assert.Equal (14, hexViewEventArgs.Position);
         Assert.Equal (14, hexViewEventArgs.Position);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -395,6 +399,7 @@ public class HexViewTests
         hv.Source = new MemoryStream ();
         hv.Source = new MemoryStream ();
         Assert.Equal (0, hv.DisplayStart);
         Assert.Equal (0, hv.DisplayStart);
         Assert.Equal (0, hv.Position - 1);
         Assert.Equal (0, hv.Position - 1);
+        top.Dispose ();
     }
     }
 
 
     private Stream LoadStream (bool unicode = false)
     private Stream LoadStream (bool unicode = false)

+ 185 - 184
UnitTests/Views/LabelTests.cs

@@ -1,14 +1,10 @@
 using System.ComponentModel;
 using System.ComponentModel;
-using Microsoft.VisualStudio.TestPlatform.Utilities;
 using Xunit.Abstractions;
 using Xunit.Abstractions;
 
 
 namespace Terminal.Gui.ViewsTests;
 namespace Terminal.Gui.ViewsTests;
 
 
-public class LabelTests
+public class LabelTests (ITestOutputHelper output)
 {
 {
-    private readonly ITestOutputHelper _output;
-    public LabelTests (ITestOutputHelper output) { _output = output; }
-
     // Test that Title and Text are the same
     // Test that Title and Text are the same
     [Fact]
     [Fact]
     public void Text_Mirrors_Title ()
     public void Text_Mirrors_Title ()
@@ -37,9 +33,9 @@ public class LabelTests
     [Fact]
     [Fact]
     public void HotKey_Command_SetsFocus_OnNextSubview ()
     public void HotKey_Command_SetsFocus_OnNextSubview ()
     {
     {
-        var superView = new View () { CanFocus = true };
+        var superView = new View { CanFocus = true };
         var label = new Label ();
         var label = new Label ();
-        var nextSubview = new View () { CanFocus = true };
+        var nextSubview = new View { CanFocus = true };
         superView.Add (label, nextSubview);
         superView.Add (label, nextSubview);
         superView.BeginInit ();
         superView.BeginInit ();
         superView.EndInit ();
         superView.EndInit ();
@@ -52,14 +48,13 @@ public class LabelTests
         Assert.True (nextSubview.HasFocus);
         Assert.True (nextSubview.HasFocus);
     }
     }
 
 
-
     [Fact]
     [Fact]
     public void MouseClick_SetsFocus_OnNextSubview ()
     public void MouseClick_SetsFocus_OnNextSubview ()
     {
     {
-        var superView = new View () { CanFocus = true, Height = 1, Width = 15 };
-        var focusedView = new View () { CanFocus = true, Width = 1, Height = 1 };
-        var label = new Label () { X = 2, Title = "_x" };
-        var nextSubview = new View () { CanFocus = true, X = 4, Width = 4, Height = 1 };
+        var superView = new View { CanFocus = true, Height = 1, Width = 15 };
+        var focusedView = new View { CanFocus = true, Width = 1, Height = 1 };
+        var label = new Label { X = 2, Title = "_x" };
+        var nextSubview = new View { CanFocus = true, X = 4, Width = 4, Height = 1 };
         superView.Add (focusedView, label, nextSubview);
         superView.Add (focusedView, label, nextSubview);
         superView.BeginInit ();
         superView.BeginInit ();
         superView.EndInit ();
         superView.EndInit ();
@@ -68,7 +63,7 @@ public class LabelTests
         Assert.False (label.HasFocus);
         Assert.False (label.HasFocus);
         Assert.False (nextSubview.HasFocus);
         Assert.False (nextSubview.HasFocus);
 
 
-        label.NewMouseEvent (new MouseEvent () { Position = new (0, 0), Flags = MouseFlags.Button1Clicked });
+        label.NewMouseEvent (new() { Position = new (0, 0), Flags = MouseFlags.Button1Clicked });
         Assert.False (label.HasFocus);
         Assert.False (label.HasFocus);
         Assert.True (nextSubview.HasFocus);
         Assert.True (nextSubview.HasFocus);
     }
     }
@@ -85,6 +80,7 @@ public class LabelTests
         Assert.False (accepted);
         Assert.False (accepted);
 
 
         return;
         return;
+
         void LabelOnAccept (object sender, CancelEventArgs e) { accepted = true; }
         void LabelOnAccept (object sender, CancelEventArgs e) { accepted = true; }
     }
     }
 
 
@@ -100,8 +96,6 @@ public class LabelTests
         var top = new Toplevel ();
         var top = new Toplevel ();
         top.Add (win);
         top.Add (win);
 
 
-       
-
         Application.Begin (top);
         Application.Begin (top);
         ((FakeDriver)Application.Driver).SetBufferSize (30, 5);
         ((FakeDriver)Application.Driver).SetBufferSize (30, 5);
 
 
@@ -113,11 +107,10 @@ public class LabelTests
 └────────────────────────────┘
 └────────────────────────────┘
 ";
 ";
 
 
-        TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
 
 
-       
         label.Text = "Say Hello 你 changed";
         label.Text = "Say Hello 你 changed";
-       
+
         Application.Refresh ();
         Application.Refresh ();
 
 
         expected = @"
         expected = @"
@@ -128,7 +121,8 @@ public class LabelTests
 └────────────────────────────┘
 └────────────────────────────┘
 ";
 ";
 
 
-        TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -153,11 +147,10 @@ public class LabelTests
 └────────────────────────────┘
 └────────────────────────────┘
 ";
 ";
 
 
-        TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
 
 
-       
         label.Text = "Say Hello 你 changed";
         label.Text = "Say Hello 你 changed";
-       
+
         Application.Refresh ();
         Application.Refresh ();
 
 
         expected = @"
         expected = @"
@@ -168,7 +161,8 @@ public class LabelTests
 └────────────────────────────┘
 └────────────────────────────┘
 ";
 ";
 
 
-        TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -182,12 +176,8 @@ public class LabelTests
         var top = new Toplevel ();
         var top = new Toplevel ();
         top.Add (win);
         top.Add (win);
 
 
-       
-
         label.Text = "Say Hello 你";
         label.Text = "Say Hello 你";
 
 
-       
-
         Application.Begin (top);
         Application.Begin (top);
         ((FakeDriver)Application.Driver).SetBufferSize (30, 5);
         ((FakeDriver)Application.Driver).SetBufferSize (30, 5);
 
 
@@ -199,7 +189,8 @@ public class LabelTests
 └────────────────────────────┘
 └────────────────────────────┘
 ";
 ";
 
 
-        TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -209,7 +200,7 @@ public class LabelTests
         Assert.Equal (string.Empty, label.Text);
         Assert.Equal (string.Empty, label.Text);
         Assert.Equal (Alignment.Start, label.TextAlignment);
         Assert.Equal (Alignment.Start, label.TextAlignment);
         Assert.False (label.CanFocus);
         Assert.False (label.CanFocus);
-        Assert.Equal (new Rectangle (0, 0, 0, 0), label.Frame);
+        Assert.Equal (new (0, 0, 0, 0), label.Frame);
         Assert.Equal (KeyCode.Null, label.HotKey);
         Assert.Equal (KeyCode.Null, label.HotKey);
     }
     }
 
 
@@ -217,7 +208,7 @@ public class LabelTests
     [AutoInitShutdown]
     [AutoInitShutdown]
     public void Label_Draw_Fill_Remaining_AutoSize_False ()
     public void Label_Draw_Fill_Remaining_AutoSize_False ()
     {
     {
-        Size tfSize = new Size (80, 1);
+        var tfSize = new Size (80, 1);
 
 
         var label = new Label { Text = "This label needs to be cleared before rewritten.", Width = tfSize.Width, Height = tfSize.Height };
         var label = new Label { Text = "This label needs to be cleared before rewritten.", Width = tfSize.Width, Height = tfSize.Height };
 
 
@@ -238,16 +229,16 @@ public class LabelTests
         Assert.False (tf1.FillRemaining);
         Assert.False (tf1.FillRemaining);
         Assert.True (tf2.FillRemaining);
         Assert.True (tf2.FillRemaining);
 
 
-        tf1.Draw (new Rectangle (new Point (0, 1), tfSize), label.GetNormalColor (), label.ColorScheme.HotNormal);
+        tf1.Draw (new (new (0, 1), tfSize), label.GetNormalColor (), label.ColorScheme.HotNormal);
 
 
-        tf2.Draw (new Rectangle (new Point (0, 2), tfSize), label.GetNormalColor (), label.ColorScheme.HotNormal);
+        tf2.Draw (new (new (0, 2), tfSize), label.GetNormalColor (), label.ColorScheme.HotNormal);
 
 
         TestHelpers.AssertDriverContentsWithFrameAre (
         TestHelpers.AssertDriverContentsWithFrameAre (
                                                       @"
                                                       @"
 This label needs to be cleared before rewritten.                       
 This label needs to be cleared before rewritten.                       
 This TextFormatter (tf1) without fill will not be cleared on rewritten.
 This TextFormatter (tf1) without fill will not be cleared on rewritten.
 This TextFormatter (tf2) with fill will be cleared on rewritten.       ",
 This TextFormatter (tf2) with fill will be cleared on rewritten.       ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Assert.False (label.NeedsDisplay);
         Assert.False (label.NeedsDisplay);
@@ -260,18 +251,19 @@ This TextFormatter (tf2) with fill will be cleared on rewritten.       ",
         label.Draw ();
         label.Draw ();
 
 
         tf1.Text = "This TextFormatter (tf1) is rewritten.";
         tf1.Text = "This TextFormatter (tf1) is rewritten.";
-        tf1.Draw (new Rectangle (new Point (0, 1), tfSize), label.GetNormalColor (), label.ColorScheme.HotNormal);
+        tf1.Draw (new (new (0, 1), tfSize), label.GetNormalColor (), label.ColorScheme.HotNormal);
 
 
         tf2.Text = "This TextFormatter (tf2) is rewritten.";
         tf2.Text = "This TextFormatter (tf2) is rewritten.";
-        tf2.Draw (new Rectangle (new Point (0, 2), tfSize), label.GetNormalColor (), label.ColorScheme.HotNormal);
+        tf2.Draw (new (new (0, 2), tfSize), label.GetNormalColor (), label.ColorScheme.HotNormal);
 
 
         TestHelpers.AssertDriverContentsWithFrameAre (
         TestHelpers.AssertDriverContentsWithFrameAre (
                                                       @"
                                                       @"
 This label is rewritten.                                               
 This label is rewritten.                                               
 This TextFormatter (tf1) is rewritten.will not be cleared on rewritten.
 This TextFormatter (tf1) is rewritten.will not be cleared on rewritten.
 This TextFormatter (tf2) is rewritten.                                 ",
 This TextFormatter (tf2) is rewritten.                                 ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -283,15 +275,15 @@ This TextFormatter (tf2) is rewritten.                                 ",
         top.Add (label);
         top.Add (label);
         Application.Begin (top);
         Application.Begin (top);
 
 
-       
-        Assert.Equal (new Rectangle (0, 0, 16, 1), label.Frame);
+        Assert.Equal (new (0, 0, 16, 1), label.Frame);
 
 
         var expected = @"
         var expected = @"
 Demo Simple Rune
 Demo Simple Rune
 ";
 ";
 
 
-        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
-        Assert.Equal (new Rectangle (0, 0, 16, 1), pos);
+        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+        Assert.Equal (new (0, 0, 16, 1), pos);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -325,8 +317,9 @@ n
 e
 e
 ";
 ";
 
 
-        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
-        Assert.Equal (new Rectangle (0, 0, 1, 16), pos);
+        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+        Assert.Equal (new (0, 0, 1, 16), pos);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -348,12 +341,12 @@ e
 ";
 ";
 
 
-        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
-        Assert.Equal (new Rectangle (0, 0, 2, 7), pos);
+        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+        Assert.Equal (new (0, 0, 2, 7), pos);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown]
     public void Label_HotKeyChanged_EventFires ()
     public void Label_HotKeyChanged_EventFires ()
     {
     {
         var label = new Label { Text = "Yar" };
         var label = new Label { Text = "Yar" };
@@ -375,7 +368,6 @@ e
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown]
     public void Label_HotKeyChanged_EventFires_WithNone ()
     public void Label_HotKeyChanged_EventFires_WithNone ()
     {
     {
         var label = new Label ();
         var label = new Label ();
@@ -427,7 +419,7 @@ e
         Assert.True (label.IsInitialized);
         Assert.True (label.IsInitialized);
         Assert.Equal ("Say Hello 你", label.Text);
         Assert.Equal ("Say Hello 你", label.Text);
         Assert.Equal ("Say Hello 你", label.TextFormatter.Text);
         Assert.Equal ("Say Hello 你", label.TextFormatter.Text);
-        Assert.Equal (new Rectangle (0, 0, 12, 1), label.Viewport);
+        Assert.Equal (new (0, 0, 12, 1), label.Viewport);
 
 
         var expected = @"
         var expected = @"
 ┌────────────────────────────┐
 ┌────────────────────────────┐
@@ -436,8 +428,9 @@ e
 │                            │
 │                            │
 └────────────────────────────┘
 └────────────────────────────┘
 ";
 ";
-        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
-        Assert.Equal (new Rectangle (0, 0, 30, 5), pos);
+        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+        Assert.Equal (new (0, 0, 30, 5), pos);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -458,7 +451,7 @@ e
         Assert.True (label.IsInitialized);
         Assert.True (label.IsInitialized);
         Assert.Equal ("Say Hello 你", label.Text);
         Assert.Equal ("Say Hello 你", label.Text);
         Assert.Equal ("Say Hello 你", label.TextFormatter.Text);
         Assert.Equal ("Say Hello 你", label.TextFormatter.Text);
-        Assert.Equal (new Rectangle (0, 0, 12, 1), label.Viewport);
+        Assert.Equal (new (0, 0, 12, 1), label.Viewport);
 
 
         var expected = @"
         var expected = @"
 ┌────────────────────────────┐
 ┌────────────────────────────┐
@@ -468,18 +461,18 @@ e
 └────────────────────────────┘
 └────────────────────────────┘
 ";
 ";
 
 
-        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
-        Assert.Equal (new Rectangle (0, 0, 30, 5), pos);
+        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+        Assert.Equal (new (0, 0, 30, 5), pos);
+        top.Dispose ();
     }
     }
 
 
-
     [Fact]
     [Fact]
     [SetupFakeDriver]
     [SetupFakeDriver]
     public void Full_Border ()
     public void Full_Border ()
     {
     {
-        var label = new Label { BorderStyle = LineStyle.Single , Text = "Test",} ;
-        label.BeginInit();
-        label.EndInit();
+        var label = new Label { BorderStyle = LineStyle.Single, Text = "Test" };
+        label.BeginInit ();
+        label.EndInit ();
         label.SetRelativeLayout (Application.Driver.Screen.Size);
         label.SetRelativeLayout (Application.Driver.Screen.Size);
 
 
         Assert.Equal (new (0, 0, 4, 1), label.Viewport);
         Assert.Equal (new (0, 0, 4, 1), label.Viewport);
@@ -492,7 +485,7 @@ e
 ┌┤Te├┐
 ┌┤Te├┐
 │Test│
 │Test│
 └────┘",
 └────┘",
-                                                      _output
+                                                      output
                                                      );
                                                      );
         label.Dispose ();
         label.Dispose ();
     }
     }
@@ -502,8 +495,8 @@ e
     public void With_Top_Margin_Without_Top_Border ()
     public void With_Top_Margin_Without_Top_Border ()
     {
     {
         var label = new Label { Text = "Test", /*Width = 6, Height = 3,*/ BorderStyle = LineStyle.Single };
         var label = new Label { Text = "Test", /*Width = 6, Height = 3,*/ BorderStyle = LineStyle.Single };
-        label.Margin.Thickness = new Thickness (0, 1, 0, 0);
-        label.Border.Thickness = new Thickness (1, 0, 1, 1);
+        label.Margin.Thickness = new (0, 1, 0, 0);
+        label.Border.Thickness = new (1, 0, 1, 1);
         var top = new Toplevel ();
         var top = new Toplevel ();
         top.Add (label);
         top.Add (label);
         Application.Begin (top);
         Application.Begin (top);
@@ -516,8 +509,9 @@ e
                                                       @"
                                                       @"
 │Test│
 │Test│
 └────┘",
 └────┘",
-                                                      _output
+                                                      output
                                                      );
                                                      );
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -525,7 +519,7 @@ e
     public void Without_Top_Border ()
     public void Without_Top_Border ()
     {
     {
         var label = new Label { Text = "Test", /* Width = 6, Height = 3, */BorderStyle = LineStyle.Single };
         var label = new Label { Text = "Test", /* Width = 6, Height = 3, */BorderStyle = LineStyle.Single };
-        label.Border.Thickness = new Thickness (1, 0, 1, 1);
+        label.Border.Thickness = new (1, 0, 1, 1);
         var top = new Toplevel ();
         var top = new Toplevel ();
         top.Add (label);
         top.Add (label);
         Application.Begin (top);
         Application.Begin (top);
@@ -538,13 +532,14 @@ e
                                                       @"
                                                       @"
 │Test│
 │Test│
 └────┘",
 └────┘",
-                                                      _output
+                                                      output
                                                      );
                                                      );
+        top.Dispose ();
     }
     }
 
 
     // These tests were formally in AutoSizetrue.cs. They are (poor) Label tests.
     // These tests were formally in AutoSizetrue.cs. They are (poor) Label tests.
     private readonly string [] expecteds = new string [21]
     private readonly string [] expecteds = new string [21]
-  {
+    {
         @"
         @"
 ┌────────────────────┐
 ┌────────────────────┐
 │View with long text │
 │View with long text │
@@ -860,7 +855,7 @@ e
 │Label 19            │
 │Label 19            │
 │Label 19            │
 │Label 19            │
 └────────────────────┘"
 └────────────────────┘"
-  };
+    };
 
 
     private static readonly Size _size1x1 = new (1, 1);
     private static readonly Size _size1x1 = new (1, 1);
 
 
@@ -889,9 +884,9 @@ e
         ((FakeDriver)Application.Driver).SetBufferSize (40, 10);
         ((FakeDriver)Application.Driver).SetBufferSize (40, 10);
 
 
         Assert.Equal (29, label.Text.Length);
         Assert.Equal (29, label.Text.Length);
-        Assert.Equal (new Rectangle (0, 0, 40, 10), top.Frame);
-        Assert.Equal (new Rectangle (0, 0, 40, 10), win.Frame);
-        Assert.Equal (new Rectangle (0, 7, 29, 1), label.Frame);
+        Assert.Equal (new (0, 0, 40, 10), top.Frame);
+        Assert.Equal (new (0, 0, 40, 10), win.Frame);
+        Assert.Equal (new (0, 7, 29, 1), label.Frame);
 
 
         var expected = @"
         var expected = @"
 ┌──────────────────────────────────────┐
 ┌──────────────────────────────────────┐
@@ -905,10 +900,11 @@ e
 │This should be the last line.         │
 │This should be the last line.         │
 └──────────────────────────────────────┘
 └──────────────────────────────────────┘
 "
 "
-        ;
+            ;
 
 
-        TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Application.End (rs);
         Application.End (rs);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -935,11 +931,11 @@ e
         top.Add (win, menu, status);
         top.Add (win, menu, status);
         RunState rs = Application.Begin (top);
         RunState rs = Application.Begin (top);
 
 
-        Assert.Equal (new Rectangle (0, 0, 80, 25), top.Frame);
-        Assert.Equal (new Rectangle (0, 0, 80, 1), menu.Frame);
-        Assert.Equal (new Rectangle (0, 24, 80, 1), status.Frame);
-        Assert.Equal (new Rectangle (0, 1, 80, 23), win.Frame);
-        Assert.Equal (new Rectangle (0, 20, 29, 1), label.Frame);
+        Assert.Equal (new (0, 0, 80, 25), top.Frame);
+        Assert.Equal (new (0, 0, 80, 1), menu.Frame);
+        Assert.Equal (new (0, 24, 80, 1), status.Frame);
+        Assert.Equal (new (0, 1, 80, 23), win.Frame);
+        Assert.Equal (new (0, 20, 29, 1), label.Frame);
 
 
         var expected = @"
         var expected = @"
  Menu                                                                           
  Menu                                                                           
@@ -969,8 +965,9 @@ e
  F1 Help                                                                        
  F1 Help                                                                        
 ";
 ";
 
 
-        TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Application.End (rs);
         Application.End (rs);
+        top.Dispose ();
     }
     }
 
 
     // TODO: This is a Label test. Move to label tests if there's not already a test for this.
     // TODO: This is a Label test. Move to label tests if there's not already a test for this.
@@ -999,9 +996,9 @@ e
         RunState rs = Application.Begin (top);
         RunState rs = Application.Begin (top);
         ((FakeDriver)Application.Driver).SetBufferSize (40, 10);
         ((FakeDriver)Application.Driver).SetBufferSize (40, 10);
 
 
-        Assert.Equal (new Rectangle (0, 0, 40, 10), top.Frame);
-        Assert.Equal (new Rectangle (0, 0, 40, 10), win.Frame);
-        Assert.Equal (new Rectangle (0, 7, 29, 1), label.Frame);
+        Assert.Equal (new (0, 0, 40, 10), top.Frame);
+        Assert.Equal (new (0, 0, 40, 10), win.Frame);
+        Assert.Equal (new (0, 7, 29, 1), label.Frame);
 
 
         var expected = @"
         var expected = @"
 ┌──────────────────────────────────────┐
 ┌──────────────────────────────────────┐
@@ -1016,8 +1013,9 @@ e
 └──────────────────────────────────────┘
 └──────────────────────────────────────┘
 ";
 ";
 
 
-        TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Application.End (rs);
         Application.End (rs);
+        top.Dispose ();
     }
     }
 
 
     // TODO: This is a Label test. Move to label tests if there's not already a test for this.
     // TODO: This is a Label test. Move to label tests if there's not already a test for this.
@@ -1047,11 +1045,11 @@ e
         top.Add (win, menu, status);
         top.Add (win, menu, status);
         RunState rs = Application.Begin (top);
         RunState rs = Application.Begin (top);
 
 
-        Assert.Equal (new Rectangle (0, 0, 80, 25), top.Frame);
-        Assert.Equal (new Rectangle (0, 0, 80, 1), menu.Frame);
-        Assert.Equal (new Rectangle (0, 24, 80, 1), status.Frame);
-        Assert.Equal (new Rectangle (0, 1, 80, 23), win.Frame);
-        Assert.Equal (new Rectangle (0, 20, 29, 1), label.Frame);
+        Assert.Equal (new (0, 0, 80, 25), top.Frame);
+        Assert.Equal (new (0, 0, 80, 1), menu.Frame);
+        Assert.Equal (new (0, 24, 80, 1), status.Frame);
+        Assert.Equal (new (0, 1, 80, 23), win.Frame);
+        Assert.Equal (new (0, 20, 29, 1), label.Frame);
 
 
         var expected = @"
         var expected = @"
  Menu                                                                           
  Menu                                                                           
@@ -1081,11 +1079,11 @@ e
  F1 Help                                                                        
  F1 Help                                                                        
 ";
 ";
 
 
-        TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Application.End (rs);
         Application.End (rs);
+        top.Dispose ();
     }
     }
 
 
-
     // TODO: This is a Dim test. Move to Dim tests.
     // TODO: This is a Dim test. Move to Dim tests.
 
 
     [Fact]
     [Fact]
@@ -1132,53 +1130,53 @@ e
         }
         }
 
 
         field.KeyDown += (s, k) =>
         field.KeyDown += (s, k) =>
-        {
-            if (k.KeyCode == KeyCode.Enter)
-            {
-                ((FakeDriver)Application.Driver).SetBufferSize (22, count + 4);
-                Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expecteds [count], _output);
-                Assert.Equal (new Rectangle (0, 0, 22, count + 4), pos);
-
-                if (count > 0)
-                {
-                    Assert.Equal ($"Label {count - 1}", listLabels [count - 1].Text);
-                    view.Remove (listLabels [count - 1]);
-                    listLabels [count - 1].Dispose ();
-                    listLabels.RemoveAt (count - 1);
-                    Assert.Equal ($"Absolute({count + 1})", view.Height.ToString ());
-                    view.Height -= 1;
-                    count--;
-
-                    if (listLabels.Count > 0)
-                    {
-                        field.Text = listLabels [count - 1].Text;
-                    }
-                    else
-                    {
-                        field.Text = string.Empty;
-                    }
-                }
-
-                Assert.Equal ($"Absolute({count + 1})", view.Height.ToString ());
-            }
-        };
+                         {
+                             if (k.KeyCode == KeyCode.Enter)
+                             {
+                                 ((FakeDriver)Application.Driver).SetBufferSize (22, count + 4);
+                                 Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expecteds [count], output);
+                                 Assert.Equal (new (0, 0, 22, count + 4), pos);
+
+                                 if (count > 0)
+                                 {
+                                     Assert.Equal ($"Label {count - 1}", listLabels [count - 1].Text);
+                                     view.Remove (listLabels [count - 1]);
+                                     listLabels [count - 1].Dispose ();
+                                     listLabels.RemoveAt (count - 1);
+                                     Assert.Equal ($"Absolute({count + 1})", view.Height.ToString ());
+                                     view.Height -= 1;
+                                     count--;
+
+                                     if (listLabels.Count > 0)
+                                     {
+                                         field.Text = listLabels [count - 1].Text;
+                                     }
+                                     else
+                                     {
+                                         field.Text = string.Empty;
+                                     }
+                                 }
+
+                                 Assert.Equal ($"Absolute({count + 1})", view.Height.ToString ());
+                             }
+                         };
 
 
         Application.Iteration += (s, a) =>
         Application.Iteration += (s, a) =>
-        {
-            while (count > -1)
-            {
-                field.NewKeyDownEvent (Key.Enter);
+                                 {
+                                     while (count > -1)
+                                     {
+                                         field.NewKeyDownEvent (Key.Enter);
 
 
-                if (count == 0)
-                {
-                    field.NewKeyDownEvent (Key.Enter);
+                                         if (count == 0)
+                                         {
+                                             field.NewKeyDownEvent (Key.Enter);
 
 
-                    break;
-                }
-            }
+                                             break;
+                                         }
+                                     }
 
 
-            Application.RequestStop ();
-        };
+                                     Application.RequestStop ();
+                                 };
 
 
         var win = new Window ();
         var win = new Window ();
         win.Add (view);
         win.Add (view);
@@ -1190,6 +1188,7 @@ e
 
 
         Assert.Equal (0, count);
         Assert.Equal (0, count);
         Assert.Equal (count, listLabels.Count);
         Assert.Equal (count, listLabels.Count);
+        top.Dispose ();
     }
     }
 
 
     // TODO: This is a Label test. Move to Label tests.
     // TODO: This is a Label test. Move to Label tests.
@@ -1200,9 +1199,10 @@ e
     {
     {
         ((FakeDriver)Application.Driver).SetBufferSize (10, 4);
         ((FakeDriver)Application.Driver).SetBufferSize (10, 4);
         var text = "Label";
         var text = "Label";
+
         var label = new Label
         var label = new Label
         {
         {
-            Text = text,
+            Text = text
         };
         };
         label.Width = Dim.Fill () - text.Length;
         label.Width = Dim.Fill () - text.Length;
         label.Height = 0;
         label.Height = 0;
@@ -1216,6 +1216,7 @@ e
 
 
         Assert.Equal (5, text.Length);
         Assert.Equal (5, text.Length);
         Assert.Equal (new (0, 0, 3, 0), label.Frame);
         Assert.Equal (new (0, 0, 3, 0), label.Frame);
+
         //Assert.Equal (new (5, 1), label.TextFormatter.Size);
         //Assert.Equal (new (5, 1), label.TextFormatter.Size);
         Assert.Single (label.TextFormatter.GetLines ());
         Assert.Single (label.TextFormatter.GetLines ());
         Assert.Equal (new (0, 0, 10, 4), win.Frame);
         Assert.Equal (new (0, 0, 10, 4), win.Frame);
@@ -1227,7 +1228,7 @@ e
 └────────┘
 └────────┘
 ";
 ";
 
 
-        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Assert.Equal (new (0, 0, 10, 4), pos);
         Assert.Equal (new (0, 0, 10, 4), pos);
 
 
         text = "0123456789";
         text = "0123456789";
@@ -1238,6 +1239,7 @@ e
         win.Draw ();
         win.Draw ();
 
 
         Assert.Equal (Rectangle.Empty, label.Frame);
         Assert.Equal (Rectangle.Empty, label.Frame);
+
         //        Assert.Equal (new (5, 1), label.TextFormatter.Size);
         //        Assert.Equal (new (5, 1), label.TextFormatter.Size);
 
 
         //Exception exception = Record.Exception (
         //Exception exception = Record.Exception (
@@ -1255,7 +1257,7 @@ e
 └────────┘
 └────────┘
 ";
 ";
 
 
-        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Assert.Equal (new (0, 0, 10, 4), pos);
         Assert.Equal (new (0, 0, 10, 4), pos);
     }
     }
 
 
@@ -1280,55 +1282,55 @@ e
         List<Label> listLabels = new ();
         List<Label> listLabels = new ();
 
 
         field.KeyDown += (s, k) =>
         field.KeyDown += (s, k) =>
-        {
-            if (k.KeyCode == KeyCode.Enter)
-            {
-                ((FakeDriver)Application.Driver).SetBufferSize (22, count + 4);
-                Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expecteds [count], _output);
-                Assert.Equal (new Rectangle (0, 0, 22, count + 4), pos);
-
-                if (count < 20)
-                {
-                    field.Text = $"Label {count}";
-
-                    // Label is AutoSize = true
-                    var label = new Label { Text = field.Text, X = 0, Y = view.Viewport.Height /*, Width = 10*/ };
-                    view.Add (label);
-                    Assert.Equal ($"Label {count}", label.Text);
-                    Assert.Equal ($"Absolute({count + 1})", label.Y.ToString ());
-                    listLabels.Add (label);
-
-                    //if (count == 0) {
-                    //	Assert.Equal ($"Absolute({count})", view.Height.ToString ());
-                    //	view.Height += 2;
-                    //} else {
-                    Assert.Equal ($"Absolute({count + 1})", view.Height.ToString ());
-                    view.Height += 1;
-
-                    //}
-                    count++;
-                }
-
-                Assert.Equal ($"Absolute({count + 1})", view.Height.ToString ());
-            }
-        };
+                         {
+                             if (k.KeyCode == KeyCode.Enter)
+                             {
+                                 ((FakeDriver)Application.Driver).SetBufferSize (22, count + 4);
+                                 Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expecteds [count], output);
+                                 Assert.Equal (new (0, 0, 22, count + 4), pos);
+
+                                 if (count < 20)
+                                 {
+                                     field.Text = $"Label {count}";
+
+                                     // Label is AutoSize = true
+                                     var label = new Label { Text = field.Text, X = 0, Y = view.Viewport.Height /*, Width = 10*/ };
+                                     view.Add (label);
+                                     Assert.Equal ($"Label {count}", label.Text);
+                                     Assert.Equal ($"Absolute({count + 1})", label.Y.ToString ());
+                                     listLabels.Add (label);
+
+                                     //if (count == 0) {
+                                     //	Assert.Equal ($"Absolute({count})", view.Height.ToString ());
+                                     //	view.Height += 2;
+                                     //} else {
+                                     Assert.Equal ($"Absolute({count + 1})", view.Height.ToString ());
+                                     view.Height += 1;
+
+                                     //}
+                                     count++;
+                                 }
+
+                                 Assert.Equal ($"Absolute({count + 1})", view.Height.ToString ());
+                             }
+                         };
 
 
         Application.Iteration += (s, a) =>
         Application.Iteration += (s, a) =>
-        {
-            while (count < 21)
-            {
-                field.NewKeyDownEvent (Key.Enter);
+                                 {
+                                     while (count < 21)
+                                     {
+                                         field.NewKeyDownEvent (Key.Enter);
 
 
-                if (count == 20)
-                {
-                    field.NewKeyDownEvent (Key.Enter);
+                                         if (count == 20)
+                                         {
+                                             field.NewKeyDownEvent (Key.Enter);
 
 
-                    break;
-                }
-            }
+                                             break;
+                                         }
+                                     }
 
 
-            Application.RequestStop ();
-        };
+                                     Application.RequestStop ();
+                                 };
 
 
         var win = new Window ();
         var win = new Window ();
         win.Add (view);
         win.Add (view);
@@ -1340,10 +1342,9 @@ e
 
 
         Assert.Equal (20, count);
         Assert.Equal (20, count);
         Assert.Equal (count, listLabels.Count);
         Assert.Equal (count, listLabels.Count);
+        top.Dispose ();
     }
     }
 
 
-
-
     [Fact]
     [Fact]
     [AutoInitShutdown]
     [AutoInitShutdown]
     public void Label_IsEmpty_False_Minimum_Height ()
     public void Label_IsEmpty_False_Minimum_Height ()
@@ -1376,7 +1377,7 @@ e
 └────────┘
 └────────┘
 ";
 ";
 
 
-        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Assert.Equal (new (0, 0, 10, 4), pos);
         Assert.Equal (new (0, 0, 10, 4), pos);
 
 
         text = "0123456789";
         text = "0123456789";
@@ -1397,8 +1398,9 @@ e
 └────────┘
 └────────┘
 ";
 ";
 
 
-        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Assert.Equal (new (0, 0, 10, 4), pos);
         Assert.Equal (new (0, 0, 10, 4), pos);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -1434,7 +1436,7 @@ e
 └────────┘
 └────────┘
 ";
 ";
 
 
-        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Assert.Equal (new (0, 0, 10, 4), pos);
         Assert.Equal (new (0, 0, 10, 4), pos);
 
 
         text = "0123456789";
         text = "0123456789";
@@ -1443,7 +1445,6 @@ e
         //label.Width = Dim.Fill () - text.Length;
         //label.Width = Dim.Fill () - text.Length;
         Application.Refresh ();
         Application.Refresh ();
 
 
-
         Assert.Equal (new (0, 0, 5, 1), label.Frame);
         Assert.Equal (new (0, 0, 5, 1), label.Frame);
         Assert.Equal (new (5, 1), label.TextFormatter.Size);
         Assert.Equal (new (5, 1), label.TextFormatter.Size);
         Assert.Single (label.TextFormatter.GetLines ());
         Assert.Single (label.TextFormatter.GetLines ());
@@ -1455,14 +1456,15 @@ e
 └────────┘
 └────────┘
 ";
 ";
 
 
-        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Assert.Equal (new (0, 0, 10, 4), pos);
         Assert.Equal (new (0, 0, 10, 4), pos);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
     public void Label_ResizeView_With_Dim_Absolute ()
     public void Label_ResizeView_With_Dim_Absolute ()
     {
     {
-        var super = new View ()
+        var super = new View
         {
         {
             Width = Dim.Fill (),
             Width = Dim.Fill (),
             Height = Dim.Fill ()
             Height = Dim.Fill ()
@@ -1477,5 +1479,4 @@ e
         Assert.Equal (expectedLabelBounds, label.Viewport);
         Assert.Equal (expectedLabelBounds, label.Viewport);
         super.Dispose ();
         super.Dispose ();
     }
     }
-
 }
 }

+ 78 - 57
UnitTests/Views/ListViewTests.cs

@@ -6,11 +6,8 @@ using Xunit.Abstractions;
 
 
 namespace Terminal.Gui.ViewsTests;
 namespace Terminal.Gui.ViewsTests;
 
 
-public class ListViewTests
+public class ListViewTests (ITestOutputHelper output)
 {
 {
-    private readonly ITestOutputHelper _output;
-    public ListViewTests (ITestOutputHelper output) { _output = output; }
-
     [Fact]
     [Fact]
     public void Constructors_Defaults ()
     public void Constructors_Defaults ()
     {
     {
@@ -19,26 +16,26 @@ public class ListViewTests
         Assert.True (lv.CanFocus);
         Assert.True (lv.CanFocus);
         Assert.Equal (-1, lv.SelectedItem);
         Assert.Equal (-1, lv.SelectedItem);
 
 
-        lv = new ListView { Source = new ListWrapper<string> (["One", "Two", "Three"]) };
+        lv = new () { Source = new ListWrapper<string> (["One", "Two", "Three"]) };
         Assert.NotNull (lv.Source);
         Assert.NotNull (lv.Source);
         Assert.Equal (-1, lv.SelectedItem);
         Assert.Equal (-1, lv.SelectedItem);
 
 
-        lv = new ListView { Source = new NewListDataSource () };
+        lv = new() { Source = new NewListDataSource () };
         Assert.NotNull (lv.Source);
         Assert.NotNull (lv.Source);
         Assert.Equal (-1, lv.SelectedItem);
         Assert.Equal (-1, lv.SelectedItem);
 
 
-        lv = new ListView
+        lv = new()
         {
         {
             Y = 1, Width = 10, Height = 20, Source = new ListWrapper<string> (["One", "Two", "Three"])
             Y = 1, Width = 10, Height = 20, Source = new ListWrapper<string> (["One", "Two", "Three"])
         };
         };
         Assert.NotNull (lv.Source);
         Assert.NotNull (lv.Source);
         Assert.Equal (-1, lv.SelectedItem);
         Assert.Equal (-1, lv.SelectedItem);
-        Assert.Equal (new Rectangle (0, 1, 10, 20), lv.Frame);
+        Assert.Equal (new (0, 1, 10, 20), lv.Frame);
 
 
-        lv = new ListView { Y = 1, Width = 10, Height = 20, Source = new NewListDataSource () };
+        lv = new() { Y = 1, Width = 10, Height = 20, Source = new NewListDataSource () };
         Assert.NotNull (lv.Source);
         Assert.NotNull (lv.Source);
         Assert.Equal (-1, lv.SelectedItem);
         Assert.Equal (-1, lv.SelectedItem);
-        Assert.Equal (new Rectangle (0, 1, 10, 20), lv.Frame);
+        Assert.Equal (new (0, 1, 10, 20), lv.Frame);
     }
     }
 
 
     [Fact]
     [Fact]
@@ -77,10 +74,10 @@ public class ListViewTests
 │Line8     │
 │Line8     │
 │Line9     │
 │Line9     │
 └──────────┘",
 └──────────┘",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
-        Assert.True (lv.ScrollVertical(10));
+        Assert.True (lv.ScrollVertical (10));
         lv.Draw ();
         lv.Draw ();
         Assert.Equal (-1, lv.SelectedItem);
         Assert.Equal (-1, lv.SelectedItem);
 
 
@@ -98,7 +95,7 @@ public class ListViewTests
 │Line18    │
 │Line18    │
 │Line19    │
 │Line19    │
 └──────────┘",
 └──────────┘",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Assert.True (lv.MoveDown ());
         Assert.True (lv.MoveDown ());
@@ -119,7 +116,7 @@ public class ListViewTests
 │Line8     │
 │Line8     │
 │Line9     │
 │Line9     │
 └──────────┘",
 └──────────┘",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Assert.True (lv.MoveEnd ());
         Assert.True (lv.MoveEnd ());
@@ -140,7 +137,7 @@ public class ListViewTests
 │Line18    │
 │Line18    │
 │Line19    │
 │Line19    │
 └──────────┘",
 └──────────┘",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Assert.True (lv.ScrollVertical (-20));
         Assert.True (lv.ScrollVertical (-20));
@@ -161,7 +158,7 @@ public class ListViewTests
 │Line8     │
 │Line8     │
 │Line9     │
 │Line9     │
 └──────────┘",
 └──────────┘",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Assert.True (lv.MoveDown ());
         Assert.True (lv.MoveDown ());
@@ -182,7 +179,7 @@ public class ListViewTests
 │Line18    │
 │Line18    │
 │Line19    │
 │Line19    │
 └──────────┘",
 └──────────┘",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Assert.True (lv.ScrollVertical (-20));
         Assert.True (lv.ScrollVertical (-20));
@@ -203,7 +200,7 @@ public class ListViewTests
 │Line8     │
 │Line8     │
 │Line9     │
 │Line9     │
 └──────────┘",
 └──────────┘",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Assert.True (lv.MoveDown ());
         Assert.True (lv.MoveDown ());
@@ -224,7 +221,7 @@ public class ListViewTests
 │Line18    │
 │Line18    │
 │Line19    │
 │Line19    │
 └──────────┘",
 └──────────┘",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Assert.True (lv.MoveHome ());
         Assert.True (lv.MoveHome ());
@@ -245,7 +242,7 @@ public class ListViewTests
 │Line8     │
 │Line8     │
 │Line9     │
 │Line9     │
 └──────────┘",
 └──────────┘",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Assert.True (lv.ScrollVertical (20));
         Assert.True (lv.ScrollVertical (20));
@@ -266,7 +263,7 @@ public class ListViewTests
 │          │
 │          │
 │          │
 │          │
 └──────────┘",
 └──────────┘",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Assert.True (lv.MoveUp ());
         Assert.True (lv.MoveUp ());
@@ -287,8 +284,9 @@ public class ListViewTests
 │Line8     │
 │Line8     │
 │Line9     │
 │Line9     │
 └──────────┘",
 └──────────┘",
-                                                      _output
+                                                      output
                                                      );
                                                      );
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -314,7 +312,7 @@ Item 1
 Item 2
 Item 2
 Item 3
 Item 3
 Item 4",
 Item 4",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         // EnsureSelectedItemVisible is auto enabled on the OnSelectedChanged
         // EnsureSelectedItemVisible is auto enabled on the OnSelectedChanged
@@ -328,8 +326,9 @@ Item 3
 Item 4
 Item 4
 Item 5
 Item 5
 Item 6",
 Item 6",
-                                                      _output
+                                                      output
                                                      );
                                                      );
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -344,13 +343,13 @@ Item 6",
         Application.Begin (top);
         Application.Begin (top);
 
 
         Assert.Equal ("Second ", GetContents (0));
         Assert.Equal ("Second ", GetContents (0));
-        Assert.Equal (new string (' ', 7), GetContents (1));
+        Assert.Equal (new (' ', 7), GetContents (1));
 
 
         lv.MoveUp ();
         lv.MoveUp ();
         lv.Draw ();
         lv.Draw ();
 
 
         Assert.Equal ("First  ", GetContents (0));
         Assert.Equal ("First  ", GetContents (0));
-        Assert.Equal (new string (' ', 7), GetContents (1));
+        Assert.Equal (new (' ', 7), GetContents (1));
 
 
         string GetContents (int line)
         string GetContents (int line)
         {
         {
@@ -363,6 +362,7 @@ Item 6",
 
 
             return item;
             return item;
         }
         }
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -419,10 +419,10 @@ Item 6",
         Assert.False (accepted);
         Assert.False (accepted);
 
 
         return;
         return;
+
         void OnAccept (object sender, CancelEventArgs e) { accepted = true; }
         void OnAccept (object sender, CancelEventArgs e) { accepted = true; }
     }
     }
 
 
-
     [Fact]
     [Fact]
     public void Accept_Command_Accepts_and_Opens_Selected_Item ()
     public void Accept_Command_Accepts_and_Opens_Selected_Item ()
     {
     {
@@ -432,7 +432,7 @@ Item 6",
 
 
         var accepted = false;
         var accepted = false;
         var opened = false;
         var opened = false;
-        string selectedValue = string.Empty;
+        var selectedValue = string.Empty;
 
 
         listView.Accept += Accept;
         listView.Accept += Accept;
         listView.OpenSelectedItem += OpenSelectedItem;
         listView.OpenSelectedItem += OpenSelectedItem;
@@ -450,6 +450,7 @@ Item 6",
             opened = true;
             opened = true;
             selectedValue = e.Value.ToString ();
             selectedValue = e.Value.ToString ();
         }
         }
+
         void Accept (object sender, CancelEventArgs e) { accepted = true; }
         void Accept (object sender, CancelEventArgs e) { accepted = true; }
     }
     }
 
 
@@ -462,7 +463,7 @@ Item 6",
 
 
         var accepted = false;
         var accepted = false;
         var opened = false;
         var opened = false;
-        string selectedValue = string.Empty;
+        var selectedValue = string.Empty;
 
 
         listView.Accept += Accept;
         listView.Accept += Accept;
         listView.OpenSelectedItem += OpenSelectedItem;
         listView.OpenSelectedItem += OpenSelectedItem;
@@ -505,7 +506,7 @@ Item 6",
         // bind shift down to move down twice in control
         // bind shift down to move down twice in control
         lv.KeyBindings.Add (Key.CursorDown.WithShift, Command.LineDown, Command.LineDown);
         lv.KeyBindings.Add (Key.CursorDown.WithShift, Command.LineDown, Command.LineDown);
 
 
-        var ev = Key.CursorDown.WithShift;
+        Key ev = Key.CursorDown.WithShift;
 
 
         Assert.True (lv.NewKeyDownEvent (ev), "The first time we move down 2 it should be possible");
         Assert.True (lv.NewKeyDownEvent (ev), "The first time we move down 2 it should be possible");
 
 
@@ -537,7 +538,7 @@ Item 6",
 
 
         lv.KeyBindings.Add (Key.Space.WithShift, Command.Select, Command.LineDown);
         lv.KeyBindings.Add (Key.Space.WithShift, Command.Select, Command.LineDown);
 
 
-        var ev = Key.Space.WithShift;
+        Key ev = Key.Space.WithShift;
 
 
         // view should indicate that it has accepted and consumed the event
         // view should indicate that it has accepted and consumed the event
         Assert.True (lv.NewKeyDownEvent (ev));
         Assert.True (lv.NewKeyDownEvent (ev));
@@ -631,6 +632,7 @@ Item 6",
         lv.SetSource (source);
         lv.SetSource (source);
         lv.Draw ();
         lv.Draw ();
         Assert.True (rendered);
         Assert.True (rendered);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -656,7 +658,7 @@ Item 6",
         lv.Source = null;
         lv.Source = null;
         Assert.Null (lv.Source);
         Assert.Null (lv.Source);
 
 
-        lv = new ListView { Source = new ListWrapper<string> (["One", "Two"]) };
+        lv = new () { Source = new ListWrapper<string> (["One", "Two"]) };
         Assert.NotNull (lv.Source);
         Assert.NotNull (lv.Source);
 
 
         lv.SetSourceAsync<string> (null);
         lv.SetSourceAsync<string> (null);
@@ -707,6 +709,7 @@ Item 6",
     public void Clicking_On_Border_Is_Ignored ()
     public void Clicking_On_Border_Is_Ignored ()
     {
     {
         var selected = "";
         var selected = "";
+
         var lv = new ListView
         var lv = new ListView
         {
         {
             Height = 5,
             Height = 5,
@@ -719,47 +722,55 @@ Item 6",
         top.Add (lv);
         top.Add (lv);
         Application.Begin (top);
         Application.Begin (top);
 
 
-        Assert.Equal (new Thickness (1), lv.Border.Thickness);
+        Assert.Equal (new (1), lv.Border.Thickness);
         Assert.Equal (-1, lv.SelectedItem);
         Assert.Equal (-1, lv.SelectedItem);
         Assert.Equal ("", lv.Text);
         Assert.Equal ("", lv.Text);
-        TestHelpers.AssertDriverContentsWithFrameAre (@"
+
+        TestHelpers.AssertDriverContentsWithFrameAre (
+                                                      @"
 ┌─────┐
 ┌─────┐
 │One  │
 │One  │
 │Two  │
 │Two  │
 │Three│
 │Three│
-└─────┘", _output);
+└─────┘",
+                                                      output);
 
 
         Application.OnMouseEvent (new () { Position = new (0, 0), Flags = MouseFlags.Button1Clicked });
         Application.OnMouseEvent (new () { Position = new (0, 0), Flags = MouseFlags.Button1Clicked });
         Assert.Equal ("", selected);
         Assert.Equal ("", selected);
         Assert.Equal (-1, lv.SelectedItem);
         Assert.Equal (-1, lv.SelectedItem);
 
 
-        Application.OnMouseEvent (new ()
-        {
-            Position = new (1, 1), Flags = MouseFlags.Button1Clicked
-        });
+        Application.OnMouseEvent (
+                                  new ()
+                                  {
+                                      Position = new (1, 1), Flags = MouseFlags.Button1Clicked
+                                  });
         Assert.Equal ("One", selected);
         Assert.Equal ("One", selected);
         Assert.Equal (0, lv.SelectedItem);
         Assert.Equal (0, lv.SelectedItem);
 
 
-        Application.OnMouseEvent (new ()
-        {
-            Position = new (1, 2), Flags = MouseFlags.Button1Clicked
-        });
+        Application.OnMouseEvent (
+                                  new ()
+                                  {
+                                      Position = new (1, 2), Flags = MouseFlags.Button1Clicked
+                                  });
         Assert.Equal ("Two", selected);
         Assert.Equal ("Two", selected);
         Assert.Equal (1, lv.SelectedItem);
         Assert.Equal (1, lv.SelectedItem);
 
 
-        Application.OnMouseEvent (new ()
-        {
-            Position = new (1, 3), Flags = MouseFlags.Button1Clicked
-        });
+        Application.OnMouseEvent (
+                                  new ()
+                                  {
+                                      Position = new (1, 3), Flags = MouseFlags.Button1Clicked
+                                  });
         Assert.Equal ("Three", selected);
         Assert.Equal ("Three", selected);
         Assert.Equal (2, lv.SelectedItem);
         Assert.Equal (2, lv.SelectedItem);
 
 
-        Application.OnMouseEvent (new ()
-        {
-            Position = new (1, 4), Flags = MouseFlags.Button1Clicked
-        });
+        Application.OnMouseEvent (
+                                  new ()
+                                  {
+                                      Position = new (1, 4), Flags = MouseFlags.Button1Clicked
+                                  });
         Assert.Equal ("Three", selected);
         Assert.Equal ("Three", selected);
         Assert.Equal (2, lv.SelectedItem);
         Assert.Equal (2, lv.SelectedItem);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -767,10 +778,14 @@ Item 6",
     public void LeftItem_TopItem_Tests ()
     public void LeftItem_TopItem_Tests ()
     {
     {
         ObservableCollection<string> source = [];
         ObservableCollection<string> source = [];
-        for (int i = 0; i < 5; i++) {
+
+        for (int i = 0; i < 5; i++)
+        {
             source.Add ($"Item {i}");
             source.Add ($"Item {i}");
         }
         }
-        var lv = new ListView () {
+
+        var lv = new ListView
+        {
             X = 1,
             X = 1,
             Width = 10,
             Width = 10,
             Height = 5,
             Height = 5,
@@ -780,21 +795,27 @@ Item 6",
         top.Add (lv);
         top.Add (lv);
         Application.Begin (top);
         Application.Begin (top);
 
 
-        TestHelpers.AssertDriverContentsWithFrameAre (@"
+        TestHelpers.AssertDriverContentsWithFrameAre (
+                                                      @"
  Item 0
  Item 0
  Item 1
  Item 1
  Item 2
  Item 2
  Item 3
  Item 3
- Item 4", _output);
+ Item 4",
+                                                      output);
 
 
         lv.LeftItem = 1;
         lv.LeftItem = 1;
         lv.TopItem = 1;
         lv.TopItem = 1;
         Application.Refresh ();
         Application.Refresh ();
-        TestHelpers.AssertDriverContentsWithFrameAre (@"
+
+        TestHelpers.AssertDriverContentsWithFrameAre (
+                                                      @"
  tem 1
  tem 1
  tem 2
  tem 2
  tem 3
  tem 3
- tem 4", _output);
+ tem 4",
+                                                      output);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]

File diff suppressed because it is too large
+ 229 - 211
UnitTests/Views/MenuBarTests.cs


+ 13 - 1
UnitTests/Views/OverlappedTests.cs

@@ -1,4 +1,5 @@
-using Xunit.Abstractions;
+using System.Threading;
+using Xunit.Abstractions;
 
 
 namespace Terminal.Gui.ViewsTests;
 namespace Terminal.Gui.ViewsTests;
 
 
@@ -100,6 +101,7 @@ public class OverlappedTests
         Assert.Empty (Application.OverlappedChildren);
         Assert.Empty (Application.OverlappedChildren);
         Assert.NotNull (Application.OverlappedTop);
         Assert.NotNull (Application.OverlappedTop);
         Assert.NotNull (Application.Top);
         Assert.NotNull (Application.Top);
+        overlapped.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -182,6 +184,7 @@ public class OverlappedTests
         Application.Run (top1);
         Application.Run (top1);
 
 
         Assert.Null (Application.OverlappedChildren);
         Assert.Null (Application.OverlappedChildren);
+        top1.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -237,6 +240,7 @@ public class OverlappedTests
                                  };
                                  };
 
 
         Application.Run (overlapped);
         Application.Run (overlapped);
+        overlapped.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -338,6 +342,7 @@ public class OverlappedTests
         Assert.Empty (Application.OverlappedChildren);
         Assert.Empty (Application.OverlappedChildren);
         Assert.NotNull (Application.OverlappedTop);
         Assert.NotNull (Application.OverlappedTop);
         Assert.NotNull (Application.Top);
         Assert.NotNull (Application.Top);
+        overlapped.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -429,6 +434,7 @@ public class OverlappedTests
         Assert.Empty (Application.OverlappedChildren);
         Assert.Empty (Application.OverlappedChildren);
         Assert.NotNull (Application.OverlappedTop);
         Assert.NotNull (Application.OverlappedTop);
         Assert.NotNull (Application.Top);
         Assert.NotNull (Application.Top);
+        overlapped.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -514,6 +520,7 @@ public class OverlappedTests
         Assert.Empty (Application.OverlappedChildren);
         Assert.Empty (Application.OverlappedChildren);
         Assert.NotNull (Application.OverlappedTop);
         Assert.NotNull (Application.OverlappedTop);
         Assert.NotNull (Application.Top);
         Assert.NotNull (Application.Top);
+        overlapped.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -609,6 +616,7 @@ public class OverlappedTests
         Assert.Empty (Application.OverlappedChildren);
         Assert.Empty (Application.OverlappedChildren);
         Assert.NotNull (Application.OverlappedTop);
         Assert.NotNull (Application.OverlappedTop);
         Assert.NotNull (Application.Top);
         Assert.NotNull (Application.Top);
+        overlapped.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -625,6 +633,7 @@ public class OverlappedTests
                             };
                             };
 
 
         Application.Run (overlapped);
         Application.Run (overlapped);
+        overlapped.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -703,6 +712,7 @@ public class OverlappedTests
         Assert.Empty (Application.OverlappedChildren);
         Assert.Empty (Application.OverlappedChildren);
         Assert.NotNull (Application.OverlappedTop);
         Assert.NotNull (Application.OverlappedTop);
         Assert.NotNull (Application.Top);
         Assert.NotNull (Application.Top);
+        overlapped.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -782,6 +792,7 @@ public class OverlappedTests
         Assert.Empty (Application.OverlappedChildren);
         Assert.Empty (Application.OverlappedChildren);
         Assert.NotNull (Application.OverlappedTop);
         Assert.NotNull (Application.OverlappedTop);
         Assert.NotNull (Application.Top);
         Assert.NotNull (Application.Top);
+        overlapped.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -860,6 +871,7 @@ public class OverlappedTests
         Assert.Empty (Application.OverlappedChildren);
         Assert.Empty (Application.OverlappedChildren);
         Assert.NotNull (Application.OverlappedTop);
         Assert.NotNull (Application.OverlappedTop);
         Assert.NotNull (Application.Top);
         Assert.NotNull (Application.Top);
+        overlapped.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]

+ 15 - 15
UnitTests/Views/RadioGroupTests.cs

@@ -3,11 +3,8 @@ using Xunit.Abstractions;
 
 
 namespace Terminal.Gui.ViewsTests;
 namespace Terminal.Gui.ViewsTests;
 
 
-public class RadioGroupTests
+public class RadioGroupTests (ITestOutputHelper output)
 {
 {
-    private readonly ITestOutputHelper _output;
-    public RadioGroupTests (ITestOutputHelper output) { _output = output; }
-
     [Fact]
     [Fact]
     public void Constructors_Defaults ()
     public void Constructors_Defaults ()
     {
     {
@@ -17,12 +14,12 @@ public class RadioGroupTests
         Assert.Equal (Rectangle.Empty, rg.Frame);
         Assert.Equal (Rectangle.Empty, rg.Frame);
         Assert.Equal (0, rg.SelectedItem);
         Assert.Equal (0, rg.SelectedItem);
 
 
-        rg = new RadioGroup { RadioLabels = new [] { "Test" } };
+        rg = new() { RadioLabels = new [] { "Test" } };
         Assert.True (rg.CanFocus);
         Assert.True (rg.CanFocus);
         Assert.Single (rg.RadioLabels);
         Assert.Single (rg.RadioLabels);
         Assert.Equal (0, rg.SelectedItem);
         Assert.Equal (0, rg.SelectedItem);
 
 
-        rg = new RadioGroup
+        rg = new()
         {
         {
             X = 1,
             X = 1,
             Y = 2,
             Y = 2,
@@ -32,10 +29,10 @@ public class RadioGroupTests
         };
         };
         Assert.True (rg.CanFocus);
         Assert.True (rg.CanFocus);
         Assert.Single (rg.RadioLabels);
         Assert.Single (rg.RadioLabels);
-        Assert.Equal (new Rectangle (1, 2, 20, 5), rg.Frame);
+        Assert.Equal (new (1, 2, 20, 5), rg.Frame);
         Assert.Equal (0, rg.SelectedItem);
         Assert.Equal (0, rg.SelectedItem);
 
 
-        rg = new RadioGroup { X = 1, Y = 2, RadioLabels = new [] { "Test" } };
+        rg = new() { X = 1, Y = 2, RadioLabels = new [] { "Test" } };
 
 
         var view = new View { Width = 30, Height = 40 };
         var view = new View { Width = 30, Height = 40 };
         view.Add (rg);
         view.Add (rg);
@@ -45,7 +42,7 @@ public class RadioGroupTests
 
 
         Assert.True (rg.CanFocus);
         Assert.True (rg.CanFocus);
         Assert.Single (rg.RadioLabels);
         Assert.Single (rg.RadioLabels);
-        Assert.Equal (new Rectangle (1, 2, 6, 1), rg.Frame);
+        Assert.Equal (new (1, 2, 6, 1), rg.Frame);
         Assert.Equal (0, rg.SelectedItem);
         Assert.Equal (0, rg.SelectedItem);
     }
     }
 
 
@@ -145,6 +142,7 @@ public class RadioGroupTests
         Assert.False (accepted);
         Assert.False (accepted);
 
 
         return;
         return;
+
         void OnAccept (object sender, CancelEventArgs e) { accepted = true; }
         void OnAccept (object sender, CancelEventArgs e) { accepted = true; }
     }
     }
 
 
@@ -160,6 +158,7 @@ public class RadioGroupTests
         Assert.True (accepted);
         Assert.True (accepted);
 
 
         return;
         return;
+
         void OnAccept (object sender, CancelEventArgs e) { accepted = true; }
         void OnAccept (object sender, CancelEventArgs e) { accepted = true; }
     }
     }
 
 
@@ -195,8 +194,8 @@ public class RadioGroupTests
 └────────────────────────────┘
 └────────────────────────────┘
 ";
 ";
 
 
-        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
-        Assert.Equal (new Rectangle (0, 0, 30, 5), pos);
+        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+        Assert.Equal (new (0, 0, 30, 5), pos);
 
 
         rg.Orientation = Orientation.Horizontal;
         rg.Orientation = Orientation.Horizontal;
         Application.Refresh ();
         Application.Refresh ();
@@ -220,8 +219,8 @@ public class RadioGroupTests
 └────────────────────────────┘
 └────────────────────────────┘
 ";
 ";
 
 
-        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
-        Assert.Equal (new Rectangle (0, 0, 30, 5), pos);
+        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+        Assert.Equal (new (0, 0, 30, 5), pos);
 
 
         rg.HorizontalSpace = 4;
         rg.HorizontalSpace = 4;
         Application.Refresh ();
         Application.Refresh ();
@@ -245,8 +244,9 @@ public class RadioGroupTests
 └────────────────────────────┘
 └────────────────────────────┘
 ";
 ";
 
 
-        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
-        Assert.Equal (new Rectangle (0, 0, 30, 5), pos);
+        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+        Assert.Equal (new (0, 0, 30, 5), pos);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]

+ 28 - 30
UnitTests/Views/RuneCellTests.cs

@@ -3,11 +3,8 @@ using Xunit.Abstractions;
 
 
 namespace Terminal.Gui.ViewsTests;
 namespace Terminal.Gui.ViewsTests;
 
 
-public class RuneCellTests
+public class RuneCellTests (ITestOutputHelper output)
 {
 {
-    private readonly ITestOutputHelper _output;
-    public RuneCellTests (ITestOutputHelper output) { _output = output; }
-
     [Fact]
     [Fact]
     public void Constructor_Defaults ()
     public void Constructor_Defaults ()
     {
     {
@@ -24,13 +21,13 @@ public class RuneCellTests
 
 
         var rc2 = new RuneCell
         var rc2 = new RuneCell
         {
         {
-            Rune = new Rune ('a'), ColorScheme = new ColorScheme { Normal = new Attribute (Color.Red) }
+            Rune = new ('a'), ColorScheme = new() { Normal = new (Color.Red) }
         };
         };
         Assert.False (rc1.Equals (rc2));
         Assert.False (rc1.Equals (rc2));
         Assert.False (rc2.Equals (rc1));
         Assert.False (rc2.Equals (rc1));
 
 
-        rc1.Rune = new Rune ('a');
-        rc1.ColorScheme = new ColorScheme ();
+        rc1.Rune = new ('a');
+        rc1.ColorScheme = new ();
         Assert.Equal (rc1.Rune, rc2.Rune);
         Assert.Equal (rc1.Rune, rc2.Rune);
         Assert.False (rc1.Equals (rc2));
         Assert.False (rc1.Equals (rc2));
         Assert.False (rc2.Equals (rc1));
         Assert.False (rc2.Equals (rc1));
@@ -44,10 +41,10 @@ public class RuneCellTests
         Assert.True (rc1.Equals (rc2));
         Assert.True (rc1.Equals (rc2));
         Assert.True (rc2.Equals (rc1));
         Assert.True (rc2.Equals (rc1));
 
 
-        rc1.Rune = new Rune ('a');
-        rc1.ColorScheme = new ColorScheme ();
-        rc2.Rune = new Rune ('a');
-        rc2.ColorScheme = new ColorScheme ();
+        rc1.Rune = new ('a');
+        rc1.ColorScheme = new ();
+        rc2.Rune = new ('a');
+        rc2.ColorScheme = new ();
         Assert.True (rc1.Equals (rc2));
         Assert.True (rc1.Equals (rc2));
         Assert.True (rc2.Equals (rc1));
         Assert.True (rc2.Equals (rc1));
     }
     }
@@ -64,10 +61,10 @@ public class RuneCellTests
 
 
             foreach (Rune rune in csName.EnumerateRunes ())
             foreach (Rune rune in csName.EnumerateRunes ())
             {
             {
-                runeCells.Add (new RuneCell { Rune = rune, ColorScheme = color.Value });
+                runeCells.Add (new() { Rune = rune, ColorScheme = color.Value });
             }
             }
 
 
-            runeCells.Add (new RuneCell { Rune = (Rune)'\n', ColorScheme = color.Value });
+            runeCells.Add (new() { Rune = (Rune)'\n', ColorScheme = color.Value });
         }
         }
 
 
         TextView tv = CreateTextView ();
         TextView tv = CreateTextView ();
@@ -83,7 +80,7 @@ Base
 Dialog  
 Dialog  
 Menu    
 Menu    
 Error   ";
 Error   ";
-        TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
+        TestHelpers.AssertDriverContentsWithFrameAre (expectedText, output);
 
 
         Attribute [] attributes =
         Attribute [] attributes =
         {
         {
@@ -113,16 +110,16 @@ Error   ";
 
 
         tv.WordWrap = true;
         tv.WordWrap = true;
         Application.Refresh ();
         Application.Refresh ();
-        TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
+        TestHelpers.AssertDriverContentsWithFrameAre (expectedText, output);
         TestHelpers.AssertDriverAttributesAre (expectedColor, Application.Driver, attributes);
         TestHelpers.AssertDriverAttributesAre (expectedColor, Application.Driver, attributes);
 
 
-        tv.CursorPosition = new Point (6, 2);
+        tv.CursorPosition = new (6, 2);
         tv.SelectionStartColumn = 0;
         tv.SelectionStartColumn = 0;
         tv.SelectionStartRow = 0;
         tv.SelectionStartRow = 0;
         Assert.Equal ($"TopLevel{Environment.NewLine}Base{Environment.NewLine}Dialog", tv.SelectedText);
         Assert.Equal ($"TopLevel{Environment.NewLine}Base{Environment.NewLine}Dialog", tv.SelectedText);
         tv.Copy ();
         tv.Copy ();
         tv.Selecting = false;
         tv.Selecting = false;
-        tv.CursorPosition = new Point (2, 4);
+        tv.CursorPosition = new (2, 4);
         tv.Paste ();
         tv.Paste ();
         Application.Refresh ();
         Application.Refresh ();
 
 
@@ -134,7 +131,7 @@ Menu
 ErTopLevel
 ErTopLevel
 Base      
 Base      
 Dialogror ";
 Dialogror ";
-        TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
+        TestHelpers.AssertDriverContentsWithFrameAre (expectedText, output);
 
 
         expectedColor = @"
         expectedColor = @"
 0000000000
 0000000000
@@ -147,7 +144,7 @@ Dialogror ";
         TestHelpers.AssertDriverAttributesAre (expectedColor, Application.Driver, attributes);
         TestHelpers.AssertDriverAttributesAre (expectedColor, Application.Driver, attributes);
 
 
         tv.Undo ();
         tv.Undo ();
-        tv.CursorPosition = new Point (0, 3);
+        tv.CursorPosition = new (0, 3);
         tv.SelectionStartColumn = 0;
         tv.SelectionStartColumn = 0;
         tv.SelectionStartRow = 0;
         tv.SelectionStartRow = 0;
 
 
@@ -157,7 +154,7 @@ Dialogror ";
                      );
                      );
         tv.Copy ();
         tv.Copy ();
         tv.Selecting = false;
         tv.Selecting = false;
-        tv.CursorPosition = new Point (2, 4);
+        tv.CursorPosition = new (2, 4);
         tv.Paste ();
         tv.Paste ();
         Application.Refresh ();
         Application.Refresh ();
 
 
@@ -170,7 +167,7 @@ ErTopLevel
 Base      
 Base      
 Dialog    
 Dialog    
 ror       ";
 ror       ";
-        TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
+        TestHelpers.AssertDriverContentsWithFrameAre (expectedText, output);
 
 
         expectedColor = @"
         expectedColor = @"
 0000000000
 0000000000
@@ -184,18 +181,18 @@ ror       ";
         TestHelpers.AssertDriverAttributesAre (expectedColor, Application.Driver, attributes);
         TestHelpers.AssertDriverAttributesAre (expectedColor, Application.Driver, attributes);
 
 
         Application.End (rs);
         Application.End (rs);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
-    [AutoInitShutdown]
     public void RuneCell_LoadRuneCells_Without_ColorScheme_Is_Never_Null ()
     public void RuneCell_LoadRuneCells_Without_ColorScheme_Is_Never_Null ()
     {
     {
         List<RuneCell> cells = new ()
         List<RuneCell> cells = new ()
         {
         {
-            new RuneCell { Rune = new Rune ('T') },
-            new RuneCell { Rune = new Rune ('e') },
-            new RuneCell { Rune = new Rune ('s') },
-            new RuneCell { Rune = new Rune ('t') }
+            new() { Rune = new ('T') },
+            new() { Rune = new ('e') },
+            new() { Rune = new ('s') },
+            new() { Rune = new ('t') }
         };
         };
         TextView tv = CreateTextView ();
         TextView tv = CreateTextView ();
         var top = new Toplevel ();
         var top = new Toplevel ();
@@ -250,7 +247,7 @@ ror       ";
                                                       @"
                                                       @"
 This is the first line. 
 This is the first line. 
 This is the second line.",
 This is the second line.",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         tv.Width = 10;
         tv.Width = 10;
@@ -268,10 +265,11 @@ This is
 the    
 the    
 second 
 second 
 line.  ",
 line.  ",
-                                                      _output
+                                                      output
                                                      );
                                                      );
 
 
         Assert.Equal (eventCount, (text [0].Count + text [1].Count) * 2);
         Assert.Equal (eventCount, (text [0].Count + text [1].Count) * 2);
+        top.Dispose ();
     }
     }
 
 
     [Fact]
     [Fact]
@@ -281,7 +279,7 @@ line.  ",
 
 
         var rc2 = new RuneCell
         var rc2 = new RuneCell
         {
         {
-            Rune = new Rune ('a'), ColorScheme = new ColorScheme { Normal = new Attribute (Color.Red) }
+            Rune = new ('a'), ColorScheme = new() { Normal = new (Color.Red) }
         };
         };
         Assert.Equal ("U+0000 '\0'; null", rc1.ToString ());
         Assert.Equal ("U+0000 '\0'; null", rc1.ToString ());
 
 
@@ -292,5 +290,5 @@ line.  ",
     }
     }
 
 
     // TODO: Move the tests below to View or Color - they test ColorScheme, not RuneCell primitives.
     // TODO: Move the tests below to View or Color - they test ColorScheme, not RuneCell primitives.
-    private TextView CreateTextView () { return new TextView { Width = 30, Height = 10 }; }
+    private TextView CreateTextView () { return new() { Width = 30, Height = 10 }; }
 }
 }

Some files were not shown because too many files changed in this diff