Browse Source

Resolving merge conflicts.

BDisp 1 năm trước cách đây
mục cha
commit
308227761f
100 tập tin đã thay đổi với 1951 bổ sung2027 xóa
  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 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 ()
     {
         Cols = FakeConsole.WindowWidth = FakeConsole.BufferWidth = FakeConsole.WIDTH;

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

@@ -6,8 +6,7 @@ namespace Terminal.Gui;
 /// <summary>
 ///     <para>
 ///         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>
 ///         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.
     ///     This method is typically used internally by the layout system to determine the size of a View.
     /// </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>
     ///     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

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

@@ -69,12 +69,15 @@ public class DimAuto () : Dim
 
         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
             {
+                // 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).
                 subviewsSize = 0;
 

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

@@ -10,11 +10,9 @@ namespace Terminal.Gui;
 public enum DimAutoStyle
 {
     /// <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>
-    ///         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>
     ///         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.
     ///     </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>
     /// </summary>
     Text = 2,
 
     /// <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>
     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="mode">
 ///     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>
 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})"; }
 
     /// <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>
     public DimPercentMode Mode { get; } = mode;
 

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

@@ -15,7 +15,7 @@ public enum DimPercentMode
     Position = 0,
 
     /// <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>
     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>
     ///     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 used
     ///     internally by the layout system to determine where a View should be positioned.
     /// </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>
     ///     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

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

@@ -1,6 +1,5 @@
 #nullable enable
 using System.Diagnostics;
-using Microsoft.CodeAnalysis;
 
 namespace Terminal.Gui;
 
@@ -13,14 +12,13 @@ public partial class View
     /// <summary>Gets or sets the absolute location and dimension of the view.</summary>
     /// <value>
     ///     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>
     /// <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>
     ///         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.
-    ///         This causes <see cref="LayoutStyle"/> to be <see cref="LayoutStyle.Absolute"/>.
     ///     </para>
     ///     <para>
     ///         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) });
 
-            // 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;
             _y = _frame.Y;
             _width = _frame.Width;
@@ -136,7 +133,7 @@ public partial class View
     /// <value>The <see cref="Pos"/> object representing the X position.</value>
     /// <remarks>
     ///     <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>
     ///         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.
     ///     </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>The default value is <c>Pos.At (0)</c>.</para>
     /// </remarks>
@@ -175,7 +171,7 @@ public partial class View
     /// <value>The <see cref="Pos"/> object representing the Y position.</value>
     /// <remarks>
     ///     <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>
     ///         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.
     ///     </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>The default value is <c>Pos.At (0)</c>.</para>
     /// </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>
     /// <remarks>
     ///     <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>
@@ -226,8 +221,7 @@ public partial class View
     ///         <see cref="LayoutSubview(View, Size)"/> and <see cref="OnDrawContent(Rectangle)"/> methods to be called.
     ///     </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>The default value is <c>Dim.Sized (0)</c>.</para>
     /// </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>
     /// <remarks>
     ///     <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>
@@ -272,8 +266,7 @@ public partial class View
     ///         <see cref="LayoutSubview(View, Size)"/> and <see cref="OnDrawContent(Rectangle)"/> methods to be called.
     ///     </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>The default value is <c>Dim.Sized (0)</c>.</para>
     /// </remarks>
@@ -303,78 +296,6 @@ public partial class View
 
     #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
 
     /// <summary>
@@ -649,7 +570,7 @@ public partial class View
 
         CheckDimAuto ();
 
-        var contentSize = ContentSize;
+        var contentSize = GetContentSize ();
         OnLayoutStarted (new (contentSize));
 
         LayoutAdornments ();
@@ -673,7 +594,7 @@ public partial class View
         {
             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 - 
         //  First try SuperView.Viewport, then Application.Top, then Driver.Viewport.
         //  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);
 
         SetTextFormatterSize ();
@@ -769,7 +690,7 @@ public partial class View
 
     /// <summary>
     ///     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
     ///     <see cref="Height"/>).
     /// </summary>
@@ -781,7 +702,7 @@ public partial class View
     ///     </para>
     /// </remarks>
     /// <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>
     internal void SetRelativeLayout (Size superviewContentSize)
     {
@@ -819,8 +740,7 @@ public partial class View
 
         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);
 
             if (_x is PosAbsolute)
@@ -858,12 +778,6 @@ public partial class View
         foreach (View? v in from.InternalSubviews)
         {
             nNodes.Add (v);
-
-            if (v.LayoutStyle != LayoutStyle.Computed)
-            {
-                continue;
-            }
-
             CollectPos (v.X, v, ref nNodes, ref nEdges);
             CollectPos (v.Y, 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.
         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.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.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.
 ///     </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
 ///         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
@@ -79,9 +72,7 @@ namespace Terminal.Gui;
 ///         To flag the entire view for redraw call <see cref="SetNeedsDisplay()"/>.
 ///     </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>
 ///         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>
     ///     <para>
     ///         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>
     /// </remarks>
     public View ()
@@ -520,9 +503,23 @@ public partial class View : Responder, ISupportInitializeNotification
     /// <returns></returns>
     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)
     {
+        // BUGBUG: We should only dispose these objects if disposing == true
         LineCanvas.Dispose ();
 
         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
 {
@@ -13,33 +11,31 @@ public partial class View
     /// </summary>
     /// <remarks>
     ///     <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>
-    ///         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>
-    ///         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>
-    ///         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>
-    ///         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>
-    /// </param>
+    /// </remarks>
     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));
         }
@@ -56,19 +52,86 @@ public partial class View
     /// <summary>
     ///     Gets the size of the View's content.
     /// </summary>
-    /// <remarks>
+    /// <remarks>a>
     ///     <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>
-    ///         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>
     /// </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>
-    /// 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>
     /// <param name="e"></param>
     /// <returns></returns>
@@ -79,6 +142,7 @@ public partial class View
         if (e.Cancel != true)
         {
             OnResizeNeeded ();
+
             //SetNeedsLayout ();
             //SetNeedsDisplay ();
         }
@@ -87,7 +151,7 @@ public partial class View
     }
 
     /// <summary>
-    ///     Event raised when the <see cref="ContentSize"/> changes.
+    ///     Event raised when the <see cref="GetContentSize ()"/> changes.
     /// </summary>
     public event EventHandler<SizeChangedEventArgs> ContentSizeChanged;
 
@@ -155,37 +219,35 @@ public partial class View
     /// <summary>
     ///     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
-    ///     is <see cref="ContentSize"/>.
+    ///     is <see cref="GetContentSize ()"/>.
     /// </summary>
     private Point _viewportLocation;
 
     /// <summary>
     ///     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"/>.
-    ///     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>.
     /// </summary>
     /// <value>
     ///     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>
     /// <remarks>
     ///     <para>
     ///         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>
     ///         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).
     ///     </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>
     ///         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 ();
+
             return new (
                         _viewportLocation,
                         new (
@@ -239,6 +302,7 @@ public partial class View
             }
 
             OnViewportChanged (new (IsInitialized ? Viewport : Rectangle.Empty, oldViewport));
+
             return;
         }
 
@@ -254,9 +318,9 @@ public partial class View
         {
             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 (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>
-    ///     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>
     [CanBeNull]
     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.
     /// </summary>
     /// <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>
     ///     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>
     /// <param name="viewport">Viewport-relative location and size.</param>
     /// <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>
     ///     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>
     public bool? ScrollVertical (int rows)
     {
-        if (ContentSize == Size.Empty || ContentSize == Viewport.Size)
+        if (GetContentSize () == Size.Empty || GetContentSize () == Viewport.Size)
         {
             return false;
         }
@@ -388,7 +447,7 @@ public partial class View
     /// <returns><see langword="true"/> if the <see cref="Viewport"/> was changed.</returns>
     public bool? ScrollHorizontal (int cols)
     {
-        if (ContentSize == Size.Empty || ContentSize == Viewport.Size)
+        if (GetContentSize () == Size.Empty || GetContentSize () == Viewport.Size)
         {
             return false;
         }

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

@@ -106,7 +106,7 @@ public partial class View
 
         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);
         }
 
@@ -172,7 +172,7 @@ public partial class View
         if (ViewportSettings.HasFlag (ViewportSettings.ClipContentOnly))
         {
             // 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);
         }
 
@@ -445,12 +445,12 @@ public partial class View
     ///     </para>
     ///     <para>
     ///         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>
     ///         the 6th row of the content should be drawn using <c>MoveTo (x, 5)</c>.
     ///     </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.
     ///     </para>
     ///     <para>
@@ -485,7 +485,7 @@ public partial class View
 
             // This should NOT clear 
             // 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 (
                                  drawRect,
@@ -594,7 +594,7 @@ public partial class View
     /// <remarks>
     ///     <para>
     ///         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>
     ///         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"/>.
     ///     </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.
     ///     </para>
     ///     <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>
     /// </remarks>
     public virtual string Text
@@ -84,7 +84,7 @@ public partial class View
     ///     redisplay the <see cref="View"/>.
     /// </summary>
     /// <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>
     /// <value>The text alignment.</value>
     public virtual Alignment TextAlignment
@@ -103,7 +103,7 @@ public partial class View
     ///     <see cref="View"/>.
     /// </summary>
     /// <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>
     /// <value>The text direction.</value>
     public virtual TextDirection TextDirection
@@ -127,7 +127,7 @@ public partial class View
     ///     the <see cref="View"/>.
     /// </summary>
     /// <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>
     /// <value>The vertical text alignment.</value>
     public virtual Alignment VerticalTextAlignment
@@ -179,8 +179,8 @@ public partial class View
         // We need to ensure TextFormatter is accurate by calling it here.
         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
         // 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))
             {
-                size.Width = ContentSize.Width;
+                size.Width = GetContentSize ().Width;
             }
 
             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,
 
     /// <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
     ///     of the content area.
     /// </summary>
     /// <remarks>
     ///     <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>.
     ///         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.
@@ -65,13 +65,13 @@ public enum ViewportSettings
     AllowXGreaterThanContentWidth = 4,
 
     /// <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
     ///     of the content area.
     /// </summary>
     /// <remarks>
     ///     <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>.
     ///         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.
@@ -83,13 +83,13 @@ public enum ViewportSettings
     AllowYGreaterThanContentHeight = 8,
 
     /// <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
     ///     of the content area.
     /// </summary>
     /// <remarks>
     ///     <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
     ///         scroll the Viewport past the last column or row.
     ///     </para>

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

@@ -33,8 +33,7 @@ public class Button : View
     private readonly Rune _rightDefault;
     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 ()
     {
         TextAlignment = Alignment.Center;

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

@@ -11,8 +11,7 @@ public class CheckBox : View
     private bool? _checked = false;
 
     /// <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>
     public CheckBox ()
     {

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

@@ -39,7 +39,7 @@ public class ColorPicker : View
 
         Width = Dim.Auto (minimumContentDim: _boxWidth * _cols);
         Height = Dim.Auto (minimumContentDim: _boxHeight * _rows);
-        SetContentSize(new (_boxWidth * _cols, _boxHeight * _rows));
+        SetContentSize (new (_boxWidth * _cols, _boxHeight * _rows));
 
         MouseClick += ColorPicker_MouseClick;
     }
@@ -178,9 +178,9 @@ public class ColorPicker : View
         Driver.SetAttribute (HasFocus ? ColorScheme.Focus : GetNormalColor ());
         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;
                 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;
             _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 _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) { }
 
-    /// <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>
     public DateField (DateTime date)
     {

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

@@ -9,7 +9,8 @@ namespace Terminal.Gui;
 /// </summary>
 /// <remarks>
 ///     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
 ///     <see cref="Application.RequestStop"/>.
 /// </remarks>
@@ -41,7 +42,6 @@ public class Dialog : Window
     [SerializableConfigurationProperty (Scope = typeof (ThemeScope))]
     public static int DefaultMinimumHeight { get; set; } = 25;
 
-
     // TODO: Reenable once border/borderframe design is settled
     /// <summary>
     ///     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 ();
 
     /// <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>
     /// <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>
     public Dialog ()
     {
@@ -69,8 +68,8 @@ public class Dialog : Window
         X = 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"];
 
         Modal = true;
@@ -87,7 +86,6 @@ public class Dialog : Window
                         return true;
                     });
         KeyBindings.Add (Key.Esc, Command.QuitToplevel);
-
     }
 
     private bool _canceled;
@@ -115,8 +113,6 @@ public class Dialog : Window
             }
 #endif
             _canceled = value;
-
-            return;
         }
     }
 
@@ -125,7 +121,7 @@ public class Dialog : Window
     public Alignment ButtonAlignment { get; set; }
 
     /// <summary>
-    /// Gets or sets the alignment modes for the dialog's buttons.
+    ///     Gets or sets the alignment modes for the dialog's buttons.
     /// </summary>
     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
-        button.X = Pos.Align (ButtonAlignment, ButtonAlignmentModes, groupId: GetHashCode ());
+        button.X = Pos.Align (ButtonAlignment, ButtonAlignmentModes, GetHashCode ());
         button.Y = Pos.AnchorEnd ();
 
         _buttons.Add (button);

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

@@ -3,13 +3,12 @@
 namespace Terminal.Gui;
 
 /// <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>
 public class FrameView : View
 {
     /// <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.
     /// </summary>
     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 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">
     ///     The <see cref="Stream"/> to view and edit as hex, this <see cref="Stream"/> must support seeking,
     ///     or an exception will be thrown.
@@ -98,7 +98,7 @@ public class HexView : View
         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 ()) { }
 
     /// <summary>

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

@@ -256,7 +256,7 @@ public class MenuBar : View
         X = 0;
         Y = 0;
         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 [] { };
 
         //CanFocus = true;

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

@@ -405,7 +405,7 @@ public static class MessageBox
             Size GetWrapSize ()
             {
                 // 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 ();
             }
         }

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

@@ -11,8 +11,7 @@ public class RadioGroup : View
     private int _selected;
 
     /// <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>
     public RadioGroup ()
     {

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

@@ -33,8 +33,7 @@ public class ScrollBarView : View
     private bool _vertical;
 
     /// <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>
     public ScrollBarView ()
     {
@@ -46,8 +45,7 @@ public class ScrollBarView : View
     }
 
     /// <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>
     /// <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>

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

@@ -21,7 +21,7 @@ namespace Terminal.Gui;
 ///     <para>
 ///         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="View.ContentSize"/>.
+///         <see cref="View.GetContentSize ()"/>.
 ///     </para>
 ///     <para>Use the</para>
 /// </remarks>
@@ -38,8 +38,7 @@ public class ScrollView : View
     private bool _showVerticalScrollIndicator;
 
     /// <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>
     public ScrollView ()
     {
@@ -88,10 +87,10 @@ public class ScrollView : View
         AddCommand (Command.PageDown, () => ScrollDown (Viewport.Height));
         AddCommand (Command.PageLeft, () => ScrollLeft (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
         KeyBindings.Add (Key.CursorUp, Command.ScrollUp);
@@ -127,7 +126,7 @@ public class ScrollView : View
                            }
 
                            SetContentOffset (_contentOffset);
-                           _contentView.Frame = new Rectangle (ContentOffset, ContentSize);
+                           _contentView.Frame = new Rectangle (ContentOffset, GetContentSize ());
 
                            // PERF: How about calls to Point.Offset instead?
                            _vertical.ChangedPosition += delegate { ContentOffset = new Point (ContentOffset.X, _vertical.Position); };
@@ -220,12 +219,12 @@ public class ScrollView : View
     //    get => ContentSize;
     //    set
     //    {
-    //        if (ContentSize != value)
+    //        if (GetContentSize () != value)
     //        {
     //            ContentSize = value;
     //            _contentView.Frame = new Rectangle (_contentOffset, value);
-    //            _vertical.Size = ContentSize.Height;
-    //            _horizontal.Size = ContentSize.Width;
+    //            _vertical.Size = GetContentSize ().Height;
+    //            _horizontal.Size = GetContentSize ().Width;
     //            SetNeedsDisplay ();
     //        }
     //    }
@@ -244,26 +243,26 @@ public class ScrollView : View
                 _horizontal.OtherScrollBarView.KeepContentAlwaysInViewport = value;
                 Point p = default;
 
-                if (value && -_contentOffset.X + Viewport.Width > ContentSize.Width)
+                if (value && -_contentOffset.X + Viewport.Width > GetContentSize ().Width)
                 {
                     p = new Point (
-                                   ContentSize.Width - Viewport.Width + (_showVerticalScrollIndicator ? 1 : 0),
+                                   GetContentSize ().Width - Viewport.Width + (_showVerticalScrollIndicator ? 1 : 0),
                                    -_contentOffset.Y
                                   );
                 }
 
-                if (value && -_contentOffset.Y + Viewport.Height > ContentSize.Height)
+                if (value && -_contentOffset.Y + Viewport.Height > GetContentSize ().Height)
                 {
                     if (p == default (Point))
                     {
                         p = new Point (
                                        -_contentOffset.X,
-                                       ContentSize.Height - Viewport.Height + (_showHorizontalScrollIndicator ? 1 : 0)
+                                       GetContentSize ().Height - Viewport.Height + (_showHorizontalScrollIndicator ? 1 : 0)
                                       );
                     }
                     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?
         _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);
 
         if (_vertical.Position != p)
@@ -638,7 +637,7 @@ public class ScrollView : View
         bool v = false, h = 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)
             {
@@ -647,7 +646,7 @@ public class ScrollView : View
 
             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;
         }
@@ -661,7 +660,7 @@ public class ScrollView : View
             v = true;
         }
 
-        if (ContentSize is { } && (Viewport.Width == 0 || Viewport.Width > ContentSize.Width))
+        if (GetContentSize () is { } && (Viewport.Width == 0 || Viewport.Width > GetContentSize ().Width))
         {
             if (ShowHorizontalScrollIndicator)
             {
@@ -670,7 +669,7 @@ public class ScrollView : View
 
             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)
             {

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

@@ -93,7 +93,7 @@ public class StatusBar : View
         X = 0;
         Y = Pos.AnchorEnd (1);
         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);
     }
 

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

@@ -21,7 +21,7 @@ public class TabView : View
     private TabToRender [] _tabLocations;
     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 ()
     {
         CanFocus = true;
@@ -564,7 +564,7 @@ public class TabView : View
             _host = host;
 
             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 ();
 
             _rightScrollIndicator = new View

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

@@ -37,12 +37,12 @@ public class TableView : View
     private TableStyle style = new ();
     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>
     public TableView (ITableSource table) : this () { Table = table; }
 
     /// <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
     /// </summary>
     public TableView ()
@@ -908,10 +908,10 @@ public class TableView : View
         // What columns to render at what X offset in viewport
         ColumnToRender [] columnsToRender = CalculateViewport (Viewport).ToArray ();
 
-        Driver.SetAttribute (GetNormalColor ());
+        Driver?.SetAttribute (GetNormalColor ());
 
         //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;
 
@@ -2014,7 +2014,7 @@ public class TableView : View
 
     /// <summary>
     ///     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>
     /// <returns></returns>
     private bool TableIsNullOrInvisible ()

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

@@ -21,8 +21,7 @@ public class TextField : View
     private List<Rune> _text;
 
     /// <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>
     public TextField ()
     {

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

@@ -392,8 +392,7 @@ namespace Terminal.Gui
         private ITextValidateProvider _provider;
 
         /// <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>
         public TextValidateField ()
         {

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

@@ -2588,25 +2588,6 @@ public class TextView : View
     /// </summary>
     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>
     public ContextMenu? ContextMenu { get; }
 
@@ -2678,7 +2659,7 @@ public class TextView : View
     public int Lines => _model.Count;
 
     /// <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>
     public bool Multiline
@@ -2736,30 +2717,12 @@ public class TextView : View
                 _isReadOnly = value;
 
                 SetNeedsDisplay ();
+                WrapTextModel ();
                 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>
     public int SelectedLength => GetSelectedLength ();
 
@@ -2852,7 +2815,7 @@ public class TextView : View
             if (_wordWrap)
             {
                 _wrapManager = new (_model);
-                _model = _wrapManager.WrapModel (_frameWidth, out _, out _, out _, out _);
+                _model = _wrapManager.WrapModel (Viewport.Width, out _, out _, out _, out _);
             }
 
             OnTextChanged (old, Text);
@@ -2897,7 +2860,7 @@ public class TextView : View
             if (_wordWrap)
             {
                 _wrapManager = new (_model);
-                _model = _wrapManager.WrapModel (_frameWidth, out _, out _, out _, out _);
+                WrapTextModel ();
             }
             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>
     public void ClearHistoryChanges () { _historyText?.Clear (Text); }
@@ -3389,34 +3351,34 @@ public class TextView : View
 
             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)
                 {
-                    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)
                 {
                     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)
                 {
-                    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)
                 {
@@ -3585,8 +3547,8 @@ public class TextView : View
         SetNormalColor ();
 
         (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;
 
         for (int idxRow = _topRow; idxRow < _model.Count; idxRow++)
@@ -3826,9 +3788,9 @@ public class TextView : View
         if (Application.MouseGrabView == this && Selecting)
         {
             // 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 ();
         }
 
@@ -3851,7 +3813,7 @@ public class TextView : View
                     cols += TabWidth + 1;
                 }
 
-                if (!TextModel.SetCol (ref col, Frame.Width, cols))
+                if (!TextModel.SetCol (ref col, Viewport.Width, cols))
                 {
                     col = CurrentColumn;
 
@@ -3863,7 +3825,7 @@ public class TextView : View
         int posX = CurrentColumn - _leftColumn;
         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);
             return new (col, CurrentRow - _topRow);
@@ -3934,7 +3896,7 @@ public class TextView : View
         else if (!_wordWrap)
         {
             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);
         }
 
@@ -4113,18 +4075,18 @@ public class TextView : View
             need = true;
         }
         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 (
                                                          line,
                                                          _leftColumn,
                                                          CurrentColumn,
-                                                         Frame.Width + offB.width - RightOffset,
+                                                         Viewport.Width + offB.width,
                                                          TabWidth
                                                         );
             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)
             {
@@ -4138,9 +4100,9 @@ public class TextView : View
             _topRow = CurrentRow;
             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;
         }
         else if (_topRow > 0 && CurrentRow < _topRow)
@@ -4285,7 +4247,7 @@ public class TextView : View
             {
                 //QUESTION: Is the below comment still relevant?
                 // 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 ();
             }
 
@@ -4381,7 +4343,7 @@ public class TextView : View
             else
             {
                 // 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 ();
             }
         }
@@ -4473,7 +4435,7 @@ public class TextView : View
                 _wrapNeeded = true;
             }
 
-            DoSetNeedsDisplay (new (0, CurrentRow - _topRow, Frame.Width, CurrentRow - _topRow + 1));
+            DoSetNeedsDisplay (new (0, CurrentRow - _topRow, Viewport.Width, CurrentRow - _topRow + 1));
         }
         else
         {
@@ -4496,8 +4458,8 @@ public class TextView : View
                                new (
                                     CurrentColumn - _leftColumn,
                                     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)
         {
             // 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 ();
         }
     }
@@ -4828,9 +4790,9 @@ public class TextView : View
                               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)
@@ -4840,7 +4802,7 @@ public class TextView : View
             else
             {
                 // 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 ();
             }
 
@@ -4936,7 +4898,7 @@ public class TextView : View
                 Insert (new () { Rune = a.AsRune, ColorScheme = colorScheme });
                 CurrentColumn++;
 
-                if (CurrentColumn >= _leftColumn + Frame.Width)
+                if (CurrentColumn >= _leftColumn + Viewport.Width)
                 {
                     _leftColumn++;
                     SetNeedsDisplay ();
@@ -5054,7 +5016,7 @@ public class TextView : View
 
         UpdateWrapModel ();
 
-        DoSetNeedsDisplay (new (0, CurrentRow - _topRow, Frame.Width, Frame.Height));
+        DoSetNeedsDisplay (new (0, CurrentRow - _topRow, Viewport.Width, Viewport.Height));
 
         _lastWasKill = setLastWasKill;
         DoNeededAction ();
@@ -5161,7 +5123,7 @@ public class TextView : View
 
         UpdateWrapModel ();
 
-        DoSetNeedsDisplay (new (0, CurrentRow - _topRow, Frame.Width, Frame.Height));
+        DoSetNeedsDisplay (new (0, CurrentRow - _topRow, Viewport.Width, Viewport.Height));
 
         _lastWasKill = setLastWasKill;
         DoNeededAction ();
@@ -5231,7 +5193,7 @@ public class TextView : View
 
         UpdateWrapModel ();
 
-        DoSetNeedsDisplay (new (0, CurrentRow - _topRow, Frame.Width, Frame.Height));
+        DoSetNeedsDisplay (new (0, CurrentRow - _topRow, Viewport.Width, Viewport.Height));
         DoNeededAction ();
     }
 
@@ -5290,7 +5252,7 @@ public class TextView : View
 
         UpdateWrapModel ();
 
-        DoSetNeedsDisplay (new (0, CurrentRow - _topRow, Frame.Width, Frame.Height));
+        DoSetNeedsDisplay (new (0, CurrentRow - _topRow, Viewport.Width, Viewport.Height));
         DoNeededAction ();
     }
 
@@ -5306,7 +5268,7 @@ public class TextView : View
         if (!_multiline && !IsInitialized)
         {
             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++;
 
-            if (CurrentRow + BottomOffset >= _topRow + Frame.Height)
+            if (CurrentRow >= _topRow + Viewport.Height)
             {
                 _topRow++;
                 SetNeedsDisplay ();
@@ -5349,7 +5311,7 @@ public class TextView : View
             TrackColumn ();
             PositionCursor ();
         }
-        else if (CurrentRow > Frame.Height)
+        else if (CurrentRow > Viewport.Height)
         {
             Adjust ();
         }
@@ -5360,7 +5322,7 @@ public class TextView : View
     private void MoveEndOfLine ()
     {
         List<RuneCell> currentLine = GetCurrentLine ();
-        CurrentColumn = currentLine.Count;
+        CurrentColumn = Math.Max (currentLine.Count - (ReadOnly ? 1 : 0), 0);
         Adjust ();
         DoNeededAction ();
     }
@@ -5384,7 +5346,7 @@ public class TextView : View
                 }
 
                 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 ()
     {
-        int nPageDnShift = Frame.Height - 1;
+        int nPageDnShift = Viewport.Height - 1;
 
         if (CurrentRow >= 0 && CurrentRow < _model.Count)
         {
@@ -5434,7 +5396,7 @@ public class TextView : View
 
     private void MovePageUp ()
     {
-        int nPageUpShift = Frame.Height - 1;
+        int nPageUpShift = Viewport.Height - 1;
 
         if (CurrentRow > 0)
         {
@@ -5472,7 +5434,7 @@ public class TextView : View
     {
         List<RuneCell> currentLine = GetCurrentLine ();
 
-        if (CurrentColumn < currentLine.Count)
+        if ((ReadOnly ? CurrentColumn + 1 : CurrentColumn) < currentLine.Count)
         {
             CurrentColumn++;
         }
@@ -5483,7 +5445,7 @@ public class TextView : View
                 CurrentRow++;
                 CurrentColumn = 0;
 
-                if (CurrentRow >= _topRow + Frame.Height)
+                if (CurrentRow >= _topRow + Viewport.Height)
                 {
                     _topRow++;
                     SetNeedsDisplay ();
@@ -5584,14 +5546,14 @@ public class TextView : View
         var w = 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);
@@ -5838,9 +5800,9 @@ public class TextView : View
             r = GetCurrentLine ();
             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
             {
@@ -6126,7 +6088,7 @@ public class TextView : View
 
         var fullNeedsDisplay = false;
 
-        if (CurrentRow >= _topRow + Frame.Height)
+        if (CurrentRow >= _topRow + Viewport.Height)
         {
             _topRow++;
             fullNeedsDisplay = true;
@@ -6153,7 +6115,7 @@ public class TextView : View
         else
         {
             // 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 ();
         }
 
@@ -6484,7 +6446,7 @@ public class TextView : View
         if (_wordWrap && _wrapManager is { })
         {
             _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 nCol,
                                              out int nStartRow,

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

@@ -21,7 +21,7 @@ public class TimeField : TextField
     private bool _isShort;
     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 ()
     {
         CultureInfo cultureInfo = CultureInfo.CurrentCulture;

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

@@ -23,7 +23,7 @@ namespace Terminal.Gui;
 public partial class Toplevel : View
 {
     /// <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
     ///     dimensions of the terminal using <see cref="Dim.Fill"/>.
     /// </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))
-
-            // 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)
             {

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

@@ -15,8 +15,7 @@ namespace Terminal.Gui;
 public class Window : Toplevel
 {
     /// <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>
     public Window ()
     {

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

@@ -57,8 +57,7 @@ public class Wizard : Dialog
     private string _wizardTitle = string.Empty;
 
     /// <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>
     /// <remarks>
     ///     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 ();
 
     /// <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>
     public WizardStep ()
     {

+ 3 - 2
UICatalog/Scenarios/ASCIICustomButton.cs

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

+ 0 - 4
UICatalog/Scenarios/AllViewsTester.cs

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

+ 2 - 1
UICatalog/Scenarios/Clipping.cs

@@ -23,12 +23,13 @@ public class Clipping : Scenario
         //Win.Height = Dim.Fill () - 2;
         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);
 
         var scrollView = new ScrollView { X = 3, Y = 3, Width = 50, Height = 20 };
         scrollView.ColorScheme = Colors.ColorSchemes ["Menu"];
+        // BUGBUG: set_ContentSize is supposed to be `protected`. 
         scrollView.SetContentSize (new (200, 100));
 
         //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 Terminal.Gui;
 
 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 ("Drawing")]
 [ScenarioCategory ("Scrolling")]
@@ -86,7 +87,7 @@ public class ContentScrolling : Scenario
 
             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.Height = Border.Thickness.Top;
             }
@@ -230,7 +231,7 @@ public class ContentScrolling : Scenario
 
         Buttons.NumericUpDown<int> contentSizeWidth = new Buttons.NumericUpDown<int>
         {
-            Value = view.ContentSize.Width,
+            Value = view.GetContentSize ().Width,
             X = Pos.Right (labelContentSize) + 1,
             Y = Pos.Top (labelContentSize)
         };
@@ -244,8 +245,8 @@ public class ContentScrolling : Scenario
 
                 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
@@ -257,7 +258,7 @@ public class ContentScrolling : Scenario
 
         Buttons.NumericUpDown<int> contentSizeHeight = new Buttons.NumericUpDown<int>
         {
-            Value = view.ContentSize.Height,
+            Value = view.GetContentSize ().Height,
             X = Pos.Right (labelComma) + 1,
             Y = Pos.Top (labelContentSize),
             CanFocus = false
@@ -272,8 +273,8 @@ public class ContentScrolling : Scenario
 
                 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
@@ -355,8 +356,8 @@ public class ContentScrolling : Scenario
         {
             X = Pos.Center (),
             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) =>

+ 1 - 32
UICatalog/Scenarios/Editor.cs

@@ -60,9 +60,7 @@ public class Editor : Scenario
             X = 0,
             Y = 0,
             Width = Dim.Fill (),
-            Height = Dim.Fill (),
-            BottomOffset = 1,
-            RightOffset = 1
+            Height = Dim.Fill ()
         };
 
         CreateDemoFile (_fileName);
@@ -297,30 +295,6 @@ public class Editor : Scenario
                                                              _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) =>
                                  {
                                      _scrollBar.Size = _textView.Lines;
@@ -834,11 +808,6 @@ public class Editor : Scenario
                            if (_textView.WordWrap)
                            {
                                _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,
             ShowHorizontalScrollIndicator = true
         };
+        // BUGBUG: set_ContentSize is supposed to be `protected`. 
         scrollView.SetContentSize (new (120, 40));
         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";
 

+ 0 - 12
UICatalog/Scenarios/Wizards.cs

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

+ 5 - 0
UnitTests/Application/KeyboardTests.cs

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

+ 2 - 0
UnitTests/Application/MainLoopTests.cs

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

+ 4 - 0
UnitTests/Application/MouseTests.cs

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

+ 10 - 1
UnitTests/Dialogs/DialogTests.cs

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

+ 32 - 41
UnitTests/Dialogs/WizardTests.cs

@@ -2,21 +2,16 @@
 
 namespace Terminal.Gui.DialogTests;
 
-public class WizardTests
+public class WizardTests ()
 {
-    private readonly ITestOutputHelper _output;
-    public WizardTests (ITestOutputHelper output) { _output = output; }
-
     // =========== Wizard Tests
     [Fact]
-    [AutoInitShutdown]
     public void DefaultConstructor_SizedProperly ()
     {
-        var d = (FakeDriver)Application.Driver;
-
         var wizard = new Wizard ();
         Assert.NotEqual (0, wizard.Width);
         Assert.NotEqual (0, wizard.Height);
+        wizard.Dispose ();
     }
 
     [Fact]
@@ -47,9 +42,9 @@ public class WizardTests
         wizard.Dispose ();
 
         // Same test, but with two steps
-        wizard = new Wizard ();
+        wizard = new ();
         firstIteration = false;
-        step1 = new WizardStep { Title = "step1" };
+        step1 = new() { Title = "step1" };
         wizard.AddStep (step1);
         var step2 = new WizardStep { Title = "step2" };
         wizard.AddStep (step2);
@@ -80,11 +75,11 @@ public class WizardTests
         wizard.Dispose ();
 
         // Same test, but with two steps but the 1st one disabled
-        wizard = new Wizard ();
+        wizard = new ();
         firstIteration = false;
-        step1 = new WizardStep { Title = "step1" };
+        step1 = new() { Title = "step1" };
         wizard.AddStep (step1);
-        step2 = new WizardStep { Title = "step2" };
+        step2 = new() { Title = "step2" };
         wizard.AddStep (step2);
         step1.Enabled = false;
 
@@ -103,10 +98,10 @@ public class WizardTests
         Application.End (runstate);
         Assert.True (finishedFired);
         Assert.True (closedFired);
+        wizard.Dispose ();
     }
 
     [Fact]
-    [AutoInitShutdown]
     public void Navigate_GetFirstStep_Works ()
     {
         var wizard = new Wizard ();
@@ -134,10 +129,10 @@ public class WizardTests
         step1.Enabled = false;
         step2.Enabled = false;
         Assert.Equal (step3.Title, wizard.GetFirstStep ().Title);
+        wizard.Dispose ();
     }
 
     [Fact]
-    [AutoInitShutdown]
     public void Navigate_GetLastStep_Works ()
     {
         var wizard = new Wizard ();
@@ -165,6 +160,7 @@ public class WizardTests
         step3.Enabled = false;
         step2.Enabled = false;
         Assert.Equal (step1.Title, wizard.GetLastStep ().Title);
+        wizard.Dispose ();
     }
 
     [Fact]
@@ -263,6 +259,7 @@ public class WizardTests
         step2.Enabled = false;
         step3.Enabled = false;
         Assert.Equal (step1.Title, wizard.GetNextStep ().Title);
+        wizard.Dispose ();
     }
 
     [Fact]
@@ -356,10 +353,10 @@ public class WizardTests
         step2.Enabled = false;
         step3.Enabled = false;
         Assert.Equal (step1.Title, wizard.GetPreviousStep ().Title);
+        wizard.Dispose ();
     }
 
     [Fact]
-    [AutoInitShutdown]
     public void Navigate_GoBack_Works ()
     {
         // If zero steps do nothing
@@ -374,7 +371,6 @@ public class WizardTests
     }
 
     [Fact]
-    [AutoInitShutdown]
     public void Navigate_GoNext_Works ()
     {
         // If zero steps do nothing
@@ -429,16 +425,16 @@ public class WizardTests
             } - {
                 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
             }";
-        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 row4 = row3;
 
         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 =
             $"{
@@ -446,7 +442,7 @@ public class WizardTests
             }{
                 btnBack
             }{
-                new string (' ', width - btnBack.Length - btnNext.Length - 2)
+                new (' ', width - btnBack.Length - btnNext.Length - 2)
             }{
                 btnNext
             }{
@@ -457,13 +453,13 @@ public class WizardTests
             $"{
                 CM.Glyphs.LLCornerDbl
             }{
-                new string (CM.Glyphs.HLineDbl.ToString () [0], width - 2)
+                new (CM.Glyphs.HLineDbl.ToString () [0], width - 2)
             }{
                 CM.Glyphs.LRCornerDbl
             }";
 
         var wizard = new Wizard { Title = title, Width = width, Height = height };
-        wizard.AddStep (new WizardStep { Title = stepTitle });
+        wizard.AddStep (new() { Title = stepTitle });
 
         //wizard.LayoutSubviews ();
         var firstIteration = false;
@@ -476,6 +472,7 @@ public class WizardTests
         //                                              _output
         //                                             );
         Application.End (runstate);
+        wizard.Dispose ();
     }
 
     [Fact]
@@ -516,36 +513,36 @@ public class WizardTests
             }{
                 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
             }";
 
         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
         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 bottomRow =
             $"{
                 CM.Glyphs.LLCornerDbl
             }{
-                new string (CM.Glyphs.HLineDbl.ToString () [0], width - 2)
+                new (CM.Glyphs.HLineDbl.ToString () [0], width - 2)
             }{
                 CM.Glyphs.LRCornerDbl
             }";
 
         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));
+        wizard.Dispose ();
     }
 
     [Fact]
-    [AutoInitShutdown]
 
     // This test verifies that the 2nd step in a wizard with more than 2 steps 
     // shows the correct buttons on all steps
@@ -564,7 +561,6 @@ public class WizardTests
     }
 
     [Fact]
-    [AutoInitShutdown]
 
     // This test verifies that the 2nd step in a wizard with 2 steps 
     // shows the correct buttons on both steps
@@ -585,7 +581,6 @@ public class WizardTests
     // =========== WizardStep Tests
 
     [Fact]
-    [AutoInitShutdown]
     public void WizardStep_ButtonText ()
     {
         // Verify default button text
@@ -684,15 +679,15 @@ public class WizardTests
             }{
                 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
             }";
-        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;
 
         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 =
             $"{
@@ -700,7 +695,7 @@ public class WizardTests
             }{
                 btnBack
             }{
-                new string (' ', width - btnBack.Length - btnNext.Length - 2)
+                new (' ', width - btnBack.Length - btnNext.Length - 2)
             }{
                 btnNext
             }{
@@ -711,24 +706,20 @@ public class WizardTests
             $"{
                 CM.Glyphs.LLCornerDbl
             }{
-                new string (CM.Glyphs.HLineDbl.ToString () [0], width - 2)
+                new (CM.Glyphs.HLineDbl.ToString () [0], width - 2)
             }{
                 CM.Glyphs.LRCornerDbl
             }";
 
         var wizard = new Wizard { Title = title, Width = width, Height = height };
         RunState runstate = Application.Begin (wizard);
+
         // TODO: Disabled until Dim.Auto is used in Dialog
         //TestHelpers.AssertDriverContentsWithFrameAre (
         //                                              $"{topRow}\n{row2}\n{row3}\n{separatorRow}\n{buttonRow}\n{bottomRow}",
         //                                              _output
         //                                             );
         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]
-    [AutoInitShutdown]
     public void ColorAndColorNamesConstructor ()
     {
         // Arrange & Act
@@ -26,7 +25,6 @@ public class AttributeTests
     }
 
     [Fact]
-    [AutoInitShutdown]
     public void ColorConstructor ()
     {
         // Arrange & Act
@@ -143,11 +141,8 @@ public class AttributeTests
     }
 
     [Fact]
-    [AutoInitShutdown]
     public void Equals_Initialized ()
     {
-        Assert.NotNull (Application.Driver);
-
         var attr1 = new Attribute (Color.Red, Color.Green);
         var attr2 = new Attribute (Color.Red, Color.Green);
 
@@ -324,7 +319,6 @@ public class AttributeTests
     }
 
     [Fact]
-    [AutoInitShutdown]
     public void NotEquals_Initialized ()
     {
         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)
     {
-        bool tryParseStatus = Color.TryParse (input, out Color? color);
+        bool tryParseStatus = Color.TryParse (input ?? string.Empty, out Color? color);
         Assert.False (tryParseStatus);
         Assert.Null (color);
     }
@@ -94,9 +94,9 @@ public partial class ColorTests
                     nameof (ColorTestsTheoryDataGenerators.TryParse_string_Returns_True_For_Valid_Inputs),
                     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.NotNull (color);
         Assert.IsType<Color> (color);

+ 121 - 114
UnitTests/Drawing/LineCanvasTests.cs

@@ -3,13 +3,9 @@ using Xunit.Abstractions;
 
 namespace Terminal.Gui.DrawingTests;
 
-public class LineCanvasTests
+public class LineCanvasTests (ITestOutputHelper output)
 {
-    private readonly ITestOutputHelper output;
-    public LineCanvasTests (ITestOutputHelper output) { this.output = output; }
-
     [Theory]
-    [AutoInitShutdown]
 
     // Horizontal lines with a vertical zero-length
     [InlineData (
@@ -293,12 +289,13 @@ public class LineCanvasTests
         View v = GetCanvas (out LineCanvas lc);
         v.Width = 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 ());
+        v.Dispose ();
     }
 
     [InlineData (
@@ -377,10 +374,10 @@ public class LineCanvasTests
     )
     {
         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 (
@@ -459,9 +456,9 @@ public class LineCanvasTests
     )
     {
         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]
@@ -482,28 +479,28 @@ public class LineCanvasTests
         // ║  ║2
 
         // 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
-        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 ╡
-        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 ╞
-        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
-        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
-        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 (
                                  output,
@@ -532,28 +529,28 @@ public class LineCanvasTests
         // ║  ║2
 
         // 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
-        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 ╡
-        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 ╞
-        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
-        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
-        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 (
                                  output,
@@ -598,7 +595,7 @@ public class LineCanvasTests
         var canvas = new LineCanvas ();
 
         // 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}");
     }
 
@@ -653,7 +650,7 @@ public class LineCanvasTests
     public void Length_n_Is_n_Long (int x, int y, int length, Orientation orientation, string expected)
     {
         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 ();
         TestHelpers.AssertEqual (output, expected, result);
@@ -731,7 +728,6 @@ public class LineCanvasTests
     }
 
     [Fact]
-    [AutoInitShutdown]
     public void TestLineCanvas_LeaveMargin_Top1_Left1 ()
     {
         var canvas = new LineCanvas ();
@@ -748,19 +744,19 @@ public class LineCanvasTests
     }
 
     [Fact]
-    [AutoInitShutdown]
+    [SetupFakeDriver]
     public void TestLineCanvas_Window_Heavy ()
     {
         View v = GetCanvas (out LineCanvas canvas);
 
         // outer box
         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 ();
 
@@ -772,10 +768,11 @@ public class LineCanvasTests
 ┃    ┃   ┃
 ┗━━━━┻━━━┛";
         TestHelpers.AssertDriverContentsAre (looksLike, output);
+        v.Dispose ();
     }
 
     [Theory]
-    [AutoInitShutdown]
+    [SetupFakeDriver]
     [InlineData (LineStyle.Single)]
     [InlineData (LineStyle.Rounded)]
     public void TestLineCanvas_Window_HeavyTop_ThinSides (LineStyle thinStyle)
@@ -784,12 +781,12 @@ public class LineCanvasTests
 
         // outer box
         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 ();
 
@@ -802,10 +799,11 @@ public class LineCanvasTests
 ┕━━━━┷━━━┙
 ";
         TestHelpers.AssertDriverContentsAre (looksLike, output);
+        v.Dispose ();
     }
 
     [Theory]
-    [AutoInitShutdown]
+    [SetupFakeDriver]
     [InlineData (LineStyle.Single)]
     [InlineData (LineStyle.Rounded)]
     public void TestLineCanvas_Window_ThinTop_HeavySides (LineStyle thinStyle)
@@ -814,12 +812,12 @@ public class LineCanvasTests
 
         // outer box
         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 ();
 
@@ -833,6 +831,7 @@ public class LineCanvasTests
 
 ";
         TestHelpers.AssertDriverContentsAre (looksLike, output);
+        v.Dispose ();
     }
 
     [Fact]
@@ -843,7 +842,7 @@ public class LineCanvasTests
 
         // Upper box
         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 =
             @"
@@ -862,7 +861,7 @@ public class LineCanvasTests
         canvas.AddLine (Point.Empty, 1, Orientation.Horizontal, LineStyle.Single);
 
         // Bottom   ─
-        canvas.AddLine (new Point (1, 1), -1, Orientation.Horizontal, LineStyle.Single);
+        canvas.AddLine (new (1, 1), -1, Orientation.Horizontal, LineStyle.Single);
 
         //// Right down
         //canvas.AddLine (new Point (9, 0), 3, Orientation.Vertical, LineStyle.Single);
@@ -873,7 +872,7 @@ public class LineCanvasTests
         //// Left Up
         //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 ();
         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)
     {
         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}");
     }
 
@@ -933,8 +932,8 @@ public class LineCanvasTests
     public void ToString_Positive_Horizontal_2Line_Offset (int x1, int y1, int x2, int y2, string expected)
     {
         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}");
     }
@@ -976,7 +975,7 @@ public class LineCanvasTests
     [InlineData (0, 0, 2, Orientation.Vertical, LineStyle.Double, "║\n║")]
     [InlineData (0, 0, 2, Orientation.Horizontal, LineStyle.Single, "──")]
     [InlineData (0, 0, 2, Orientation.Vertical, LineStyle.Single, "│\n│")]
-    [AutoInitShutdown]
+    [SetupFakeDriver]
     [Theory]
     public void View_Draws_1LineTests (
         int x1,
@@ -990,18 +989,19 @@ public class LineCanvasTests
         View v = GetCanvas (out LineCanvas lc);
         v.Width = 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 ();
 
         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>
     [Fact]
-    [AutoInitShutdown]
+    [SetupFakeDriver]
     public void View_Draws_Corner_Correct ()
     {
         View v = GetCanvas (out LineCanvas canvas);
@@ -1015,6 +1015,7 @@ public class LineCanvasTests
 ┌─
 │";
         TestHelpers.AssertDriverContentsAre (looksLike, output);
+        v.Dispose ();
     }
 
     /// <summary>
@@ -1022,12 +1023,12 @@ public class LineCanvasTests
     ///     another.
     /// </summary>
     [Fact]
-    [AutoInitShutdown]
+    [SetupFakeDriver]
     public void View_Draws_Corner_NoOverlap ()
     {
         View v = GetCanvas (out LineCanvas canvas);
         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 ();
 
@@ -1037,12 +1038,13 @@ public class LineCanvasTests
 │";
         TestHelpers.AssertDriverContentsAre (looksLike, output);
+        v.Dispose ();
     }
 
     [InlineData (LineStyle.Single)]
     [InlineData (LineStyle.Rounded)]
     [Theory]
-    [AutoInitShutdown]
+    [SetupFakeDriver]
     public void View_Draws_Horizontal (LineStyle style)
     {
         View v = GetCanvas (out LineCanvas canvas);
@@ -1054,10 +1056,11 @@ public class LineCanvasTests
             @"    
 ──";
         TestHelpers.AssertDriverContentsAre (looksLike, output);
+        v.Dispose ();
     }
 
     [Fact]
-    [AutoInitShutdown]
+    [SetupFakeDriver]
     public void View_Draws_Horizontal_Double ()
     {
         View v = GetCanvas (out LineCanvas canvas);
@@ -1069,12 +1072,13 @@ public class LineCanvasTests
             @" 
 ══";
         TestHelpers.AssertDriverContentsAre (looksLike, output);
+        v.Dispose ();
     }
 
     [InlineData (LineStyle.Single)]
     [InlineData (LineStyle.Rounded)]
     [Theory]
-    [AutoInitShutdown]
+    [SetupFakeDriver]
     public void View_Draws_Vertical (LineStyle style)
     {
         View v = GetCanvas (out LineCanvas canvas);
@@ -1087,10 +1091,11 @@ public class LineCanvasTests
 │";
         TestHelpers.AssertDriverContentsAre (looksLike, output);
+        v.Dispose ();
     }
 
     [Fact]
-    [AutoInitShutdown]
+    [SetupFakeDriver]
     public void View_Draws_Vertical_Double ()
     {
         View v = GetCanvas (out LineCanvas canvas);
@@ -1103,22 +1108,23 @@ public class LineCanvasTests
 ║";
         TestHelpers.AssertDriverContentsAre (looksLike, output);
+        v.Dispose ();
     }
 
     [Fact]
-    [AutoInitShutdown]
+    [SetupFakeDriver]
     public void View_Draws_Window_Double ()
     {
         View v = GetCanvas (out LineCanvas canvas);
 
         // outer box
         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 ();
 
@@ -1130,10 +1136,11 @@ public class LineCanvasTests
 ║    ║   ║
 ╚════╩═══╝";
         TestHelpers.AssertDriverContentsAre (looksLike, output);
+        v.Dispose ();
     }
 
     [Theory]
-    [AutoInitShutdown]
+    [SetupFakeDriver]
     [InlineData (LineStyle.Single)]
     [InlineData (LineStyle.Rounded)]
     public void View_Draws_Window_DoubleTop_SingleSides (LineStyle thinStyle)
@@ -1142,12 +1149,12 @@ public class LineCanvasTests
 
         // outer box
         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 ();
 
@@ -1160,6 +1167,7 @@ public class LineCanvasTests
 ╘════╧═══╛
 ";
         TestHelpers.AssertDriverContentsAre (looksLike, output);
+        v.Dispose ();
     }
 
     /// <summary>
@@ -1168,7 +1176,7 @@ public class LineCanvasTests
     ///     used.
     /// </summary>
     [Fact]
-    [AutoInitShutdown]
+    [SetupFakeDriver]
     public void View_Draws_Window_Rounded ()
     {
         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
         // 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.
-        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 ();
 
@@ -1196,24 +1204,25 @@ public class LineCanvasTests
 │    │   │
 ╰────┴───╯";
         TestHelpers.AssertDriverContentsAre (looksLike, output);
+        v.Dispose ();
     }
 
     [Theory]
-    [AutoInitShutdown]
     [InlineData (LineStyle.Single)]
     [InlineData (LineStyle.Rounded)]
+    [SetupFakeDriver]
     public void View_Draws_Window_SingleTop_DoubleSides (LineStyle thinStyle)
     {
         View v = GetCanvas (out LineCanvas canvas);
 
         // outer box
         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 ();
 
@@ -1227,6 +1236,7 @@ public class LineCanvasTests
 
 ";
         TestHelpers.AssertDriverContentsAre (looksLike, output);
+        v.Dispose ();
     }
 
     [Fact]
@@ -1237,13 +1247,13 @@ public class LineCanvasTests
 
         // Frame
         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
-        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 =
             @"
@@ -1270,22 +1280,22 @@ public class LineCanvasTests
 
         // ╔╡╞═════╗
         // 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
-        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 ╡
-        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 ╞
-        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
-        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
-        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 = @"
 ╔╡╞══╗
@@ -1304,12 +1314,9 @@ public class LineCanvasTests
     /// <returns></returns>
     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) =>
                                  {

+ 16 - 16
UnitTests/Drawing/RulerTests.cs

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

+ 10 - 16
UnitTests/Drawing/ThicknessTests.cs

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

+ 30 - 21
UnitTests/FileServices/FileDialogTests.cs

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

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

+ 3 - 1
UnitTests/TestHelpers.cs

@@ -77,7 +77,7 @@ public class AutoInitShutdownAttribute : BeforeAfterTestAttribute
         if (AutoInit)
         {
             // 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 ();
 #if DEBUG_IDISPOSABLE
             if (Responder.Instances.Count == 0)
@@ -171,6 +171,8 @@ public class SetupFakeDriverAttribute : BeforeAfterTestAttribute
         Debug.WriteLine ($"Before: {methodUnderTest.Name}");
         Assert.Null (Application.Driver);
         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);
     }
 }

+ 38 - 40
UnitTests/Text/AutocompleteTests.cs

@@ -3,11 +3,8 @@ using Xunit.Abstractions;
 
 namespace Terminal.Gui.TextTests;
 
-public class AutocompleteTests
+public class AutocompleteTests (ITestOutputHelper output)
 {
-    private readonly ITestOutputHelper _output;
-    public AutocompleteTests (ITestOutputHelper output) { _output = output; }
-
     [Fact]
     [AutoInitShutdown]
     public void CursorLeft_CursorRight_Mouse_Button_Pressed_Does_Not_Show_Popup ()
@@ -34,7 +31,7 @@ public class AutocompleteTests
                 TestHelpers.AssertDriverContentsWithFrameAre (
                                                               @"
 This a long line and against TextView.",
-                                                              _output
+                                                              output
                                                              );
             }
             else
@@ -44,15 +41,15 @@ This a long line and against TextView.",
 This a long line and against TextView.
      and                              
      against                          ",
-                                                              _output
+                                                              output
                                                              );
             }
         }
 
         Assert.True (
                      tv.NewMouseEvent (
-                                    new MouseEvent { Position = new (6, 0), Flags = MouseFlags.Button1Pressed }
-                                   )
+                                       new() { Position = new (6, 0), Flags = MouseFlags.Button1Pressed }
+                                      )
                     );
         Application.Refresh ();
 
@@ -61,7 +58,7 @@ This a long line and against TextView.
 This a long line and against TextView.
      and                              
      against                          ",
-                                                      _output
+                                                      output
                                                      );
 
         Assert.True (tv.NewKeyDownEvent (Key.G));
@@ -71,7 +68,7 @@ This a long line and against TextView.
                                                       @"
 This ag long line and against TextView.
      against                           ",
-                                                      _output
+                                                      output
                                                      );
 
         Assert.True (tv.NewKeyDownEvent (Key.CursorLeft));
@@ -81,7 +78,7 @@ This ag long line and against TextView.
                                                       @"
 This ag long line and against TextView.
      against                           ",
-                                                      _output
+                                                      output
                                                      );
 
         Assert.True (tv.NewKeyDownEvent (Key.CursorLeft));
@@ -91,7 +88,7 @@ This ag long line and against TextView.
                                                       @"
 This ag long line and against TextView.
      against                           ",
-                                                      _output
+                                                      output
                                                      );
 
         Assert.True (tv.NewKeyDownEvent (Key.CursorLeft));
@@ -100,7 +97,7 @@ This ag long line and against TextView.
         TestHelpers.AssertDriverContentsWithFrameAre (
                                                       @"
 This ag long line and against TextView.",
-                                                      _output
+                                                      output
                                                      );
 
         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.
      against                           ",
-                                                          _output
+                                                          output
                                                          );
         }
 
@@ -124,7 +121,7 @@ This ag long line and against TextView.
 This a long line and against TextView.
      and                              
      against                          ",
-                                                      _output
+                                                      output
                                                      );
 
         Assert.True (tv.NewKeyDownEvent (Key.N));
@@ -134,7 +131,7 @@ This a long line and against TextView.
                                                       @"
 This an long line and against TextView.
      and                               ",
-                                                      _output
+                                                      output
                                                      );
 
         Assert.True (tv.NewKeyDownEvent (Key.CursorRight));
@@ -143,8 +140,9 @@ This an long line and against TextView.
         TestHelpers.AssertDriverContentsWithFrameAre (
                                                       @"
 This an long line and against TextView.",
-                                                      _output
+                                                      output
                                                      );
+        top.Dispose ();
     }
 
     [Fact]
@@ -175,7 +173,7 @@ This an long line and against TextView.",
         Assert.True (tv.NewKeyDownEvent (Key.F.WithShift));
         top.Draw ();
         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 ("Fortunately", tv.Autocomplete.Suggestions [0].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));
         top.Draw ();
         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 ("Fortunately", tv.Autocomplete.Suggestions [0].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));
         top.Draw ();
         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 ("Fortunately", tv.Autocomplete.Suggestions [0].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));
         top.Draw ();
         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 ("Fortunately", tv.Autocomplete.Suggestions [0].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));
         top.Draw ();
         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 ("Fortunately", tv.Autocomplete.Suggestions [0].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.True (tv.Autocomplete.Visible);
         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 (new Point (1, 0), tv.CursorPosition);
+        Assert.Equal (new (1, 0), tv.CursorPosition);
         Assert.Empty (tv.Autocomplete.Suggestions);
         Assert.Equal (3, g.AllSuggestions.Count);
         Assert.False (tv.Autocomplete.Visible);
         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 (new Point (1, 0), tv.CursorPosition);
+        Assert.Equal (new (1, 0), tv.CursorPosition);
         Assert.Equal (2, tv.Autocomplete.Suggestions.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 ();
         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.Equal (3, g.AllSuggestions.Count);
         Assert.False (tv.Autocomplete.Visible);
+        top.Dispose ();
     }
 
     [Fact]
@@ -246,7 +245,7 @@ This an long line and against TextView.",
         var ac = new TextViewAutocomplete ();
 
         ((SingleWordSuggestionGenerator)ac.SuggestionGenerator).AllSuggestions =
-            new List<string> { "fish", "const", "Cobble" };
+            new() { "fish", "const", "Cobble" };
 
         var tv = new TextView ();
         tv.InsertText ("co");
@@ -254,10 +253,10 @@ This an long line and against TextView.",
         ac.HostControl = tv;
 
         ac.GenerateSuggestions (
-                                new AutocompleteContext (
-                                                         TextModel.ToRuneCellList (tv.Text),
-                                                         2
-                                                        )
+                                new (
+                                     TextModel.ToRuneCellList (tv.Text),
+                                     2
+                                    )
                                );
 
         Assert.Equal (2, ac.Suggestions.Count);
@@ -266,7 +265,6 @@ This an long line and against TextView.",
     }
 
     [Fact]
-    [AutoInitShutdown]
     public void TestSettingColorSchemeOnAutocomplete ()
     {
         var tv = new TextView ();
@@ -275,19 +273,19 @@ This an long line and against TextView.",
         Assert.Same (Colors.ColorSchemes ["Menu"], tv.Autocomplete.ColorScheme);
 
         // 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
         Assert.NotSame (Colors.ColorSchemes ["Menu"], tv.Autocomplete.ColorScheme);
 
         // 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
         FrameView _settingsPane;
-        CheckBox _computedCheckBox;
         FrameView _locationFrame;
         RadioGroup _xRadioGroup;
         TextField _xText;
@@ -165,15 +164,13 @@ public class ScenarioTests : TestsAllViews
             ColorScheme = Colors.ColorSchemes ["TopLevel"],
             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)" };
 
         _locationFrame = new ()
         {
-            X = Pos.Left (_computedCheckBox),
-            Y = Pos.Bottom (_computedCheckBox),
+            X = 0,
+            Y = 0,
             Height = 3 + radioItems.Length,
             Width = 36,
             Title = "Location (Pos)"
@@ -250,15 +247,6 @@ public class ScenarioTests : TestsAllViews
                                                   _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);
 
         _xText.TextChanged += (s, args) =>
@@ -352,12 +340,8 @@ public class ScenarioTests : TestsAllViews
                 return;
             }
 
-            LayoutStyle layout = view.LayoutStyle;
-
             try
             {
-                //view.LayoutStyle = LayoutStyle.Absolute;
-
                 switch (_xRadioGroup.SelectedItem)
                 {
                     case 0:
@@ -532,9 +516,6 @@ public class ScenarioTests : TestsAllViews
                 view?.GetType ().GetProperty ("Source")?.GetSetMethod ()?.Invoke (view, new [] { source });
             }
 
-            // Set Settings
-            _computedCheckBox.Checked = view.LayoutStyle == LayoutStyle.Computed;
-
             // Add
             _hostPane.Add (view);
 

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

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

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

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

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

@@ -2,22 +2,19 @@
 
 namespace Terminal.Gui.ViewTests;
 
-public class PaddingTests
+public class PaddingTests (ITestOutputHelper output)
 {
-    private readonly ITestOutputHelper _output;
-    public PaddingTests (ITestOutputHelper output) { _output = output; }
-
     [Fact]
     [SetupFakeDriver]
     public void Padding_Uses_Parent_ColorScheme ()
     {
         ((FakeDriver)Application.Driver).SetBufferSize (5, 5);
         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 ());
@@ -34,7 +31,7 @@ public class PaddingTests
 PPP
 P P
 PPP",
-                                             _output
+                                             output
                                             );
         TestHelpers.AssertDriverAttributesAre ("0", null, view.GetNormalColor ());
     }

+ 7 - 6
UnitTests/View/DiagnosticsTests.cs

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

+ 17 - 14
UnitTests/View/DrawTests.cs

@@ -155,12 +155,9 @@ public class DrawTests (ITestOutputHelper _output)
                                                       _output);
     }
 
-    [Theory]
-    [InlineData (0, 0, 1, 1)]
-    [InlineData (0, 0, 2, 2)]
-    [InlineData (-1, -1, 2, 2)]
+    [Fact]
     [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 () };
 
@@ -193,12 +190,9 @@ public class DrawTests (ITestOutputHelper _output)
                                                       _output);
     }
 
-    [Theory]
-    [InlineData (0, 0, 1, 1)]
-    [InlineData (0, 0, 2, 2)]
-    [InlineData (-1, -1, 2, 2)]
+    [Fact]
     [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 () };
 
@@ -270,6 +264,7 @@ public class DrawTests (ITestOutputHelper _output)
         TestHelpers.AssertDriverContentsAre (expectedOutput, _output);
 
         // 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
@@ -326,7 +321,9 @@ public class DrawTests (ITestOutputHelper _output)
         Assert.Equal (new Rectangle (0, 0, 30, 10), pos);
 
         Application.End (rsDiag);
+        dg.Dispose ();
         Application.End (rsTop);
+        top.Dispose ();
     }
 
     [Fact]
@@ -385,8 +382,9 @@ public class DrawTests (ITestOutputHelper _output)
                                                0
                                                """,
                                                Application.Driver,
-                                               Colors.ColorSchemes ["Base"].Normal
+                                               Colors.ColorSchemes ["Base"]!.Normal
                                               );
+        top.Dispose ();
     }
 
     [Fact]
@@ -647,6 +645,7 @@ public class DrawTests (ITestOutputHelper _output)
         content.Y = 0;
         Application.Refresh ();
         TestHelpers.AssertDriverContentsWithFrameAre ("", _output);
+        top.Dispose ();
     }
 
     [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???
 
-        void Top_LayoutComplete (object sender, LayoutEventArgs e) { Application.Driver.Clip = container.Frame; }
-
         top.LayoutComplete += Top_LayoutComplete;
         Application.Begin (top);
 
@@ -726,6 +723,11 @@ public class DrawTests (ITestOutputHelper _output)
         content.Y = 0;
         Application.Refresh ();
         TestHelpers.AssertDriverContentsWithFrameAre ("", _output);
+        top.Dispose ();
+
+        return;
+
+        void Top_LayoutComplete (object? sender, LayoutEventArgs e) { Application.Driver.Clip = container.Frame; }
     }
 
     [Fact]
@@ -849,6 +851,7 @@ public class DrawTests (ITestOutputHelper _output)
         content.Y = 0;
         Application.Refresh ();
         TestHelpers.AssertDriverContentsWithFrameAre ("", _output);
+        top.Dispose ();
     }
 
     [Theory]
@@ -898,7 +901,7 @@ public class DrawTests (ITestOutputHelper _output)
         TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
 
         TestHelpers.AssertDriverContentsAre (expected, _output);
-
+        top.Dispose ();
         // 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 ();
         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 (superView.IsInitialized, "SuperView should not be initialized");

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

@@ -1,16 +1,10 @@
 using Xunit.Abstractions;
 
-//using GraphViewTests = Terminal.Gui.Views.GraphViewTests;
-
-// Alias Console to MockConsole so we don't accidentally use Console
-
 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]
     [TestRespondersDisposed]
@@ -22,11 +16,10 @@ public class AbsoluteLayoutTests
         var v = new View { Frame = frame };
         v.Height = newFrame.Height;
         v.Width = newFrame.Width;
-        Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
         Assert.Equal (newFrame, v.Frame);
 
         Assert.Equal (
-                      new Rectangle (0, 0, newFrame.Width, newFrame.Height),
+                      new (0, 0, newFrame.Width, newFrame.Height),
                       v.Viewport
                      ); // With Absolute Viewport *is* deterministic before Layout
         Assert.Equal (Pos.Absolute (1), v.X);
@@ -43,7 +36,6 @@ public class AbsoluteLayoutTests
         var v = new View { Frame = Rectangle.Empty };
         v.Height = Dim.Fill ();
         v.Width = Dim.Fill ();
-        Assert.True (v.LayoutStyle == LayoutStyle.Computed);
         v.Dispose ();
     }
 
@@ -57,11 +49,10 @@ public class AbsoluteLayoutTests
         var v = new View { Frame = frame };
         v.X = newFrame.X;
         v.Y = newFrame.Y;
-        Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
         Assert.Equal (newFrame, v.Frame);
 
         Assert.Equal (
-                      new Rectangle (0, 0, newFrame.Width, newFrame.Height),
+                      new (0, 0, newFrame.Width, newFrame.Height),
                       v.Viewport
                      ); // With Absolute Viewport *is* deterministic before Layout
         Assert.Equal ($"Absolute({newFrame.X})", v.X.ToString ());
@@ -78,7 +69,6 @@ public class AbsoluteLayoutTests
         var v = new View { Frame = Rectangle.Empty };
         v.X = Pos.Center ();
         v.Y = Pos.Center ();
-        Assert.True (v.LayoutStyle == LayoutStyle.Computed);
         v.Dispose ();
     }
 
@@ -91,73 +81,61 @@ public class AbsoluteLayoutTests
         v.Y = 2;
         v.Height = 3;
         v.Width = 4;
-        Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
         v.Dispose ();
 
-        v = new View { Frame = Rectangle.Empty };
+        v = new() { Frame = Rectangle.Empty };
         v.X = Pos.Center ();
         v.Y = Pos.Center ();
         v.Width = Dim.Fill ();
         v.Height = Dim.Fill ();
-        Assert.True (v.LayoutStyle == LayoutStyle.Computed);
         v.Dispose ();
 
-        v = new View { Frame = Rectangle.Empty };
+        v = new() { Frame = Rectangle.Empty };
         v.X = Pos.Center ();
         v.Y = Pos.Center ();
         v.Width = Dim.Fill ();
         v.Height = Dim.Fill ();
-        Assert.True (v.LayoutStyle == LayoutStyle.Computed);
 
         v.X = 1;
-        Assert.True (v.LayoutStyle == LayoutStyle.Computed);
         v.Dispose ();
 
-        v = new View { Frame = Rectangle.Empty };
+        v = new() { Frame = Rectangle.Empty };
         v.X = Pos.Center ();
         v.Y = Pos.Center ();
         v.Width = Dim.Fill ();
         v.Height = Dim.Fill ();
-        Assert.True (v.LayoutStyle == LayoutStyle.Computed);
 
         v.Y = 2;
-        Assert.True (v.LayoutStyle == LayoutStyle.Computed);
         v.Dispose ();
 
-        v = new View { Frame = Rectangle.Empty };
+        v = new() { Frame = Rectangle.Empty };
         v.X = Pos.Center ();
         v.Y = Pos.Center ();
         v.Width = Dim.Fill ();
         v.Height = Dim.Fill ();
-        Assert.True (v.LayoutStyle == LayoutStyle.Computed);
 
         v.Width = 3;
-        Assert.True (v.LayoutStyle == LayoutStyle.Computed);
         v.Dispose ();
 
-        v = new View { Frame = Rectangle.Empty };
+        v = new() { Frame = Rectangle.Empty };
         v.X = Pos.Center ();
         v.Y = Pos.Center ();
         v.Width = Dim.Fill ();
         v.Height = Dim.Fill ();
-        Assert.True (v.LayoutStyle == LayoutStyle.Computed);
 
         v.Height = 3;
-        Assert.True (v.LayoutStyle == LayoutStyle.Computed);
         v.Dispose ();
 
-        v = new View { Frame = Rectangle.Empty };
+        v = new() { Frame = Rectangle.Empty };
         v.X = Pos.Center ();
         v.Y = Pos.Center ();
         v.Width = Dim.Fill ();
         v.Height = Dim.Fill ();
-        Assert.True (v.LayoutStyle == LayoutStyle.Computed);
 
         v.X = 1;
         v.Y = 2;
         v.Height = 3;
         v.Width = 4;
-        Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
         v.Dispose ();
     }
 
@@ -166,16 +144,14 @@ public class AbsoluteLayoutTests
     public void AbsoluteLayout_Constructor ()
     {
         var v = new View ();
-        Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
         v.Dispose ();
 
         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 (
-                      new Rectangle (0, 0, frame.Width, frame.Height),
+                      new (0, 0, frame.Width, frame.Height),
                       v.Viewport
                      ); // With Absolute Viewport *is* deterministic before Layout
         Assert.Equal (Pos.Absolute (0), v.X);
@@ -184,13 +160,12 @@ public class AbsoluteLayoutTests
         Assert.Equal (Dim.Absolute (0), v.Height);
         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 (
-                      new Rectangle (0, 0, frame.Width, frame.Height),
+                      new (0, 0, frame.Width, frame.Height),
                       v.Viewport
                      ); // With Absolute Viewport *is* deterministic before Layout
         Assert.Equal (Pos.Absolute (1), v.X);
@@ -199,12 +174,11 @@ public class AbsoluteLayoutTests
         Assert.Equal (Dim.Absolute (4), v.Height);
         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 (
-                      new Rectangle (0, 0, frame.Width, frame.Height),
+                      new (0, 0, frame.Width, frame.Height),
                       v.Viewport
                      ); // With Absolute Viewport *is* deterministic before Layout
         Assert.Equal (Pos.Absolute (1), v.X);
@@ -213,34 +187,28 @@ public class AbsoluteLayoutTests
         Assert.Equal (Dim.Absolute (4), v.Height);
         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 (2), v.Y);
         Assert.Equal (Dim.Absolute (0), v.Width);
         Assert.Equal (Dim.Absolute (0), v.Height);
         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.Y);
         Assert.Equal (Dim.Absolute (0), v.Width);
         Assert.Equal (Dim.Absolute (0), v.Height);
         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 (2), v.Y);
         Assert.Equal (Dim.Absolute (3), v.Width);
@@ -254,20 +222,15 @@ public class AbsoluteLayoutTests
     {
         var superRect = new Rectangle (0, 0, 100, 100);
         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 };
-        Assert.True (v1.LayoutStyle == LayoutStyle.Absolute);
 
         var v2 = new View { X = 10, Y = 10, Width = 10, Height = 10 };
-        Assert.True (v2.LayoutStyle == LayoutStyle.Absolute);
 
         super.Add (v1, v2);
-        Assert.True (v1.LayoutStyle == LayoutStyle.Absolute);
-        Assert.True (v2.LayoutStyle == LayoutStyle.Absolute);
 
         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 ();
     }
 }

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

@@ -671,7 +671,7 @@ public class DimAutoTests (ITestOutputHelper output)
 
         superView.BeginInit ();
         superView.EndInit ();
-        superView.SetRelativeLayout (superView.ContentSize);
+        superView.SetRelativeLayout (superView.GetContentSize ());
 
         superView.LayoutSubviews ();
         Assert.Equal (expectedSubWidth, subView.Frame.Width);
@@ -720,7 +720,7 @@ public class DimAutoTests (ITestOutputHelper output)
 
         superView.BeginInit ();
         superView.EndInit ();
-        superView.SetRelativeLayout (superView.ContentSize);
+        superView.SetRelativeLayout (superView.GetContentSize ());
 
         superView.LayoutSubviews ();
         Assert.Equal (expectedSubWidth, subView.Frame.Width);
@@ -745,7 +745,7 @@ public class DimAutoTests (ITestOutputHelper output)
         super.Add (view);
 
         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.Viewport);
 
@@ -943,19 +943,19 @@ public class DimAutoTests (ITestOutputHelper output)
         };
 
         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
         view.Text = "0123456789";
 
         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
         view.Width = 5;
         view.Height = 1;
 
-        Assert.Equal (new Size (5, 1), view.ContentSize);
+        Assert.Equal (new Size (5, 1), view.GetContentSize ());
     }
 
     // DimAutoStyle.Content tests
@@ -972,6 +972,22 @@ public class DimAutoTests (ITestOutputHelper output)
         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]
     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));
         Assert.Equal (32, view.Frame.Width);
         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 static Terminal.Gui.Dim;
 
-
-// Alias Console to MockConsole so we don't accidentally use Console
-using Console = Terminal.Gui.FakeConsole;
-
 namespace Terminal.Gui.LayoutTests;
 
 public class DimTests
@@ -28,7 +24,7 @@ public class DimTests
     public void DimAbsolute_Calculate_ReturnsCorrectValue ()
     {
         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);
     }
 
@@ -144,39 +140,7 @@ public class DimTests
         Application.Run (top);
 
         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
@@ -203,64 +167,10 @@ public class DimTests
         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]
     public void DimHeight_Set_To_Null_Throws ()
     {
-        Dim dim = Dim.Height (null);
+        Dim dim = Height (null);
         Assert.Throws<NullReferenceException> (() => dim.ToString ());
     }
 
@@ -270,13 +180,13 @@ public class DimTests
     {
         var testVal = Rectangle.Empty;
         var testValview = new View { Frame = testVal };
-        Dim dim = Dim.Height (testValview);
+        Dim dim = Height (testValview);
         Assert.Equal ($"View(Height,View(){testVal})", dim.ToString ());
         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 ());
         testValview.Dispose ();
     }
@@ -299,7 +209,7 @@ public class DimTests
         Assert.Equal (dimCombine.Right, dimAbsolute);
         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);
         Assert.Equal (1, dimViewHeight.GetAnchor (0));
         var dimViewWidth = new DimView (view, Dimension.Width);
@@ -323,7 +233,7 @@ public class DimTests
         {
             X = 0,
             Y = 0,
-            Width = Dim.Percent (50),
+            Width = Percent (50),
             Height = 5,
             Title = "f1"
         };
@@ -332,7 +242,7 @@ public class DimTests
         {
             X = Pos.Right (f1),
             Y = 0,
-            Width = Dim.Fill (),
+            Width = Fill (),
             Height = 5,
             Title = "f2"
         };
@@ -341,8 +251,8 @@ public class DimTests
         {
             X = Pos.X (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,
             Text = "v1"
         };
@@ -351,32 +261,32 @@ public class DimTests
         {
             X = Pos.X (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,
             Text = "v2"
         };
 
         var v3 = new Button
         {
-            Width = Dim.Percent (10),
-            Height = Dim.Percent (10),
+            Width = Percent (10),
+            Height = Percent (10),
             ValidatePosDim = true,
             Text = "v3"
         };
 
         var v4 = new Button
         {
-            Width = Dim.Absolute (50),
-            Height = Dim.Absolute (50),
+            Width = Absolute (50),
+            Height = Absolute (50),
             ValidatePosDim = true,
             Text = "v4"
         };
 
         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,
             Text = "v5"
         };
@@ -385,8 +295,8 @@ public class DimTests
         {
             X = Pos.X (f2),
             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,
             Text = "v6"
         };
@@ -449,10 +359,10 @@ public class DimTests
 #else
                        Assert.Equal ($"Combine(View(Height,Button(){v1.Frame})-View(Height,Button(){v3.Viewport}))", v5.Height.ToString ( ));
 #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 (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
 
                        w.Width = 200;
@@ -482,7 +392,7 @@ public class DimTests
                        Assert.Equal ($"Combine(View(Width,FrameView(){f1.Frame})-Absolute(2))", v1.Width.ToString ());
 #endif
                        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
 
                        v2.Text = "Button2";
@@ -493,21 +403,22 @@ public class DimTests
                        Assert.Equal ($"Combine(View(Width,FrameView(){f2.Frame})-Absolute(2))", v2.Width.ToString ());
 #endif
                        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
 
                        v3.Text = "Button3";
 
                        // 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);
+
                        // 199*10%=19
                        Assert.Equal (19, v3.Frame.Height);
 
                        v4.Text = "Button4";
-                       v4.Width = Auto(DimAutoStyle.Text);
+                       v4.Width = 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 (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 ());
 #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
 
                        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
                    };
 
         Application.Iteration += (s, a) => Application.RequestStop ();
 
         Application.Run (t);
+        t.Dispose ();
     }
 
     // TODO: This actually a SetRelativeLayout/LayoutSubViews test and should be moved
@@ -544,8 +456,8 @@ public class DimTests
 
         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"
         };
 
@@ -563,39 +475,39 @@ public class DimTests
     {
         var n1 = 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);
 
         n1 = n2 = 1;
-        dim1 = Dim.Absolute (n1);
-        dim2 = Dim.Absolute (n2);
+        dim1 = Absolute (n1);
+        dim2 = Absolute (n2);
         Assert.Equal (dim1, dim2);
 
         n1 = n2 = -1;
-        dim1 = Dim.Absolute (n1);
-        dim2 = Dim.Absolute (n2);
+        dim1 = Absolute (n1);
+        dim2 = Absolute (n2);
         Assert.Equal (dim1, dim2);
 
         n1 = 0;
         n2 = 1;
-        dim1 = Dim.Absolute (n1);
-        dim2 = Dim.Absolute (n2);
+        dim1 = Absolute (n1);
+        dim2 = Absolute (n2);
         Assert.NotEqual (dim1, dim2);
     }
 
     [Fact]
     public void DimSized_SetsValue ()
     {
-        Dim dim = Dim.Absolute (0);
+        Dim dim = Absolute (0);
         Assert.Equal ("Absolute(0)", dim.ToString ());
 
         var testVal = 5;
-        dim = Dim.Absolute (testVal);
+        dim = Absolute (testVal);
         Assert.Equal ($"Absolute({testVal})", dim.ToString ());
 
         testVal = -1;
-        dim = Dim.Absolute (testVal);
+        dim = Absolute (testVal);
         Assert.Equal ($"Absolute({testVal})", dim.ToString ());
     }
 
@@ -610,8 +522,8 @@ public class DimTests
 
         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"
         };
 
@@ -657,39 +569,39 @@ public class DimTests
         var testRect2 = Rectangle.Empty;
         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.
         Assert.Equal (dim1, dim2);
 
-        dim2 = Dim.Width (view2);
+        dim2 = Width (view2);
         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.
         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.
         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;
-        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);
 #if DEBUG_IDISPOSABLE
 
@@ -702,7 +614,7 @@ public class DimTests
     [Fact]
     public void DimWidth_Set_To_Null_Throws ()
     {
-        Dim dim = Dim.Width (null);
+        Dim dim = Width (null);
         Assert.Throws<NullReferenceException> (() => dim.ToString ());
     }
 
@@ -712,13 +624,13 @@ public class DimTests
     {
         var testVal = Rectangle.Empty;
         var testValView = new View { Frame = testVal };
-        Dim dim = Dim.Width (testValView);
+        Dim dim = Width (testValView);
         Assert.Equal ($"View(Width,View(){testVal})", dim.ToString ());
         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 ());
         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 v = new View ();
-        Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
         v.Dispose ();
 
         v = new View { Frame = frame };
-        Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
 
         v.Frame = newFrame;
-        Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
         Assert.Equal (newFrame, v.Frame);
 
         Assert.Equal (
@@ -62,7 +59,6 @@ public class FrameTests (ITestOutputHelper output)
 
         v = new View { X = frame.X, Y = frame.Y, Text = "v" };
         v.Frame = newFrame;
-        Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
         Assert.Equal (newFrame, v.Frame);
 
         Assert.Equal (
@@ -78,7 +74,6 @@ public class FrameTests (ITestOutputHelper output)
         newFrame = new Rectangle (10, 20, 30, 40);
         v = new View { Frame = frame };
         v.Frame = newFrame;
-        Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
         Assert.Equal (newFrame, v.Frame);
 
         Assert.Equal (
@@ -93,7 +88,6 @@ public class FrameTests (ITestOutputHelper output)
 
         v = new View { X = frame.X, Y = frame.Y, Text = "v" };
         v.Frame = newFrame;
-        Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
         Assert.Equal (newFrame, v.Frame);
 
         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 (68, 22, 10, 1), tv.Frame);
         Application.End (rs);
+        top.Dispose ();
     }
 
     // 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);
 
         Application.End (rs);
+        top.Dispose ();
     }
 
     [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.Pos;
 
@@ -16,7 +15,6 @@ public class PosCenterTests (ITestOutputHelper output)
         Assert.NotNull (posCenter);
     }
 
-
     [Fact]
     public void PosCenter_Equals ()
     {
@@ -27,7 +25,6 @@ public class PosCenterTests (ITestOutputHelper output)
         Assert.False (posCenter2.Equals (posCenter1));
     }
 
-
     [Fact]
     public void PosCenter_ToString ()
     {
@@ -42,7 +39,7 @@ public class PosCenterTests (ITestOutputHelper output)
     {
         var posCenter = new PosCenter ();
         var width = 50;
-        var expectedAnchor = width / 2;
+        int expectedAnchor = width / 2;
 
         Assert.Equal (expectedAnchor, posCenter.GetAnchor (width));
     }
@@ -50,16 +47,15 @@ public class PosCenterTests (ITestOutputHelper output)
     [Fact]
     public void PosCenter_CreatesCorrectInstance ()
     {
-        var pos = Pos.Center ();
+        Pos pos = Center ();
         Assert.IsType<PosCenter> (pos);
     }
 
-
     [Fact]
     public void PosCenter_Calculate_ReturnsExpectedValue ()
     {
         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);
     }
 
@@ -77,11 +73,11 @@ public class PosCenterTests (ITestOutputHelper output)
     [InlineData (10)]
     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
         {
-            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);
@@ -200,12 +196,14 @@ public class PosCenterTests (ITestOutputHelper output)
 │ └─────────────┘  │
 │                  │
 └──────────────────┘"
-                ;
+                    ;
+
                 break;
         }
 
         _ = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
         Application.End (rs);
+        win.Dispose ();
     }
 
     [Theory]
@@ -222,11 +220,11 @@ public class PosCenterTests (ITestOutputHelper output)
     [InlineData (10)]
     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
         {
-            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);
@@ -241,7 +239,7 @@ public class PosCenterTests (ITestOutputHelper output)
         switch (width)
         {
             case 1:
-                Assert.Equal (new Rectangle (0, 0, 0, 4), subview.Frame);
+                Assert.Equal (new (0, 0, 0, 4), subview.Frame);
 
                 expected = @"
@@ -254,7 +252,7 @@ public class PosCenterTests (ITestOutputHelper output)
 
                 break;
             case 2:
-                Assert.Equal (new Rectangle (0, 0, 0, 4), subview.Frame);
+                Assert.Equal (new (0, 0, 0, 4), subview.Frame);
 
                 expected = @"
 ┌┐
@@ -267,7 +265,7 @@ public class PosCenterTests (ITestOutputHelper output)
 
                 break;
             case 3:
-                Assert.Equal (new Rectangle (0, 0, 0, 4), subview.Frame);
+                Assert.Equal (new (0, 0, 0, 4), subview.Frame);
 
                 expected = @"
 ┌─┐
@@ -280,7 +278,7 @@ public class PosCenterTests (ITestOutputHelper output)
 
                 break;
             case 4:
-                Assert.Equal (new Rectangle (0, 0, 1, 4), subview.Frame);
+                Assert.Equal (new (0, 0, 1, 4), subview.Frame);
 
                 expected = @"
 ┌──┐
@@ -293,7 +291,7 @@ public class PosCenterTests (ITestOutputHelper output)
 
                 break;
             case 5:
-                Assert.Equal (new Rectangle (0, 0, 2, 4), subview.Frame);
+                Assert.Equal (new (0, 0, 2, 4), subview.Frame);
 
                 expected = @"
 ┌───┐
@@ -306,7 +304,7 @@ public class PosCenterTests (ITestOutputHelper output)
 
                 break;
             case 6:
-                Assert.Equal (new Rectangle (0, 0, 3, 4), subview.Frame);
+                Assert.Equal (new (0, 0, 3, 4), subview.Frame);
 
                 expected = @"
 ┌────┐
@@ -319,7 +317,7 @@ public class PosCenterTests (ITestOutputHelper output)
 
                 break;
             case 7:
-                Assert.Equal (new Rectangle (0, 0, 4, 4), subview.Frame);
+                Assert.Equal (new (0, 0, 4, 4), subview.Frame);
 
                 expected = @"
 ┌─────┐
@@ -332,7 +330,7 @@ public class PosCenterTests (ITestOutputHelper output)
 
                 break;
             case 8:
-                Assert.Equal (new Rectangle (0, 0, 5, 4), subview.Frame);
+                Assert.Equal (new (0, 0, 5, 4), subview.Frame);
 
                 expected = @"
 ┌──────┐
@@ -345,7 +343,7 @@ public class PosCenterTests (ITestOutputHelper output)
 
                 break;
             case 9:
-                Assert.Equal (new Rectangle (1, 0, 5, 4), subview.Frame);
+                Assert.Equal (new (1, 0, 5, 4), subview.Frame);
 
                 expected = @"
 ┌───────┐
@@ -358,7 +356,7 @@ public class PosCenterTests (ITestOutputHelper output)
 
                 break;
             case 10:
-                Assert.Equal (new Rectangle (1, 0, 6, 4), subview.Frame);
+                Assert.Equal (new (1, 0, 6, 4), subview.Frame);
 
                 expected = @"
 ┌────────┐
@@ -368,11 +366,13 @@ public class PosCenterTests (ITestOutputHelper output)
 │ └────┘ │
 │        │
 └────────┘"
-                ;
+                    ;
+
                 break;
         }
 
         _ = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
         Application.End (rs);
+        win.Dispose ();
     }
 }

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

@@ -66,7 +66,6 @@ public class PosCombineTests (ITestOutputHelper output)
     [SetupFakeDriver]
     public void PosCombine_DimCombine_View_With_SubViews ()
     {
-        var clicked = false;
         Toplevel top = new Toplevel () { Width = 80, Height = 25 };
         var win1 = new Window { Id = "win1", Width = 20, Height = 10 };
         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 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 };
 
         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;
 
 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: A new test that calls SetRelativeLayout directly is needed.
     [Theory]
-    [AutoInitShutdown]
     [InlineData (true)]
     [InlineData (false)]
     public void PosPercent_PlusOne (bool testHorizontal)
@@ -21,8 +18,8 @@ public class PosPercentTests (ITestOutputHelper output)
 
         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,
             Height = 10
         };
@@ -45,29 +42,31 @@ public class PosPercentTests (ITestOutputHelper output)
             Assert.Equal (1, view.Frame.X);
             Assert.Equal (61, view.Frame.Y);
         }
+
+        top.Dispose ();
     }
 
     [Fact]
     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 ());
         f = 50;
-        pos = Pos.Percent (f);
+        pos = Percent (f);
         Assert.Equal ($"Percent({f})", pos.ToString ());
         f = 100;
-        pos = Pos.Percent (f);
+        pos = Percent (f);
         Assert.Equal ($"Percent({f})", pos.ToString ());
     }
 
     [Fact]
     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 (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 v = new View { Frame = frame };
-        Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
 
         v.Viewport = newViewport;
-        Assert.True (v.LayoutStyle == LayoutStyle.Absolute);
         Assert.Equal (newViewport, v.Viewport);
         Assert.Equal (new Rectangle (1, 2, newViewport.Width, newViewport.Height), v.Frame);
         Assert.Equal (new Rectangle (0, 0, newViewport.Width, newViewport.Height), v.Viewport);
@@ -340,14 +338,57 @@ public class ViewportTests (ITestOutputHelper output)
     }
 
     [Fact]
-    public void ContentSize_Matches_ViewportSize_If_Not_Set ()
+    public void ContentSize_Tracks_ViewportSize_If_Not_Set ()
     {
         View view = new ()
         {
             Width = 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]

+ 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 });
 
         Assert.Equal (expectedMoved, new Point (5, 5) == testView.Frame.Location);
+        top.Dispose ();
     }
 
     [Theory]

+ 17 - 12
UnitTests/View/NavigationTests.cs

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

+ 42 - 1
UnitTests/View/SubviewTests.cs

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

+ 6 - 3
UnitTests/View/ViewKeyBindingTests.cs

@@ -2,10 +2,9 @@
 
 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]
     [AutoInitShutdown]
@@ -42,6 +41,7 @@ public class ViewKeyBindingTests
         Assert.True (view.ApplicationCommand);
         Assert.True (view.HotKeyCommand);
         Assert.True (view.FocusedCommand);
+        top.Dispose ();
     }
 
     [Fact]
@@ -69,6 +69,7 @@ public class ViewKeyBindingTests
         Assert.False (view.ApplicationCommand);
         Assert.False (view.HotKeyCommand);
         Assert.False (view.FocusedCommand);
+        top.Dispose ();
     }
 
     [Fact]
@@ -98,6 +99,7 @@ public class ViewKeyBindingTests
         Application.OnKeyDown (Key.Z); // new hot key
         Assert.True (invoked);
         Assert.True (view.HotKeyCommand);
+        top.Dispose ();
     }
 
     [Fact]
@@ -119,6 +121,7 @@ public class ViewKeyBindingTests
         invoked = false;
         Application.OnKeyDown (Key.F);
         Assert.False (view.HotKeyCommand);
+        top.Dispose ();
     }
 
     // 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;
 
-public class ViewTests
+public class ViewTests (ITestOutputHelper output)
 {
-    private readonly ITestOutputHelper _output;
-    public ViewTests (ITestOutputHelper output) { _output = output; }
-
     [Fact]
     [AutoInitShutdown]
     public void Clear_Viewport_Can_Use_Driver_AddRune_Or_AddStr_Methods ()
@@ -18,7 +15,7 @@ public class ViewTests
         view.DrawContent += (s, e) =>
                             {
                                 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++)
                                 {
@@ -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);
 
@@ -69,7 +66,7 @@ public class ViewTests
 └──────────────────┘
 ";
 
-        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         top.Dispose ();
     }
 
@@ -82,7 +79,7 @@ public class ViewTests
         view.DrawContent += (s, e) =>
                             {
                                 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++)
                                 {
@@ -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);
 
@@ -133,7 +130,7 @@ public class ViewTests
 └──────────────────┘
 ";
 
-        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
 
         top.Dispose ();
     }
@@ -147,8 +144,8 @@ public class ViewTests
         var root = new View { Width = 20, Height = 10, ColorScheme = Colors.ColorSchemes ["Base"] };
 
         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);
 
@@ -159,18 +156,19 @@ public class ViewTests
         if (label)
         {
             Assert.False (v.CanFocus);
+
             //Assert.Equal (new Rectangle (0, 0, 20, 1), v.Frame);
         }
         else
         {
             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 (
                                                       @"
 cccccccccccccccccccc",
-                                                      _output
+                                                      output
                                                      );
 
         Attribute [] attributes =
@@ -220,6 +218,7 @@ cccccccccccccccccccc",
         }
 
         Application.End (runState);
+        top.Dispose ();
     }
 
     [Fact]
@@ -246,14 +245,13 @@ At 0,0
                              
   A text with some long width
    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 ();
 
         TestHelpers.AssertDriverContentsWithFrameAre (
@@ -262,9 +260,10 @@ At 0,0
              
              
    A text wit",
-                                                      _output
+                                                      output
                                                      );
         Application.End (runState);
+        top.Dispose ();
     }
 
     [Fact]
@@ -293,16 +292,16 @@ At 0,0
                              
   A text with some long width
    and also with two lines.  ",
-                                                      _output
+                                                      output
                                                      );
 
         view.X = 3;
         view.Y = 3;
         view.Width = 10;
         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 ();
 
         TestHelpers.AssertDriverContentsWithFrameAre (
@@ -311,9 +310,10 @@ At 0,0
              
              
    A text wit",
-                                                      _output
+                                                      output
                                                      );
         Application.End (runState);
+        top.Dispose ();
     }
 
     [Fact]
@@ -342,23 +342,23 @@ At 0,0
                              
   A text with some long width
    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 ();
 
         TestHelpers.AssertDriverContentsWithFrameAre (
                                                       @"
 At 0,0     
  A text wit",
-                                                      _output
+                                                      output
                                                      );
         Application.End (runState);
+        top.Dispose ();
     }
 
     [Fact]
@@ -387,25 +387,26 @@ At 0,0
                              
   A text with some long width
    and also with two lines.  ",
-                                                      _output
+                                                      output
                                                      );
 
         view.X = 1;
         view.Y = 1;
         view.Width = 10;
         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 ();
 
         TestHelpers.AssertDriverContentsWithFrameAre (
                                                       @"
 At 0,0     
  A text wit",
-                                                      _output
+                                                      output
                                                      );
         Application.End (runState);
+        top.Dispose ();
     }
 
     [Fact]
@@ -445,6 +446,7 @@ At 0,0
 
         Assert.True (viewCalled);
         Assert.True (tvCalled);
+        top.Dispose ();
     }
 
     [Fact]
@@ -478,33 +480,33 @@ At 0,0
 
         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 (
-                      new Rectangle (20, 8, 60, 16),
+                      new (20, 8, 60, 16),
                       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);
+        top.Dispose ();
     }
 
     [Fact]
-    [AutoInitShutdown]
     public void GetHotNormalColor_ColorScheme ()
     {
         var view = new View { ColorScheme = Colors.ColorSchemes ["Base"] };
@@ -517,7 +519,6 @@ At 0,0
     }
 
     [Fact]
-    [AutoInitShutdown]
     public void GetNormalColor_ColorScheme ()
     {
         var view = new View { ColorScheme = Colors.ColorSchemes ["Base"] };
@@ -555,12 +556,12 @@ At 0,0
                              
   A text with some long width
    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 ();
 
         TestHelpers.AssertDriverContentsWithFrameAre (
@@ -569,9 +570,10 @@ At 0,0
                              
   A text with some long width
    A text witith two lines.  ",
-                                                      _output
+                                                      output
                                                      );
         Application.End (runState);
+        top.Dispose ();
     }
 
     [Fact]
@@ -600,16 +602,16 @@ At 0,0
                              
   A text with some long width
    and also with two lines.  ",
-                                                      _output
+                                                      output
                                                      );
 
         view.X = 3;
         view.Y = 3;
         view.Width = 10;
         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 ();
 
         TestHelpers.AssertDriverContentsWithFrameAre (
@@ -618,9 +620,10 @@ At 0,0
                              
   A text with some long width
    A text witith two lines.  ",
-                                                      _output
+                                                      output
                                                      );
         Application.End (runState);
+        top.Dispose ();
     }
 
     [Fact]
@@ -649,14 +652,13 @@ At 0,0
                              
   A text with some long width
    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 ();
 
         TestHelpers.AssertDriverContentsWithFrameAre (
@@ -665,9 +667,10 @@ At 0,0
  A text wit                  
   A text with some long width
    and also with two lines.  ",
-                                                      _output
+                                                      output
                                                      );
         Application.End (runState);
+        top.Dispose ();
     }
 
     [Fact]
@@ -696,16 +699,16 @@ At 0,0
                              
   A text with some long width
    and also with two lines.  ",
-                                                      _output
+                                                      output
                                                      );
 
         view.X = 1;
         view.Y = 1;
         view.Width = 10;
         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 ();
 
         TestHelpers.AssertDriverContentsWithFrameAre (
@@ -714,9 +717,10 @@ At 0,0
  A text wit                  
   A text with some long width
    and also with two lines.  ",
-                                                      _output
+                                                      output
                                                      );
         Application.End (runState);
+        top.Dispose ();
     }
 
     [Fact]
@@ -738,7 +742,7 @@ At 0,0
         view.EndInit ();
         view.Draw ();
 
-        TestHelpers.AssertDriverContentsWithFrameAre (text, _output);
+        TestHelpers.AssertDriverContentsWithFrameAre (text, output);
     }
 
     [Fact]
@@ -751,12 +755,11 @@ At 0,0
         Assert.True (r.Enabled);
         Assert.True (r.Visible);
 
-        Assert.Equal (LayoutStyle.Absolute, r.LayoutStyle);
         Assert.Equal ($"View(){r.Viewport}", r.ToString ());
         Assert.False (r.CanFocus);
         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.ColorScheme);
         Assert.Equal (0, r.Width);
@@ -774,14 +777,13 @@ At 0,0
         r.Dispose ();
 
         // Empty Rect
-        r = new View { Frame = Rectangle.Empty };
+        r = new() { Frame = Rectangle.Empty };
         Assert.NotNull (r);
-        Assert.Equal (LayoutStyle.Absolute, r.LayoutStyle);
         Assert.Equal ($"View(){r.Viewport}", r.ToString ());
         Assert.False (r.CanFocus);
         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.ColorScheme);
         Assert.Equal (0, r.Width);
@@ -799,14 +801,13 @@ At 0,0
         r.Dispose ();
 
         // 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.Equal (LayoutStyle.Absolute, r.LayoutStyle);
         Assert.Equal ($"View(){r.Frame}", r.ToString ());
         Assert.False (r.CanFocus);
         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.ColorScheme);
         Assert.Equal (3, r.Width);
@@ -824,7 +825,7 @@ At 0,0
         r.Dispose ();
 
         // Initializes a view with a vertical direction
-        r = new View
+        r = new()
         {
             Text = "Vertical View",
             TextDirection = TextDirection.TopBottom_LeftRight,
@@ -832,15 +833,14 @@ At 0,0
             Height = Dim.Auto ()
         }; // BUGBUG: AutoSize or Height need be set
         Assert.NotNull (r);
-        Assert.Equal (LayoutStyle.Computed, r.LayoutStyle);
 
         // BUGBUG: IsInitialized must be true to process calculation
         r.BeginInit ();
         r.EndInit ();
         Assert.False (r.CanFocus);
         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.ColorScheme);
         Assert.False (r.IsCurrentTop);
@@ -864,13 +864,13 @@ At 0,0
     {
         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.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 ();
         Assert.False (r.OnEnter (v1));
@@ -889,7 +889,7 @@ At 0,0
     [AutoInitShutdown]
     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 bottom = new View { Width = Dim.Fill (), Height = 1, Y = 2 };
@@ -910,7 +910,7 @@ At 0,0
 111
 ───────────
 222";
-        TestHelpers.AssertDriverContentsAre (looksLike, _output);
+        TestHelpers.AssertDriverContentsAre (looksLike, output);
         v.Dispose ();
         top.Dispose ();
         bottom.Dispose ();
@@ -924,7 +924,7 @@ At 0,0
         var view = new View { X = 1, Y = 2, Width = 3, Height = 4 };
 
         // 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.BeginInit ();
         super.EndInit ();
@@ -935,9 +935,9 @@ At 0,0
         Assert.Equal (3, view.Width);
         Assert.Equal (4, view.Height);
         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.Equal (new Rectangle (0, 0, 3, 4), view.Viewport);
+        Assert.Equal (new (0, 0, 3, 4), view.Viewport);
 
         view.LayoutSubviews ();
 
@@ -954,7 +954,7 @@ At 0,0
 #endif
 
         // Default Constructor
-        view = new View ();
+        view = new ();
         Assert.Equal (0, view.X);
         Assert.Equal (0, view.Y);
         Assert.Equal (0, view.Width);
@@ -964,7 +964,7 @@ At 0,0
         view.Dispose ();
 
         // Object Initializer
-        view = new View { X = 1, Y = 2, Text = "" };
+        view = new() { X = 1, Y = 2, Text = "" };
         Assert.Equal (1, view.X);
         Assert.Equal (2, view.Y);
         Assert.Equal (0, view.Width);
@@ -974,12 +974,12 @@ At 0,0
         view.Dispose ();
 
         // Default Constructor and post assignment equivalent to Object Initializer
-        view = new View ();
+        view = new ();
         view.X = 1;
         view.Y = 2;
         view.Width = 3;
         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.BeginInit ();
         super.EndInit ();
@@ -989,9 +989,9 @@ At 0,0
         Assert.Equal (3, view.Width);
         Assert.Equal (4, view.Height);
         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.Equal (new Rectangle (0, 0, 3, 4), view.Viewport);
+        Assert.Equal (new (0, 0, 3, 4), view.Viewport);
         super.Dispose ();
     }
 
@@ -1024,7 +1024,7 @@ At 0,0
 │                            │
 └────────────────────────────┘
 ",
-                                                      _output
+                                                      output
                                                      );
 
         view.Visible = false;
@@ -1040,9 +1040,10 @@ At 0,0
 │                            │
 └────────────────────────────┘
 ",
-                                                      _output
+                                                      output
                                                      );
         Application.End (rs);
+        top.Dispose ();
     }
 
     [Fact]
@@ -1096,7 +1097,7 @@ At 0,0
                                  };
 
         Application.Run (top);
-
+        top.Dispose ();
         Assert.Equal (1, iterations);
 
         int RunesCount ()
@@ -1194,6 +1195,7 @@ At 0,0
         Assert.True (accepted);
 
         return;
+
         void ViewOnAccept (object sender, CancelEventArgs e) { accepted = true; }
     }
 
@@ -1205,11 +1207,12 @@ At 0,0
 
         view.Accept += ViewOnAccept;
 
-        var ret = view.InvokeCommand (Command.Accept);
+        bool? ret = view.InvokeCommand (Command.Accept);
         Assert.True (ret);
         Assert.True (acceptInvoked);
 
         return;
+
         void ViewOnAccept (object sender, CancelEventArgs e)
         {
             acceptInvoked = true;
@@ -1229,6 +1232,7 @@ At 0,0
         Assert.True (accepted);
 
         return;
+
         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;
 
-public class AppendAutocompleteTests
+public class AppendAutocompleteTests (ITestOutputHelper output)
 {
-    private readonly ITestOutputHelper output;
-    public AppendAutocompleteTests (ITestOutputHelper output) { this.output = output; }
-
     [Fact]
     [AutoInitShutdown]
     public void TestAutoAppend_AfterCloseKey_NoAutocomplete ()
@@ -34,6 +31,7 @@ public class AppendAutocompleteTests
         // But can tab away
         Application.Driver.SendKeys ('\t', ConsoleKey.Tab, false, false, false);
         Assert.NotSame (tf, Application.Top.Focused);
+        Application.Top.Dispose ();
     }
 
     [Fact]
@@ -63,6 +61,7 @@ public class AppendAutocompleteTests
         tf.PositionCursor ();
         TestHelpers.AssertDriverContentsAre ("fish", output);
         Assert.Equal ("fi", tf.Text);
+        Application.Top.Dispose ();
     }
 
     [Theory]
@@ -94,6 +93,7 @@ public class AppendAutocompleteTests
         tf.PositionCursor ();
         TestHelpers.AssertDriverContentsAre ("fish", output);
         Assert.Equal ("f", tf.Text);
+        Application.Top.Dispose ();
     }
 
     [Fact]
@@ -116,6 +116,7 @@ public class AppendAutocompleteTests
         tf.Draw ();
         TestHelpers.AssertDriverContentsAre ("f", output);
         Assert.Equal ("f ", tf.Text);
+        Application.Top.Dispose ();
     }
 
     [Fact]
@@ -136,6 +137,7 @@ public class AppendAutocompleteTests
         tf.Draw ();
         TestHelpers.AssertDriverContentsAre ("fx", output);
         Assert.Equal ("fx", tf.Text);
+        Application.Top.Dispose ();
     }
 
     [Fact]
@@ -168,6 +170,7 @@ public class AppendAutocompleteTests
         tf.Draw ();
         TestHelpers.AssertDriverContentsAre ("my FISH", output);
         Assert.Equal ("my FISH", tf.Text);
+        Application.Top.Dispose ();
     }
 
     [Fact]
@@ -203,6 +206,7 @@ public class AppendAutocompleteTests
         // Second tab should move focus (nothing to autocomplete)
         Application.Driver.SendKeys ('\t', ConsoleKey.Tab, false, false, false);
         Assert.NotSame (tf, Application.Top.Focused);
+        Application.Top.Dispose ();
     }
 
     [Theory]
@@ -220,6 +224,7 @@ public class AppendAutocompleteTests
         tf.PositionCursor ();
         TestHelpers.AssertDriverContentsAre (expectRender, output);
         Assert.Equal ("f", tf.Text);
+        Application.Top.Dispose ();
     }
 
     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你", 1, 1, 1, 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)
     {
         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.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);
 
         btn1.Dispose ();
@@ -91,7 +90,6 @@ public class ButtonTests (ITestOutputHelper output)
     }
 
     [Fact]
-    [AutoInitShutdown]
     public void Button_HotKeyChanged_EventFires ()
     {
         var btn = new Button { Text = "_Yar" };
@@ -204,7 +202,7 @@ public class ButtonTests (ITestOutputHelper output)
         Assert.Equal ('_', btn.HotKeySpecifier.Value);
         Assert.Equal (10, btn.TextFormatter.Format ().Length);
         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.Frame);
         Assert.Equal (KeyCode.T, btn.HotKey);
@@ -240,15 +238,11 @@ public class ButtonTests (ITestOutputHelper output)
     }
 
     [Fact]
-    [AutoInitShutdown]
     public void HotKeyChange_Works ()
     {
         var clicked = false;
         var btn = new Button { Text = "_Test" };
         btn.Accept += (s, e) => clicked = true;
-        var top = new Toplevel ();
-        top.Add (btn);
-        Application.Begin (top);
 
         Assert.Equal (KeyCode.T, btn.HotKey);
         Assert.True (btn.NewKeyDownEvent (Key.T));
@@ -262,7 +256,6 @@ public class ButtonTests (ITestOutputHelper output)
         btn.HotKey = KeyCode.E;
         Assert.True (btn.NewKeyDownEvent (Key.E.WithAlt));
         Assert.True (clicked);
-        top.Dispose ();
     }
 
     /// <summary>
@@ -573,11 +566,11 @@ public class ButtonTests (ITestOutputHelper output)
     }
 
     [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 ();
 

+ 43 - 42
UnitTests/Views/CheckBoxTests.cs

@@ -3,12 +3,9 @@ using Xunit.Abstractions;
 
 namespace Terminal.Gui.ViewsTests;
 
-public class CheckBoxTests
+public class CheckBoxTests (ITestOutputHelper output)
 {
-    private readonly ITestOutputHelper _output;
     private static readonly Size _size25x1 = new (25, 1);
-    public CheckBoxTests (ITestOutputHelper output) { _output = output; }
-
 
     [Theory]
     [InlineData ("01234", 0, 0, 0, 0)]
@@ -39,9 +36,9 @@ public class CheckBoxTests
             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 ();
     }
@@ -60,12 +57,12 @@ public class CheckBoxTests
             X = 0,
             Y = 0,
             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 ();
     }
@@ -77,7 +74,7 @@ public class CheckBoxTests
         var view = new CheckBox ();
         view.Title = "Hello";
         Assert.Equal ("Hello", view.Title);
-        Assert.Equal ($"Hello", view.TitleTextFormatter.Text);
+        Assert.Equal ("Hello", view.TitleTextFormatter.Text);
 
         Assert.Equal ("Hello", view.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 ("Hello", view.Title);
-        Assert.Equal ($"Hello", view.TitleTextFormatter.Text);
+        Assert.Equal ("Hello", view.TitleTextFormatter.Text);
     }
 
     [Fact]
-    [AutoInitShutdown]
+    [SetupFakeDriver]
     public void AllowNullChecked_Get_Set ()
     {
         var checkBox = new CheckBox { Text = "Check this out 你" };
-        Toplevel top = new ();
-        top.Add (checkBox);
-        Application.Begin (top);
 
         Assert.False (checkBox.Checked);
         Assert.True (checkBox.NewKeyDownEvent (Key.Space));
         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);
 
         checkBox.AllowNullChecked = true;
         Assert.True (checkBox.NewKeyDownEvent (Key.Space));
         Assert.Null (checkBox.Checked);
-        Application.Refresh ();
+        checkBox.Draw();
 
         TestHelpers.AssertDriverContentsWithFrameAre (
                                                       @$"
 {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.NewKeyDownEvent (Key.Space));
         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);
 
         checkBox.AllowNullChecked = false;
@@ -142,9 +136,9 @@ public class CheckBoxTests
         Assert.Equal (string.Empty, ckb.Text);
         Assert.Equal ($"{CM.Glyphs.UnChecked} ", ckb.TextFormatter.Text);
         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.Height is DimAuto);
         Assert.True (ckb.Checked);
@@ -152,9 +146,9 @@ public class CheckBoxTests
         Assert.Equal ("Test", ckb.Text);
         Assert.Equal ($"{CM.Glyphs.Checked} Test", ckb.TextFormatter.Text);
         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.Height is DimAuto);
         Assert.False (ckb.Checked);
@@ -162,9 +156,9 @@ public class CheckBoxTests
         Assert.Equal ("Test", ckb.Text);
         Assert.Equal ($"{CM.Glyphs.UnChecked} Test", ckb.TextFormatter.Text);
         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.Height is DimAuto);
         Assert.True (ckb.Checked);
@@ -172,7 +166,7 @@ public class CheckBoxTests
         Assert.Equal ("Test", ckb.Text);
         Assert.Equal ($"{CM.Glyphs.Checked} Test", ckb.TextFormatter.Text);
         Assert.True (ckb.CanFocus);
-        Assert.Equal (new Rectangle (3, 4, 6, 1), ckb.Frame);
+        Assert.Equal (new (3, 4, 6, 1), ckb.Frame);
     }
 
     [Fact]
@@ -229,11 +223,12 @@ public class CheckBoxTests
 
         ckb.Accept += ViewOnAccept;
 
-        var ret = ckb.InvokeCommand (Command.Accept);
+        bool? ret = ckb.InvokeCommand (Command.Accept);
         Assert.True (ret);
         Assert.True (acceptInvoked);
 
         return;
+
         void ViewOnAccept (object sender, CancelEventArgs e)
         {
             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);
 
         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);
+        top.Dispose ();
     }
 
     [Fact]
@@ -324,7 +320,7 @@ public class CheckBoxTests
         Assert.Equal (new (1, 1, 25, 1), checkBox1.Frame);
         Assert.Equal (Alignment.Fill, checkBox2.TextAlignment);
         Assert.Equal (new (1, 2, 25, 1), checkBox2.Frame);
- 
+
         var expected = @$"
 ┌┤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);
 
         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);
+        top.Dispose ();
     }
 
     [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);
 
         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);
+        top.Dispose ();
     }
 
     [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);
 
         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);
+        top.Dispose ();
     }
 
     [Fact]
@@ -469,6 +468,7 @@ public class CheckBoxTests
         Assert.True (accepted);
 
         return;
+
         void CheckBoxOnAccept (object sender, CancelEventArgs e) { accepted = true; }
     }
 
@@ -478,19 +478,20 @@ public class CheckBoxTests
     [InlineData (null)]
     public void Toggled_Cancel_Event_Prevents_Toggle (bool? initialState)
     {
-        var ckb = new CheckBox () { AllowNullChecked = true };
+        var ckb = new CheckBox { AllowNullChecked = true };
         var checkedInvoked = false;
 
         ckb.Toggled += CheckBoxToggled;
 
         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 (checkedInvoked);
         Assert.Equal (initialState, ckb.Checked);
 
         return;
+
         void CheckBoxToggled (object sender, CancelEventArgs e)
         {
             checkedInvoked = true;

+ 5 - 6
UnitTests/Views/ColorPickerTests.cs

@@ -13,11 +13,10 @@ public class ColorPickerTests
         colorPicker.BeginInit ();
         colorPicker.EndInit ();
         colorPicker.LayoutSubviews ();
-        Assert.Equal (new Rectangle (0, 0, 32, 4), colorPicker.Frame);
+        Assert.Equal (new (0, 0, 32, 4), colorPicker.Frame);
     }
 
     [Fact]
-    [AutoInitShutdown]
     public void KeyBindings_Command ()
     {
         var colorPicker = new ColorPicker ();
@@ -52,14 +51,14 @@ public class ColorPickerTests
         top.Add (colorPicker);
         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);
+        top.Dispose ();
     }
 
     [Fact]
-    [AutoInitShutdown]
     public void SelectedColorAndCursor ()
     {
         var colorPicker = new ColorPicker ();
@@ -71,7 +70,7 @@ public class ColorPickerTests
         Assert.Equal (0, colorPicker.Cursor.X);
         Assert.Equal (0, colorPicker.Cursor.Y);
 
-        colorPicker.Cursor = new Point (7, 1);
+        colorPicker.Cursor = new (7, 1);
         Assert.Equal (ColorName.White, colorPicker.SelectedColor);
 
         colorPicker.Cursor = Point.Empty;

+ 16 - 11
UnitTests/Views/ComboBoxTests.cs

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

+ 86 - 63
UnitTests/Views/ContextMenuTests.cs

@@ -1,15 +1,10 @@
 using System.Globalization;
 using Xunit.Abstractions;
 
-//using GraphViewTests = Terminal.Gui.Views.GraphViewTests;
-
 namespace Terminal.Gui.ViewsTests;
 
-public class ContextMenuTests
+public class ContextMenuTests (ITestOutputHelper output)
 {
-    private readonly ITestOutputHelper _output;
-    public ContextMenuTests (ITestOutputHelper output) { _output = output; }
-
     [Fact]
     [AutoInitShutdown]
     public void ContextMenu_Constructors ()
@@ -107,14 +102,15 @@ public class ContextMenuTests
         Assert.True (ContextMenu.IsShow);
         Assert.Equal (cm.MenuBar, Application.MouseGrabView);
         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.Equal (cm.MenuBar, Application.MouseGrabView);
         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.Equal (menu, Application.MouseGrabView);
         Assert.True (menu.IsMenuOpen);
+        top.Dispose ();
     }
 
     [Fact]
@@ -176,8 +172,9 @@ public class ContextMenuTests
  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);
+        top.Dispose ();
     }
 
     [Fact]
@@ -243,8 +240,9 @@ public class ContextMenuTests
  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);
+        top.Dispose ();
     }
 
     [Fact]
@@ -254,7 +252,7 @@ public class ContextMenuTests
         ((FakeDriver)Application.Driver).SetBufferSize (20, 15);
 
         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 };
         top.Add (new TextField { X = Pos.Center (), Width = 10, Text = "Test" });
@@ -266,7 +264,7 @@ public class ContextMenuTests
         TestHelpers.AssertDriverContentsWithFrameAre (
                                                       @"
     Test",
-                                                      _output
+                                                      output
                                                      );
 
         Application.OnMouseEvent (new MouseEvent { Position = new (8, 2), Flags = MouseFlags.Button3Clicked });
@@ -286,10 +284,11 @@ public class ContextMenuTests
 │ Undo         Ctrl+
 │ Redo         Ctrl+
 └───────────────────",
-                                                      _output
+                                                      output
                                                      );
 
         Application.End (rs);
+        top.Dispose ();
     }
 
     [Fact]
@@ -321,7 +320,7 @@ public class ContextMenuTests
 │                  │
 │                  │
 └──────────────────┘",
-                                                      _output
+                                                      output
                                                      );
 
         // 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 });
@@ -373,11 +372,12 @@ public class ContextMenuTests
 └───────────────────
 │                  │
 └──────────────────┘",
-                                                      _output
+                                                      output
                                                      );
 
         Application.End (rsDialog);
         Application.End (rsTop);
+        top.Dispose ();
     }
 
     [Fact]
@@ -387,7 +387,7 @@ public class ContextMenuTests
         ((FakeDriver)Application.Driver).SetBufferSize (20, 15);
 
         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.
         var dialog = new Window { X = 2, Y = 2, Width = 15, Height = 4 };
@@ -403,7 +403,7 @@ public class ContextMenuTests
   │ Test        │
   │             │
   └─────────────┘",
-                                                      _output
+                                                      output
                                                      );
 
         Application.OnMouseEvent (new MouseEvent { Position = new (9, 3), Flags = MouseFlags.Button3Clicked });
@@ -424,10 +424,11 @@ public class ContextMenuTests
 │ Undo         Ctrl+
 │ Redo         Ctrl+
 └───────────────────",
-                                                      _output
+                                                      output
                                                      );
 
         Application.End (rs);
+        dialog.Dispose ();
     }
 
     [Fact]
@@ -446,8 +447,9 @@ public class ContextMenuTests
         };
 
         Assert.Equal (new Point (-1, -2), cm.Position);
-
-        Application.Begin (new ());
+        
+        Toplevel top = new ();
+        Application.Begin (top);
 
         cm.Show ();
         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);
 
         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);
+        top.Dispose ();
     }
 
     [Fact]
@@ -504,6 +507,7 @@ public class ContextMenuTests
 
         top.RequestStop ();
         Assert.False (ContextMenu.IsShow);
+        top.Dispose ();
     }
 
     [Fact]
@@ -519,6 +523,7 @@ public class ContextMenuTests
         Assert.True (tf.ContextMenu.MenuBar.IsMenuOpen);
         Assert.True (Application.OnKeyDown (ContextMenu.DefaultKey));
         Assert.Null (tf.ContextMenu.MenuBar);
+        top.Dispose ();
     }
 
     [Fact]
@@ -550,7 +555,8 @@ public class ContextMenuTests
                                         )
         };
 
-        Application.Begin (new ());
+        Toplevel top = new ();
+        Application.Begin (top);
         cm.Show ();
         Application.Refresh ();
 
@@ -561,7 +567,7 @@ public class ContextMenuTests
           └──────┘
 ";
 
-        TestHelpers.AssertDriverContentsAre (expected, _output);
+        TestHelpers.AssertDriverContentsAre (expected, output);
 
         cm.MenuItems = new MenuBarItem (
                                         [
@@ -582,7 +588,8 @@ public class ContextMenuTests
           └─────────┘
 ";
 
-        TestHelpers.AssertDriverContentsAre (expected, _output);
+        TestHelpers.AssertDriverContentsAre (expected, output);
+        top.Dispose ();
     }
 
     [Fact]
@@ -636,7 +643,7 @@ public class ContextMenuTests
 │ Six    │
 └────────┘
 ",
-                                                      _output
+                                                      output
                                                      );
 
         Assert.True (
@@ -664,7 +671,7 @@ public class ContextMenuTests
           │ SubMenu7  │
           └───────────┘
 ",
-                                                      _output
+                                                      output
                                                      );
 
         ((FakeDriver)Application.Driver).SetBufferSize (40, 20);
@@ -684,7 +691,7 @@ public class ContextMenuTests
                               │ Six    │
                               └────────┘
 ",
-                                                      _output
+                                                      output
                                                      );
 
         Assert.True (
@@ -712,7 +719,7 @@ public class ContextMenuTests
                  │ SubMenu7  │          
                  └───────────┘          
 ",
-                                                      _output
+                                                      output
                                                      );
 
         cm.Position = new Point (41, 9);
@@ -731,7 +738,7 @@ public class ContextMenuTests
                               │ Six    │
                               └────────┘
 ",
-                                                      _output
+                                                      output
                                                      );
 
         Assert.True (
@@ -756,7 +763,7 @@ public class ContextMenuTests
                  │ SubMenu7  │          
                  └───────────┘          
 ",
-                                                      _output
+                                                      output
                                                      );
 
         cm.Position = new Point (41, 22);
@@ -775,7 +782,7 @@ public class ContextMenuTests
                               │ Six    │
                               └────────┘
 ",
-                                                      _output
+                                                      output
                                                      );
 
         Assert.True (
@@ -799,7 +806,7 @@ public class ContextMenuTests
                  │ SubMenu7  ││ Six    │
                  └───────────┘└────────┘
 ",
-                                                      _output
+                                                      output
                                                      );
 
         ((FakeDriver)Application.Driver).SetBufferSize (18, 8);
@@ -819,7 +826,7 @@ public class ContextMenuTests
         │ Six    │
         └────────┘
 ",
-                                                      _output
+                                                      output
                                                      );
 
         Assert.True (
@@ -842,8 +849,9 @@ public class ContextMenuTests
 │ SubMenu6  │    │
 │ SubMenu7  │────┘
 ",
-                                                      _output
+                                                      output
                                                      );
+        top.Dispose ();
     }
 
     [Fact]
@@ -874,10 +882,10 @@ public class ContextMenuTests
         cm.MouseFlags = MouseFlags.Button2Clicked;
         Assert.True (lbl.NewMouseEvent (new MouseEvent { Flags = cm.MouseFlags }));
         Assert.Equal ("Replaced", lbl.Text);
+        top.Dispose ();
     }
 
     [Fact]
-    [AutoInitShutdown]
     public void MouseFlagsChanged_Event ()
     {
         var oldMouseFlags = new MouseFlags ();
@@ -905,7 +913,8 @@ public class ContextMenuTests
                                         )
         };
 
-        Application.Begin (new ());
+        Toplevel top = new ();
+        Application.Begin (top);
         cm.Show ();
         Application.Refresh ();
 
@@ -916,7 +925,7 @@ public class ContextMenuTests
           └──────┘
 ";
 
-        TestHelpers.AssertDriverContentsAre (expected, _output);
+        TestHelpers.AssertDriverContentsAre (expected, output);
 
         cm.Position = new Point (5, 10);
 
@@ -930,7 +939,8 @@ public class ContextMenuTests
      └──────┘
 ";
 
-        TestHelpers.AssertDriverContentsAre (expected, _output);
+        TestHelpers.AssertDriverContentsAre (expected, output);
+        top.Dispose ();
     }
 
     [Fact]
@@ -1006,6 +1016,7 @@ public class ContextMenuTests
         Assert.True (isTopClosed);
         Assert.False (ContextMenu.IsShow);
         Assert.True (isMenuAllClosed);
+        top.Dispose ();
     }
 
     [Fact]
@@ -1027,7 +1038,8 @@ public class ContextMenuTests
 
         Assert.Equal (Point.Empty, cm.Position);
 
-        Application.Begin (new ());
+        Toplevel top = new ();
+        Application.Begin (top);
         cm.Show ();
         Assert.Equal (Point.Empty, cm.Position);
         Application.Refresh ();
@@ -1037,11 +1049,12 @@ public class ContextMenuTests
 │ One  │
 │ Two  │";
 
-        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Assert.Equal (new Rectangle (0, 0, 8, 3), pos);
 
         cm.Hide ();
         Assert.Equal (Point.Empty, cm.Position);
+        top.Dispose ();
     }
 
     [Fact]
@@ -1063,7 +1076,8 @@ public class ContextMenuTests
 
         Assert.Equal (Point.Empty, cm.Position);
 
-        Application.Begin (new ());
+        Toplevel top = new ();
+        Application.Begin (top);
         cm.Show ();
         Assert.Equal (Point.Empty, cm.Position);
         Application.Refresh ();
@@ -1074,11 +1088,12 @@ public class ContextMenuTests
 │ Two
 └────";
 
-        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Assert.Equal (new Rectangle (0, 1, 5, 4), pos);
 
         cm.Hide ();
         Assert.Equal (Point.Empty, cm.Position);
+        top.Dispose ();
     }
 
     [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);
 
         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);
 
         cm.Hide ();
         Assert.Equal (new Point (5, 12), cm.Position);
+        top.Dispose ();
     }
 
     [Fact]
@@ -1171,7 +1187,8 @@ public class ContextMenuTests
 
         Assert.Equal (new Point (80, 25), cm.Position);
 
-        Application.Begin (new ());
+        Toplevel top = new ();
+        Application.Begin (top);
         cm.Show ();
         Assert.Equal (new Point (80, 25), cm.Position);
         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);
 
         cm.Hide ();
         Assert.Equal (new Point (80, 25), cm.Position);
+        top.Dispose ();
     }
 
     [Fact]
@@ -1233,11 +1251,12 @@ public class ContextMenuTests
                                                                       View    
 ";
 
-        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Assert.Equal (new Rectangle (70, 20, 78, 5), pos);
 
         cm.Hide ();
         Assert.Equal (new Point (70, 24), cm.Position);
+        top.Dispose ();
     }
 
     [Fact]
@@ -1246,7 +1265,8 @@ public class ContextMenuTests
     {
         ContextMenu cm = Create_ContextMenu_With_Two_MenuItem (10, 5);
 
-        Application.Begin (new ());
+        Toplevel top = new ();
+        Application.Begin (top);
         cm.Show ();
         Assert.True (ContextMenu.IsShow);
         Application.Refresh ();
@@ -1258,7 +1278,7 @@ public class ContextMenuTests
           └──────┘
 ";
 
-        TestHelpers.AssertDriverContentsAre (expected, _output);
+        TestHelpers.AssertDriverContentsAre (expected, output);
 
         cm.Hide ();
         Assert.False (ContextMenu.IsShow);
@@ -1267,7 +1287,8 @@ public class ContextMenuTests
 
         expected = "";
 
-        TestHelpers.AssertDriverContentsAre (expected, _output);
+        TestHelpers.AssertDriverContentsAre (expected, output);
+        top.Dispose ();
     }
 
     [Fact]
@@ -1297,8 +1318,8 @@ public class ContextMenuTests
                                         ),
             UseSubMenusSingleFrame = true
         };
-
-        RunState rs = Application.Begin (new ());
+        Toplevel top = new ();
+        RunState rs = Application.Begin (top);
         cm.Show ();
         Assert.Equal (new Rectangle (5, 11, 10, 5), Application.Top.Subviews [0].Frame);
         Application.Refresh ();
@@ -1310,7 +1331,7 @@ public class ContextMenuTests
      │ Two   ►│
      │ Three  │
      └────────┘",
-                                                      _output
+                                                      output
                                                      );
 
         // 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 2  │
      └─────────────┘",
-                                                      _output
+                                                      output
                                                      );
 
         Application.OnMouseEvent (new MouseEvent { Position = new (6, 12), Flags = MouseFlags.Button1Clicked });
@@ -1345,10 +1366,11 @@ public class ContextMenuTests
      │ Two   ►│
      │ Three  │
      └────────┘",
-                                                      _output
+                                                      output
                                                      );
 
         Application.End (rs);
+        top.Dispose ();
     }
 
     [Fact]
@@ -1386,8 +1408,8 @@ public class ContextMenuTests
                                          ]
                                         )
         };
-
-        RunState rs = Application.Begin (new ());
+        Toplevel top = new ();
+        RunState rs = Application.Begin (top);
         cm.Show ();
 
         Assert.Equal (new Rectangle (5, 11, 10, 5), Application.Top.Subviews [0].Frame);
@@ -1400,7 +1422,7 @@ public class ContextMenuTests
      │ Two   ►│
      │ Three ►│
      └────────┘",
-                                                      _output
+                                                      output
                                                      );
 
         Application.OnMouseEvent (new MouseEvent { Position = new (6, 13), Flags = MouseFlags.ReportMousePosition });
@@ -1417,7 +1439,7 @@ public class ContextMenuTests
      │ Three ►││ Two-Menu 1  │
      └────────┘│ Two-Menu 2  │
                └─────────────┘",
-                                                      _output
+                                                      output
                                                      );
 
         Application.OnMouseEvent (new MouseEvent { Position = new (6, 14), Flags = MouseFlags.ReportMousePosition });
@@ -1435,7 +1457,7 @@ public class ContextMenuTests
      └────────┘│ Three-Menu 1  │
                │ Three-Menu 2  │
                └───────────────┘",
-                                                      _output
+                                                      output
                                                      );
 
         Application.OnMouseEvent (new MouseEvent { Position = new (6, 13), Flags = MouseFlags.ReportMousePosition });
@@ -1452,10 +1474,11 @@ public class ContextMenuTests
      │ Three ►││ Two-Menu 1  │
      └────────┘│ Two-Menu 2  │
                └─────────────┘",
-                                                      _output
+                                                      output
                                                      );
 
         Application.End (rs);
+        top.Dispose ();
     }
 
     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]
     [TestDate]
-    [AutoInitShutdown]
+    [SetupFakeDriver]
     public void Copy_Paste ()
     {
         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 top = new Toplevel ();
-       top.Add (datePicker);
+        top.Add (datePicker);
         Application.Begin (top);
 
         // Set focus to next month button
@@ -65,6 +65,7 @@ public class DatePickerTests
         // Date should not change as next month button is disabled
         Assert.False (datePicker.NewKeyDownEvent (Key.Enter));
         Assert.Equal (12, datePicker.Date.Month);
+        top.Dispose ();
     }
 
     [Fact]
@@ -90,5 +91,6 @@ public class DatePickerTests
         // Date should not change as previous month button is disabled
         Assert.False (datePicker.NewKeyDownEvent (Key.Enter));
         Assert.Equal (1, datePicker.Date.Month);
+        top.Dispose ();
     }
 }

+ 15 - 17
UnitTests/Views/FrameViewTests.cs

@@ -2,11 +2,8 @@
 
 namespace Terminal.Gui.ViewsTests;
 
-public class FrameViewTests
+public class FrameViewTests (ITestOutputHelper output)
 {
-    private readonly ITestOutputHelper _output;
-    public FrameViewTests (ITestOutputHelper output) { _output = output; }
-
     [Fact]
     public void Constructors_Defaults ()
     {
@@ -15,12 +12,12 @@ public class FrameViewTests
         Assert.Equal (string.Empty, fv.Text);
         Assert.Equal (LineStyle.Single, fv.BorderStyle);
 
-        fv = new FrameView { Title = "Test" };
+        fv = new() { Title = "Test" };
         Assert.Equal ("Test", fv.Title);
         Assert.Equal (string.Empty, fv.Text);
         Assert.Equal (LineStyle.Single, fv.BorderStyle);
 
-        fv = new FrameView
+        fv = new()
         {
             X = 1,
             Y = 2,
@@ -33,7 +30,7 @@ public class FrameViewTests
         fv.BeginInit ();
         fv.EndInit ();
         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]
@@ -47,12 +44,12 @@ public class FrameViewTests
         var top = new Toplevel ();
         top.Add (fv);
         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.Width = 5;
-        Assert.Equal (new Rectangle (0, 0, 5, 5), fv.Frame);
+        Assert.Equal (new (0, 0, 5, 5), fv.Frame);
         Application.Refresh ();
 
         TestHelpers.AssertDriverContentsWithFrameAre (
@@ -62,12 +59,12 @@ public class FrameViewTests
 │   │
 │   │
 └───┘",
-                                                      _output
+                                                      output
                                                      );
 
         fv.X = 1;
         fv.Y = 2;
-        Assert.Equal (new Rectangle (1, 2, 5, 5), fv.Frame);
+        Assert.Equal (new (1, 2, 5, 5), fv.Frame);
         Application.Refresh ();
 
         TestHelpers.AssertDriverContentsWithFrameAre (
@@ -77,12 +74,12 @@ public class FrameViewTests
  │   │
  │   │
  └───┘",
-                                                      _output
+                                                      output
                                                      );
 
         fv.X = -1;
         fv.Y = -2;
-        Assert.Equal (new Rectangle (-1, -2, 5, 5), fv.Frame);
+        Assert.Equal (new (-1, -2, 5, 5), fv.Frame);
         Application.Refresh ();
 
         TestHelpers.AssertDriverContentsWithFrameAre (
@@ -90,19 +87,20 @@ public class FrameViewTests
 ───┘",
-                                                      _output
+                                                      output
                                                      );
 
         fv.X = 7;
         fv.Y = 8;
-        Assert.Equal (new Rectangle (7, 8, 5, 5), fv.Frame);
+        Assert.Equal (new (7, 8, 5, 5), fv.Frame);
         Application.Refresh ();
 
         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.AllowEdits);
 
-        hv = new HexView (new MemoryStream ());
+        hv = new (new MemoryStream ());
         Assert.NotNull (hv.Source);
         Assert.IsAssignableFrom<Stream> (hv.Source);
         Assert.True (hv.CanFocus);
@@ -102,7 +102,7 @@ public class HexViewTests
         top.Add (hv);
         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.CursorRight.WithCtrl));
@@ -110,16 +110,17 @@ public class HexViewTests
         Assert.True (hv.NewKeyDownEvent (Key.Home));
 
         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.Equal (new Point (2, 2), hv.CursorPosition);
+        Assert.Equal (new (2, 2), hv.CursorPosition);
 
         Assert.True (hv.NewKeyDownEvent (Key.End));
         int col = hv.CursorPosition.X;
         int line = hv.CursorPosition.Y;
         int offset = (line - 1) * (hv.BytesPerLine - col);
         Assert.Equal (hv.Position, col * line + offset);
+        top.Dispose ();
     }
 
     [Fact]
@@ -131,7 +132,7 @@ public class HexViewTests
         top.Add (hv);
         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.CursorRight.WithCtrl));
@@ -139,16 +140,17 @@ public class HexViewTests
         Assert.True (hv.NewKeyDownEvent (Key.Home));
 
         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.Equal (new Point (2, 2), hv.CursorPosition);
+        Assert.Equal (new (2, 2), hv.CursorPosition);
 
         Assert.True (hv.NewKeyDownEvent (Key.End));
         int col = hv.CursorPosition.X;
         int line = hv.CursorPosition.Y;
         int offset = (line - 1) * (hv.BytesPerLine - col);
         Assert.Equal (hv.Position, col * line + offset);
+        top.Dispose ();
     }
 
     [Fact]
@@ -200,7 +202,7 @@ public class HexViewTests
         hv.LayoutSubviews ();
 
         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.D6));
@@ -248,7 +250,7 @@ public class HexViewTests
         Assert.True (hv.NewKeyDownEvent (Key.V.WithCtrl));
         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.True (hv.NewKeyDownEvent (Key.PageDown));
@@ -274,6 +276,7 @@ public class HexViewTests
 
         Assert.True (hv.NewKeyDownEvent (Key.CursorUp.WithCtrl));
         Assert.Equal (1, hv.Position);
+        top.Dispose ();
     }
 
     [Fact]
@@ -360,8 +363,9 @@ public class HexViewTests
         Assert.True (hv.NewKeyDownEvent (Key.CursorDown));
 
         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);
+        top.Dispose ();
     }
 
     [Fact]
@@ -395,6 +399,7 @@ public class HexViewTests
         hv.Source = new MemoryStream ();
         Assert.Equal (0, hv.DisplayStart);
         Assert.Equal (0, hv.Position - 1);
+        top.Dispose ();
     }
 
     private Stream LoadStream (bool unicode = false)

+ 185 - 184
UnitTests/Views/LabelTests.cs

@@ -1,14 +1,10 @@
 using System.ComponentModel;
-using Microsoft.VisualStudio.TestPlatform.Utilities;
 using Xunit.Abstractions;
 
 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
     [Fact]
     public void Text_Mirrors_Title ()
@@ -37,9 +33,9 @@ public class LabelTests
     [Fact]
     public void HotKey_Command_SetsFocus_OnNextSubview ()
     {
-        var superView = new View () { CanFocus = true };
+        var superView = new View { CanFocus = true };
         var label = new Label ();
-        var nextSubview = new View () { CanFocus = true };
+        var nextSubview = new View { CanFocus = true };
         superView.Add (label, nextSubview);
         superView.BeginInit ();
         superView.EndInit ();
@@ -52,14 +48,13 @@ public class LabelTests
         Assert.True (nextSubview.HasFocus);
     }
 
-
     [Fact]
     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.BeginInit ();
         superView.EndInit ();
@@ -68,7 +63,7 @@ public class LabelTests
         Assert.False (label.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.True (nextSubview.HasFocus);
     }
@@ -85,6 +80,7 @@ public class LabelTests
         Assert.False (accepted);
 
         return;
+
         void LabelOnAccept (object sender, CancelEventArgs e) { accepted = true; }
     }
 
@@ -100,8 +96,6 @@ public class LabelTests
         var top = new Toplevel ();
         top.Add (win);
 
-       
-
         Application.Begin (top);
         ((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";
-       
+
         Application.Refresh ();
 
         expected = @"
@@ -128,7 +121,8 @@ public class LabelTests
 └────────────────────────────┘
 ";
 
-        TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+        top.Dispose ();
     }
 
     [Fact]
@@ -153,11 +147,10 @@ public class LabelTests
 └────────────────────────────┘
 ";
 
-        TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
 
-       
         label.Text = "Say Hello 你 changed";
-       
+
         Application.Refresh ();
 
         expected = @"
@@ -168,7 +161,8 @@ public class LabelTests
 └────────────────────────────┘
 ";
 
-        TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+        top.Dispose ();
     }
 
     [Fact]
@@ -182,12 +176,8 @@ public class LabelTests
         var top = new Toplevel ();
         top.Add (win);
 
-       
-
         label.Text = "Say Hello 你";
 
-       
-
         Application.Begin (top);
         ((FakeDriver)Application.Driver).SetBufferSize (30, 5);
 
@@ -199,7 +189,8 @@ public class LabelTests
 └────────────────────────────┘
 ";
 
-        TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
+        top.Dispose ();
     }
 
     [Fact]
@@ -209,7 +200,7 @@ public class LabelTests
         Assert.Equal (string.Empty, label.Text);
         Assert.Equal (Alignment.Start, label.TextAlignment);
         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);
     }
 
@@ -217,7 +208,7 @@ public class LabelTests
     [AutoInitShutdown]
     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 };
 
@@ -238,16 +229,16 @@ public class LabelTests
         Assert.False (tf1.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 (
                                                       @"
 This label needs to be cleared before rewritten.                       
 This TextFormatter (tf1) without fill will not be cleared on rewritten.
 This TextFormatter (tf2) with fill will be cleared on rewritten.       ",
-                                                      _output
+                                                      output
                                                      );
 
         Assert.False (label.NeedsDisplay);
@@ -260,18 +251,19 @@ This TextFormatter (tf2) with fill will be cleared on rewritten.       ",
         label.Draw ();
 
         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.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 (
                                                       @"
 This label is rewritten.                                               
 This TextFormatter (tf1) is rewritten.will not be cleared on rewritten.
 This TextFormatter (tf2) is rewritten.                                 ",
-                                                      _output
+                                                      output
                                                      );
+        top.Dispose ();
     }
 
     [Fact]
@@ -283,15 +275,15 @@ This TextFormatter (tf2) is rewritten.                                 ",
         top.Add (label);
         Application.Begin (top);
 
-       
-        Assert.Equal (new Rectangle (0, 0, 16, 1), label.Frame);
+        Assert.Equal (new (0, 0, 16, 1), label.Frame);
 
         var expected = @"
 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]
@@ -325,8 +317,9 @@ n
 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]
@@ -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]
-    [AutoInitShutdown]
     public void Label_HotKeyChanged_EventFires ()
     {
         var label = new Label { Text = "Yar" };
@@ -375,7 +368,6 @@ e
     }
 
     [Fact]
-    [AutoInitShutdown]
     public void Label_HotKeyChanged_EventFires_WithNone ()
     {
         var label = new Label ();
@@ -427,7 +419,7 @@ e
         Assert.True (label.IsInitialized);
         Assert.Equal ("Say Hello 你", label.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 = @"
 ┌────────────────────────────┐
@@ -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]
@@ -458,7 +451,7 @@ e
         Assert.True (label.IsInitialized);
         Assert.Equal ("Say Hello 你", label.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 = @"
 ┌────────────────────────────┐
@@ -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]
     [SetupFakeDriver]
     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);
 
         Assert.Equal (new (0, 0, 4, 1), label.Viewport);
@@ -492,7 +485,7 @@ e
 ┌┤Te├┐
 │Test│
 └────┘",
-                                                      _output
+                                                      output
                                                      );
         label.Dispose ();
     }
@@ -502,8 +495,8 @@ e
     public void With_Top_Margin_Without_Top_Border ()
     {
         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 ();
         top.Add (label);
         Application.Begin (top);
@@ -516,8 +509,9 @@ e
                                                       @"
 │Test│
 └────┘",
-                                                      _output
+                                                      output
                                                      );
+        top.Dispose ();
     }
 
     [Fact]
@@ -525,7 +519,7 @@ e
     public void Without_Top_Border ()
     {
         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 ();
         top.Add (label);
         Application.Begin (top);
@@ -538,13 +532,14 @@ e
                                                       @"
 │Test│
 └────┘",
-                                                      _output
+                                                      output
                                                      );
+        top.Dispose ();
     }
 
     // These tests were formally in AutoSizetrue.cs. They are (poor) Label tests.
     private readonly string [] expecteds = new string [21]
-  {
+    {
         @"
 ┌────────────────────┐
 │View with long text │
@@ -860,7 +855,7 @@ e
 │Label 19            │
 │Label 19            │
 └────────────────────┘"
-  };
+    };
 
     private static readonly Size _size1x1 = new (1, 1);
 
@@ -889,9 +884,9 @@ e
         ((FakeDriver)Application.Driver).SetBufferSize (40, 10);
 
         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 = @"
 ┌──────────────────────────────────────┐
@@ -905,10 +900,11 @@ e
 │This should be the last line.         │
 └──────────────────────────────────────┘
 "
-        ;
+            ;
 
-        TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Application.End (rs);
+        top.Dispose ();
     }
 
     [Fact]
@@ -935,11 +931,11 @@ e
         top.Add (win, menu, status);
         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 = @"
  Menu                                                                           
@@ -969,8 +965,9 @@ e
  F1 Help                                                                        
 ";
 
-        TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Application.End (rs);
+        top.Dispose ();
     }
 
     // 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);
         ((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 = @"
 ┌──────────────────────────────────────┐
@@ -1016,8 +1013,9 @@ e
 └──────────────────────────────────────┘
 ";
 
-        TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Application.End (rs);
+        top.Dispose ();
     }
 
     // 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);
         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 = @"
  Menu                                                                           
@@ -1081,11 +1079,11 @@ e
  F1 Help                                                                        
 ";
 
-        TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
+        TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
         Application.End (rs);
+        top.Dispose ();
     }
 
-
     // TODO: This is a Dim test. Move to Dim tests.
 
     [Fact]
@@ -1132,53 +1130,53 @@ e
         }
 
         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) =>
-        {
-            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 ();
         win.Add (view);
@@ -1190,6 +1188,7 @@ e
 
         Assert.Equal (0, count);
         Assert.Equal (count, listLabels.Count);
+        top.Dispose ();
     }
 
     // TODO: This is a Label test. Move to Label tests.
@@ -1200,9 +1199,10 @@ e
     {
         ((FakeDriver)Application.Driver).SetBufferSize (10, 4);
         var text = "Label";
+
         var label = new Label
         {
-            Text = text,
+            Text = text
         };
         label.Width = Dim.Fill () - text.Length;
         label.Height = 0;
@@ -1216,6 +1216,7 @@ e
 
         Assert.Equal (5, text.Length);
         Assert.Equal (new (0, 0, 3, 0), label.Frame);
+
         //Assert.Equal (new (5, 1), label.TextFormatter.Size);
         Assert.Single (label.TextFormatter.GetLines ());
         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);
 
         text = "0123456789";
@@ -1238,6 +1239,7 @@ e
         win.Draw ();
 
         Assert.Equal (Rectangle.Empty, label.Frame);
+
         //        Assert.Equal (new (5, 1), label.TextFormatter.Size);
 
         //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);
     }
 
@@ -1280,55 +1282,55 @@ e
         List<Label> listLabels = new ();
 
         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) =>
-        {
-            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 ();
         win.Add (view);
@@ -1340,10 +1342,9 @@ e
 
         Assert.Equal (20, count);
         Assert.Equal (count, listLabels.Count);
+        top.Dispose ();
     }
 
-
-
     [Fact]
     [AutoInitShutdown]
     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);
 
         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);
+        top.Dispose ();
     }
 
     [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);
 
         text = "0123456789";
@@ -1443,7 +1445,6 @@ e
         //label.Width = Dim.Fill () - text.Length;
         Application.Refresh ();
 
-
         Assert.Equal (new (0, 0, 5, 1), label.Frame);
         Assert.Equal (new (5, 1), label.TextFormatter.Size);
         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);
+        top.Dispose ();
     }
 
     [Fact]
     public void Label_ResizeView_With_Dim_Absolute ()
     {
-        var super = new View ()
+        var super = new View
         {
             Width = Dim.Fill (),
             Height = Dim.Fill ()
@@ -1477,5 +1479,4 @@ e
         Assert.Equal (expectedLabelBounds, label.Viewport);
         super.Dispose ();
     }
-
 }

+ 78 - 57
UnitTests/Views/ListViewTests.cs

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

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 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;
 
@@ -100,6 +101,7 @@ public class OverlappedTests
         Assert.Empty (Application.OverlappedChildren);
         Assert.NotNull (Application.OverlappedTop);
         Assert.NotNull (Application.Top);
+        overlapped.Dispose ();
     }
 
     [Fact]
@@ -182,6 +184,7 @@ public class OverlappedTests
         Application.Run (top1);
 
         Assert.Null (Application.OverlappedChildren);
+        top1.Dispose ();
     }
 
     [Fact]
@@ -237,6 +240,7 @@ public class OverlappedTests
                                  };
 
         Application.Run (overlapped);
+        overlapped.Dispose ();
     }
 
     [Fact]
@@ -338,6 +342,7 @@ public class OverlappedTests
         Assert.Empty (Application.OverlappedChildren);
         Assert.NotNull (Application.OverlappedTop);
         Assert.NotNull (Application.Top);
+        overlapped.Dispose ();
     }
 
     [Fact]
@@ -429,6 +434,7 @@ public class OverlappedTests
         Assert.Empty (Application.OverlappedChildren);
         Assert.NotNull (Application.OverlappedTop);
         Assert.NotNull (Application.Top);
+        overlapped.Dispose ();
     }
 
     [Fact]
@@ -514,6 +520,7 @@ public class OverlappedTests
         Assert.Empty (Application.OverlappedChildren);
         Assert.NotNull (Application.OverlappedTop);
         Assert.NotNull (Application.Top);
+        overlapped.Dispose ();
     }
 
     [Fact]
@@ -609,6 +616,7 @@ public class OverlappedTests
         Assert.Empty (Application.OverlappedChildren);
         Assert.NotNull (Application.OverlappedTop);
         Assert.NotNull (Application.Top);
+        overlapped.Dispose ();
     }
 
     [Fact]
@@ -625,6 +633,7 @@ public class OverlappedTests
                             };
 
         Application.Run (overlapped);
+        overlapped.Dispose ();
     }
 
     [Fact]
@@ -703,6 +712,7 @@ public class OverlappedTests
         Assert.Empty (Application.OverlappedChildren);
         Assert.NotNull (Application.OverlappedTop);
         Assert.NotNull (Application.Top);
+        overlapped.Dispose ();
     }
 
     [Fact]
@@ -782,6 +792,7 @@ public class OverlappedTests
         Assert.Empty (Application.OverlappedChildren);
         Assert.NotNull (Application.OverlappedTop);
         Assert.NotNull (Application.Top);
+        overlapped.Dispose ();
     }
 
     [Fact]
@@ -860,6 +871,7 @@ public class OverlappedTests
         Assert.Empty (Application.OverlappedChildren);
         Assert.NotNull (Application.OverlappedTop);
         Assert.NotNull (Application.Top);
+        overlapped.Dispose ();
     }
 
     [Fact]

+ 15 - 15
UnitTests/Views/RadioGroupTests.cs

@@ -3,11 +3,8 @@ using Xunit.Abstractions;
 
 namespace Terminal.Gui.ViewsTests;
 
-public class RadioGroupTests
+public class RadioGroupTests (ITestOutputHelper output)
 {
-    private readonly ITestOutputHelper _output;
-    public RadioGroupTests (ITestOutputHelper output) { _output = output; }
-
     [Fact]
     public void Constructors_Defaults ()
     {
@@ -17,12 +14,12 @@ public class RadioGroupTests
         Assert.Equal (Rectangle.Empty, rg.Frame);
         Assert.Equal (0, rg.SelectedItem);
 
-        rg = new RadioGroup { RadioLabels = new [] { "Test" } };
+        rg = new() { RadioLabels = new [] { "Test" } };
         Assert.True (rg.CanFocus);
         Assert.Single (rg.RadioLabels);
         Assert.Equal (0, rg.SelectedItem);
 
-        rg = new RadioGroup
+        rg = new()
         {
             X = 1,
             Y = 2,
@@ -32,10 +29,10 @@ public class RadioGroupTests
         };
         Assert.True (rg.CanFocus);
         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);
 
-        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 };
         view.Add (rg);
@@ -45,7 +42,7 @@ public class RadioGroupTests
 
         Assert.True (rg.CanFocus);
         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);
     }
 
@@ -145,6 +142,7 @@ public class RadioGroupTests
         Assert.False (accepted);
 
         return;
+
         void OnAccept (object sender, CancelEventArgs e) { accepted = true; }
     }
 
@@ -160,6 +158,7 @@ public class RadioGroupTests
         Assert.True (accepted);
 
         return;
+
         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;
         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;
         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]

+ 28 - 30
UnitTests/Views/RuneCellTests.cs

@@ -3,11 +3,8 @@ using Xunit.Abstractions;
 
 namespace Terminal.Gui.ViewsTests;
 
-public class RuneCellTests
+public class RuneCellTests (ITestOutputHelper output)
 {
-    private readonly ITestOutputHelper _output;
-    public RuneCellTests (ITestOutputHelper output) { _output = output; }
-
     [Fact]
     public void Constructor_Defaults ()
     {
@@ -24,13 +21,13 @@ public class RuneCellTests
 
         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 (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.False (rc1.Equals (rc2));
         Assert.False (rc2.Equals (rc1));
@@ -44,10 +41,10 @@ public class RuneCellTests
         Assert.True (rc1.Equals (rc2));
         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 (rc2.Equals (rc1));
     }
@@ -64,10 +61,10 @@ public class RuneCellTests
 
             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 ();
@@ -83,7 +80,7 @@ Base
 Dialog  
 Menu    
 Error   ";
-        TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
+        TestHelpers.AssertDriverContentsWithFrameAre (expectedText, output);
 
         Attribute [] attributes =
         {
@@ -113,16 +110,16 @@ Error   ";
 
         tv.WordWrap = true;
         Application.Refresh ();
-        TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
+        TestHelpers.AssertDriverContentsWithFrameAre (expectedText, output);
         TestHelpers.AssertDriverAttributesAre (expectedColor, Application.Driver, attributes);
 
-        tv.CursorPosition = new Point (6, 2);
+        tv.CursorPosition = new (6, 2);
         tv.SelectionStartColumn = 0;
         tv.SelectionStartRow = 0;
         Assert.Equal ($"TopLevel{Environment.NewLine}Base{Environment.NewLine}Dialog", tv.SelectedText);
         tv.Copy ();
         tv.Selecting = false;
-        tv.CursorPosition = new Point (2, 4);
+        tv.CursorPosition = new (2, 4);
         tv.Paste ();
         Application.Refresh ();
 
@@ -134,7 +131,7 @@ Menu
 ErTopLevel
 Base      
 Dialogror ";
-        TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
+        TestHelpers.AssertDriverContentsWithFrameAre (expectedText, output);
 
         expectedColor = @"
 0000000000
@@ -147,7 +144,7 @@ Dialogror ";
         TestHelpers.AssertDriverAttributesAre (expectedColor, Application.Driver, attributes);
 
         tv.Undo ();
-        tv.CursorPosition = new Point (0, 3);
+        tv.CursorPosition = new (0, 3);
         tv.SelectionStartColumn = 0;
         tv.SelectionStartRow = 0;
 
@@ -157,7 +154,7 @@ Dialogror ";
                      );
         tv.Copy ();
         tv.Selecting = false;
-        tv.CursorPosition = new Point (2, 4);
+        tv.CursorPosition = new (2, 4);
         tv.Paste ();
         Application.Refresh ();
 
@@ -170,7 +167,7 @@ ErTopLevel
 Base      
 Dialog    
 ror       ";
-        TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output);
+        TestHelpers.AssertDriverContentsWithFrameAre (expectedText, output);
 
         expectedColor = @"
 0000000000
@@ -184,18 +181,18 @@ ror       ";
         TestHelpers.AssertDriverAttributesAre (expectedColor, Application.Driver, attributes);
 
         Application.End (rs);
+        top.Dispose ();
     }
 
     [Fact]
-    [AutoInitShutdown]
     public void RuneCell_LoadRuneCells_Without_ColorScheme_Is_Never_Null ()
     {
         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 ();
         var top = new Toplevel ();
@@ -250,7 +247,7 @@ ror       ";
                                                       @"
 This is the first line. 
 This is the second line.",
-                                                      _output
+                                                      output
                                                      );
 
         tv.Width = 10;
@@ -268,10 +265,11 @@ This is
 the    
 second 
 line.  ",
-                                                      _output
+                                                      output
                                                      );
 
         Assert.Equal (eventCount, (text [0].Count + text [1].Count) * 2);
+        top.Dispose ();
     }
 
     [Fact]
@@ -281,7 +279,7 @@ line.  ",
 
         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 ());
 
@@ -292,5 +290,5 @@ line.  ",
     }
 
     // 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 }; }
 }

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác