ソースを参照

Cleans up/Refactors `View.Subviews` (#3962)

* Subview clean up

* New Add/Remove event pattern

* Using Logging

* cleanup

* Subview -> SubView

* Test code cleanup. Killed many warnings.

* Fix tznind feedback

* Refactored AllViewTest helpers

* Moved keyboard tests to parallel

* Moved mouse tests to parallel

* Moved view tests to parallel

* Test code cleanup. Killed many warnings.

* dupe test

* Some mouse tests can't run in parallel because MouseGrabView

* Made SpinnerView more testable

* Moved more tests

* SubViews to IReadOnlyCollection<View>

* SubViews to IReadOnlyCollection<View> 2

* scrollbar tests

* shortcut tests

* Use InternalSubViews vs. _subviews

* Nuked View.IsAdded.
Added View.SuperViewChanged.

* API doc updats

* Unit Test tweak

* Unit Test tweak
Tig 4 ヶ月 前
コミット
acb5979e6c
100 ファイル変更2153 行追加1944 行削除
  1. 1 1
      Terminal.Gui/Application/Application.Initialization.cs
  2. 1 1
      Terminal.Gui/Application/Application.Run.cs
  3. 2 2
      Terminal.Gui/Application/ApplicationNavigation.cs
  4. 1 1
      Terminal.Gui/ConsoleDrivers/AnsiEscapeSequence.cs
  5. 1 1
      Terminal.Gui/ConsoleDrivers/AnsiEscapeSequenceRequest.cs
  6. 4 4
      Terminal.Gui/ConsoleDrivers/AnsiResponseParser/AnsiMouseParser.cs
  7. 5 5
      Terminal.Gui/ConsoleDrivers/AnsiResponseParser/AnsiRequestScheduler.cs
  8. 2 2
      Terminal.Gui/ConsoleDrivers/AnsiResponseParser/AnsiResponseExpectation.cs
  9. 49 47
      Terminal.Gui/ConsoleDrivers/AnsiResponseParser/AnsiResponseParser.cs
  10. 1 1
      Terminal.Gui/ConsoleDrivers/AnsiResponseParser/GenericHeld.cs
  11. 3 3
      Terminal.Gui/ConsoleDrivers/AnsiResponseParser/IAnsiResponseParser.cs
  12. 1 1
      Terminal.Gui/ConsoleDrivers/AnsiResponseParser/IHeld.cs
  13. 1 1
      Terminal.Gui/ConsoleDrivers/AnsiResponseParser/Keyboard/AnsiKeyboardParser.cs
  14. 3 3
      Terminal.Gui/ConsoleDrivers/AnsiResponseParser/Keyboard/AnsiKeyboardParserPattern.cs
  15. 3 3
      Terminal.Gui/ConsoleDrivers/AnsiResponseParser/Keyboard/CsiKeyPattern.cs
  16. 5 3
      Terminal.Gui/ConsoleDrivers/AnsiResponseParser/Keyboard/EscAsAltPattern.cs
  17. 5 3
      Terminal.Gui/ConsoleDrivers/AnsiResponseParser/Keyboard/Ss3Pattern.cs
  18. 1 1
      Terminal.Gui/ConsoleDrivers/AnsiResponseParser/StringHeld.cs
  19. 4 4
      Terminal.Gui/ConsoleDrivers/V2/MainLoop.cs
  20. 4 0
      Terminal.Gui/Input/InputBindings.cs
  21. 1 6
      Terminal.Gui/Text/Autocomplete/PopupAutocomplete.cs
  22. 2 17
      Terminal.Gui/View/Adornment/Adornment.cs
  23. 1 1
      Terminal.Gui/View/Adornment/Border.cs
  24. 2 2
      Terminal.Gui/View/Adornment/Margin.cs
  25. 1 1
      Terminal.Gui/View/Layout/Dim.cs
  26. 23 23
      Terminal.Gui/View/Layout/DimAuto.cs
  27. 4 4
      Terminal.Gui/View/Layout/DimAutoStyle.cs
  28. 1 1
      Terminal.Gui/View/Layout/LayoutEventArgs.cs
  29. 2 2
      Terminal.Gui/View/Layout/PosAlign.cs
  30. 2 2
      Terminal.Gui/View/SuperViewChangedEventArgs.cs
  31. 3 3
      Terminal.Gui/View/View.Adornments.cs
  32. 2 2
      Terminal.Gui/View/View.Command.cs
  33. 4 4
      Terminal.Gui/View/View.Content.cs
  34. 32 32
      Terminal.Gui/View/View.Drawing.cs
  35. 188 97
      Terminal.Gui/View/View.Hierarchy.cs
  36. 3 3
      Terminal.Gui/View/View.Keyboard.cs
  37. 33 33
      Terminal.Gui/View/View.Layout.cs
  38. 6 6
      Terminal.Gui/View/View.Mouse.cs
  39. 14 14
      Terminal.Gui/View/View.Navigation.cs
  40. 10 18
      Terminal.Gui/View/View.cs
  41. 1 1
      Terminal.Gui/View/ViewArrangement.cs
  42. 3 3
      Terminal.Gui/View/ViewportSettings.cs
  43. 16 16
      Terminal.Gui/Views/Bar.cs
  44. 7 7
      Terminal.Gui/Views/ComboBox.cs
  45. 1 1
      Terminal.Gui/Views/FileDialog.cs
  46. 2 2
      Terminal.Gui/Views/HexView.cs
  47. 6 6
      Terminal.Gui/Views/Label.cs
  48. 4 4
      Terminal.Gui/Views/Menu/MenuBar.cs
  49. 4 9
      Terminal.Gui/Views/MenuBarv2.cs
  50. 7 10
      Terminal.Gui/Views/Menuv2.cs
  51. 1 1
      Terminal.Gui/Views/RadioGroup.cs
  52. 2 2
      Terminal.Gui/Views/ScrollBar/ScrollBar.cs
  53. 5 5
      Terminal.Gui/Views/Shortcut.cs
  54. 1 1
      Terminal.Gui/Views/Slider.cs
  55. 19 31
      Terminal.Gui/Views/SpinnerView/SpinnerView.cs
  56. 7 12
      Terminal.Gui/Views/StatusBar.cs
  57. 4 4
      Terminal.Gui/Views/TabView/TabRow.cs
  58. 1 1
      Terminal.Gui/Views/TabView/TabView.cs
  59. 13 10
      Terminal.Gui/Views/TextField.cs
  60. 12 7
      Terminal.Gui/Views/TextView.cs
  61. 6 6
      Terminal.Gui/Views/TileView.cs
  62. 14 14
      Terminal.Gui/Views/Toplevel.cs
  63. 3 3
      Terminal.Gui/Views/Wizard/Wizard.cs
  64. 4 4
      Terminal.Gui/Views/Wizard/WizardStep.cs
  65. 2 0
      Terminal.sln.DotSettings
  66. 217 261
      Tests/IntegrationTests/UICatalog/ScenarioTests.cs
  67. 6 3
      Tests/StressTests/ApplicationStressTests.cs
  68. 6 6
      Tests/StressTests/ScenariosStressTests.cs
  69. 9 14
      Tests/UnitTests/ConsoleDrivers/AnsiKeyboardParserTests.cs
  70. 261 237
      Tests/UnitTests/ConsoleDrivers/AnsiResponseParserTests.cs
  71. 21 22
      Tests/UnitTests/ConsoleDrivers/ContentsTests.cs
  72. 4 3
      Tests/UnitTests/ConsoleDrivers/V2/ApplicationV2Tests.cs
  73. 171 156
      Tests/UnitTests/ConsoleDrivers/V2/WindowsInputProcessorTests.cs
  74. 270 271
      Tests/UnitTests/Dialogs/DialogTests.cs
  75. 40 43
      Tests/UnitTests/Dialogs/MessageBoxTests.cs
  76. 1 1
      Tests/UnitTests/Dialogs/WizardTests.cs
  77. 54 55
      Tests/UnitTests/Drawing/LineCanvasTests.cs
  78. 18 20
      Tests/UnitTests/Drawing/RulerTests.cs
  79. 84 85
      Tests/UnitTests/Drawing/StraightLineExtensionsTests.cs
  80. 51 52
      Tests/UnitTests/Drawing/ThicknessTests.cs
  81. 6 6
      Tests/UnitTests/FileServices/FileDialogTests.cs
  82. 154 3
      Tests/UnitTests/TestsAllViews.cs
  83. 37 38
      Tests/UnitTests/Text/AutocompleteTests.cs
  84. 10 12
      Tests/UnitTests/Text/TextFormatterTests.cs
  85. 0 1
      Tests/UnitTests/UnitTests.csproj
  86. 2 3
      Tests/UnitTests/View/Adornment/BorderTests.cs
  87. 1 2
      Tests/UnitTests/View/Adornment/MarginTests.cs
  88. 1 2
      Tests/UnitTests/View/Adornment/PaddingTests.cs
  89. 37 0
      Tests/UnitTests/View/Adornment/ShadowStyleTests.cs
  90. 5 6
      Tests/UnitTests/View/Draw/AllViewsDrawTests.cs
  91. 51 53
      Tests/UnitTests/View/Draw/ClearViewportTests.cs
  92. 1 1
      Tests/UnitTests/View/Draw/ClipTests.cs
  93. 44 44
      Tests/UnitTests/View/Draw/DrawTests.cs
  94. 4 4
      Tests/UnitTests/View/Draw/NeedsDrawTests.cs
  95. 4 6
      Tests/UnitTests/View/Draw/TransparentTests.cs
  96. 1 1
      Tests/UnitTests/View/Layout/Dim.Tests.cs
  97. 4 5
      Tests/UnitTests/View/Layout/LayoutTests.cs
  98. 1 8
      Tests/UnitTests/View/Layout/Pos.AnchorEndTests.cs
  99. 0 1
      Tests/UnitTests/View/Layout/Pos.CenterTests.cs
  100. 1 1
      Tests/UnitTests/View/Layout/Pos.CombineTests.cs

+ 1 - 1
Terminal.Gui/Application/Application.Initialization.cs

@@ -7,7 +7,7 @@ namespace Terminal.Gui;
 
 public static partial class Application // Initialization (Init/Shutdown)
 {
-    /// <summary>Initializes a new instance of <see cref="Terminal.Gui"/> Application.</summary>
+    /// <summary>Initializes a new instance of a Terminal.Gui Application. <see cref="Shutdown"/> must be called when the application is closing.</summary>
     /// <para>Call this method once per instance (or after <see cref="Shutdown"/> has been called).</para>
     /// <para>
     ///     This function loads the right <see cref="IConsoleDriver"/> for the platform, Creates a <see cref="Toplevel"/>. and

+ 1 - 1
Terminal.Gui/Application/Application.Run.cs

@@ -71,7 +71,7 @@ public static partial class Application // Run (Begin, Run, End, Stop)
     /// <param name="toplevel">The <see cref="Toplevel"/> to prepare execution for.</param>
     /// <remarks>
     ///     This method prepares the provided <see cref="Toplevel"/> for running with the focus, it adds this to the list
-    ///     of <see cref="Toplevel"/>s, lays out the Subviews, focuses the first element, and draws the <see cref="Toplevel"/>
+    ///     of <see cref="Toplevel"/>s, lays out the SubViews, focuses the first element, and draws the <see cref="Toplevel"/>
     ///     in the screen. This is usually followed by executing the <see cref="RunLoop"/> method, and then the
     ///     <see cref="End(RunState)"/> method upon termination which will undo these changes.
     /// </remarks>

+ 2 - 2
Terminal.Gui/Application/ApplicationNavigation.cs

@@ -33,7 +33,7 @@ public class ApplicationNavigation
     }
 
     /// <summary>
-    ///     Gets whether <paramref name="view"/> is in the Subview hierarchy of <paramref name="start"/>.
+    ///     Gets whether <paramref name="view"/> is in the SubView hierarchy of <paramref name="start"/>.
     /// </summary>
     /// <param name="start"></param>
     /// <param name="view"></param>
@@ -50,7 +50,7 @@ public class ApplicationNavigation
             return true;
         }
 
-        foreach (View subView in start.Subviews)
+        foreach (View subView in start.SubViews)
         {
             if (view == subView)
             {

+ 1 - 1
Terminal.Gui/ConsoleDrivers/AnsiEscapeSequence.cs

@@ -33,7 +33,7 @@ public class AnsiEscapeSequence
     ///         to the oldest outstanding request.
     ///     </para>
     /// </summary>
-    public required string Terminator { get; init; }
+    public required string? Terminator { get; init; }
 
 
 

+ 1 - 1
Terminal.Gui/ConsoleDrivers/AnsiEscapeSequenceRequest.cs

@@ -12,7 +12,7 @@ public class AnsiEscapeSequenceRequest : AnsiEscapeSequence
     ///     Invoked when the console responds with an ANSI response code that matches the
     ///     <see cref="AnsiEscapeSequence.Terminator"/>
     /// </summary>
-    public required Action<string> ResponseReceived { get; init; }
+    public required Action<string?> ResponseReceived { get; init; }
 
     /// <summary>
     ///     Invoked if the console fails to responds to the ANSI response code

+ 4 - 4
Terminal.Gui/ConsoleDrivers/AnsiResponseParser/AnsiMouseParser.cs

@@ -17,11 +17,11 @@ public class AnsiMouseParser
     /// </summary>
     /// <param name="cur"></param>
     /// <returns></returns>
-    public bool IsMouse (string cur)
+    public bool IsMouse (string? cur)
     {
         // Typically in this format
         // ESC [ < {button_code};{x_pos};{y_pos}{final_byte}
-        return cur.EndsWith ('M') || cur.EndsWith ('m');
+        return cur!.EndsWith ('M') || cur.EndsWith ('m');
     }
 
     /// <summary>
@@ -30,10 +30,10 @@ public class AnsiMouseParser
     /// </summary>
     /// <param name="input"></param>
     /// <returns></returns>
-    public MouseEventArgs? ProcessMouseInput (string input)
+    public MouseEventArgs? ProcessMouseInput (string? input)
     {
         // Match mouse wheel events first
-        Match match = _mouseEventPattern.Match (input);
+        Match match = _mouseEventPattern.Match (input!);
 
         if (match.Success)
         {

+ 5 - 5
Terminal.Gui/ConsoleDrivers/AnsiResponseParser/AnsiRequestScheduler.cs

@@ -108,7 +108,7 @@ public class AnsiRequestScheduler
 
     private void EvictStaleRequests ()
     {
-        foreach (string stale in _lastSend.Where (v => IsStale (v.Value)).Select (k => k.Key))
+        foreach (string? stale in _lastSend.Where (v => IsStale (v.Value)).Select (k => k.Key))
         {
             EvictStaleRequests (stale);
         }
@@ -123,9 +123,9 @@ public class AnsiRequestScheduler
     /// </summary>
     /// <param name="withTerminator"></param>
     /// <returns></returns>
-    private bool EvictStaleRequests (string withTerminator)
+    private bool EvictStaleRequests (string? withTerminator)
     {
-        if (_lastSend.TryGetValue (withTerminator, out DateTime dt))
+        if (_lastSend.TryGetValue (withTerminator!, out DateTime dt))
         {
             if (IsStale (dt))
             {
@@ -178,7 +178,7 @@ public class AnsiRequestScheduler
 
     private void Send (AnsiEscapeSequenceRequest r)
     {
-        _lastSend.AddOrUpdate (r.Terminator, _ => Now (), (_, _) => Now ());
+        _lastSend.AddOrUpdate (r.Terminator!, _ => Now (), (_, _) => Now ());
         _parser.ExpectResponse (r.Terminator, r.ResponseReceived, r.Abandoned, false);
         r.Send ();
     }
@@ -206,7 +206,7 @@ public class AnsiRequestScheduler
 
     private bool ShouldThrottle (AnsiEscapeSequenceRequest r)
     {
-        if (_lastSend.TryGetValue (r.Terminator, out DateTime value))
+        if (_lastSend.TryGetValue (r.Terminator!, out DateTime value))
         {
             return Now () - value < _throttle;
         }

+ 2 - 2
Terminal.Gui/ConsoleDrivers/AnsiResponseParser/AnsiResponseExpectation.cs

@@ -1,7 +1,7 @@
 #nullable enable
 namespace Terminal.Gui;
 
-internal record AnsiResponseExpectation (string Terminator, Action<IHeld> Response, Action? Abandoned)
+internal record AnsiResponseExpectation (string? Terminator, Action<IHeld> Response, Action? Abandoned)
 {
-    public bool Matches (string cur) { return cur.EndsWith (Terminator); }
+    public bool Matches (string? cur) { return cur!.EndsWith (Terminator!); }
 }

+ 49 - 47
Terminal.Gui/ConsoleDrivers/AnsiResponseParser/AnsiResponseParser.cs

@@ -6,12 +6,32 @@ namespace Terminal.Gui;
 
 internal abstract class AnsiResponseParserBase : IAnsiResponseParser
 {
-    private const char Escape = '\x1B';
+    private const char ESCAPE = '\x1B';
     private readonly AnsiMouseParser _mouseParser = new ();
+#pragma warning disable IDE1006 // Naming Styles
     protected readonly AnsiKeyboardParser _keyboardParser = new ();
     protected object _lockExpectedResponses = new ();
 
     protected object _lockState = new ();
+    protected readonly IHeld _heldContent;
+
+    /// <summary>
+    ///     Responses we are expecting to come in.
+    /// </summary>
+    protected readonly List<AnsiResponseExpectation> _expectedResponses = [];
+
+    /// <summary>
+    ///     Collection of responses that we <see cref="StopExpecting"/>.
+    /// </summary>
+    protected readonly List<AnsiResponseExpectation> _lateResponses = [];
+
+    /// <summary>
+    ///     Responses that you want to look out for that will come in continuously e.g. mouse events.
+    ///     Key is the terminator.
+    /// </summary>
+    protected readonly List<AnsiResponseExpectation> _persistentExpectations = [];
+
+#pragma warning restore IDE1006 // Naming Styles
 
     /// <summary>
     ///     Event raised when mouse events are detected - requires setting <see cref="HandleMouse"/> to true
@@ -35,22 +55,6 @@ internal abstract class AnsiResponseParserBase : IAnsiResponseParser
     /// </summary>
     public bool HandleKeyboard { get; set; } = false;
 
-    /// <summary>
-    ///     Responses we are expecting to come in.
-    /// </summary>
-    protected readonly List<AnsiResponseExpectation> _expectedResponses = [];
-
-    /// <summary>
-    ///     Collection of responses that we <see cref="StopExpecting"/>.
-    /// </summary>
-    protected readonly List<AnsiResponseExpectation> _lateResponses = [];
-
-    /// <summary>
-    ///     Responses that you want to look out for that will come in continuously e.g. mouse events.
-    ///     Key is the terminator.
-    /// </summary>
-    protected readonly List<AnsiResponseExpectation> _persistentExpectations = [];
-
     private AnsiResponseParserState _state = AnsiResponseParserState.Normal;
 
     /// <inheritdoc/>
@@ -64,8 +68,6 @@ internal abstract class AnsiResponseParserBase : IAnsiResponseParser
         }
     }
 
-    protected readonly IHeld _heldContent;
-
     /// <summary>
     ///     When <see cref="State"/> was last changed.
     /// </summary>
@@ -74,17 +76,17 @@ internal abstract class AnsiResponseParserBase : IAnsiResponseParser
     // These all are valid terminators on ansi responses,
     // see CSI in https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s
     // No - N or O
-    protected readonly HashSet<char> _knownTerminators = new (
-                                                              [
-                                                                  '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
-
-                                                                  // No - N or O
-                                                                  'P', 'Q', 'R', 'S', 'T', 'W', 'X', 'Z',
-                                                                  '^', '`', '~',
-                                                                  'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
-                                                                  'l', 'm', 'n',
-                                                                  'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
-                                                              ]);
+    protected readonly HashSet<char> _knownTerminators =
+    [
+        '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
+
+        // No - N or O
+        'P', 'Q', 'R', 'S', 'T', 'W', 'X', 'Z',
+        '^', '`', '~',
+        'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
+        'l', 'm', 'n',
+        'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
+    ];
 
     protected AnsiResponseParserBase (IHeld heldContent) { _heldContent = heldContent; }
 
@@ -137,7 +139,7 @@ internal abstract class AnsiResponseParserBase : IAnsiResponseParser
             char currentChar = getCharAtIndex (index);
             object currentObj = getObjectAtIndex (index);
 
-            bool isEscape = currentChar == Escape;
+            bool isEscape = currentChar == ESCAPE;
 
             switch (State)
             {
@@ -233,7 +235,7 @@ internal abstract class AnsiResponseParserBase : IAnsiResponseParser
     {
         lock (_lockState)
         {
-            string cur = _heldContent.HeldToString ();
+            string? cur = _heldContent.HeldToString ();
 
             if (HandleKeyboard)
             {
@@ -250,7 +252,7 @@ internal abstract class AnsiResponseParserBase : IAnsiResponseParser
 
             // We have something totally unexpected, not a CSI and
             // still Esc+<something>. So give last minute swallow chance
-            if (cur.Length >= 2 && cur [0] == Escape)
+            if (cur!.Length >= 2 && cur [0] == ESCAPE)
             {
                 // Maybe swallow anyway if user has custom delegate
                 bool swallow = ShouldSwallowUnexpectedResponse ();
@@ -270,7 +272,7 @@ internal abstract class AnsiResponseParserBase : IAnsiResponseParser
     {
         lock (_lockState)
         {
-            string cur = _heldContent.HeldToString ();
+            string? cur = _heldContent.HeldToString ();
 
             if (HandleMouse && IsMouse (cur))
             {
@@ -328,7 +330,7 @@ internal abstract class AnsiResponseParserBase : IAnsiResponseParser
 
             // Finally if it is a valid ansi response but not one we are expect (e.g. its mouse activity)
             // then we can release it back to input processing stream
-            if (_knownTerminators.Contains (cur.Last ()) && cur.StartsWith (EscSeqUtils.CSI))
+            if (_knownTerminators.Contains (cur!.Last ()) && cur!.StartsWith (EscSeqUtils.CSI))
             {
                 // We have found a terminator so bail
                 State = AnsiResponseParserState.Normal;
@@ -354,7 +356,7 @@ internal abstract class AnsiResponseParserBase : IAnsiResponseParser
         return false; // Continue accumulating
     }
 
-    private void RaiseMouseEvent (string cur)
+    private void RaiseMouseEvent (string? cur)
     {
         MouseEventArgs? ev = _mouseParser.ProcessMouseInput (cur);
 
@@ -364,9 +366,9 @@ internal abstract class AnsiResponseParserBase : IAnsiResponseParser
         }
     }
 
-    private bool IsMouse (string cur) { return _mouseParser.IsMouse (cur); }
+    private bool IsMouse (string? cur) { return _mouseParser.IsMouse (cur); }
 
-    protected void RaiseKeyboardEvent (AnsiKeyboardParserPattern pattern, string cur)
+    protected void RaiseKeyboardEvent (AnsiKeyboardParserPattern pattern, string? cur)
     {
         Key? k = pattern.GetKey (cur);
 
@@ -394,7 +396,7 @@ internal abstract class AnsiResponseParserBase : IAnsiResponseParser
     /// <returns></returns>
     protected abstract bool ShouldSwallowUnexpectedResponse ();
 
-    private bool MatchResponse (string cur, List<AnsiResponseExpectation> collection, bool invokeCallback, bool removeExpectation)
+    private bool MatchResponse (string? cur, List<AnsiResponseExpectation> collection, bool invokeCallback, bool removeExpectation)
     {
         // Check for expected responses
         AnsiResponseExpectation? matchingResponse = collection.FirstOrDefault (r => r.Matches (cur));
@@ -422,7 +424,7 @@ internal abstract class AnsiResponseParserBase : IAnsiResponseParser
     }
 
     /// <inheritdoc/>
-    public void ExpectResponse (string terminator, Action<string> response, Action? abandoned, bool persistent)
+    public void ExpectResponse (string? terminator, Action<string?> response, Action? abandoned, bool persistent)
     {
         lock (_lockExpectedResponses)
         {
@@ -438,17 +440,17 @@ internal abstract class AnsiResponseParserBase : IAnsiResponseParser
     }
 
     /// <inheritdoc/>
-    public bool IsExpecting (string terminator)
+    public bool IsExpecting (string? terminator)
     {
         lock (_lockExpectedResponses)
         {
             // If any of the new terminator matches any existing terminators characters it's a collision so true.
-            return _expectedResponses.Any (r => r.Terminator.Intersect (terminator).Any ());
+            return _expectedResponses.Any (r => r.Terminator!.Intersect (terminator!).Any ());
         }
     }
 
     /// <inheritdoc/>
-    public void StopExpecting (string terminator, bool persistent)
+    public void StopExpecting (string? terminator, bool persistent)
     {
         lock (_lockExpectedResponses)
         {
@@ -530,7 +532,7 @@ internal class AnsiResponseParser<T> : AnsiResponseParserBase
     /// <param name="response"></param>
     /// <param name="abandoned"></param>
     /// <param name="persistent"></param>
-    public void ExpectResponseT (string terminator, Action<IEnumerable<Tuple<char, T>>> response, Action? abandoned, bool persistent)
+    public void ExpectResponseT (string? terminator, Action<IEnumerable<Tuple<char, T>>> response, Action? abandoned, bool persistent)
     {
         lock (_lockExpectedResponses)
         {
@@ -562,7 +564,7 @@ internal class AnsiResponseParser () : AnsiResponseParserBase (new StringHeld ()
     ///         keystrokes 'swallowed' (i.e. not returned to input stream).
     ///     </para>
     /// </summary>
-    public Func<string, bool> UnknownResponseHandler { get; set; } = _ => false;
+    public Func<string?, bool> UnknownResponseHandler { get; set; } = _ => false;
 
     public string ProcessInput (string input)
     {
@@ -583,13 +585,13 @@ internal class AnsiResponseParser () : AnsiResponseParserBase (new StringHeld ()
         output.Append (c);
     }
 
-    public string Release ()
+    public string? Release ()
     {
         lock (_lockState)
         {
             TryLastMinuteSequences ();
 
-            string output = _heldContent.HeldToString ();
+            string? output = _heldContent.HeldToString ();
             ResetState ();
 
             return output;

+ 1 - 1
Terminal.Gui/ConsoleDrivers/AnsiResponseParser/GenericHeld.cs

@@ -11,7 +11,7 @@ internal class GenericHeld<T> : IHeld
 
     public void ClearHeld () { held.Clear (); }
 
-    public string HeldToString () { return new (held.Select (h => h.Item1).ToArray ()); }
+    public string? HeldToString () { return new (held.Select (h => h.Item1).ToArray ()); }
 
     public IEnumerable<object> HeldToObjects () { return held; }
 

+ 3 - 3
Terminal.Gui/ConsoleDrivers/AnsiResponseParser/IAnsiResponseParser.cs

@@ -30,7 +30,7 @@ public interface IAnsiResponseParser
     ///     that already has one.
     ///     exists.
     /// </exception>
-    void ExpectResponse (string terminator, Action<string> response, Action? abandoned, bool persistent);
+    void ExpectResponse (string? terminator, Action<string?> response, Action? abandoned, bool persistent);
 
     /// <summary>
     ///     Returns true if there is an existing expectation (i.e. we are waiting a response
@@ -38,7 +38,7 @@ public interface IAnsiResponseParser
     /// </summary>
     /// <param name="terminator"></param>
     /// <returns></returns>
-    bool IsExpecting (string terminator);
+    bool IsExpecting (string? terminator);
 
     /// <summary>
     ///     Removes callback and expectation that we will get a response for the
@@ -50,5 +50,5 @@ public interface IAnsiResponseParser
     ///     <see langword="true"/> if you want to remove a persistent
     ///     request listener.
     /// </param>
-    void StopExpecting (string requestTerminator, bool persistent);
+    void StopExpecting (string? requestTerminator, bool persistent);
 }

+ 1 - 1
Terminal.Gui/ConsoleDrivers/AnsiResponseParser/IHeld.cs

@@ -16,7 +16,7 @@ internal interface IHeld
     ///     Returns string representation of the held objects
     /// </summary>
     /// <returns></returns>
-    string HeldToString ();
+    string? HeldToString ();
 
     /// <summary>
     ///     Returns the collection objects directly e.g. <see langword="char"/>

+ 1 - 1
Terminal.Gui/ConsoleDrivers/AnsiResponseParser/Keyboard/AnsiKeyboardParser.cs

@@ -20,7 +20,7 @@ public class AnsiKeyboardParser
     /// <param name="input"></param>
     /// <param name="isLastMinute"></param>
     /// <returns></returns>
-    public AnsiKeyboardParserPattern? IsKeyboard (string input, bool isLastMinute = false)
+    public AnsiKeyboardParserPattern? IsKeyboard (string? input, bool isLastMinute = false)
     {
         return _patterns.FirstOrDefault (pattern => pattern.IsLastMinute == isLastMinute && pattern.IsMatch (input));
     }

+ 3 - 3
Terminal.Gui/ConsoleDrivers/AnsiResponseParser/Keyboard/AnsiKeyboardParserPattern.cs

@@ -23,7 +23,7 @@ public abstract class AnsiKeyboardParserPattern
     /// </summary>
     /// <param name="input"></param>
     /// <returns></returns>
-    public abstract bool IsMatch (string input);
+    public abstract bool IsMatch (string? input);
 
     private readonly string _name;
 
@@ -37,7 +37,7 @@ public abstract class AnsiKeyboardParserPattern
     /// </summary>
     /// <param name="input"></param>
     /// <returns></returns>
-    public Key? GetKey (string input)
+    public Key? GetKey (string? input)
     {
         Key? key = GetKeyImpl (input);
         Logging.Trace ($"{nameof (AnsiKeyboardParser)} interpreted {input} as {key} using {_name}");
@@ -51,5 +51,5 @@ public abstract class AnsiKeyboardParserPattern
     /// </summary>
     /// <param name="input"></param>
     /// <returns></returns>
-    protected abstract Key? GetKeyImpl (string input);
+    protected abstract Key? GetKeyImpl (string? input);
 }

+ 3 - 3
Terminal.Gui/ConsoleDrivers/AnsiResponseParser/Keyboard/CsiKeyPattern.cs

@@ -41,7 +41,7 @@ public class CsiKeyPattern : AnsiKeyboardParserPattern
     private readonly Regex _pattern;
 
     /// <inheritdoc/>
-    public override bool IsMatch (string input) { return _pattern.IsMatch (input); }
+    public override bool IsMatch (string? input) { return _pattern.IsMatch (input!); }
 
     /// <summary>
     ///     Creates a new instance of the <see cref="CsiKeyPattern"/> class.
@@ -57,9 +57,9 @@ public class CsiKeyPattern : AnsiKeyboardParserPattern
     /// </summary>
     /// <param name="input"></param>
     /// <returns></returns>
-    protected override Key? GetKeyImpl (string input)
+    protected override Key? GetKeyImpl (string? input)
     {
-        Match match = _pattern.Match (input);
+        Match match = _pattern.Match (input!);
 
         if (!match.Success)
         {

+ 5 - 3
Terminal.Gui/ConsoleDrivers/AnsiResponseParser/Keyboard/EscAsAltPattern.cs

@@ -7,13 +7,15 @@ internal class EscAsAltPattern : AnsiKeyboardParserPattern
 {
     public EscAsAltPattern () { IsLastMinute = true; }
 
+#pragma warning disable IDE1006 // Naming Styles
     private static readonly Regex _pattern = new (@"^\u001b([a-zA-Z0-9_])$");
+#pragma warning restore IDE1006 // Naming Styles
 
-    public override bool IsMatch (string input) { return _pattern.IsMatch (input); }
+    public override bool IsMatch (string? input) { return _pattern.IsMatch (input!); }
 
-    protected override Key? GetKeyImpl (string input)
+    protected override Key? GetKeyImpl (string? input)
     {
-        Match match = _pattern.Match (input);
+        Match match = _pattern.Match (input!);
 
         if (!match.Success)
         {

+ 5 - 3
Terminal.Gui/ConsoleDrivers/AnsiResponseParser/Keyboard/Ss3Pattern.cs

@@ -9,19 +9,21 @@ namespace Terminal.Gui;
 /// </summary>
 public class Ss3Pattern : AnsiKeyboardParserPattern
 {
+#pragma warning disable IDE1006 // Naming Styles
     private static readonly Regex _pattern = new (@"^\u001bO([PQRStDCAB])$");
+#pragma warning restore IDE1006 // Naming Styles
 
     /// <inheritdoc/>
-    public override bool IsMatch (string input) { return _pattern.IsMatch (input); }
+    public override bool IsMatch (string? input) { return _pattern.IsMatch (input!); }
 
     /// <summary>
     ///     Returns the ss3 key that corresponds to the provided input escape sequence
     /// </summary>
     /// <param name="input"></param>
     /// <returns></returns>
-    protected override Key? GetKeyImpl (string input)
+    protected override Key? GetKeyImpl (string? input)
     {
-        Match match = _pattern.Match (input);
+        Match match = _pattern.Match (input!);
 
         if (!match.Success)
         {

+ 1 - 1
Terminal.Gui/ConsoleDrivers/AnsiResponseParser/StringHeld.cs

@@ -10,7 +10,7 @@ internal class StringHeld : IHeld
 
     public void ClearHeld () { _held.Clear (); }
 
-    public string HeldToString () { return _held.ToString (); }
+    public string? HeldToString () { return _held.ToString (); }
 
     public IEnumerable<object> HeldToObjects () { return _held.ToString ().Select (c => (object)c); }
 

+ 4 - 4
Terminal.Gui/ConsoleDrivers/V2/MainLoop.cs

@@ -122,7 +122,7 @@ public class MainLoop<T> : IMainLoop<T>
 
         if (Application.Top != null)
         {
-            bool needsDrawOrLayout = AnySubviewsNeedDrawn (Application.Top);
+            bool needsDrawOrLayout = AnySubViewsNeedDrawn (Application.Top);
 
             bool sizeChanged = WindowSizeMonitor.Poll ();
 
@@ -174,7 +174,7 @@ public class MainLoop<T> : IMainLoop<T>
         }
     }
 
-    private bool AnySubviewsNeedDrawn (View v)
+    private bool AnySubViewsNeedDrawn (View v)
     {
         if (v.NeedsDraw || v.NeedsLayout)
         {
@@ -183,9 +183,9 @@ public class MainLoop<T> : IMainLoop<T>
             return true;
         }
 
-        foreach (View subview in v.Subviews)
+        foreach (View subview in v.SubViews)
         {
-            if (AnySubviewsNeedDrawn (subview))
+            if (AnySubViewsNeedDrawn (subview))
             {
                 return true;
             }

+ 4 - 0
Terminal.Gui/Input/InputBindings.cs

@@ -43,10 +43,12 @@ public abstract class InputBindings<TEvent, TBinding> where TBinding : IInputBin
             throw new ArgumentException (@"Invalid newEventArgs", nameof (eventArgs));
         }
 
+#pragma warning disable CS8601 // Possible null reference assignment.
         if (TryGet (eventArgs, out TBinding _))
         {
             throw new InvalidOperationException (@$"A binding for {eventArgs} exists ({binding}).");
         }
+#pragma warning restore CS8601 // Possible null reference assignment.
 
         // IMPORTANT: Add a COPY of the eventArgs. This is needed because ConfigurationManager.Apply uses DeepMemberWiseCopy 
         // IMPORTANT: update the memory referenced by the key, and Dictionary uses caching for performance, and thus 
@@ -208,6 +210,7 @@ public abstract class InputBindings<TEvent, TBinding> where TBinding : IInputBin
     /// <param name="newCommands">The set of commands to replace the old ones with.</param>
     public void ReplaceCommands (TEvent eventArgs, params Command [] newCommands)
     {
+#pragma warning disable CS8601 // Possible null reference assignment.
         if (TryGet (eventArgs, out TBinding _))
         {
             Remove (eventArgs);
@@ -217,6 +220,7 @@ public abstract class InputBindings<TEvent, TBinding> where TBinding : IInputBin
         {
             Add (eventArgs, newCommands);
         }
+#pragma warning restore CS8601 // Possible null reference assignment.
     }
 
     /// <summary>Removes a <typeparamref name="TEvent"/> from the collection.</summary>

+ 1 - 6
Terminal.Gui/Text/Autocomplete/PopupAutocomplete.cs

@@ -75,11 +75,6 @@ public abstract partial class PopupAutocomplete : AutocompleteBase
         }
     }
 
-    private void _top_Added (object sender, SuperViewChangedEventArgs e)
-    {
-        throw new NotImplementedException ();
-    }
-
     /// <inheritdoc/>
     public override void EnsureSelectedIdxIsValid ()
     {
@@ -559,7 +554,7 @@ public abstract partial class PopupAutocomplete : AutocompleteBase
 
     private void RemovePopupFromTop ()
     {
-        if (_popup is { } && _top.Subviews.Contains (_popup))
+        if (_popup is { } && _top.SubViews.Contains (_popup))
         {
             _top?.Remove (_popup);
             _popup.Dispose ();

+ 2 - 17
Terminal.Gui/View/Adornment/Adornment.cs

@@ -11,7 +11,7 @@ namespace Terminal.Gui;
 ///     <para>
 ///         Each of <see cref="Margin"/>, <see cref="Border"/>, and <see cref="Padding"/> has slightly different
 ///         behavior relative to <see cref="ColorScheme"/>, <see cref="View.SetFocus()"/>, keyboard input, and
-///         mouse input. Each can be customized by manipulating their Subviews.
+///         mouse input. Each can be customized by manipulating their SubViews.
 ///     </para>
 /// </remarsk>
 public class Adornment : View, IDesignable
@@ -82,21 +82,6 @@ public class Adornment : View, IDesignable
     #endregion Thickness
 
     #region View Overrides
-
-    /// <summary>
-    ///     Adornments cannot be used as sub-views (see <see cref="Parent"/>); setting this property will throw
-    ///     <see cref="InvalidOperationException"/>.
-    /// </summary>
-    /// <remarks>
-    ///     While there are no real use cases for an Adornment being a subview, it is not explicitly dis-allowed to support
-    ///     testing. E.g. in AllViewsTester.
-    /// </remarks>
-    public override View? SuperView
-    {
-        get => base.SuperView!;
-        set => throw new InvalidOperationException (@"Adornments can not be Subviews or have SuperViews. Use Parent instead.");
-    }
-
     /// <summary>
     ///     Gets the rectangle that describes the area of the Adornment. The Location is always (0,0).
     ///     The size is the size of the <see cref="View.Frame"/>.
@@ -180,7 +165,7 @@ public class Adornment : View, IDesignable
     protected override bool OnDrawingText () { return Thickness == Thickness.Empty; }
 
     /// <inheritdoc/>
-    protected override bool OnDrawingSubviews () { return Thickness == Thickness.Empty; }
+    protected override bool OnDrawingSubViews () { return Thickness == Thickness.Empty; }
 
 
     /// <summary>Does nothing for Adornment</summary>

+ 1 - 1
Terminal.Gui/View/Adornment/Border.cs

@@ -711,7 +711,7 @@ public class Border : Adornment
         {
             Attribute focus = Parent.GetNormalColor ();
 
-            if (Parent.SuperView is { } && Parent.SuperView?.Subviews!.Count (s => s.CanFocus) > 1)
+            if (Parent.SuperView is { } && Parent.SuperView?.SubViews!.Count (s => s.CanFocus) > 1)
             {
                 // Only use focus color if there are multiple focusable views
                 focus = GetFocusColor ();

+ 2 - 2
Terminal.Gui/View/Adornment/Margin.cs

@@ -32,7 +32,7 @@ public class Margin : Adornment
         // BUGBUG: We should not set HighlightStyle.Pressed here, but wherever it is actually needed
         // HighlightStyle |= HighlightStyle.Pressed;
         Highlight += Margin_Highlight;
-        SubviewLayout += Margin_LayoutStarted;
+        SubViewLayout += Margin_LayoutStarted;
 
         // Margin should not be focusable
         CanFocus = false;
@@ -82,7 +82,7 @@ public class Margin : Adornment
 
             view.NeedsDraw = false;
 
-            foreach (var subview in view.Subviews)
+            foreach (var subview in view.SubViews)
             {
                 stack.Push (subview);
             }

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

@@ -96,7 +96,7 @@ public abstract record Dim : IEqualityOperators<Dim, Dim, bool>
     public static Dim? Absolute (int size) { return new DimAbsolute (size); }
 
     /// <summary>
-    ///     Creates a <see cref="Dim"/> object that automatically sizes the view to fit all the view's Content, Subviews, and/or Text.
+    ///     Creates a <see cref="Dim"/> object that automatically sizes the view to fit all the view's Content, SubViews, and/or Text.
     /// </summary>
     /// <remarks>
     ///     <para>

+ 23 - 23
Terminal.Gui/View/Layout/DimAuto.cs

@@ -72,7 +72,7 @@ public record DimAuto (Dim? MaximumContentDim, Dim? MinimumContentDim, DimAutoSt
         {
             maxCalculatedSize = textSize;
 
-            if (us is { ContentSizeTracksViewport: false, Subviews.Count: 0 })
+            if (us is { ContentSizeTracksViewport: false, InternalSubViews.Count: 0 })
             {
                 // ContentSize was explicitly set. Use `us.ContentSize` to determine size.
                 maxCalculatedSize = dimension == Dimension.Width ? us.GetContentSize ().Width : us.GetContentSize ().Height;
@@ -81,12 +81,12 @@ public record DimAuto (Dim? MaximumContentDim, Dim? MinimumContentDim, DimAutoSt
             {
                 // TOOD: All the below is a naive implementation. It may be possible to optimize this.
 
-                List<View> includedSubviews = us.Subviews.ToList ();
+                List<View> includedSubViews = us.InternalSubViews.ToList ();
 
                 // If [x] it can cause `us.ContentSize` to change.
                 // If [ ] it doesn't need special processing for us to determine `us.ContentSize`.
 
-                // -------------------- Pos types that are dependent on `us.Subviews`
+                // -------------------- Pos types that are dependent on `us.SubViews`
                 // [ ] PosAlign     - Position is dependent on other views with `GroupId` AND `us.ContentSize`
                 // [x] PosView      - Position is dependent on `subview.Target` - it can cause a change in `us.ContentSize`
                 // [x] PosCombine   - Position is dependent if `Pos.Has [one of the above]` - it can cause a change in `us.ContentSize`
@@ -98,11 +98,11 @@ public record DimAuto (Dim? MaximumContentDim, Dim? MinimumContentDim, DimAutoSt
                 // [ ] PosPercent   - Position is dependent `us.ContentSize` - Will always be 0 if there is no other content that makes the superview have a size.
                 // [x] PosCombine   - Position is dependent if `Pos.Has [one of the above]` - it can cause a change in `us.ContentSize`
 
-                // -------------------- Pos types that are not dependent on either `us.Subviews` or `us.ContentSize`
+                // -------------------- Pos types that are not dependent on either `us.SubViews` or `us.ContentSize`
                 // [ ] PosAbsolute  - Position is fixed.
                 // [ ] PosFunc      - Position is internally calculated.
 
-                // -------------------- Dim types that are dependent on `us.Subviews`
+                // -------------------- Dim types that are dependent on `us.SubViews`
                 // [x] DimView      - Dimension is dependent on `subview.Target`
                 // [x] DimCombine   - Dimension is dependent if `Dim.Has [one of the above]` - it can cause a change in `us.ContentSize`
 
@@ -111,7 +111,7 @@ public record DimAuto (Dim? MaximumContentDim, Dim? MinimumContentDim, DimAutoSt
                 // [ ] DimPercent   - Dimension is dependent on `us.ContentSize` - Will always be 0 if there is no other content that makes the superview have a size.
                 // [ ] DimCombine   - Dimension is dependent if `Dim.Has [one of the above]`
 
-                // -------------------- Dim types that are not dependent on either `us.Subviews` or `us.ContentSize`
+                // -------------------- Dim types that are not dependent on either `us.SubViews` or `us.ContentSize`
                 // [ ] DimAuto      - Dimension is internally calculated
                 // [ ] DimAbsolute  - Dimension is fixed
                 // [ ] DimFunc      - Dimension is internally calculated
@@ -128,7 +128,7 @@ public record DimAuto (Dim? MaximumContentDim, Dim? MinimumContentDim, DimAutoSt
 
                 if (dimension == Dimension.Width)
                 {
-                    notDependentSubViews = includedSubviews.Where (
+                    notDependentSubViews = includedSubViews.Where (
                                                                    v => v.Width is { }
                                                                         && (v.X is PosAbsolute or PosFunc
                                                                             || v.Width is DimAuto
@@ -144,7 +144,7 @@ public record DimAuto (Dim? MaximumContentDim, Dim? MinimumContentDim, DimAutoSt
                 }
                 else
                 {
-                    notDependentSubViews = includedSubviews.Where (
+                    notDependentSubViews = includedSubViews.Where (
                                                                    v => v.Height is { }
                                                                         && (v.Y is PosAbsolute or PosFunc
                                                                             || v.Height is DimAuto
@@ -197,11 +197,11 @@ public record DimAuto (Dim? MaximumContentDim, Dim? MinimumContentDim, DimAutoSt
 
                 if (dimension == Dimension.Width)
                 {
-                    centeredSubViews = us.Subviews.Where (v => v.X.Has<PosCenter> (out _)).ToList ();
+                    centeredSubViews = us.InternalSubViews.Where (v => v.X.Has<PosCenter> (out _)).ToList ();
                 }
                 else
                 {
-                    centeredSubViews = us.Subviews.Where (v => v.Y.Has<PosCenter> (out _)).ToList ();
+                    centeredSubViews = us.InternalSubViews.Where (v => v.Y.Has<PosCenter> (out _)).ToList ();
                 }
 
                 viewsNeedingLayout.AddRange (centeredSubViews);
@@ -241,7 +241,7 @@ public record DimAuto (Dim? MaximumContentDim, Dim? MinimumContentDim, DimAutoSt
                 var maxAlign = 0;
 
                 // Use Linq to get a list of distinct GroupIds from the subviews
-                List<int> groupIds = includedSubviews.Select (
+                List<int> groupIds = includedSubViews.Select (
                                                               v =>
                                                               {
                                                                   return dimension switch
@@ -259,7 +259,7 @@ public record DimAuto (Dim? MaximumContentDim, Dim? MinimumContentDim, DimAutoSt
                 foreach (int groupId in groupIds.Where (g => g != -1))
                 {
                     // PERF: If this proves a perf issue, consider caching a ref to this list in each item
-                    List<PosAlign?> posAlignsInGroup = includedSubviews.Where (v => PosAlign.HasGroupId (v, dimension, groupId))
+                    List<PosAlign?> posAlignsInGroup = includedSubViews.Where (v => PosAlign.HasGroupId (v, dimension, groupId))
                                                                        .Select (v => dimension == Dimension.Width ? v.X as PosAlign : v.Y as PosAlign)
                                                                        .ToList ();
 
@@ -268,7 +268,7 @@ public record DimAuto (Dim? MaximumContentDim, Dim? MinimumContentDim, DimAutoSt
                         continue;
                     }
 
-                    maxAlign = PosAlign.CalculateMinDimension (groupId, includedSubviews, dimension);
+                    maxAlign = PosAlign.CalculateMinDimension (groupId, includedSubViews, dimension);
                 }
 
                 maxCalculatedSize = int.Max (maxCalculatedSize, maxAlign);
@@ -282,11 +282,11 @@ public record DimAuto (Dim? MaximumContentDim, Dim? MinimumContentDim, DimAutoSt
 
                 if (dimension == Dimension.Width)
                 {
-                    anchoredSubViews = includedSubviews.Where (v => v.X.Has<PosAnchorEnd> (out _)).ToList ();
+                    anchoredSubViews = includedSubViews.Where (v => v.X.Has<PosAnchorEnd> (out _)).ToList ();
                 }
                 else
                 {
-                    anchoredSubViews = includedSubviews.Where (v => v.Y.Has<PosAnchorEnd> (out _)).ToList ();
+                    anchoredSubViews = includedSubViews.Where (v => v.Y.Has<PosAnchorEnd> (out _)).ToList ();
                 }
 
                 viewsNeedingLayout.AddRange (anchoredSubViews);
@@ -324,11 +324,11 @@ public record DimAuto (Dim? MaximumContentDim, Dim? MinimumContentDim, DimAutoSt
 
                 if (dimension == Dimension.Width)
                 {
-                    posViewSubViews = includedSubviews.Where (v => v.X.Has<PosView> (out _)).ToList ();
+                    posViewSubViews = includedSubViews.Where (v => v.X.Has<PosView> (out _)).ToList ();
                 }
                 else
                 {
-                    posViewSubViews = includedSubviews.Where (v => v.Y.Has<PosView> (out _)).ToList ();
+                    posViewSubViews = includedSubViews.Where (v => v.Y.Has<PosView> (out _)).ToList ();
                 }
 
                 for (var i = 0; i < posViewSubViews.Count; i++)
@@ -358,11 +358,11 @@ public record DimAuto (Dim? MaximumContentDim, Dim? MinimumContentDim, DimAutoSt
 
                 if (dimension == Dimension.Width)
                 {
-                    dimViewSubViews = includedSubviews.Where (v => v.Width is { } && v.Width.Has<DimView> (out _)).ToList ();
+                    dimViewSubViews = includedSubViews.Where (v => v.Width is { } && v.Width.Has<DimView> (out _)).ToList ();
                 }
                 else
                 {
-                    dimViewSubViews = includedSubviews.Where (v => v.Height is { } && v.Height.Has<DimView> (out _)).ToList ();
+                    dimViewSubViews = includedSubViews.Where (v => v.Height is { } && v.Height.Has<DimView> (out _)).ToList ();
                 }
 
                 for (var i = 0; i < dimViewSubViews.Count; i++)
@@ -391,11 +391,11 @@ public record DimAuto (Dim? MaximumContentDim, Dim? MinimumContentDim, DimAutoSt
 
                 if (dimension == Dimension.Width)
                 {
-                    dimAutoSubViews = includedSubviews.Where (v => v.Width is { } && v.Width.Has<DimAuto> (out _)).ToList ();
+                    dimAutoSubViews = includedSubViews.Where (v => v.Width is { } && v.Width.Has<DimAuto> (out _)).ToList ();
                 }
                 else
                 {
-                    dimAutoSubViews = includedSubviews.Where (v => v.Height is { } && v.Height.Has<DimAuto> (out _)).ToList ();
+                    dimAutoSubViews = includedSubViews.Where (v => v.Height is { } && v.Height.Has<DimAuto> (out _)).ToList ();
                 }
 
                 for (var i = 0; i < dimAutoSubViews.Count; i++)
@@ -423,11 +423,11 @@ public record DimAuto (Dim? MaximumContentDim, Dim? MinimumContentDim, DimAutoSt
 
                 //if (dimension == Dimension.Width)
                 //{
-                //    DimFillSubViews = includedSubviews.Where (v => v.Width is { } && v.Width.Has<DimFill> (out _)).ToList ();
+                //    DimFillSubViews = includedSubViews.Where (v => v.Width is { } && v.Width.Has<DimFill> (out _)).ToList ();
                 //}
                 //else
                 //{
-                //    DimFillSubViews = includedSubviews.Where (v => v.Height is { } && v.Height.Has<DimFill> (out _)).ToList ();
+                //    DimFillSubViews = includedSubViews.Where (v => v.Height is { } && v.Height.Has<DimFill> (out _)).ToList ();
                 //}
 
                 //for (var i = 0; i < DimFillSubViews.Count; i++)

+ 4 - 4
Terminal.Gui/View/Layout/DimAutoStyle.cs

@@ -10,12 +10,12 @@ namespace Terminal.Gui;
 public enum DimAutoStyle
 {
     /// <summary>
-    ///     The dimensions will be computed based on the View's <see cref="View.GetContentSize ()"/> and/or <see cref="View.Subviews"/>.
+    ///     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.ContentSizeTracksViewport"/> 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
+    ///         Otherwise, the SubView in <see cref="View.SubViews"/> with the largest corresponding position plus dimension
     ///         will determine the dimension.
     ///     </para>
     ///     <para>
@@ -31,7 +31,7 @@ public enum DimAutoStyle
     ///         will be used to determine the dimension.
     ///     </para>
     ///     <para>
-    ///         The corresponding dimensions of <see cref="View.GetContentSize ()"/> and/or <see cref="View.Subviews"/> will be ignored.
+    ///         The corresponding dimensions of <see cref="View.GetContentSize ()"/> and/or <see cref="View.SubViews"/> will be ignored.
     ///     </para>
     ///     <para>
     ///         If <see cref="DimAuto.MaximumContentDim"/> is set, the dimension will be the maximum of the formatted text and the
@@ -42,7 +42,7 @@ public enum DimAutoStyle
 
     /// <summary>
     ///     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
+    ///     <see cref="View.SubViews"/> corresponding dimension
     /// </summary>
     Auto = Content | Text,
 }

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

@@ -1,6 +1,6 @@
 namespace Terminal.Gui;
 
-/// <summary>Event arguments for the <see cref="View.SubviewsLaidOut"/> event.</summary>
+/// <summary>Event arguments for the <see cref="View.SubViewsLaidOut"/> event.</summary>
 public class LayoutEventArgs : EventArgs
 {
     /// <summary>Creates a new instance of the <see cref="Terminal.Gui.LayoutEventArgs"/> class.</summary>

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

@@ -58,7 +58,7 @@ public record PosAlign : Pos
     /// <param name="views"></param>
     /// <param name="dimension"></param>
     /// <returns></returns>
-    public static int CalculateMinDimension (int groupId, IList<View> views, Dimension dimension)
+    public static int CalculateMinDimension (int groupId, IReadOnlyCollection<View> views, Dimension dimension)
     {
         int dimensionsSum = 0;
         foreach (var view in views)
@@ -117,7 +117,7 @@ public record PosAlign : Pos
         }
         else
         {
-            groupViews = us.SuperView!.Subviews.Where (v => HasGroupId (v, dimension, GroupId)).ToList ();
+            groupViews = us.SuperView!.SubViews.Where (v => HasGroupId (v, dimension, GroupId)).ToList ();
         }
 
         AlignAndUpdateGroup (GroupId, groupViews, dimension, superviewDimension);

+ 2 - 2
Terminal.Gui/View/SuperViewChangedEventArgs.cs

@@ -2,7 +2,7 @@
 
 /// <summary>
 ///     Args for events where the <see cref="View.SuperView"/> of a <see cref="View"/> is changed (e.g.
-///     <see cref="View.Removed"/> / <see cref="View.Added"/> events).
+///     <see cref="View.Removed"/> / <see cref="View.IsAddedChanged"/> events).
 /// </summary>
 public class SuperViewChangedEventArgs : EventArgs
 {
@@ -20,7 +20,7 @@ public class SuperViewChangedEventArgs : EventArgs
 
     /// <summary>
     ///     The parent.  For <see cref="View.Removed"/> this is the old parent (new parent now being null).  For
-    ///     <see cref="View.Added"/> it is the new parent to whom view now belongs.
+    ///     <see cref="View.IsAddedChanged"/> it is the new parent to whom view now belongs.
     /// </summary>
     public View SuperView { get; }
 }

+ 3 - 3
Terminal.Gui/View/View.Adornments.cs

@@ -60,7 +60,7 @@ public partial class View // Adornments
     ///     <para>
     ///         Changing the size of an adornment (<see cref="Margin"/>, <see cref="Border"/>, or <see cref="Padding"/>) will
     ///         change the size of <see cref="Frame"/> which will call <see cref="SetNeedsLayout"/> to update the layout of the
-    ///         <see cref="SuperView"/> and its <see cref="Subviews"/>.
+    ///         <see cref="SuperView"/> and its <see cref="SubViews"/>.
     ///     </para>
     /// </remarks>
     public Margin? Margin { get; private set; }
@@ -116,7 +116,7 @@ public partial class View // Adornments
     ///     <para>
     ///         Changing the size of an adornment (<see cref="Margin"/>, <see cref="Border"/>, or <see cref="Padding"/>) will
     ///         change the size of <see cref="Frame"/> which will call <see cref="SetNeedsLayout"/> to update the layout of the
-    ///         <see cref="SuperView"/> and its <see cref="Subviews"/>.
+    ///         <see cref="SuperView"/> and its <see cref="SubViews"/>.
     ///     </para>
     /// </remarks>
     public Border? Border { get; private set; }
@@ -233,7 +233,7 @@ public partial class View // Adornments
     ///     <para>
     ///         Changing the size of an adornment (<see cref="Margin"/>, <see cref="Border"/>, or <see cref="Padding"/>) will
     ///         change the size of <see cref="Frame"/> which will call <see cref="SetNeedsLayout"/> to update the layout of the
-    ///         <see cref="SuperView"/> and its <see cref="Subviews"/>.
+    ///         <see cref="SuperView"/> and its <see cref="SubViews"/>.
     ///     </para>
     /// </remarks>
     public Padding? Padding { get; private set; }

+ 2 - 2
Terminal.Gui/View/View.Command.cs

@@ -90,8 +90,8 @@ public partial class View // Command APIs
         //  - bubbled up the SuperView hierarchy.
         if (!args.Cancel)
         {
-            // If there's an IsDefault peer view in Subviews, try it
-            var isDefaultView = SuperView?.Subviews.FirstOrDefault (v => v is Button { IsDefault: true });
+            // If there's an IsDefault peer view in SubViews, try it
+            var isDefaultView = SuperView?.InternalSubViews.FirstOrDefault (v => v is Button { IsDefault: true });
 
             if (isDefaultView != this && isDefaultView is Button { IsDefault: true } button)
             {

+ 4 - 4
Terminal.Gui/View/View.Content.cs

@@ -25,7 +25,7 @@ public partial class View
     ///     <para>
     ///         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
+    ///         position + dimension of the SubViews, supporting <see cref="Dim.Auto"/> with the
     ///         <see cref="DimAutoStyle.Content"/> flag set.
     ///     </para>
     ///     <para>
@@ -68,7 +68,7 @@ public partial class View
     ///     <para>
     ///         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
+    ///         position + dimension of the SubViews, supporting <see cref="Dim.Auto"/> with the
     ///         <see cref="DimAutoStyle.Content"/> flag set.
     ///     </para>
     ///     <para>
@@ -109,7 +109,7 @@ public partial class View
     ///                     disabled.
     ///                 </para>
     ///                 <para>
-    ///                     The behavior of <see cref="DimAutoStyle.Content"/> will be to use position and size of the Subviews
+    ///                     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>
@@ -128,7 +128,7 @@ public partial class View
     ///                     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.
+    ///                     size of the view, ignoring the position and size of the SubViews.
     ///                 </para>
     ///             </description>
     ///         </item>

+ 32 - 32
Terminal.Gui/View/View.Drawing.cs

@@ -78,11 +78,11 @@ public partial class View // Drawing APIs
             DoClearViewport ();
 
             // ------------------------------------
-            // Draw the subviews first (order matters: Subviews, Text, Content)
+            // Draw the subviews first (order matters: SubViews, Text, Content)
             if (SubViewNeedsDraw)
             {
                 DoSetAttribute ();
-                DoDrawSubviews (context);
+                DoDrawSubViews (context);
             }
 
             // ------------------------------------
@@ -133,10 +133,10 @@ public partial class View // Drawing APIs
 
     private void DoDrawBorderAndPaddingSubViews ()
     {
-        if (Border?.Subviews is { } && Border.Thickness != Thickness.Empty)
+        if (Border?.SubViews is { } && Border.Thickness != Thickness.Empty)
         {
             // PERFORMANCE: Get the check for DrawIndicator out of this somehow.
-            foreach (View subview in Border.Subviews.Where (v => v.Visible || v.Id == "DrawIndicator"))
+            foreach (View subview in Border.SubViews.Where (v => v.Visible || v.Id == "DrawIndicator"))
             {
                 if (subview.Id != "DrawIndicator")
                 {
@@ -147,19 +147,19 @@ public partial class View // Drawing APIs
             }
 
             Region? saved = Border?.AddFrameToClip ();
-            Border?.DoDrawSubviews ();
+            Border?.DoDrawSubViews ();
             SetClip (saved);
         }
 
-        if (Padding?.Subviews is { } && Padding.Thickness != Thickness.Empty)
+        if (Padding?.SubViews is { } && Padding.Thickness != Thickness.Empty)
         {
-            foreach (View subview in Padding.Subviews)
+            foreach (View subview in Padding.SubViews)
             {
                 subview.SetNeedsDraw ();
             }
 
             Region? saved = Padding?.AddFrameToClip ();
-            Padding?.DoDrawSubviews ();
+            Padding?.DoDrawSubViews ();
             SetClip (saved);
         }
     }
@@ -191,7 +191,7 @@ public partial class View // Drawing APIs
 
         if (SubViewNeedsDraw)
         {
-            // A Subview may add to the LineCanvas. This ensures any Adornment LineCanvas updates happen.
+            // A SubView may add to the LineCanvas. This ensures any Adornment LineCanvas updates happen.
             Border?.SetNeedsDraw ();
             Padding?.SetNeedsDraw ();
         }
@@ -525,22 +525,22 @@ public partial class View // Drawing APIs
 
     #endregion DrawContent
 
-    #region DrawSubviews
+    #region DrawSubViews
 
-    private void DoDrawSubviews (DrawContext? context = null)
+    private void DoDrawSubViews (DrawContext? context = null)
     {
-        if (OnDrawingSubviews (context))
+        if (OnDrawingSubViews (context))
         {
             return;
         }
 
-        if (OnDrawingSubviews ())
+        if (OnDrawingSubViews ())
         {
             return;
         }
 
         var dev = new DrawEventArgs (Viewport, Rectangle.Empty, context);
-        DrawingSubviews?.Invoke (this, dev);
+        DrawingSubViews?.Invoke (this, dev);
 
         if (dev.Cancel)
         {
@@ -552,44 +552,44 @@ public partial class View // Drawing APIs
             return;
         }
 
-        DrawSubviews (context);
+        DrawSubViews (context);
     }
 
     /// <summary>
-    ///     Called when the <see cref="Subviews"/> are to be drawn.
+    ///     Called when the <see cref="SubViews"/> are to be drawn.
     /// </summary>
     /// <param name="context">The draw context to report drawn areas to, or null if not tracking.</param>
-    /// <returns><see langword="true"/> to stop further drawing of <see cref="Subviews"/>.</returns>
-    protected virtual bool OnDrawingSubviews (DrawContext? context) { return false; }
+    /// <returns><see langword="true"/> to stop further drawing of <see cref="SubViews"/>.</returns>
+    protected virtual bool OnDrawingSubViews (DrawContext? context) { return false; }
 
     /// <summary>
-    ///     Called when the <see cref="Subviews"/> are to be drawn.
+    ///     Called when the <see cref="SubViews"/> are to be drawn.
     /// </summary>
-    /// <returns><see langword="true"/> to stop further drawing of <see cref="Subviews"/>.</returns>
-    protected virtual bool OnDrawingSubviews () { return false; }
+    /// <returns><see langword="true"/> to stop further drawing of <see cref="SubViews"/>.</returns>
+    protected virtual bool OnDrawingSubViews () { return false; }
 
-    /// <summary>Raised when the <see cref="Subviews"/> are to be drawn.</summary>
+    /// <summary>Raised when the <see cref="SubViews"/> are to be drawn.</summary>
     /// <remarks>
     /// </remarks>
     /// <returns>
     ///     Set <see cref="CancelEventArgs.Cancel"/> to <see langword="true"/> to stop further drawing of
-    ///     <see cref="Subviews"/>.
+    ///     <see cref="SubViews"/>.
     /// </returns>
-    public event EventHandler<DrawEventArgs>? DrawingSubviews;
+    public event EventHandler<DrawEventArgs>? DrawingSubViews;
 
     /// <summary>
-    ///     Draws the <see cref="Subviews"/>.
+    ///     Draws the <see cref="SubViews"/>.
     /// </summary>
     /// <param name="context">The draw context to report drawn areas to, or null if not tracking.</param>
-    public void DrawSubviews (DrawContext? context = null)
+    public void DrawSubViews (DrawContext? context = null)
     {
-        if (_subviews is null)
+        if (InternalSubViews.Count == 0)
         {
             return;
         }
 
         // Draw the subviews in reverse order to leverage clipping.
-        foreach (View view in _subviews.Where (view => view.Visible).Reverse ())
+        foreach (View view in InternalSubViews.Where (view => view.Visible).Reverse ())
         {
             // TODO: HACK - This forcing of SetNeedsDraw with SuperViewRendersLineCanvas enables auto line join to work, but is brute force.
             if (view.SuperViewRendersLineCanvas || view.ViewportSettings.HasFlag (ViewportSettings.Transparent))
@@ -606,7 +606,7 @@ public partial class View // Drawing APIs
         }
     }
 
-    #endregion DrawSubviews
+    #endregion DrawSubViews
 
     #region DrawLineCanvas
 
@@ -772,7 +772,7 @@ public partial class View // Drawing APIs
         }
     }
 
-    /// <summary>Gets whether any Subviews need to be redrawn.</summary>
+    /// <summary>Gets whether any SubViews need to be redrawn.</summary>
     public bool SubViewNeedsDraw { get; private set; }
 
     /// <summary>Sets that the <see cref="Viewport"/> of this View needs to be redrawn.</summary>
@@ -844,7 +844,7 @@ public partial class View // Drawing APIs
         }
 
         // There was multiple enumeration error here, so calling ToArray - probably a stop gap
-        foreach (View subview in Subviews.ToArray ())
+        foreach (View subview in SubViews.ToArray ())
         {
             if (subview.Frame.IntersectsWith (viewPortRelativeRegion))
             {
@@ -898,7 +898,7 @@ public partial class View // Drawing APIs
             Padding?.ClearNeedsDraw ();
         }
 
-        foreach (View subview in Subviews)
+        foreach (View subview in SubViews)
         {
             subview.ClearNeedsDraw ();
         }

+ 188 - 97
Terminal.Gui/View/View.Hierarchy.cs

@@ -7,64 +7,115 @@ namespace Terminal.Gui;
 public partial class View // SuperView/SubView hierarchy management (SuperView, SubViews, Add, Remove, etc.)
 {
     [SuppressMessage ("Style", "IDE1006:Naming Styles", Justification = "<Pending>")]
-    private static readonly IList<View> _empty = new List<View> (0).AsReadOnly ();
+    private static readonly IReadOnlyCollection<View> _empty = [];
 
-    private List<View>? _subviews; // This is null, and allocated on demand.
+    private readonly List<View>? _subviews = [];
 
-    // Internally, we use InternalSubviews rather than subviews, as we do not expect us
-    // to make the same mistakes our users make when they poke at the Subviews.
-    internal IList<View> InternalSubviews => _subviews ?? _empty;
+    // Internally, we use InternalSubViews rather than subviews, as we do not expect us
+    // to make the same mistakes our users make when they poke at the SubViews.
+    internal IList<View> InternalSubViews => _subviews ?? [];
 
-    /// <summary>This returns a list of the subviews contained by this view.</summary>
-    /// <value>The subviews.</value>
-    public IList<View> Subviews => _subviews?.AsReadOnly () ?? _empty;
+    /// <summary>Gets the list of SubViews.</summary>
+    /// <remarks>
+    ///     Use <see cref="Add(Terminal.Gui.View?)"/> and <see cref="Remove(Terminal.Gui.View?)"/> to add or remove subviews.
+    /// </remarks>
+    public IReadOnlyCollection<View> SubViews => InternalSubViews?.AsReadOnly () ?? _empty;
 
     private View? _superView;
 
-    /// <summary>Returns the container for this view, or null if this view has not been added to a container.</summary>
-    /// <value>The super view.</value>
-    public virtual View? SuperView
+    /// <summary>
+    ///     Gets this Views SuperView (the View's container), or <see langword="null"/> if this view has not been added as a
+    ///     SubView.
+    /// </summary>
+    /// <seealso cref="OnSuperViewChanged"/>
+    /// <seealso cref="SuperViewChanged"/>
+    public View? SuperView
     {
         get => _superView!;
-        set => throw new NotImplementedException ();
+        private set => SetSuperView (value);
     }
 
-    #region AddRemove
+    private void SetSuperView (View? value)
+    {
+        if (_superView == value)
+        {
+            return;
+        }
+
+        _superView = value;
+        RaiseSuperViewChanged ();
+    }
+
+    private void RaiseSuperViewChanged ()
+    {
+        SuperViewChangedEventArgs args = new (SuperView, this);
+        OnSuperViewChanged (args);
+
+        SuperViewChanged?.Invoke (this, args);
+    }
+
+    /// <summary>
+    ///     Called when the SuperView of this View has changed.
+    /// </summary>
+    /// <param name="e"></param>
+    protected virtual void OnSuperViewChanged (SuperViewChangedEventArgs e) { }
+
+    /// <summary>Raised when the SuperView of this View has changed.</summary>
+    public event EventHandler<SuperViewChangedEventArgs>? SuperViewChanged;
 
-    /// <summary>Indicates whether the view was added to <see cref="SuperView"/>.</summary>
-    public bool IsAdded { get; private set; }
+    #region AddRemove
 
-    /// <summary>Adds a subview (child) to this view.</summary>
+    /// <summary>Adds a SubView (child) to this view.</summary>
     /// <remarks>
     ///     <para>
-    ///         The Views that have been added to this view can be retrieved via the <see cref="Subviews"/> property. See also
-    ///         <seealso cref="Remove(View)"/> <seealso cref="RemoveAll"/>
+    ///         The Views that have been added to this view can be retrieved via the <see cref="SubViews"/> property. 
+    ///     </para>
+    ///     <para>
+    ///         To check if a View has been added to this View, compare it's <see cref="SuperView"/> property to this View.
     ///     </para>
     ///     <para>
-    ///         Subviews will be disposed when this View is disposed. In other-words, calling this method causes
+    ///         SubViews will be disposed when this View is disposed. In other-words, calling this method causes
     ///         the lifecycle of the subviews to be transferred to this View.
     ///     </para>
+    ///     <para>
+    ///         Calls/Raises the <see cref="OnSubViewAdded"/>/<see cref="SubViewAdded"/> event.
+    ///     </para>
+    ///     <para>
+    ///         The <see cref="OnSuperViewChanged"/>/<see cref="SuperViewChanged"/> event will be raised on the added View.
+    ///     </para>
     /// </remarks>
     /// <param name="view">The view to add.</param>
     /// <returns>The view that was added.</returns>
+    /// <seealso cref="Remove(View)"/>
+    /// <seealso cref="RemoveAll"/>
+    /// <seealso cref="OnSubViewAdded"/>
+    /// <seealso cref="SubViewAdded"/>
+
     public virtual View? Add (View? view)
     {
         if (view is null)
         {
             return null;
         }
-        if (_subviews is null)
+
+        //Debug.Assert (view.SuperView is null, $"{view} already has a SuperView: {view.SuperView}.");
+        if (view.SuperView is {})
         {
-            _subviews = [];
+            Logging.Warning ($"{view} already has a SuperView: {view.SuperView}.");
         }
 
-        Debug.WriteLineIf (_subviews.Contains (view), $"WARNING: {view} has already been added to {this}.");
+        //Debug.Assert (!InternalSubViews.Contains (view), $"{view} has already been Added to {this}.");
+        if (InternalSubViews.Contains (view))
+        {
+            Logging.Warning ($"{view} has already been Added to {this}.");
+        }
 
         // TileView likes to add views that were previously added and have HasFocus = true. No bueno.
         view.HasFocus = false;
 
-        _subviews.Add (view);
-        view._superView = this;
+        // TODO: Make this thread safe
+        InternalSubViews.Add (view);
+        view.SuperView = this;
 
         if (view is { Enabled: true, Visible: true, CanFocus: true })
         {
@@ -80,7 +131,9 @@ public partial class View // SuperView/SubView hierarchy management (SuperView,
             view.Enabled = false;
         }
 
-        OnAdded (new (this, view));
+        // Raise event indicating a subview has been added
+        // We do this before Init.
+        RaiseSubViewAdded (view);
 
         if (IsInitialized && !view.IsInitialized)
         {
@@ -94,15 +147,15 @@ public partial class View // SuperView/SubView hierarchy management (SuperView,
         return view;
     }
 
-    /// <summary>Adds the specified views (children) to the view.</summary>
+    /// <summary>Adds the specified SubView (children) to the view.</summary>
     /// <param name="views">Array of one or more views (can be optional parameter).</param>
     /// <remarks>
     ///     <para>
-    ///         The Views that have been added to this view can be retrieved via the <see cref="Subviews"/> property. See also
+    ///         The Views that have been added to this view can be retrieved via the <see cref="SubViews"/> property. See also
     ///         <seealso cref="Remove(View)"/> and <seealso cref="RemoveAll"/>.
     ///     </para>
     ///     <para>
-    ///         Subviews will be disposed when this View is disposed. In other-words, calling this method causes
+    ///         SubViews will be disposed when this View is disposed. In other-words, calling this method causes
     ///         the lifecycle of the subviews to be transferred to this View.
     ///     </para>
     /// </remarks>
@@ -119,38 +172,46 @@ public partial class View // SuperView/SubView hierarchy management (SuperView,
         }
     }
 
-    /// <summary>Event fired when this view is added to another.</summary>
-    public event EventHandler<SuperViewChangedEventArgs>? Added;
-
-    /// <summary>Method invoked when a subview is being added to this view.</summary>
-    /// <param name="e">Event where <see cref="ViewEventArgs.View"/> is the subview being added.</param>
-    public virtual void OnAdded (SuperViewChangedEventArgs e)
+    internal void RaiseSubViewAdded (View view)
     {
-        View view = e.SubView;
-        view.IsAdded = true;
-        view.Added?.Invoke (this, e);
+        OnSubViewAdded (view);
+        SubViewAdded?.Invoke (this, new (this, view));
     }
 
-    /// <summary>Method invoked when a subview is being removed from this view.</summary>
-    /// <param name="e">Event args describing the subview being removed.</param>
-    public virtual void OnRemoved (SuperViewChangedEventArgs e)
-    {
-        View view = e.SubView;
-        view.IsAdded = false;
-        view.Removed?.Invoke (this, e);
-    }
+    /// <summary>
+    ///     Called when a SubView has been added to this View.
+    /// </summary>
+    /// <remarks>
+    ///     If the SubView has not been initialized, this happens before BeginInit/EndInit is called.
+    /// </remarks>
+    /// <param name="view"></param>
+    protected virtual void OnSubViewAdded (View view) { }
 
-    /// <summary>Removes a subview added via <see cref="Add(View)"/> or <see cref="Add(View[])"/> from this View.</summary>
+    /// <summary>Raised when a SubView has been added to this View.</summary>
+    /// <remarks>
+    ///     If the SubView has not been initialized, this happens before BeginInit/EndInit is called.
+    /// </remarks>
+    public event EventHandler<SuperViewChangedEventArgs>? SubViewAdded;
+
+    /// <summary>Removes a SubView added via <see cref="Add(View)"/> or <see cref="Add(View[])"/> from this View.</summary>
     /// <remarks>
     ///     <para>
-    ///         Normally Subviews will be disposed when this View is disposed. Removing a Subview causes ownership of the
-    ///         Subview's
+    ///         Normally SubViews will be disposed when this View is disposed. Removing a SubView causes ownership of the
+    ///         SubView's
     ///         lifecycle to be transferred to the caller; the caller must call <see cref="Dispose()"/>.
     ///     </para>
+    ///     <para>
+    ///         Calls/Raises the <see cref="OnSubViewRemoved"/>/<see cref="SubViewRemoved"/> event.
+    ///     </para>
+    ///     <para>
+    ///         The <see cref="OnSuperViewChanged"/>/<see cref="SuperViewChanged"/> event will be raised on the removed View.
+    ///     </para>
     /// </remarks>
     /// <returns>
     ///     The removed View. <see langword="null"/> if the View could not be removed.
     /// </returns>
+    /// <seealso cref="OnSubViewRemoved"/>
+    /// <seealso cref="SubViewRemoved"/>"/>
     public virtual View? Remove (View? view)
     {
         if (view is null)
@@ -158,9 +219,24 @@ public partial class View // SuperView/SubView hierarchy management (SuperView,
             return null;
         }
 
-        if (_subviews is null)
+        if (InternalSubViews.Count == 0)
+        {
+           return view;
+        }
+
+        if (view.SuperView is null)
         {
-            return view;
+            Logging.Warning ($"{view} cannot be Removed. SuperView is null.");
+        }
+
+        if (view.SuperView != this)
+        {
+            Logging.Warning ($"{view} cannot be Removed. SuperView is not this ({view.SuperView}.");
+        }
+
+        if (!InternalSubViews.Contains (view))
+        {
+            Logging.Warning ($"{view} cannot be Removed. It has not been added to {this}.");
         }
 
         Rectangle touched = view.Frame;
@@ -172,22 +248,25 @@ public partial class View // SuperView/SubView hierarchy management (SuperView,
         {
             view.CanFocus = false; // If view had focus, this will ensure it doesn't and it stays that way
         }
+
         Debug.Assert (!view.HasFocus);
 
-        _subviews.Remove (view);
+        InternalSubViews.Remove (view);
 
         // Clean up focus stuff
         _previouslyFocused = null;
-        if (view._superView is { } && view._superView._previouslyFocused == this)
+
+        if (view.SuperView is { } && view.SuperView._previouslyFocused == this)
         {
-            view._superView._previouslyFocused = null;
+            view.SuperView._previouslyFocused = null;
         }
-        view._superView = null;
+
+        view.SuperView = null;
 
         SetNeedsLayout ();
         SetNeedsDraw ();
 
-        foreach (View v in _subviews)
+        foreach (View v in InternalSubViews)
         {
             if (v.Frame.IntersectsWith (touched))
             {
@@ -202,44 +281,56 @@ public partial class View // SuperView/SubView hierarchy management (SuperView,
             _previouslyFocused = null;
         }
 
-        OnRemoved (new (this, view));
+        RaiseSubViewRemoved (view);
 
         return view;
     }
 
+    internal void RaiseSubViewRemoved (View view)
+    {
+        OnSubViewRemoved (view);
+        SubViewRemoved?.Invoke (this, new (this, view));
+    }
+
     /// <summary>
-    ///     Removes all subviews (children) added via <see cref="Add(View)"/> or <see cref="Add(View[])"/> from this View.
+    ///     Called when a SubView has been removed from this View.
+    /// </summary>
+    /// <param name="view"></param>
+    protected virtual void OnSubViewRemoved (View view) { }
+
+    /// <summary>Raised when a SubView has been added to this View.</summary>
+    public event EventHandler<SuperViewChangedEventArgs>? SubViewRemoved;
+
+    /// <summary>
+    ///     Removes all SubView (children) added via <see cref="Add(View)"/> or <see cref="Add(View[])"/> from this View.
     /// </summary>
     /// <remarks>
     ///     <para>
-    ///         Normally Subviews will be disposed when this View is disposed. Removing a Subview causes ownership of the
-    ///         Subview's
+    ///         Normally SubViews will be disposed when this View is disposed. Removing a SubView causes ownership of the
+    ///         SubView's
     ///         lifecycle to be transferred to the caller; the caller must call <see cref="Dispose()"/> on any Views that were
     ///         added.
     ///     </para>
     /// </remarks>
     public virtual void RemoveAll ()
     {
-        if (_subviews is null)
-        {
-            return;
-        }
-
-        while (_subviews.Count > 0)
+        while (InternalSubViews.Count > 0)
         {
-            Remove (_subviews [0]);
+            Remove (InternalSubViews [0]);
         }
     }
 
-    /// <summary>Event fired when this view is removed from another.</summary>
+#pragma warning disable CS0067 // The event is never used
+    /// <summary>Raised when a SubView has been removed from this View.</summary>
     public event EventHandler<SuperViewChangedEventArgs>? Removed;
+#pragma warning restore CS0067 // The event is never used   
 
     #endregion AddRemove
 
-    // TODO: Mark as internal. Or nuke.
+    // TODO: This drives a weird coupling of Application.Top and View. It's not clear why this is needed.
     /// <summary>Get the top superview of a given <see cref="View"/>.</summary>
     /// <returns>The superview view.</returns>
-    public View? GetTopSuperView (View? view = null, View? superview = null)
+    internal View? GetTopSuperView (View? view = null, View? superview = null)
     {
         View? top = superview ?? Application.Top;
 
@@ -257,7 +348,7 @@ public partial class View // SuperView/SubView hierarchy management (SuperView,
     }
 
     /// <summary>
-    ///     Gets whether <paramref name="view"/> is in the Subview hierarchy of <paramref name="start"/>.
+    ///     Gets whether <paramref name="view"/> is in the SubView hierarchy of <paramref name="start"/>.
     /// </summary>
     /// <param name="start">The View at the start of the hierarchy.</param>
     /// <param name="view">The View to test.</param>
@@ -275,7 +366,7 @@ public partial class View // SuperView/SubView hierarchy management (SuperView,
             return true;
         }
 
-        foreach (View subView in start.Subviews)
+        foreach (View subView in start.InternalSubViews)
         {
             if (view == subView)
             {
@@ -320,87 +411,87 @@ public partial class View // SuperView/SubView hierarchy management (SuperView,
     #region SubViewOrdering
 
     /// <summary>
-    ///     Moves <paramref name="subview"/> one position towards the end of the <see cref="Subviews"/> list.
+    ///     Moves <paramref name="subview"/> one position towards the end of the <see cref="SubViews"/> list.
     /// </summary>
     /// <param name="subview">The subview to move.</param>
-    public void MoveSubviewTowardsEnd (View subview)
+    public void MoveSubViewTowardsEnd (View subview)
     {
-        PerformActionForSubview (
+        PerformActionForSubView (
                                  subview,
                                  x =>
                                  {
-                                     int idx = _subviews!.IndexOf (x);
+                                     int idx = InternalSubViews!.IndexOf (x);
 
-                                     if (idx + 1 < _subviews.Count)
+                                     if (idx + 1 < InternalSubViews.Count)
                                      {
-                                         _subviews.Remove (x);
-                                         _subviews.Insert (idx + 1, x);
+                                         InternalSubViews.Remove (x);
+                                         InternalSubViews.Insert (idx + 1, x);
                                      }
                                  }
                                 );
     }
 
     /// <summary>
-    ///     Moves <paramref name="subview"/> to the end of the <see cref="Subviews"/> list.
+    ///     Moves <paramref name="subview"/> to the end of the <see cref="SubViews"/> list.
     /// </summary>
     /// <param name="subview">The subview to move.</param>
-    public void MoveSubviewToEnd (View subview)
+    public void MoveSubViewToEnd (View subview)
     {
-        PerformActionForSubview (
+        PerformActionForSubView (
                                  subview,
                                  x =>
                                  {
-                                     _subviews!.Remove (x);
-                                     _subviews.Add (x);
+                                     InternalSubViews!.Remove (x);
+                                     InternalSubViews.Add (x);
                                  }
                                 );
     }
 
     /// <summary>
-    ///     Moves <paramref name="subview"/> one position towards the start of the <see cref="Subviews"/> list.
+    ///     Moves <paramref name="subview"/> one position towards the start of the <see cref="SubViews"/> list.
     /// </summary>
     /// <param name="subview">The subview to move.</param>
-    public void MoveSubviewTowardsStart (View subview)
+    public void MoveSubViewTowardsStart (View subview)
     {
-        PerformActionForSubview (
+        PerformActionForSubView (
                                  subview,
                                  x =>
                                  {
-                                     int idx = _subviews!.IndexOf (x);
+                                     int idx = InternalSubViews!.IndexOf (x);
 
                                      if (idx > 0)
                                      {
-                                         _subviews.Remove (x);
-                                         _subviews.Insert (idx - 1, x);
+                                         InternalSubViews.Remove (x);
+                                         InternalSubViews.Insert (idx - 1, x);
                                      }
                                  }
                                 );
     }
 
     /// <summary>
-    ///     Moves <paramref name="subview"/> to the start of the <see cref="Subviews"/> list.
+    ///     Moves <paramref name="subview"/> to the start of the <see cref="SubViews"/> list.
     /// </summary>
     /// <param name="subview">The subview to move.</param>
-    public void MoveSubviewToStart (View subview)
+    public void MoveSubViewToStart (View subview)
     {
-        PerformActionForSubview (
+        PerformActionForSubView (
                                  subview,
                                  x =>
                                  {
-                                     _subviews!.Remove (x);
-                                     _subviews.Insert (0, subview);
+                                     InternalSubViews!.Remove (x);
+                                     InternalSubViews.Insert (0, subview);
                                  }
                                 );
     }
 
     /// <summary>
-    ///     Internal API that runs <paramref name="action"/> on a subview if it is part of the <see cref="Subviews"/> list.
+    ///     Internal API that runs <paramref name="action"/> on a subview if it is part of the <see cref="SubViews"/> list.
     /// </summary>
     /// <param name="subview"></param>
     /// <param name="action"></param>
-    private void PerformActionForSubview (View subview, Action<View> action)
+    private void PerformActionForSubView (View subview, Action<View> action)
     {
-        if (_subviews!.Contains (subview))
+        if (InternalSubViews.Contains (subview))
         {
             action (subview);
         }

+ 3 - 3
Terminal.Gui/View/View.Keyboard.cs

@@ -562,12 +562,12 @@ public partial class View // Keyboard APIs
             return true;
         }
 
-        if (adornment?.Subviews is null)
+        if (adornment?.InternalSubViews is null)
         {
             return false;
         }
 
-        foreach (View subview in adornment.Subviews)
+        foreach (View subview in adornment.InternalSubViews)
         {
             bool? subViewHandled = subview.InvokeCommands (key);
 
@@ -604,7 +604,7 @@ public partial class View // Keyboard APIs
         }
 
         // Now, process any HotKey bindings in the subviews
-        foreach (View subview in Subviews)
+        foreach (View subview in InternalSubViews)
         {
             if (subview == Focused)
             {

+ 33 - 33
Terminal.Gui/View/View.Layout.cs

@@ -416,7 +416,7 @@ public partial class View // Layout APIs
     {
         if (SetRelativeLayout (contentSize))
         {
-            LayoutSubviews ();
+            LayoutSubViews ();
 
             // Debug.Assert(!NeedsLayout);
             return true;
@@ -475,7 +475,7 @@ public partial class View // Layout APIs
 
         CheckDimAuto ();
 
-        // TODO: Should move to View.LayoutSubviews?
+        // TODO: Should move to View.LayoutSubViews?
         SetTextFormatterSize ();
 
         int newX, newW, newY, newH;
@@ -594,9 +594,9 @@ public partial class View // Layout APIs
     ///         The position and dimensions of the view are indeterminate until the view has been initialized. Therefore, the
     ///         behavior of this method is indeterminate if <see cref="IsInitialized"/> is <see langword="false"/>.
     ///     </para>
-    ///     <para>Raises the <see cref="SubviewsLaidOut"/> event before it returns.</para>
+    ///     <para>Raises the <see cref="SubViewsLaidOut"/> event before it returns.</para>
     /// </remarks>
-    internal void LayoutSubviews ()
+    internal void LayoutSubViews ()
     {
         if (!NeedsLayout)
         {
@@ -607,23 +607,23 @@ public partial class View // Layout APIs
 
         Size contentSize = GetContentSize ();
 
-        OnSubviewLayout (new (contentSize));
-        SubviewLayout?.Invoke (this, new (contentSize));
+        OnSubViewLayout (new (contentSize));
+        SubViewLayout?.Invoke (this, new (contentSize));
 
         // The Adornments already have their Frame's set by SetRelativeLayout so we call LayoutSubViews vs. Layout here.
-        if (Margin is { Subviews.Count: > 0 })
+        if (Margin is { SubViews.Count: > 0 })
         {
-            Margin.LayoutSubviews ();
+            Margin.LayoutSubViews ();
         }
 
-        if (Border is { Subviews.Count: > 0 })
+        if (Border is { SubViews.Count: > 0 })
         {
-            Border.LayoutSubviews ();
+            Border.LayoutSubViews ();
         }
 
-        if (Padding is { Subviews.Count: > 0 })
+        if (Padding is { SubViews.Count: > 0 })
         {
-            Padding.LayoutSubviews ();
+            Padding.LayoutSubViews ();
         }
 
         // Sort out the dependencies of the X, Y, Width, Height properties
@@ -669,44 +669,44 @@ public partial class View // Layout APIs
 
         NeedsLayout = layoutStillNeeded;
 
-        OnSubviewsLaidOut (new (contentSize));
-        SubviewsLaidOut?.Invoke (this, new (contentSize));
+        OnSubViewsLaidOut (new (contentSize));
+        SubViewsLaidOut?.Invoke (this, new (contentSize));
     }
 
     /// <summary>
-    ///     Called from <see cref="LayoutSubviews"/> before any subviews
+    ///     Called from <see cref="LayoutSubViews"/> before any subviews
     ///     have been laid out.
     /// </summary>
     /// <remarks>
     ///     Override to perform tasks when the layout is changing.
     /// </remarks>
-    protected virtual void OnSubviewLayout (LayoutEventArgs args) { }
+    protected virtual void OnSubViewLayout (LayoutEventArgs args) { }
 
     /// <summary>
-    ///     Raised by <see cref="LayoutSubviews"/> before any subviews
+    ///     Raised by <see cref="LayoutSubViews"/> before any subviews
     ///     have been laid out.
     /// </summary>
     /// <remarks>
     ///     Subscribe to this event to perform tasks when the layout is changing.
     /// </remarks>
-    public event EventHandler<LayoutEventArgs>? SubviewLayout;
+    public event EventHandler<LayoutEventArgs>? SubViewLayout;
 
     /// <summary>
-    ///     Called from <see cref="LayoutSubviews"/> after all sub-views
+    ///     Called from <see cref="LayoutSubViews"/> after all sub-views
     ///     have been laid out.
     /// </summary>
     /// <remarks>
     ///     Override to perform tasks after the <see cref="View"/> has been resized or the layout has
     ///     otherwise changed.
     /// </remarks>
-    protected virtual void OnSubviewsLaidOut (LayoutEventArgs args) { }
+    protected virtual void OnSubViewsLaidOut (LayoutEventArgs args) { }
 
     /// <summary>Raised after all sub-views have been laid out.</summary>
     /// <remarks>
     ///     Subscribe to this event to perform tasks after the <see cref="View"/> has been resized or the layout has
     ///     otherwise changed.
     /// </remarks>
-    public event EventHandler<LayoutEventArgs>? SubviewsLaidOut;
+    public event EventHandler<LayoutEventArgs>? SubViewsLaidOut;
 
     #endregion Core Layout API
 
@@ -743,23 +743,23 @@ public partial class View // Layout APIs
     {
         NeedsLayout = true;
 
-        if (Margin is { Subviews.Count: > 0 })
+        if (Margin is { SubViews.Count: > 0 })
         {
             Margin.SetNeedsLayout ();
         }
 
-        if (Border is { Subviews.Count: > 0 })
+        if (Border is { SubViews.Count: > 0 })
         {
             Border.SetNeedsLayout ();
         }
 
-        if (Padding is { Subviews.Count: > 0 })
+        if (Padding is { SubViews.Count: > 0 })
         {
             Padding.SetNeedsLayout ();
         }
 
         // Use a stack to avoid recursion
-        Stack<View> stack = new (Subviews);
+        Stack<View> stack = new (SubViews);
 
         while (stack.Count > 0)
         {
@@ -769,22 +769,22 @@ public partial class View // Layout APIs
             {
                 current.NeedsLayout = true;
 
-                if (current.Margin is { Subviews.Count: > 0 })
+                if (current.Margin is { SubViews.Count: > 0 })
                 {
                     current.Margin.SetNeedsLayout ();
                 }
 
-                if (current.Border is { Subviews.Count: > 0 })
+                if (current.Border is { SubViews.Count: > 0 })
                 {
                     current.Border.SetNeedsLayout ();
                 }
 
-                if (current.Padding is { Subviews.Count: > 0 })
+                if (current.Padding is { SubViews.Count: > 0 })
                 {
                     current.Padding.SetNeedsLayout ();
                 }
 
-                foreach (View subview in current.Subviews)
+                foreach (View subview in current.SubViews)
                 {
                     stack.Push (subview);
                 }
@@ -833,7 +833,7 @@ public partial class View // Layout APIs
     /// </param>
     internal void CollectAll (View from, ref HashSet<View> nNodes, ref HashSet<(View, View)> nEdges)
     {
-        foreach (View? v in from.InternalSubviews)
+        foreach (View? v in from.InternalSubViews)
         {
             nNodes.Add (v);
             CollectPos (v.X, v, ref nNodes, ref nEdges);
@@ -1035,7 +1035,7 @@ public partial class View // Layout APIs
     /// <param name="ny">The new y location that will ensure <paramref name="viewToMove"/> will be fully visible.</param>
     /// <returns>
     ///     Either <see cref="Application.Top"/> (if <paramref name="viewToMove"/> does not have a Super View) or
-    ///     <paramref name="viewToMove"/>'s SuperView. This can be used to ensure LayoutSubviews is called on the correct View.
+    ///     <paramref name="viewToMove"/>'s SuperView. This can be used to ensure LayoutSubViews is called on the correct View.
     /// </returns>
     internal static View? GetLocationEnsuringFullVisibility (
         View viewToMove,
@@ -1184,7 +1184,7 @@ public partial class View // Layout APIs
     /// <summary>Gets or sets whether validation of <see cref="Pos"/> and <see cref="Dim"/> occurs.</summary>
     /// <remarks>
     ///     Setting this to <see langword="true"/> will enable validation of <see cref="X"/>, <see cref="Y"/>,
-    ///     <see cref="Width"/>, and <see cref="Height"/> during set operations and in <see cref="LayoutSubviews"/>. If invalid
+    ///     <see cref="Width"/>, and <see cref="Height"/> during set operations and in <see cref="LayoutSubViews"/>. If invalid
     ///     settings are discovered exceptions will be thrown indicating the error. This will impose a performance penalty and
     ///     thus should only be used for debugging.
     /// </remarks>
@@ -1207,7 +1207,7 @@ public partial class View // Layout APIs
         var heightAuto = Height as DimAuto;
 
         // Verify none of the subviews are using Dim objects that depend on the SuperView's dimensions.
-        foreach (View view in Subviews)
+        foreach (View view in SubViews)
         {
             if (widthAuto is { } && widthAuto.Style.FastHasFlags (DimAutoStyle.Content) && ContentSizeTracksViewport)
             {

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

@@ -113,7 +113,7 @@ public partial class View // Mouse APIs
     }
 
     /// <summary>
-    ///     Called when the mouse moves over the View's <see cref="Frame"/> and no other non-Subview occludes it.
+    ///     Called when the mouse moves over the View's <see cref="Frame"/> and no other non-SubView occludes it.
     ///     <see cref="MouseLeave"/> will
     ///     be raised when the mouse is no longer over the <see cref="Frame"/>.
     /// </summary>
@@ -808,13 +808,13 @@ public partial class View // Mouse APIs
 
             View? subview = null;
 
-            for (int i = start.InternalSubviews.Count - 1; i >= 0; i--)
+            for (int i = start.InternalSubViews.Count - 1; i >= 0; i--)
             {
-                if (start.InternalSubviews [i].Visible
-                    && start.InternalSubviews [i].Contains (new (startOffsetX + start.Viewport.X, startOffsetY + start.Viewport.Y))
-                    && (!ignoreTransparent || !start.InternalSubviews [i].ViewportSettings.HasFlag (ViewportSettings.TransparentMouse)))
+                if (start.InternalSubViews [i].Visible
+                    && start.InternalSubViews [i].Contains (new (startOffsetX + start.Viewport.X, startOffsetY + start.Viewport.Y))
+                    && (!ignoreTransparent || !start.InternalSubViews [i].ViewportSettings.HasFlag (ViewportSettings.TransparentMouse)))
                 {
-                    subview = start.InternalSubviews [i];
+                    subview = start.InternalSubViews [i];
                     currentLocation.X = startOffsetX + start.Viewport.X;
                     currentLocation.Y = startOffsetY + start.Viewport.Y;
 

+ 14 - 14
Terminal.Gui/View/View.Navigation.cs

@@ -265,7 +265,7 @@ public partial class View // Focus and cross-view navigation management (TabStop
     public event EventHandler? CanFocusChanged;
 
     /// <summary>
-    ///     Focuses the deepest focusable Subview if one exists. If there are no focusable Subviews then the focus is set to
+    ///     Focuses the deepest focusable SubView if one exists. If there are no focusable SubViews then the focus is set to
     ///     the view itself.
     /// </summary>
     /// <param name="direction"></param>
@@ -283,12 +283,12 @@ public partial class View // Focus and cross-view navigation management (TabStop
         return SetFocus ();
     }
 
-    /// <summary>Gets the currently focused Subview or Adornment of this view, or <see langword="null"/> if nothing is focused.</summary>
+    /// <summary>Gets the currently focused SubView or Adornment of this view, or <see langword="null"/> if nothing is focused.</summary>
     public View? Focused
     {
         get
         {
-            View? focused = Subviews.FirstOrDefault (v => v.HasFocus);
+            View? focused = SubViews.FirstOrDefault (v => v.HasFocus);
 
             if (focused is { })
             {
@@ -319,9 +319,9 @@ public partial class View // Focus and cross-view navigation management (TabStop
     public bool IsCurrentTop => Application.Top == this;
 
     /// <summary>
-    ///     Returns the most focused Subview down the subview-hierarchy.
+    ///     Returns the most focused SubView down the subview-hierarchy.
     /// </summary>
-    /// <value>The most focused Subview, or <see langword="null"/> if no Subview is focused.</value>
+    /// <value>The most focused SubView, or <see langword="null"/> if no SubView is focused.</value>
     public View? MostFocused
     {
         get
@@ -589,7 +589,7 @@ public partial class View // Focus and cross-view navigation management (TabStop
 
         if (Arrangement.HasFlag (ViewArrangement.Overlapped))
         {
-            SuperView?.MoveSubviewToEnd (this);
+            SuperView?.MoveSubViewToEnd (this);
         }
 
         // Focus work is done. Notify.
@@ -902,39 +902,39 @@ public partial class View // Focus and cross-view navigation management (TabStop
     /// <returns></returns>
     internal View [] GetFocusChain (NavigationDirection direction, TabBehavior? behavior)
     {
-        IEnumerable<View>? filteredSubviews;
+        IEnumerable<View>? filteredSubViews;
 
         if (behavior.HasValue)
         {
-            filteredSubviews = _subviews?.Where (v => v.TabStop == behavior && v is { CanFocus: true, Visible: true, Enabled: true });
+            filteredSubViews = InternalSubViews?.Where (v => v.TabStop == behavior && v is { CanFocus: true, Visible: true, Enabled: true });
         }
         else
         {
-            filteredSubviews = _subviews?.Where (v => v is { CanFocus: true, Visible: true, Enabled: true });
+            filteredSubViews = InternalSubViews?.Where (v => v is { CanFocus: true, Visible: true, Enabled: true });
         }
 
         // How about in Adornments? 
         if (Padding is { CanFocus: true, Visible: true, Enabled: true } && Padding.TabStop == behavior)
         {
-            filteredSubviews = filteredSubviews?.Append (Padding);
+            filteredSubViews = filteredSubViews?.Append (Padding);
         }
 
         if (Border is { CanFocus: true, Visible: true, Enabled: true } && Border.TabStop == behavior)
         {
-            filteredSubviews = filteredSubviews?.Append (Border);
+            filteredSubViews = filteredSubViews?.Append (Border);
         }
 
         if (Margin is { CanFocus: true, Visible: true, Enabled: true } && Margin.TabStop == behavior)
         {
-            filteredSubviews = filteredSubviews?.Append (Margin);
+            filteredSubViews = filteredSubViews?.Append (Margin);
         }
 
         if (direction == NavigationDirection.Backward)
         {
-            filteredSubviews = filteredSubviews?.Reverse ();
+            filteredSubViews = filteredSubViews?.Reverse ();
         }
 
-        return filteredSubviews?.ToArray () ?? Array.Empty<View> ();
+        return filteredSubViews?.ToArray () ?? Array.Empty<View> ();
     }
 
     private TabBehavior? _tabStop;

+ 10 - 18
Terminal.Gui/View/View.cs

@@ -81,9 +81,9 @@ public partial class View : IDisposable, ISupportInitializeNotification
         DisposeAdornments ();
         DisposeScrollBars ();
 
-        for (int i = InternalSubviews.Count - 1; i >= 0; i--)
+        for (int i = InternalSubViews.Count - 1; i >= 0; i--)
         {
-            View subview = InternalSubviews [i];
+            View subview = InternalSubViews [i];
             Remove (subview);
             subview.Dispose ();
         }
@@ -98,7 +98,7 @@ public partial class View : IDisposable, ISupportInitializeNotification
             _disposedValue = true;
         }
 
-        Debug.Assert (InternalSubviews.Count == 0);
+        Debug.Assert (InternalSubViews.Count == 0);
     }
 
     #region Constructors and Initialization
@@ -196,9 +196,9 @@ public partial class View : IDisposable, ISupportInitializeNotification
 
         BeginInitAdornments ();
 
-        if (_subviews?.Count > 0)
+        if (InternalSubViews?.Count > 0)
         {
-            foreach (View view in _subviews)
+            foreach (View view in InternalSubViews)
             {
                 if (!view.IsInitialized)
                 {
@@ -213,7 +213,7 @@ public partial class View : IDisposable, ISupportInitializeNotification
 
     /// <summary>Signals the View that initialization is ending. See <see cref="ISupportInitialize"/>.</summary>
     /// <remarks>
-    ///     <para>Initializes all Subviews and Invokes the <see cref="Initialized"/> event.</para>
+    ///     <para>Initializes all SubViews and Invokes the <see cref="Initialized"/> event.</para>
     /// </remarks>
     public virtual void EndInit ()
     {
@@ -232,14 +232,11 @@ public partial class View : IDisposable, ISupportInitializeNotification
         UpdateTextDirection (TextDirection);
         UpdateTextFormatterText ();
 
-        if (_subviews is { })
+        foreach (View view in InternalSubViews)
         {
-            foreach (View view in _subviews)
+            if (!view.IsInitialized)
             {
-                if (!view.IsInitialized)
-                {
-                    view.EndInit ();
-                }
+                view.EndInit ();
             }
         }
 
@@ -295,12 +292,7 @@ public partial class View : IDisposable, ISupportInitializeNotification
                 Border.Enabled = _enabled;
             }
 
-            if (_subviews is null)
-            {
-                return;
-            }
-
-            foreach (View view in _subviews)
+            foreach (View view in InternalSubViews)
             {
                 view.Enabled = Enabled;
             }

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

@@ -62,7 +62,7 @@ public enum ViewArrangement
     Resizable = LeftResizable | RightResizable | TopResizable | BottomResizable,
 
     /// <summary>
-    ///     The view overlaps other views (the order of <see cref="View.Subviews"/> dicates the Z-order). If this flag is not
+    ///     The view overlaps other views (the order of <see cref="View.SubViews"/> dicates the Z-order). If this flag is not
     ///     set the view will operate in tiled mode.
     ///     <para>
     ///         When set, Tab and Shift-Tab will be constrained to the subviews of the view (normally, they will navigate to

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

@@ -142,9 +142,9 @@ public enum ViewportSettings
 
     /// <summary>
     ///     If set the View will be transparent: The <see cref="View.Viewport"/> will not be cleared when the View is drawn and the clip region
-    ///     will be set to clip the View's <see cref="View.Text"/> and <see cref="View.Subviews"/>.
+    ///     will be set to clip the View's <see cref="View.Text"/> and <see cref="View.SubViews"/>.
     ///     <para>
-    ///         Only the topmost View in a Subview Hierarchy can be transparent. Any subviews of the topmost transparent view
+    ///         Only the topmost View in a SubView Hierarchy can be transparent. Any subviews of the topmost transparent view
     ///         will have indeterminate draw behavior.
     ///     </para>
     ///     <para>
@@ -154,7 +154,7 @@ public enum ViewportSettings
     Transparent = 0b_0001_0000_0000,
 
     /// <summary>
-    ///     If set the View will be transparent to mouse events: Any mouse event that occurs over the View (and it's Subviews) will be passed to the
+    ///     If set the View will be transparent to mouse events: Any mouse event that occurs over the View (and it's SubViews) will be passed to the
     ///     Views below it.
     ///     <para>
     ///         Combine this with <see cref="Transparent"/> to get a view that is both visually transparent and transparent to the mouse.

+ 16 - 16
Terminal.Gui/Views/Bar.cs

@@ -144,12 +144,12 @@ public class Bar : View, IOrientation, IDesignable
     }
 
     // TODO: Move this to View
-    /// <summary>Inserts a <see cref="Shortcut"/> in the specified index of <see cref="View.Subviews"/>.</summary>
+    /// <summary>Inserts a <see cref="Shortcut"/> in the specified index of <see cref="View.SubViews"/>.</summary>
     /// <param name="index">The zero-based index at which item should be inserted.</param>
     /// <param name="item">The item to insert.</param>
     public void AddShortcutAt (int index, Shortcut item)
     {
-        List<View> savedSubViewList = Subviews.ToList ();
+        List<View> savedSubViewList = SubViews.ToList ();
         int count = savedSubViewList.Count;
         RemoveAll ();
 
@@ -172,18 +172,18 @@ public class Bar : View, IOrientation, IDesignable
 
     // TODO: Move this to View
 
-    /// <summary>Removes a <see cref="Shortcut"/> at specified index of <see cref="View.Subviews"/>.</summary>
+    /// <summary>Removes a <see cref="Shortcut"/> at specified index of <see cref="View.SubViews"/>.</summary>
     /// <param name="index">The zero-based index of the item to remove.</param>
     /// <returns>The <see cref="Shortcut"/> removed.</returns>
     public Shortcut? RemoveShortcut (int index)
     {
         View? toRemove = null;
 
-        for (var i = 0; i < Subviews.Count; i++)
+        for (var i = 0; i < SubViews.Count; i++)
         {
             if (i == index)
             {
-                toRemove = Subviews [i];
+                toRemove = SubViews.ElementAt (i);
             }
         }
 
@@ -198,7 +198,7 @@ public class Bar : View, IOrientation, IDesignable
     }
 
     /// <inheritdoc />
-    protected override void OnSubviewLayout (LayoutEventArgs args)
+    protected override void OnSubViewLayout (LayoutEventArgs args)
     {
         LayoutBarItems (args.OldContentSize);
     }
@@ -210,9 +210,9 @@ public class Bar : View, IOrientation, IDesignable
         switch (Orientation)
         {
             case Orientation.Horizontal:
-                for (var index = 0; index < Subviews.Count; index++)
+                for (var index = 0; index < SubViews.Count; index++)
                 {
-                    View barItem = Subviews [index];
+                    View barItem = SubViews.ElementAt (index);
 
                     barItem.ColorScheme = ColorScheme;
                     barItem.X = Pos.Align (Alignment.Start, AlignmentModes);
@@ -227,7 +227,7 @@ public class Bar : View, IOrientation, IDesignable
 
                     var minKeyWidth = 0;
 
-                    List<Shortcut> shortcuts = Subviews.Where (s => s is Shortcut && s.Visible).Cast<Shortcut> ().ToList ();
+                    List<Shortcut> shortcuts = SubViews.Where (s => s is Shortcut && s.Visible).Cast<Shortcut> ().ToList ();
 
                     foreach (Shortcut shortcut in shortcuts)
                     {
@@ -235,11 +235,11 @@ public class Bar : View, IOrientation, IDesignable
                         minKeyWidth = int.Max (minKeyWidth, shortcut.KeyView.Text.GetColumns ());
                     }
 
-                    var _maxBarItemWidth = 0;
+                    var maxBarItemWidth = 0;
 
-                    for (var index = 0; index < Subviews.Count; index++)
+                    for (var index = 0; index < SubViews.Count; index++)
                     {
-                        View barItem = Subviews [index];
+                        View barItem = SubViews.ElementAt (index);
 
 
                         barItem.ColorScheme = ColorScheme;
@@ -255,7 +255,7 @@ public class Bar : View, IOrientation, IDesignable
                             scBarItem.MinimumKeyTextSize = minKeyWidth;
                             scBarItem.Width = scBarItem.GetWidthDimAuto ();
                             barItem.Layout (Application.Screen.Size);
-                            _maxBarItemWidth = Math.Max (_maxBarItemWidth, barItem.Frame.Width);
+                            maxBarItemWidth = Math.Max (maxBarItemWidth, barItem.Frame.Width);
                         }
 
                         if (prevBarItem == null)
@@ -274,17 +274,17 @@ public class Bar : View, IOrientation, IDesignable
 
                     }
 
-                    foreach (var subView in Subviews)
+                    foreach (var subView in SubViews)
                     {
                         if (subView is not Line)
                         {
-                            subView.Width = Dim.Auto (DimAutoStyle.Auto, minimumContentDim: _maxBarItemWidth);
+                            subView.Width = Dim.Auto (DimAutoStyle.Auto, minimumContentDim: maxBarItemWidth);
                         }
                     }
                 }
                 else
                 {
-                    foreach (var subView in Subviews)
+                    foreach (var subView in SubViews)
                     {
                         if (subView is not Line)
                         {

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

@@ -57,14 +57,14 @@ public class ComboBox : View, IDesignable
         Initialized += (s, e) => ProcessLayout ();
 
         // On resize
-        SubviewsLaidOut += (sender, a) => ProcessLayout ();
+        SubViewsLaidOut += (sender, a) => ProcessLayout ();
 
-        Added += (s, e) =>
+        SuperViewChanged += (s, e) =>
                  {
                      // Determine if this view is hosted inside a dialog and is the only control
                      for (View view = SuperView; view != null; view = view.SuperView)
                      {
-                         if (view is Dialog && SuperView is { } && SuperView.Subviews.Count == 1 && SuperView.Subviews [0] == this)
+                         if (view is Dialog && SuperView is { } && SuperView.SubViews.Count == 1 && SuperView.SubViews.ElementAt (0) == this)
                          {
                              _autoHide = false;
 
@@ -199,7 +199,7 @@ public class ComboBox : View, IDesignable
             _source = value;
 
             // Only need to refresh list if its been added to a container view
-            if (SuperView is { } && SuperView.Subviews.Contains (this))
+            if (SuperView is { } && SuperView.SubViews.Contains (this))
             {
                 Text = string.Empty;
                 SetNeedsDraw ();
@@ -513,7 +513,7 @@ public class ComboBox : View, IDesignable
         Reset (true);
         _listview.ClearViewport ();
         _listview.TabStop = TabBehavior.NoStop;
-        SuperView?.MoveSubviewToStart (this);
+        SuperView?.MoveSubViewToStart (this);
 
         // BUGBUG: SetNeedsDraw takes Viewport relative coordinates, not Screen
         Rectangle rect = _listview.ViewportToScreen (_listview.IsInitialized ? _listview.Viewport : Rectangle.Empty);
@@ -658,7 +658,7 @@ public class ComboBox : View, IDesignable
         _listview.SetSource (_searchSet);
         _listview.Height = CalculateHeight ();
 
-        if (Subviews.Count > 0 && HasFocus)
+        if (SubViews.Count > 0 && HasFocus)
         {
             _search.SetFocus ();
         }
@@ -814,7 +814,7 @@ public class ComboBox : View, IDesignable
 
         _listview.ClearViewport ();
         _listview.Height = CalculateHeight ();
-        SuperView?.MoveSubviewToStart (this);
+        SuperView?.MoveSubViewToStart (this);
     }
 
     private bool UnixEmulation ()

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

@@ -505,7 +505,7 @@ public class FileDialog : Dialog, IDesignable
         {
             _btnCancel.X = Pos.Func (CalculateOkButtonPosX);
             _btnOk.X = Pos.Right (_btnCancel) + 1;
-            MoveSubviewTowardsStart (_btnCancel);
+            MoveSubViewTowardsStart (_btnCancel);
         }
 
         SetNeedsDraw ();

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

@@ -106,10 +106,10 @@ public class HexView : View, IDesignable
         MouseBindings.Add (MouseFlags.WheeledUp, Command.ScrollUp);
         MouseBindings.Add (MouseFlags.WheeledDown, Command.ScrollDown);
 
-        SubviewsLaidOut += HexViewSubviewsLaidOut;
+        SubViewsLaidOut += HexViewSubViewsLaidOut;
     }
 
-    private void HexViewSubviewsLaidOut (object? sender, LayoutEventArgs e)
+    private void HexViewSubViewsLaidOut (object? sender, LayoutEventArgs e)
     {
         SetBytesPerLine ();
         SetContentSize (new (GetLeftSideStartColumn () + BytesPerLine / NUM_BYTES_PER_HEX_COLUMN * HEX_COLUMN_WIDTH + BytesPerLine - 1, (int)((GetEditedSize ()) / BytesPerLine) + 1));

+ 6 - 6
Terminal.Gui/Views/Label.cs

@@ -1,10 +1,10 @@
 namespace Terminal.Gui;
 
 /// <summary>
-///     The Label <see cref="View"/> displays text that describes the View next in the <see cref="View.Subviews"/>. When
+///     The Label <see cref="View"/> displays text that describes the View next in the <see cref="View.SubViews"/>. When
 ///     Label
 ///     receives a <see cref="Command.HotKey"/> command it will pass it to the next <see cref="View"/> in
-///     <see cref="View.Subviews"/>.
+///     <see cref="View.SubViews"/>.
 /// </summary>
 /// <remarks>
 ///     <para>
@@ -13,7 +13,7 @@
 ///     <para>
 ///         If <see cref="View.CanFocus"/> is <see langword="false"/> and the use clicks on the Label,
 ///         the <see cref="Command.HotKey"/> will be invoked on the next <see cref="View"/> in
-///         <see cref="View.Subviews"/>.
+///         <see cref="View.SubViews"/>.
 ///     </para>
 /// </remarks>
 public class Label : View, IDesignable
@@ -75,12 +75,12 @@ public class Label : View, IDesignable
 
         if (HotKey.IsValid)
         {
-            int me = SuperView?.Subviews.IndexOf (this) ?? -1;
+            int me = SuperView?.SubViews.IndexOf (this) ?? -1;
 
-            if (me != -1 && me < SuperView?.Subviews.Count - 1)
+            if (me != -1 && me < SuperView?.SubViews.Count - 1)
             {
 
-                return SuperView?.Subviews [me + 1].InvokeCommand (Command.HotKey) == true;
+                return SuperView?.SubViews.ElementAt (me + 1).InvokeCommand (Command.HotKey) == true;
             }
         }
 

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

@@ -84,7 +84,7 @@ public class MenuBar : View, IDesignable
         WantMousePositionReports = true;
         IsMenuOpen = false;
 
-        Added += MenuBar_Added;
+        SuperViewChanged += MenuBar_SuperViewChanged;
 
         // Things this view knows how to do
         AddCommand (
@@ -559,7 +559,7 @@ public class MenuBar : View, IDesignable
         if (Application.Top is { })
         {
             // Close others menu bar opened
-            Menu? menu = Application.Top.Subviews.FirstOrDefault (v => v is Menu m && m.Host != this && m.Host.IsMenuOpen) as Menu;
+            Menu? menu = Application.Top.SubViews.FirstOrDefault (v => v is Menu m && m.Host != this && m.Host.IsMenuOpen) as Menu;
             menu?.Host.CleanUp ();
         }
     }
@@ -1157,10 +1157,10 @@ public class MenuBar : View, IDesignable
         return new (-2, 0);
     }
 
-    private void MenuBar_Added (object? sender, SuperViewChangedEventArgs e)
+    private void MenuBar_SuperViewChanged (object? sender, SuperViewChangedEventArgs _)
     {
         _initialCanFocus = CanFocus;
-        Added -= MenuBar_Added;
+        SuperViewChanged -= MenuBar_SuperViewChanged;
     }
 
     private void MoveLeft ()

+ 4 - 9
Terminal.Gui/Views/MenuBarv2.cs

@@ -22,7 +22,7 @@ public class MenuBarv2 : Bar
         ColorScheme = Colors.ColorSchemes ["Menu"];
         Orientation = Orientation.Horizontal;
 
-        SubviewLayout += MenuBarv2_LayoutStarted;
+        SubViewLayout += MenuBarv2_LayoutStarted;
     }
 
     // MenuBarv2 arranges the items horizontally.
@@ -34,14 +34,11 @@ public class MenuBarv2 : Bar
     }
 
     /// <inheritdoc/>
-    public override View Add (View view)
+    protected override void OnSubViewAdded (View subView)
     {
-        // Call base first, because otherwise it resets CanFocus to true
-        base.Add (view);
+        subView.CanFocus = false;
 
-        view.CanFocus = true;
-
-        if (view is Shortcut shortcut)
+        if (subView is Shortcut shortcut)
         {
             // TODO: not happy about using AlignmentModes for this. Too implied.
             // TODO: instead, add a property (a style enum?) to Shortcut to control this
@@ -50,7 +47,5 @@ public class MenuBarv2 : Bar
             shortcut.KeyView.Visible = false;
             shortcut.HelpView.Visible = false;
         }
-
-        return view;
     }
 }

+ 7 - 10
Terminal.Gui/Views/Menuv2.cs

@@ -47,11 +47,11 @@ public class Menuv2 : Bar
     // The first item has no left border, the last item has no right border.
     // The Shortcuts are configured with the command, help, and key views aligned in reverse order (EndToStart).
     /// <inheritdoc />
-    protected override void OnSubviewLayout (LayoutEventArgs args)
+    protected override void OnSubViewLayout (LayoutEventArgs args)
     {
-        for (int index = 0; index < Subviews.Count; index++)
+        for (int index = 0; index < SubViews.Count; index++)
         {
-            View barItem = Subviews [index];
+            View barItem = SubViews.ElementAt (index);
 
             if (!barItem.Visible)
             {
@@ -59,15 +59,14 @@ public class Menuv2 : Bar
             }
 
         }
-        base.OnSubviewLayout (args);
+        base.OnSubViewLayout (args);
     }
 
     /// <inheritdoc/>
-    public override View Add (View view)
+    /// 
+    protected override void OnSubViewAdded (View subView)
     {
-        base.Add (view);
-
-        if (view is Shortcut shortcut)
+        if (subView is Shortcut shortcut)
         {
             shortcut.CanFocus = true;
             shortcut.Orientation = Orientation.Vertical;
@@ -95,7 +94,5 @@ public class Menuv2 : Bar
                 //}
             }
         }
-
-        return view;
     }
 }

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

@@ -42,7 +42,7 @@ public class RadioGroup : View, IDesignable, IOrientation
         // By default, single click is already bound to Command.Select
         MouseBindings.Add (MouseFlags.Button1DoubleClicked, Command.Accept);
 
-        SubviewLayout += RadioGroup_LayoutStarted;
+        SubViewLayout += RadioGroup_LayoutStarted;
 
         HighlightStyle = HighlightStyle.PressedOutside | HighlightStyle.Pressed;
     }

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

@@ -113,7 +113,7 @@ public class ScrollBar : View, IOrientation, IDesignable
         _slider.Position = _sliderPosition.Value;
     }
 
-    private void PositionSubviews ()
+    private void PositionSubViews ()
     {
         if (Orientation == Orientation.Vertical)
         {
@@ -180,7 +180,7 @@ public class ScrollBar : View, IOrientation, IDesignable
         TextAlignment = Alignment.Center;
         VerticalTextAlignment = Alignment.Center;
         _slider.Orientation = newOrientation;
-        PositionSubviews ();
+        PositionSubViews ();
 
         OrientationChanged?.Invoke (this, new (newOrientation));
     }

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

@@ -132,7 +132,7 @@ public class Shortcut : View, IOrientation, IDesignable
 
         Action = action;
 
-        SubviewLayout += OnLayoutStarted;
+        SubViewLayout += OnLayoutStarted;
 
         ShowHide ();
     }
@@ -221,7 +221,7 @@ public class Shortcut : View, IOrientation, IDesignable
         HelpView.SetRelativeLayout (Application.Screen.Size);
         KeyView.SetRelativeLayout (Application.Screen.Size);
 
-        _minimumNaturalWidth = PosAlign.CalculateMinDimension (0, Subviews, Dimension.Width);
+        _minimumNaturalWidth = PosAlign.CalculateMinDimension (0, SubViews, Dimension.Width);
 
         // Reset our relative layout
         SetRelativeLayout (SuperView?.GetContentSize () ?? Application.Screen.Size);
@@ -824,17 +824,17 @@ public class Shortcut : View, IOrientation, IDesignable
         {
             TitleChanged -= Shortcut_TitleChanged;
 
-            if (CommandView?.IsAdded == false)
+            if (CommandView.SuperView is null)
             {
                 CommandView.Dispose ();
             }
 
-            if (HelpView?.IsAdded == false)
+            if (HelpView.SuperView is null)
             {
                 HelpView.Dispose ();
             }
 
-            if (KeyView?.IsAdded == false)
+            if (KeyView.SuperView is null)
             {
                 KeyView.Dispose ();
             }

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

@@ -59,7 +59,7 @@ public class Slider<T> : View, IOrientation
         // BUGBUG: This should not be needed - Need to ensure SetRelativeLayout gets called during EndInit
         Initialized += (s, e) => { SetContentSize (); };
 
-        SubviewLayout += (s, e) => { SetContentSize (); };
+        SubViewLayout += (s, e) => { SetContentSize (); };
     }
 
     // TODO: Make configurable via ConfigurationManager

+ 19 - 31
Terminal.Gui/Views/SpinnerView/SpinnerView.cs

@@ -1,16 +1,15 @@
-//------------------------------------------------------------------------------
+#nullable enable
+//------------------------------------------------------------------------------
 // Windows Terminal supports Unicode and Emoji characters, but by default
 // conhost shells (e.g., PowerShell and cmd.exe) do not. See
 // <https://spectreconsole.net/best-practices>.
 //------------------------------------------------------------------------------
 
-using System.Diagnostics;
-
 namespace Terminal.Gui;
 
 /// <summary>A <see cref="View"/> which displays (by default) a spinning line character.</summary>
 /// <remarks>
-///     By default animation only occurs when you call <see cref="SpinnerView.AdvanceAnimation(bool)"/>. Use
+///     By default, animation only occurs when you call <see cref="SpinnerView.AdvanceAnimation(bool)"/>. Use
 ///     <see cref="AutoSpin"/> to make the automate calls to <see cref="SpinnerView.AdvanceAnimation(bool)"/>.
 /// </remarks>
 public class SpinnerView : View, IDesignable
@@ -25,7 +24,7 @@ public class SpinnerView : View, IDesignable
     private DateTime _lastRender = DateTime.MinValue;
     private string [] _sequence = DEFAULT_STYLE.Sequence;
     private SpinnerStyle _style = DEFAULT_STYLE;
-    private object _timeout;
+    private object? _timeout;
 
     /// <summary>Creates a new instance of the <see cref="SpinnerView"/> class.</summary>
     public SpinnerView ()
@@ -134,14 +133,7 @@ public class SpinnerView : View, IDesignable
                 {
                     if (SpinBounce)
                     {
-                        if (SpinReverse)
-                        {
-                            _bounceReverse = false;
-                        }
-                        else
-                        {
-                            _bounceReverse = true;
-                        }
+                        _bounceReverse = !SpinReverse;
 
                         _currentIdx = Sequence.Length - 1;
                     }
@@ -155,14 +147,7 @@ public class SpinnerView : View, IDesignable
                 {
                     if (SpinBounce)
                     {
-                        if (SpinReverse)
-                        {
-                            _bounceReverse = true;
-                        }
-                        else
-                        {
-                            _bounceReverse = false;
-                        }
+                        _bounceReverse = SpinReverse;
 
                         _currentIdx = 1;
                     }
@@ -182,25 +167,26 @@ public class SpinnerView : View, IDesignable
         }
     }
 
-    /// <inheritdoc />
+    /// <inheritdoc/>
     protected override bool OnClearingViewport () { return true; }
 
-    /// <inheritdoc />
+    /// <inheritdoc/>
     protected override bool OnDrawingContent ()
     {
         Render ();
+
         return true;
     }
 
     /// <summary>
-    ///    Renders the current frame of the spinner.
+    ///     Renders the current frame of the spinner.
     /// </summary>
     public void Render ()
     {
         if (Sequence is { Length: > 0 } && _currentIdx < Sequence.Length)
         {
             Move (Viewport.X, Viewport.Y);
-            View.Driver?.AddStr (Sequence [_currentIdx]);
+            Driver?.AddStr (Sequence [_currentIdx]);
         }
     }
 
@@ -214,7 +200,8 @@ public class SpinnerView : View, IDesignable
 
     private void AddAutoSpinTimeout ()
     {
-        if (_timeout is { })
+        // Only add timeout if we are initialized and not already spinning
+        if (_timeout is { } || !Application.Initialized)
         {
             return;
         }
@@ -223,7 +210,7 @@ public class SpinnerView : View, IDesignable
                                            TimeSpan.FromMilliseconds (SpinDelay),
                                            () =>
                                            {
-                                               Application.Invoke (() => AdvanceAnimation());
+                                               Application.Invoke (() => AdvanceAnimation ());
 
                                                return true;
                                            }
@@ -237,7 +224,7 @@ public class SpinnerView : View, IDesignable
             return false;
         }
 
-        if (_sequence is { } && _sequence.Length > 0)
+        if (_sequence is { Length: > 0 })
         {
             foreach (string frame in _sequence)
             {
@@ -260,7 +247,7 @@ public class SpinnerView : View, IDesignable
     {
         var max = 0;
 
-        if (_sequence is { } && _sequence.Length > 0)
+        if (_sequence is { Length: > 0 })
         {
             foreach (string frame in _sequence)
             {
@@ -295,7 +282,7 @@ public class SpinnerView : View, IDesignable
 
     private void SetSequence (string [] frames)
     {
-        if (frames is { } && frames.Length > 0)
+        if (frames is { Length: > 0 })
         {
             _style = new SpinnerStyle.Custom ();
             _sequence = frames;
@@ -303,7 +290,7 @@ public class SpinnerView : View, IDesignable
         }
     }
 
-    private void SetStyle (SpinnerStyle style)
+    private void SetStyle (SpinnerStyle? style)
     {
         if (style is { })
         {
@@ -320,6 +307,7 @@ public class SpinnerView : View, IDesignable
         Style = new SpinnerStyle.Points ();
         SpinReverse = true;
         AutoSpin = true;
+
         return true;
     }
 }

+ 7 - 12
Terminal.Gui/Views/StatusBar.cs

@@ -26,7 +26,7 @@ public class StatusBar : Bar, IDesignable
         BorderStyle = LineStyle.Dashed;
         ColorScheme = Colors.ColorSchemes ["Menu"];
 
-        SubviewLayout += StatusBar_LayoutStarted;
+        SubViewLayout += StatusBar_LayoutStarted;
     }
 
     // StatusBar arranges the items horizontally.
@@ -34,13 +34,13 @@ public class StatusBar : Bar, IDesignable
     // The Shortcuts are configured with the command, help, and key views aligned in reverse order (EndToStart).
     private void StatusBar_LayoutStarted (object sender, LayoutEventArgs e)
     {
-        for (int index = 0; index < Subviews.Count; index++)
+        for (int index = 0; index < SubViews.Count; index++)
         {
-            View barItem = Subviews [index];
+            View barItem = SubViews.ElementAt (index);
 
             barItem.BorderStyle = BorderStyle;
 
-            if (index == Subviews.Count - 1)
+            if (index == SubViews.Count - 1)
             {
                 barItem.Border.Thickness = new Thickness (0, 0, 0, 0);
             }
@@ -57,21 +57,16 @@ public class StatusBar : Bar, IDesignable
     }
 
     /// <inheritdoc/>
-    public override View Add (View view)
+    protected override void OnSubViewAdded (View subView)
     {
-        // Call base first, because otherwise it resets CanFocus to true
-        base.Add (view);
+        subView.CanFocus = false;
 
-        view.CanFocus = false;
-
-        if (view is Shortcut shortcut)
+        if (subView is Shortcut shortcut)
         {
             // TODO: not happy about using AlignmentModes for this. Too implied.
             // TODO: instead, add a property (a style enum?) to Shortcut to control this
             shortcut.AlignmentModes = AlignmentModes.EndToStart;
         }
-
-        return view;
     }
 
     /// <inheritdoc />

+ 4 - 4
Terminal.Gui/Views/TabView/TabRow.cs

@@ -115,7 +115,7 @@ internal class TabRow : View
     }
 
     /// <inheritdoc/>
-    protected override void OnSubviewLayout (LayoutEventArgs args)
+    protected override void OnSubViewLayout (LayoutEventArgs args)
     {
         _host._tabLocations = _host.CalculateViewport (Viewport).ToArray ();
 
@@ -123,7 +123,7 @@ internal class TabRow : View
 
         RenderUnderline ();
 
-        base.OnSubviewLayout (args);
+        base.OnSubViewLayout (args);
     }
 
     /// <inheritdoc />
@@ -765,7 +765,7 @@ internal class TabRow : View
             _leftScrollIndicator.Visible = true;
 
             // Ensures this is clicked instead of the first tab
-            MoveSubviewToEnd (_leftScrollIndicator);
+            MoveSubViewToEnd (_leftScrollIndicator);
         }
         else
         {
@@ -782,7 +782,7 @@ internal class TabRow : View
             _rightScrollIndicator.Visible = true;
 
             // Ensures this is clicked instead of the last tab if under this
-            MoveSubviewToStart (_rightScrollIndicator);
+            MoveSubViewToStart (_rightScrollIndicator);
         }
         else
         {

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

@@ -160,7 +160,7 @@ public class TabView : View
 
     private void ContainerViewCanFocus (object sender, EventArgs eventArgs)
     {
-        _containerView.CanFocus = _containerView.Subviews.Count (v => v.CanFocus) > 0;
+        _containerView.CanFocus = _containerView.SubViews.Count (v => v.CanFocus) > 0;
     }
 
     private TabStyle _style = new ();

+ 13 - 10
Terminal.Gui/Views/TextField.cs

@@ -45,9 +45,7 @@ public class TextField : View
 
         Initialized += TextField_Initialized;
 
-        Added += TextField_Added;
-
-        Removed += TextField_Removed;
+        SuperViewChanged += TextField_SuperViewChanged;
 
         // Things this view knows how to do
         AddCommand (
@@ -1182,7 +1180,7 @@ public class TextField : View
 
     private void Adjust ()
     {
-        if (!IsAdded)
+        if (SuperView is null)
         {
             return;
         }
@@ -1820,17 +1818,22 @@ public class TextField : View
         ContextMenu.Show (BuildContextMenuBarItem ());
     }
 
-    private void TextField_Added (object sender, SuperViewChangedEventArgs e)
+    private void TextField_SuperViewChanged (object sender, SuperViewChangedEventArgs e)
     {
-        if (Autocomplete.HostControl is null)
+        if (e.SuperView is {})
         {
-            Autocomplete.HostControl = this;
-            Autocomplete.PopupInsideContainer = false;
+            if (Autocomplete.HostControl is null)
+            {
+                Autocomplete.HostControl = this;
+                Autocomplete.PopupInsideContainer = false;
+            }
+        }
+        else
+        {
+            Autocomplete.HostControl = null;
         }
     }
 
-    private void TextField_Removed (object sender, SuperViewChangedEventArgs e) { Autocomplete.HostControl = null; }
-
     private void TextField_Initialized (object sender, EventArgs e)
     {
         _cursorPosition = Text.GetRuneCount ();

+ 12 - 7
Terminal.Gui/Views/TextView.cs

@@ -1899,9 +1899,9 @@ public class TextView : View
 
         Initialized += TextView_Initialized!;
 
-        Added += TextView_Added!;
+        SuperViewChanged += TextView_SuperViewChanged!;
 
-        SubviewsLaidOut += TextView_LayoutComplete;
+        SubViewsLaidOut += TextView_LayoutComplete;
 
         // Things this view knows how to do
 
@@ -2416,8 +2416,6 @@ public class TextView : View
         KeyBindings.Add (ContextMenu.Key, Command.Context);
     }
 
-    private void TextView_Added1 (object? sender, SuperViewChangedEventArgs e) { throw new NotImplementedException (); }
-
     // BUGBUG: AllowsReturn is mis-named. It should be EnterKeyAccepts.
     /// <summary>
     ///     Gets or sets whether pressing ENTER in a <see cref="TextView"/> creates a new line of text
@@ -6444,11 +6442,18 @@ public class TextView : View
         return StringExtensions.ToString (encoded);
     }
 
-    private void TextView_Added (object sender, SuperViewChangedEventArgs e)
+    private void TextView_SuperViewChanged (object sender, SuperViewChangedEventArgs e)
     {
-        if (Autocomplete.HostControl is null)
+        if (e.SuperView is {})
         {
-            Autocomplete.HostControl = this;
+            if (Autocomplete.HostControl is null)
+            {
+                Autocomplete.HostControl = this;
+            }
+        }
+        else
+        {
+            Autocomplete.HostControl = null;
         }
     }
 

+ 6 - 6
Terminal.Gui/Views/TileView.cs

@@ -23,7 +23,7 @@ public class TileView : View
         CanFocus = true;
         RebuildForTileCount (tiles);
 
-        SubviewLayout += (_, _) =>
+        SubViewLayout += (_, _) =>
                          {
                              Rectangle viewport = Viewport;
 
@@ -100,14 +100,14 @@ public class TileView : View
                 return i;
             }
 
-            if (v.Subviews.Contains (toFind))
+            if (v.SubViews.Contains (toFind))
             {
                 return i;
             }
 
             if (recursive)
             {
-                if (RecursiveContains (v.Subviews, toFind))
+                if (RecursiveContains (v.SubViews, toFind))
                 {
                     return i;
                 }
@@ -485,7 +485,7 @@ public class TileView : View
         };
 
         // Take everything out of the View we are moving
-        View [] childViews = toMove!.Subviews.ToArray ();
+        View [] childViews = toMove!.SubViews.ToArray ();
         toMove.RemoveAll ();
 
         // Remove the view itself and replace it with the new TileView
@@ -533,7 +533,7 @@ public class TileView : View
     {
         List<TileViewLineView> lines = new ();
 
-        foreach (View sub in v.Subviews)
+        foreach (View sub in v.SubViews)
         {
             if (sub is TileViewLineView s)
             {
@@ -756,7 +756,7 @@ public class TileView : View
                 return true;
             }
 
-            if (RecursiveContains (v.Subviews, needle))
+            if (RecursiveContains (v.SubViews, needle))
             {
                 return true;
             }

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

@@ -33,7 +33,7 @@ public partial class Toplevel : View
         Arrangement = ViewArrangement.Overlapped;
         Width = Dim.Fill ();
         Height = Dim.Fill ();
-        ColorScheme = Colors.ColorSchemes ["TopLevel"];
+        base.ColorScheme = Colors.ColorSchemes ["TopLevel"];
         MouseClick += Toplevel_MouseClick;
     }
 
@@ -66,15 +66,15 @@ public partial class Toplevel : View
 
     #endregion
 
-    #region Subviews
+    #region SubViews
 
     // TODO: Deprecate - Any view can host a menubar in v2
     /// <summary>Gets the latest <see cref="MenuBar"/> added into this Toplevel.</summary>
-    public MenuBar? MenuBar => (MenuBar?)Subviews?.LastOrDefault (s => s is MenuBar);
+    public MenuBar? MenuBar => (MenuBar?)SubViews?.LastOrDefault (s => s is MenuBar);
 
     //// TODO: Deprecate - Any view can host a statusbar in v2
     ///// <summary>Gets the latest <see cref="StatusBar"/> added into this Toplevel.</summary>
-    //public StatusBar? StatusBar => (StatusBar?)Subviews?.LastOrDefault (s => s is StatusBar);
+    //public StatusBar? StatusBar => (StatusBar?)SubViews?.LastOrDefault (s => s is StatusBar);
 
     #endregion
 
@@ -127,7 +127,7 @@ public partial class Toplevel : View
     {
         IsLoaded = true;
 
-        foreach (var view in Subviews.Where (v => v is Toplevel))
+        foreach (var view in SubViews.Where (v => v is Toplevel))
         {
             var tl = (Toplevel)view;
             tl.OnLoaded ();
@@ -180,7 +180,7 @@ public partial class Toplevel : View
     /// </summary>
     internal virtual void OnReady ()
     {
-        foreach (var view in Subviews.Where (v => v is Toplevel))
+        foreach (var view in SubViews.Where (v => v is Toplevel))
         {
             var tl = (Toplevel)view;
             tl.OnReady ();
@@ -192,7 +192,7 @@ public partial class Toplevel : View
     /// <summary>Called from <see cref="Application.End(RunState)"/> before the <see cref="Toplevel"/> is disposed.</summary>
     internal virtual void OnUnloaded ()
     {
-        foreach (var view in Subviews.Where (v => v is Toplevel))
+        foreach (var view in SubViews.Where (v => v is Toplevel))
         {
             var tl = (Toplevel)view;
             tl.OnUnloaded ();
@@ -202,7 +202,7 @@ public partial class Toplevel : View
     }
 
     #endregion
-    
+
     #region Size / Position Management
 
     // TODO: Make cancelable?
@@ -235,7 +235,7 @@ public partial class Toplevel : View
             return;
         }
 
-        //var layoutSubviews = false;
+        //var layoutSubViews = false;
         var maxWidth = 0;
 
         if (superView.Margin is { } && superView == top.SuperView)
@@ -251,25 +251,25 @@ public partial class Toplevel : View
             if (top?.X is null or PosAbsolute && top?.Frame.X != nx)
             {
                 top!.X = nx;
-                //layoutSubviews = true;
+                //layoutSubViews = true;
             }
 
             if (top?.Y is null or PosAbsolute && top?.Frame.Y != ny)
             {
                 top!.Y = ny;
-                //layoutSubviews = true;
+                //layoutSubViews = true;
             }
         }
 
 
-        //if (superView.IsLayoutNeeded () || layoutSubviews)
+        //if (superView.IsLayoutNeeded () || layoutSubViews)
         //{
-        //    superView.LayoutSubviews ();
+        //    superView.LayoutSubViews ();
         //}
 
         //if (IsLayoutNeeded ())
         //{
-        //    LayoutSubviews ();
+        //    LayoutSubViews ();
         //}
     }
 

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

@@ -357,7 +357,7 @@ public class Wizard : Dialog
         UpdateButtonsAndTitle ();
 
         // Set focus on the contentview
-        newStep?.Subviews.ToArray () [0].SetFocus ();
+        newStep?.SubViews.ToArray () [0].SetFocus ();
 
         if (OnStepChanged (oldStep, _currentStep))
         {
@@ -501,7 +501,7 @@ public class Wizard : Dialog
             step.Height = Dim.Fill (
                                     Dim.Func (
                                               () => IsInitialized
-                                                        ? Subviews.First (view => view.Y.Has<PosAnchorEnd> (out _)).Frame.Height + 1
+                                                        ? SubViews.First (view => view.Y.Has<PosAnchorEnd> (out _)).Frame.Height + 1
                                                         : 1)); // for button frame (+1 for lineView)
             step.Width = Dim.Fill ();
         }
@@ -513,7 +513,7 @@ public class Wizard : Dialog
             step.Height = Dim.Fill (
                                     Dim.Func (
                                               () => IsInitialized
-                                                        ? Subviews.First (view => view.Y.Has<PosAnchorEnd> (out _)).Frame.Height + 1
+                                                        ? SubViews.First (view => view.Y.Has<PosAnchorEnd> (out _)).Frame.Height + 1
                                                         : 2)); // for button frame (+1 for lineView)
             step.Width = Dim.Fill ();
         }

+ 4 - 4
Terminal.Gui/Views/Wizard/WizardStep.cs

@@ -88,7 +88,7 @@ public class WizardStep : View
         //		scrollBar.OtherScrollBarView.Size = helpTextView.Maxlength;
         //		scrollBar.OtherScrollBarView.Position = helpTextView.LeftColumn;
         //	}
-        //	scrollBar.LayoutSubviews ();
+        //	scrollBar.LayoutSubViews ();
         //	scrollBar.Refresh ();
         //};
         //base.Add (scrollBar);
@@ -151,7 +151,7 @@ public class WizardStep : View
             container?.Remove (view);
         }
 
-        if (_contentView.InternalSubviews.Count < 1)
+        if (_contentView.InternalSubViews.Count < 1)
         {
             CanFocus = false;
         }
@@ -176,7 +176,7 @@ public class WizardStep : View
         _helpTextView.Height = Dim.Height(_contentView);
         _helpTextView.Width = Dim.Fill ();
 
-        if (_contentView.InternalSubviews?.Count > 0)
+        if (_contentView.InternalSubViews?.Count > 0)
         {
             if (_helpTextView.Text.Length > 0)
             {
@@ -199,7 +199,7 @@ public class WizardStep : View
             // Error - no pane shown
         }
 
-        _contentView.Visible = _contentView.InternalSubviews?.Count > 0;
+        _contentView.Visible = _contentView.InternalSubViews?.Count > 0;
         _helpTextView.Visible = _helpTextView.Text.Length > 0;
     }
 } // end of WizardStep class

+ 2 - 0
Terminal.sln.DotSettings

@@ -410,8 +410,10 @@
 	<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
 	<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EPredefinedNamingRulesToUserRulesUpgrade/@EntryIndexedValue">True</s:Boolean>
 	<s:Int64 x:Key="/Default/Environment/UnitTesting/ParallelProcessesCount/@EntryValue">5</s:Int64>
+	<s:Boolean x:Key="/Default/UserDictionary/Words/=Gonek/@EntryIndexedValue">True</s:Boolean>
 	<s:Boolean x:Key="/Default/UserDictionary/Words/=Justifier/@EntryIndexedValue">True</s:Boolean>
 	<s:Boolean x:Key="/Default/UserDictionary/Words/=langword/@EntryIndexedValue">True</s:Boolean>
+	<s:Boolean x:Key="/Default/UserDictionary/Words/=ogonek/@EntryIndexedValue">True</s:Boolean>
 	<s:Boolean x:Key="/Default/UserDictionary/Words/=Roslynator/@EntryIndexedValue">True</s:Boolean>
 	<s:Boolean x:Key="/Default/UserDictionary/Words/=Toplevel/@EntryIndexedValue">True</s:Boolean>
 	<s:Boolean x:Key="/Default/UserDictionary/Words/=Toplevels/@EntryIndexedValue">True</s:Boolean>

+ 217 - 261
Tests/IntegrationTests/UICatalog/ScenarioTests.cs

@@ -2,8 +2,8 @@ using System.Collections.ObjectModel;
 using System.Diagnostics;
 using System.Reflection;
 using Terminal.Gui;
-using UnitTests;
 using UICatalog;
+using UnitTests;
 using Xunit.Abstractions;
 
 namespace IntegrationTests.UICatalog;
@@ -21,7 +21,7 @@ public class ScenarioTests : TestsAllViews
 
     private readonly ITestOutputHelper _output;
 
-    private object _timeoutLock;
+    private object? _timeoutLock;
 
     /// <summary>
     ///     <para>This runs through all Scenarios defined in UI Catalog, calling Init, Setup, and Run.</para>
@@ -42,18 +42,18 @@ public class ScenarioTests : TestsAllViews
         Application.ResetState (true);
 
         _output.WriteLine ($"Running Scenario '{scenarioType}'");
-        var scenario = (Scenario)Activator.CreateInstance (scenarioType);
+        var scenario = Activator.CreateInstance (scenarioType) as Scenario;
 
         uint abortTime = 1500;
-        object timeout = null;
+        object? timeout = null;
         var initialized = false;
         var shutdown = false;
-        int iterationCount = 0;
+        var iterationCount = 0;
 
         Application.InitializedChanged += OnApplicationOnInitializedChanged;
 
         Application.ForceDriver = "FakeDriver";
-        scenario.Main ();
+        scenario!.Main ();
         scenario.Dispose ();
         scenario = null;
         Application.ForceDriver = string.Empty;
@@ -83,9 +83,10 @@ public class ScenarioTests : TestsAllViews
         // Restore the configuration locations
         ConfigurationManager.Locations = savedConfigLocations;
         ConfigurationManager.Reset ();
+
         return;
 
-        void OnApplicationOnInitializedChanged (object s, EventArgs<bool> a)
+        void OnApplicationOnInitializedChanged (object? s, EventArgs<bool> a)
         {
             if (a.CurrentValue)
             {
@@ -96,13 +97,13 @@ public class ScenarioTests : TestsAllViews
                 {
                     timeout = Application.AddTimeout (TimeSpan.FromMilliseconds (abortTime), ForceCloseCallback);
                 }
-
             }
             else
             {
                 Application.Iteration -= OnApplicationOnIteration;
                 shutdown = true;
             }
+
             _output.WriteLine ($"Initialized == {a.CurrentValue}");
         }
 
@@ -118,7 +119,7 @@ public class ScenarioTests : TestsAllViews
             }
 
             Assert.Fail (
-                         $"'{scenario.GetName ()}' failed to Quit with {Application.QuitKey} after {abortTime}ms and {iterationCount} iterations. Force quit.");
+                         $"Scenario Failed to Quit with {Application.QuitKey} after {abortTime}ms and {iterationCount} iterations. Force quit.");
 
             // Restore the configuration locations
             ConfigurationManager.Locations = savedConfigLocations;
@@ -129,9 +130,10 @@ public class ScenarioTests : TestsAllViews
             return false;
         }
 
-        void OnApplicationOnIteration (object s, IterationEventArgs a)
+        void OnApplicationOnIteration (object? s, IterationEventArgs a)
         {
             iterationCount++;
+
             if (Application.Initialized)
             {
                 // Press QuitKey 
@@ -141,7 +143,6 @@ public class ScenarioTests : TestsAllViews
         }
     }
 
-    
     public static IEnumerable<object []> AllScenarioTypes =>
         typeof (Scenario).Assembly
                          .GetTypes ()
@@ -155,40 +156,24 @@ public class ScenarioTests : TestsAllViews
         ConfigLocations savedConfigLocations = ConfigurationManager.Locations;
         ConfigurationManager.Locations = ConfigLocations.Default;
 
-        Window _leftPane;
-        ListView _classListView;
-        FrameView _hostPane;
-
-        Dictionary<string, Type> _viewClasses;
-        View _curView = null;
+        View? curView = null;
 
         // Settings
-        FrameView _settingsPane;
-        FrameView _locationFrame;
-        RadioGroup _xRadioGroup;
-        TextField _xText;
-        var _xVal = 0;
-        RadioGroup _yRadioGroup;
-        TextField _yText;
-        var _yVal = 0;
-
-        FrameView _sizeFrame;
-        RadioGroup _wRadioGroup;
-        TextField _wText;
-        var _wVal = 0;
-        RadioGroup _hRadioGroup;
-        TextField _hText;
-        var _hVal = 0;
-        List<string> posNames = new () { "Percent", "AnchorEnd", "Center", "Absolute" };
-        List<string> dimNames = new () { "Auto", "Percent", "Fill", "Absolute" };
+        var xVal = 0;
+        var yVal = 0;
+
+        var wVal = 0;
+        var hVal = 0;
+        List<string> posNames = ["Percent", "AnchorEnd", "Center", "Absolute"];
+        List<string> dimNames = ["Auto", "Percent", "Fill", "Absolute"];
 
         Application.Init (new FakeDriver ());
 
         var top = new Toplevel ();
 
-        _viewClasses = ViewTestHelpers.GetAllViewClasses ().ToDictionary (t => t.Name);
+        Dictionary<string, Type> viewClasses = GetAllViewClasses().ToDictionary (t => t.Name);
 
-        _leftPane = new ()
+        Window leftPane = new ()
         {
             Title = "Classes",
             X = 0,
@@ -199,7 +184,7 @@ public class ScenarioTests : TestsAllViews
             ColorScheme = Colors.ColorSchemes ["TopLevel"]
         };
 
-        _classListView = new ()
+        ListView classListView = new ()
         {
             X = 0,
             Y = 0,
@@ -207,13 +192,13 @@ public class ScenarioTests : TestsAllViews
             Height = Dim.Fill (),
             AllowsMarking = false,
             ColorScheme = Colors.ColorSchemes ["TopLevel"],
-            Source = new ListWrapper<string> (new (_viewClasses.Keys.ToList ()))
+            Source = new ListWrapper<string> (new (viewClasses.Keys.ToList ()))
         };
-        _leftPane.Add (_classListView);
+        leftPane.Add (classListView);
 
-        _settingsPane = new ()
+        FrameView settingsPane = new ()
         {
-            X = Pos.Right (_leftPane),
+            X = Pos.Right (leftPane),
             Y = 0, // for menu
             Width = Dim.Fill (),
             Height = 10,
@@ -224,7 +209,7 @@ public class ScenarioTests : TestsAllViews
 
         var radioItems = new [] { "Percent(x)", "AnchorEnd(x)", "Center", "Absolute(x)" };
 
-        _locationFrame = new ()
+        FrameView locationFrame = new ()
         {
             X = 0,
             Y = 0,
@@ -232,28 +217,28 @@ public class ScenarioTests : TestsAllViews
             Width = 36,
             Title = "Location (Pos)"
         };
-        _settingsPane.Add (_locationFrame);
+        settingsPane.Add (locationFrame);
 
         var label = new Label { X = 0, Y = 0, Text = "x:" };
-        _locationFrame.Add (label);
-        _xRadioGroup = new () { X = 0, Y = Pos.Bottom (label), RadioLabels = radioItems };
-        _xText = new () { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_xVal}" };
-        _locationFrame.Add (_xText);
+        locationFrame.Add (label);
+        RadioGroup xRadioGroup = new () { X = 0, Y = Pos.Bottom (label), RadioLabels = radioItems };
+        TextField xText = new () { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{xVal}" };
+        locationFrame.Add (xText);
 
-        _locationFrame.Add (_xRadioGroup);
+        locationFrame.Add (xRadioGroup);
 
         radioItems = new [] { "Percent(y)", "AnchorEnd(y)", "Center", "Absolute(y)" };
-        label = new () { X = Pos.Right (_xRadioGroup) + 1, Y = 0, Text = "y:" };
-        _locationFrame.Add (label);
-        _yText = new () { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_yVal}" };
-        _locationFrame.Add (_yText);
-        _yRadioGroup = new () { X = Pos.X (label), Y = Pos.Bottom (label), RadioLabels = radioItems };
-        _locationFrame.Add (_yRadioGroup);
-
-        _sizeFrame = new ()
+        label = new () { X = Pos.Right (xRadioGroup) + 1, Y = 0, Text = "y:" };
+        locationFrame.Add (label);
+        TextField yText = new () { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{yVal}" };
+        locationFrame.Add (yText);
+        RadioGroup yRadioGroup = new () { X = Pos.X (label), Y = Pos.Bottom (label), RadioLabels = radioItems };
+        locationFrame.Add (yRadioGroup);
+
+        FrameView sizeFrame = new ()
         {
-            X = Pos.Right (_locationFrame),
-            Y = Pos.Y (_locationFrame),
+            X = Pos.Right (locationFrame),
+            Y = Pos.Y (locationFrame),
             Height = 3 + radioItems.Length,
             Width = 40,
             Title = "Size (Dim)"
@@ -261,131 +246,131 @@ public class ScenarioTests : TestsAllViews
 
         radioItems = new [] { "Auto()", "Percent(width)", "Fill(width)", "Absolute(width)" };
         label = new () { X = 0, Y = 0, Text = "width:" };
-        _sizeFrame.Add (label);
-        _wRadioGroup = new () { X = 0, Y = Pos.Bottom (label), RadioLabels = radioItems };
-        _wText = new () { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_wVal}" };
-        _sizeFrame.Add (_wText);
-        _sizeFrame.Add (_wRadioGroup);
+        sizeFrame.Add (label);
+        RadioGroup wRadioGroup = new () { X = 0, Y = Pos.Bottom (label), RadioLabels = radioItems };
+        TextField wText = new () { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{wVal}" };
+        sizeFrame.Add (wText);
+        sizeFrame.Add (wRadioGroup);
 
         radioItems = new [] { "Auto()", "Percent(height)", "Fill(height)", "Absolute(height)" };
-        label = new () { X = Pos.Right (_wRadioGroup) + 1, Y = 0, Text = "height:" };
-        _sizeFrame.Add (label);
-        _hText = new () { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_hVal}" };
-        _sizeFrame.Add (_hText);
+        label = new () { X = Pos.Right (wRadioGroup) + 1, Y = 0, Text = "height:" };
+        sizeFrame.Add (label);
+        TextField hText = new () { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{hVal}" };
+        sizeFrame.Add (hText);
 
-        _hRadioGroup = new () { X = Pos.X (label), Y = Pos.Bottom (label), RadioLabels = radioItems };
-        _sizeFrame.Add (_hRadioGroup);
+        RadioGroup hRadioGroup = new () { X = Pos.X (label), Y = Pos.Bottom (label), RadioLabels = radioItems };
+        sizeFrame.Add (hRadioGroup);
 
-        _settingsPane.Add (_sizeFrame);
+        settingsPane.Add (sizeFrame);
 
-        _hostPane = new ()
+        FrameView hostPane = new ()
         {
-            X = Pos.Right (_leftPane),
-            Y = Pos.Bottom (_settingsPane),
+            X = Pos.Right (leftPane),
+            Y = Pos.Bottom (settingsPane),
             Width = Dim.Fill (),
             Height = Dim.Fill (1), // + 1 for status bar
             ColorScheme = Colors.ColorSchemes ["Dialog"]
         };
 
-        _classListView.OpenSelectedItem += (s, a) => { _settingsPane.SetFocus (); };
-
-        _classListView.SelectedItemChanged += (s, args) =>
-        {
-            // Remove existing class, if any
-            if (_curView != null)
-            {
-                _curView.SubviewsLaidOut -= LayoutCompleteHandler;
-                _hostPane.Remove (_curView);
-                _curView.Dispose ();
-                _curView = null;
-                _hostPane.FillRect (_hostPane.Viewport);
-            }
-
-            _curView = CreateClass (_viewClasses.Values.ToArray () [_classListView.SelectedItem]);
-        };
-
-        _xRadioGroup.SelectedItemChanged += (s, selected) => DimPosChanged (_curView);
-
-        _xText.TextChanged += (s, args) =>
-        {
-            try
-            {
-                _xVal = int.Parse (_xText.Text);
-                DimPosChanged (_curView);
-            }
-            catch
-            { }
-        };
-
-        _yText.TextChanged += (s, e) =>
-        {
-            try
-            {
-                _yVal = int.Parse (_yText.Text);
-                DimPosChanged (_curView);
-            }
-            catch
-            { }
-        };
-
-        _yRadioGroup.SelectedItemChanged += (s, selected) => DimPosChanged (_curView);
-
-        _wRadioGroup.SelectedItemChanged += (s, selected) => DimPosChanged (_curView);
-
-        _wText.TextChanged += (s, args) =>
-        {
-            try
-            {
-                _wVal = int.Parse (_wText.Text);
-                DimPosChanged (_curView);
-            }
-            catch
-            { }
-        };
-
-        _hText.TextChanged += (s, args) =>
-        {
-            try
-            {
-                _hVal = int.Parse (_hText.Text);
-                DimPosChanged (_curView);
-            }
-            catch
-            { }
-        };
-
-        _hRadioGroup.SelectedItemChanged += (s, selected) => DimPosChanged (_curView);
-
-        top.Add (_leftPane, _settingsPane, _hostPane);
-
-        top.LayoutSubviews ();
-
-        _curView = CreateClass (_viewClasses.First ().Value);
+        classListView.OpenSelectedItem += (s, a) => { settingsPane.SetFocus (); };
+
+        classListView.SelectedItemChanged += (s, args) =>
+                                              {
+                                                  // Remove existing class, if any
+                                                  if (curView is {})
+                                                  {
+                                                      curView.SubViewsLaidOut -= LayoutCompleteHandler;
+                                                      hostPane.Remove (curView);
+                                                      curView.Dispose ();
+                                                      curView = null;
+                                                      hostPane.FillRect (hostPane.Viewport);
+                                                  }
+
+                                                  curView = CreateClass (viewClasses.Values.ToArray () [classListView.SelectedItem]);
+                                              };
+
+        xRadioGroup.SelectedItemChanged += (s, selected) => DimPosChanged (curView);
+
+        xText.TextChanged += (s, args) =>
+                              {
+                                  try
+                                  {
+                                      xVal = int.Parse (xText.Text);
+                                      DimPosChanged (curView);
+                                  }
+                                  catch
+                                  { }
+                              };
+
+        yText.TextChanged += (s, e) =>
+                              {
+                                  try
+                                  {
+                                      yVal = int.Parse (yText.Text);
+                                      DimPosChanged (curView);
+                                  }
+                                  catch
+                                  { }
+                              };
+
+        yRadioGroup.SelectedItemChanged += (s, selected) => DimPosChanged (curView);
+
+        wRadioGroup.SelectedItemChanged += (s, selected) => DimPosChanged (curView);
+
+        wText.TextChanged += (s, args) =>
+                              {
+                                  try
+                                  {
+                                      wVal = int.Parse (wText.Text);
+                                      DimPosChanged (curView);
+                                  }
+                                  catch
+                                  { }
+                              };
+
+        hText.TextChanged += (s, args) =>
+                              {
+                                  try
+                                  {
+                                      hVal = int.Parse (hText.Text);
+                                      DimPosChanged (curView);
+                                  }
+                                  catch
+                                  { }
+                              };
+
+        hRadioGroup.SelectedItemChanged += (s, selected) => DimPosChanged (curView);
+
+        top.Add (leftPane, settingsPane, hostPane);
+
+        top.LayoutSubViews ();
+
+        curView = CreateClass (viewClasses.First ().Value);
 
         var iterations = 0;
 
         Application.Iteration += (s, a) =>
-        {
-            iterations++;
-
-            if (iterations < _viewClasses.Count)
-            {
-                _classListView.MoveDown ();
-
-                Assert.Equal (
-                              _curView.GetType ().Name,
-                              _viewClasses.Values.ToArray () [_classListView.SelectedItem].Name
-                             );
-            }
-            else
-            {
-                Application.RequestStop ();
-            }
-        };
+                                 {
+                                     iterations++;
+
+                                     if (iterations < viewClasses.Count)
+                                     {
+                                         classListView.MoveDown ();
+
+                                         Assert.Equal (
+                                                       curView!.GetType ().Name,
+                                                       viewClasses.Values.ToArray () [classListView.SelectedItem].Name
+                                                      );
+                                     }
+                                     else
+                                     {
+                                         Application.RequestStop ();
+                                     }
+                                 };
 
         Application.Run (top);
 
-        Assert.Equal (_viewClasses.Count, iterations);
+        Assert.Equal (viewClasses.Count, iterations);
 
         top.Dispose ();
         Application.Shutdown ();
@@ -394,7 +379,7 @@ public class ScenarioTests : TestsAllViews
         ConfigurationManager.Locations = savedConfigLocations;
         ConfigurationManager.Reset ();
 
-        void DimPosChanged (View view)
+        void DimPosChanged (View? view)
         {
             if (view == null)
             {
@@ -403,14 +388,14 @@ public class ScenarioTests : TestsAllViews
 
             try
             {
-                switch (_xRadioGroup.SelectedItem)
+                switch (xRadioGroup.SelectedItem)
                 {
                     case 0:
-                        view.X = Pos.Percent (_xVal);
+                        view.X = Pos.Percent (xVal);
 
                         break;
                     case 1:
-                        view.X = Pos.AnchorEnd (_xVal);
+                        view.X = Pos.AnchorEnd (xVal);
 
                         break;
                     case 2:
@@ -418,19 +403,19 @@ public class ScenarioTests : TestsAllViews
 
                         break;
                     case 3:
-                        view.X = Pos.Absolute (_xVal);
+                        view.X = Pos.Absolute (xVal);
 
                         break;
                 }
 
-                switch (_yRadioGroup.SelectedItem)
+                switch (yRadioGroup.SelectedItem)
                 {
                     case 0:
-                        view.Y = Pos.Percent (_yVal);
+                        view.Y = Pos.Percent (yVal);
 
                         break;
                     case 1:
-                        view.Y = Pos.AnchorEnd (_yVal);
+                        view.Y = Pos.AnchorEnd (yVal);
 
                         break;
                     case 2:
@@ -438,39 +423,39 @@ public class ScenarioTests : TestsAllViews
 
                         break;
                     case 3:
-                        view.Y = Pos.Absolute (_yVal);
+                        view.Y = Pos.Absolute (yVal);
 
                         break;
                 }
 
-                switch (_wRadioGroup.SelectedItem)
+                switch (wRadioGroup.SelectedItem)
                 {
                     case 0:
-                        view.Width = Dim.Percent (_wVal);
+                        view.Width = Dim.Percent (wVal);
 
                         break;
                     case 1:
-                        view.Width = Dim.Fill (_wVal);
+                        view.Width = Dim.Fill (wVal);
 
                         break;
                     case 2:
-                        view.Width = Dim.Absolute (_wVal);
+                        view.Width = Dim.Absolute (wVal);
 
                         break;
                 }
 
-                switch (_hRadioGroup.SelectedItem)
+                switch (hRadioGroup.SelectedItem)
                 {
                     case 0:
-                        view.Height = Dim.Percent (_hVal);
+                        view.Height = Dim.Percent (hVal);
 
                         break;
                     case 1:
-                        view.Height = Dim.Fill (_hVal);
+                        view.Height = Dim.Fill (hVal);
 
                         break;
                     case 2:
-                        view.Height = Dim.Absolute (_hVal);
+                        view.Height = Dim.Absolute (hVal);
 
                         break;
                 }
@@ -490,8 +475,8 @@ public class ScenarioTests : TestsAllViews
 
             try
             {
-                _xRadioGroup.SelectedItem = posNames.IndexOf (posNames.First (s => x.Contains (s)));
-                _yRadioGroup.SelectedItem = posNames.IndexOf (posNames.First (s => y.Contains (s)));
+                xRadioGroup.SelectedItem = posNames.IndexOf (posNames.First (s => x.Contains (s)));
+                yRadioGroup.SelectedItem = posNames.IndexOf (posNames.First (s => y.Contains (s)));
             }
             catch (InvalidOperationException e)
             {
@@ -499,22 +484,22 @@ public class ScenarioTests : TestsAllViews
                 Debug.WriteLine ($"{e}");
             }
 
-            _xText.Text = $"{view.Frame.X}";
-            _yText.Text = $"{view.Frame.Y}";
+            xText.Text = $"{view.Frame.X}";
+            yText.Text = $"{view.Frame.Y}";
 
-            var w = view.Width.ToString ();
-            var h = view.Height.ToString ();
+            var w = view.Width!.ToString ();
+            var h = view.Height!.ToString ();
 
-            _wRadioGroup.SelectedItem = dimNames.IndexOf (dimNames.First (s => w.Contains (s)));
-            _hRadioGroup.SelectedItem = dimNames.IndexOf (dimNames.First (s => h.Contains (s)));
+            wRadioGroup.SelectedItem = dimNames.IndexOf (dimNames.First (s => w.Contains (s)));
+            hRadioGroup.SelectedItem = dimNames.IndexOf (dimNames.First (s => h.Contains (s)));
 
-            _wText.Text = $"{view.Frame.Width}";
-            _hText.Text = $"{view.Frame.Height}";
+            wText.Text = $"{view.Frame.Width}";
+            hText.Text = $"{view.Frame.Height}";
         }
 
-        void UpdateTitle (View view) { _hostPane.Title = $"{view.GetType ().Name} - {view.X}, {view.Y}, {view.Width}, {view.Height}"; }
+        void UpdateTitle (View? view) { hostPane.Title = $"{view!.GetType ().Name} - {view.X}, {view.Y}, {view.Width}, {view.Height}"; }
 
-        View CreateClass (Type type)
+        View? CreateClass (Type type)
         {
             // If we are to create a generic Type
             if (type.IsGenericType)
@@ -533,7 +518,7 @@ public class ScenarioTests : TestsAllViews
             }
 
             // Instantiate view
-            var view = (View)Activator.CreateInstance (type);
+            var view = Activator.CreateInstance (type) as View;
 
             if (view is null)
             {
@@ -562,7 +547,7 @@ public class ScenarioTests : TestsAllViews
                 }
                 catch (TargetInvocationException e)
                 {
-                    MessageBox.ErrorQuery ("Exception", e.InnerException.Message, "Ok");
+                    MessageBox.ErrorQuery ("Exception", e.InnerException!.Message, "Ok");
                     view = null;
                 }
             }
@@ -570,7 +555,7 @@ public class ScenarioTests : TestsAllViews
             // If the view supports a Title property, set it so we have something to look at
             if (view != null && view.GetType ().GetProperty ("Title") != null)
             {
-                if (view.GetType ().GetProperty ("Title").PropertyType == typeof (string))
+                if (view.GetType ().GetProperty ("Title")!.PropertyType == typeof (string))
                 {
                     view?.GetType ().GetProperty ("Title")?.GetSetMethod ()?.Invoke (view, new [] { "Test Title" });
                 }
@@ -583,28 +568,28 @@ public class ScenarioTests : TestsAllViews
             // If the view supports a Source property, set it so we have something to look at
             if (view != null
                 && view.GetType ().GetProperty ("Source") != null
-                && view.GetType ().GetProperty ("Source").PropertyType == typeof (IListDataSource))
+                && view.GetType ().GetProperty ("Source")!.PropertyType == typeof (IListDataSource))
             {
                 ListWrapper<string> source = new (["Test Text #1", "Test Text #2", "Test Text #3"]);
                 view?.GetType ().GetProperty ("Source")?.GetSetMethod ()?.Invoke (view, new [] { source });
             }
 
             // Add
-            _hostPane.Add (view);
+            hostPane.Add (view);
 
             //DimPosChanged ();
-            _hostPane.LayoutSubviews ();
-            _hostPane.ClearViewport ();
-            _hostPane.SetNeedsDraw ();
-            UpdateSettings (view);
+            hostPane.LayoutSubViews ();
+            hostPane.ClearViewport ();
+            hostPane.SetNeedsDraw ();
+            UpdateSettings (view!);
             UpdateTitle (view);
 
-            view.SubviewsLaidOut += LayoutCompleteHandler;
+            view!.SubViewsLaidOut += LayoutCompleteHandler;
 
             return view;
         }
 
-        void LayoutCompleteHandler (object sender, LayoutEventArgs args) { UpdateTitle (_curView); }
+        void LayoutCompleteHandler (object? sender, LayoutEventArgs args) { UpdateTitle (curView); }
     }
 
     [Fact]
@@ -631,40 +616,37 @@ public class ScenarioTests : TestsAllViews
         var abortCount = 0;
 
         Func<bool> abortCallback = () =>
-        {
-            abortCount++;
-            _output.WriteLine ($"'Generic' abortCount {abortCount}");
-            Application.RequestStop ();
+                                   {
+                                       abortCount++;
+                                       _output.WriteLine ($"'Generic' abortCount {abortCount}");
+                                       Application.RequestStop ();
 
-            return false;
-        };
+                                       return false;
+                                   };
 
         var iterations = 0;
-        object token = null;
+        object? token = null;
 
         Application.Iteration += (s, a) =>
-        {
-            if (token == null)
-            {
-                // Timeout only must start at first iteration
-                token = Application.AddTimeout (TimeSpan.FromMilliseconds (ms), abortCallback);
-            }
-
-            iterations++;
-            _output.WriteLine ($"'Generic' iteration {iterations}");
-
-            // Stop if we run out of control...
-            if (iterations == 10)
-            {
-                _output.WriteLine ("'Generic' had to be force quit!");
-                Application.RequestStop ();
-            }
-        };
-
-        Application.KeyDown += (sender, args) =>
-        {
-            Assert.Equal (Application.QuitKey, args.KeyCode);
-        };
+                                 {
+                                     if (token == null)
+                                     {
+                                         // Timeout only must start at first iteration
+                                         token = Application.AddTimeout (TimeSpan.FromMilliseconds (ms), abortCallback);
+                                     }
+
+                                     iterations++;
+                                     _output.WriteLine ($"'Generic' iteration {iterations}");
+
+                                     // Stop if we run out of control...
+                                     if (iterations == 10)
+                                     {
+                                         _output.WriteLine ("'Generic' had to be force quit!");
+                                         Application.RequestStop ();
+                                     }
+                                 };
+
+        Application.KeyDown += (sender, args) => { Assert.Equal (Application.QuitKey, args.KeyCode); };
 
         generic.Main ();
 
@@ -686,30 +668,4 @@ public class ScenarioTests : TestsAllViews
         Assert.Empty (View.Instances);
 #endif
     }
-
-    private int CreateInput (string input)
-    {
-        FakeConsole.MockKeyPresses.Clear ();
-
-        // Put a QuitKey in at the end
-        FakeConsole.PushMockKeyPress ((KeyCode)Application.QuitKey);
-
-        foreach (char c in input.Reverse ())
-        {
-            var key = KeyCode.Null;
-
-            if (char.IsLetter (c))
-            {
-                key = (KeyCode)char.ToUpper (c) | (char.IsUpper (c) ? KeyCode.ShiftMask : 0);
-            }
-            else
-            {
-                key = (KeyCode)c;
-            }
-
-            FakeConsole.PushMockKeyPress (key);
-        }
-
-        return FakeConsole.MockKeyPresses.Count;
-    }
 }

+ 6 - 3
Tests/StressTests/ApplicationStressTests.cs

@@ -13,7 +13,13 @@ public class ApplicationStressTests : TestsAllViews
     }
 
     private static volatile int _tbCounter;
+#pragma warning disable IDE1006 // Naming Styles
     private static readonly ManualResetEventSlim _wakeUp = new (false);
+#pragma warning restore IDE1006 // Naming Styles
+
+    private const int NUM_PASSES = 50;
+    private const int NUM_INCREMENTS = 500;
+    private const int POLL_MS = 100;
 
     [Theory]
     [InlineData (typeof (FakeDriver))]
@@ -30,9 +36,6 @@ public class ApplicationStressTests : TestsAllViews
         var top = new Toplevel ();
         top.Add (tf);
 
-        const int NUM_PASSES = 50;
-        const int NUM_INCREMENTS = 500;
-        const int POLL_MS = 100;
         _tbCounter = 0;
 
         Task task = Task.Run (() => RunTest (r, tf, NUM_PASSES, NUM_INCREMENTS, POLL_MS));

+ 6 - 6
Tests/StressTests/ScenariosStressTests.cs

@@ -150,19 +150,19 @@ public class ScenariosStressTests : TestsAllViews
         {
             // Get a list of all subviews under Application.Top (and their subviews, etc.)
             // and subscribe to their DrawComplete event
-            void SubscribeAllSubviews (View view)
+            void SubscribeAllSubViews (View view)
             {
                 view.DrawComplete += (s, a) => drawCompleteCount++;
-                view.SubviewsLaidOut += (s, a) => laidOutCount++;
-                view.Added += (s, a) => addedCount++;
+                view.SubViewsLaidOut += (s, a) => laidOutCount++;
+                view.SuperViewChanged += (s, a) => addedCount++;
 
-                foreach (View subview in view.Subviews)
+                foreach (View subview in view.SubViews)
                 {
-                    SubscribeAllSubviews (subview);
+                    SubscribeAllSubViews (subview);
                 }
             }
 
-            SubscribeAllSubviews (Application.Top!);
+            SubscribeAllSubViews (Application.Top!);
         }
 
         // If the scenario doesn't close within the abort time, this will force it to quit

+ 9 - 14
Tests/UnitTests/ConsoleDrivers/AnsiKeyboardParserTests.cs

@@ -1,15 +1,11 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
+#nullable enable
 namespace UnitTests.ConsoleDrivers;
+
 public class AnsiKeyboardParserTests
 {
     private readonly AnsiKeyboardParser _parser = new ();
 
-    public static IEnumerable<object []> GetKeyboardTestData ()
+    public static IEnumerable<object? []> GetKeyboardTestData ()
     {
         // Test data for various ANSI escape sequences and their expected Key values
         yield return new object [] { "\u001b[A", Key.CursorUp };
@@ -50,19 +46,18 @@ public class AnsiKeyboardParserTests
         yield return new object [] { "\u001b[1;7D", Key.CursorLeft.WithCtrl.WithAlt };
         yield return new object [] { "\u001b[1;8D", Key.CursorLeft.WithCtrl.WithAlt.WithShift };
 
-
         // Invalid inputs
-        yield return new object [] { "\u001b[Z", null };
-        yield return new object [] { "\u001b[invalid", null };
-        yield return new object [] { "\u001b[1", null };
-        yield return new object [] { "\u001b[AB", null };
-        yield return new object [] { "\u001b[;A", null };
+        yield return new object [] { "\u001b[Z", null! };
+        yield return new object [] { "\u001b[invalid", null! };
+        yield return new object [] { "\u001b[1", null! };
+        yield return new object [] { "\u001b[AB", null! };
+        yield return new object [] { "\u001b[;A", null! };
     }
 
     // Consolidated test for all keyboard events (e.g., arrow keys)
     [Theory]
     [MemberData (nameof (GetKeyboardTestData))]
-    public void ProcessKeyboardInput_ReturnsCorrectKey (string input, Key? expectedKey)
+    public void ProcessKeyboardInput_ReturnsCorrectKey (string? input, Key? expectedKey)
     {
         // Act
         Key? result = _parser.IsKeyboard (input)?.GetKey (input);

+ 261 - 237
Tests/UnitTests/ConsoleDrivers/AnsiResponseParserTests.cs

@@ -1,39 +1,42 @@
-using System.Diagnostics;
+#nullable enable
+using System.Diagnostics;
 using System.Text;
 using Xunit.Abstractions;
 
 namespace UnitTests.ConsoleDrivers;
+
 public class AnsiResponseParserTests (ITestOutputHelper output)
 {
-    AnsiResponseParser<int> _parser1 = new AnsiResponseParser<int> ();
-    AnsiResponseParser _parser2 = new AnsiResponseParser ();
+    private readonly AnsiResponseParser<int> _parser1 = new ();
+    private readonly AnsiResponseParser _parser2 = new ();
 
     /// <summary>
-    /// Used for the T value in batches that are passed to the  AnsiResponseParser&lt;int&gt;  (parser1)
+    ///     Used for the T value in batches that are passed to the  AnsiResponseParser&lt;int&gt;  (parser1)
     /// </summary>
-    private int tIndex = 0;
+    private int _tIndex;
 
     [Fact]
     public void TestInputProcessing ()
     {
-        string ansiStream = "\u001b[<0;10;20M" +   // ANSI escape for mouse move at (10, 20)
-                            "Hello" +             // User types "Hello"
-                            "\u001b[0c";            // Device Attributes response (e.g., terminal identification i.e. DAR)
-
+        string ansiStream = "\u001b[<0;10;20M"
+                            + // ANSI escape for mouse move at (10, 20)
+                            "Hello"
+                            + // User types "Hello"
+                            "\u001b[0c"; // Device Attributes response (e.g., terminal identification i.e. DAR)
 
-        string response1 = null;
-        string response2 = null;
+        string? response1 = null;
+        string? response2 = null;
 
-        int i = 0;
+        var i = 0;
 
         // Imagine that we are expecting a DAR
-        _parser1.ExpectResponse ("c",(s)=> response1 = s,null, false);
-        _parser2.ExpectResponse ("c", (s) => response2 = s , null, false);
+        _parser1.ExpectResponse ("c", s => response1 = s, null, false);
+        _parser2.ExpectResponse ("c", s => response2 = s, null, false);
 
         // First char is Escape which we must consume incase what follows is the DAR
         AssertConsumed (ansiStream, ref i); // Esc
 
-        for (int c = 0; c < "[<0;10;20".Length; c++)
+        for (var c = 0; c < "[<0;10;20".Length; c++)
         {
             AssertConsumed (ansiStream, ref i);
         }
@@ -42,13 +45,13 @@ public class AnsiResponseParserTests (ITestOutputHelper output)
         AssertReleased (ansiStream, ref i, "\u001b[<0;10;20M");
 
         // Regular user typing
-        for (int c = 0; c < "Hello".Length; c++)
+        for (var c = 0; c < "Hello".Length; c++)
         {
-            AssertIgnored (ansiStream,"Hello"[c], ref i);
+            AssertIgnored (ansiStream, "Hello" [c], ref i);
         }
 
         // Now we have entered the actual DAR we should be consuming these
-        for (int c = 0; c < "\u001b[0".Length; c++)
+        for (var c = 0; c < "\u001b[0".Length; c++)
         {
             AssertConsumed (ansiStream, ref i);
         }
@@ -69,7 +72,7 @@ public class AnsiResponseParserTests (ITestOutputHelper output)
     [InlineData ("\u001b[0cHi\u001b[0c", "c", "\u001b[0c", "Hi\u001b[0c")]
     [InlineData ("\u001b[<0;0;0MHe\u001b[3c", "c", "\u001b[3c", "\u001b[<0;0;0MHe")]
     [InlineData ("\u001b[<0;1;2Da\u001b[0c\u001b[1c", "c", "\u001b[0c", "\u001b[<0;1;2Da\u001b[1c")]
-    [InlineData ("\u001b[1;1M\u001b[3cAn", "c", "\u001b[3c", "\u001b[1;1MAn")] 
+    [InlineData ("\u001b[1;1M\u001b[3cAn", "c", "\u001b[3c", "\u001b[1;1MAn")]
     [InlineData ("hi\u001b[2c\u001b[<5;5;5m", "c", "\u001b[2c", "hi\u001b[<5;5;5m")]
     [InlineData ("\u001b[3c\u001b[4c\u001b[<0;0;0MIn", "c", "\u001b[3c", "\u001b[4c\u001b[<0;0;0MIn")]
     [InlineData ("\u001b[<1;2;3M\u001b[0c\u001b[<1;2;3M\u001b[2c", "c", "\u001b[0c", "\u001b[<1;2;3M\u001b[<1;2;3M\u001b[2c")]
@@ -84,8 +87,16 @@ public class AnsiResponseParserTests (ITestOutputHelper output)
     [InlineData ("\u001b[<1;1;1MJJ\u001b[9c", "c", "\u001b[9c", "\u001b[<1;1;1MJJ")] // Mixed text
     [InlineData ("Be\u001b[0cAf", "c", "\u001b[0c", "BeAf")] // Escape in the middle of the string
     [InlineData ("\u001b[<0;0;0M\u001b[2cNot e", "c", "\u001b[2c", "\u001b[<0;0;0MNot e")] // Unexpected sequence followed by text
-    [InlineData ("Just te\u001b[<0;0;0M\u001b[3c\u001b[2c\u001b[4c", "c", "\u001b[3c", "Just te\u001b[<0;0;0M\u001b[2c\u001b[4c")] // Multiple unexpected responses
-    [InlineData ("\u001b[1;2;3M\u001b[0c\u001b[2;2M\u001b[0;0;0MTe", "c", "\u001b[0c", "\u001b[1;2;3M\u001b[2;2M\u001b[0;0;0MTe")] // Multiple commands with responses
+    [InlineData (
+                    "Just te\u001b[<0;0;0M\u001b[3c\u001b[2c\u001b[4c",
+                    "c",
+                    "\u001b[3c",
+                    "Just te\u001b[<0;0;0M\u001b[2c\u001b[4c")] // Multiple unexpected responses
+    [InlineData (
+                    "\u001b[1;2;3M\u001b[0c\u001b[2;2M\u001b[0;0;0MTe",
+                    "c",
+                    "\u001b[0c",
+                    "\u001b[1;2;3M\u001b[2;2M\u001b[0;0;0MTe")] // Multiple commands with responses
     [InlineData ("\u001b[<3;3;3Mabc\u001b[4cde", "c", "\u001b[4c", "\u001b[<3;3;3Mabcde")] // Escape sequences mixed with regular text
 
     // Edge cases
@@ -94,58 +105,57 @@ public class AnsiResponseParserTests (ITestOutputHelper output)
     [InlineData ("Normal", "c", "", "Normal")] // No escape sequences
     [InlineData ("\u001b[<0;0;0M", "c", "", "\u001b[<0;0;0M")] // Escape sequence only
     [InlineData ("\u001b[1;2;3M\u001b[0c", "c", "\u001b[0c", "\u001b[1;2;3M")] // Last response consumed
-
     [InlineData ("Inpu\u001b[0c\u001b[1;0;0M", "c", "\u001b[0c", "Inpu\u001b[1;0;0M")] // Single input followed by escape
     [InlineData ("\u001b[2c\u001b[<5;6;7MDa", "c", "\u001b[2c", "\u001b[<5;6;7MDa")] // Multiple escape sequences followed by text
     [InlineData ("\u001b[0cHi\u001b[1cGo", "c", "\u001b[0c", "Hi\u001b[1cGo")] // Normal text with multiple escape sequences
-
     [InlineData ("\u001b[<1;1;1MTe", "c", "", "\u001b[<1;1;1MTe")]
+
     // Add more test cases here...
-    public void TestInputSequences (string ansiStream, string expectedTerminator, string expectedResponse, string expectedOutput)
+    public void TestInputSequences (string ansiStream, string? expectedTerminator, string expectedResponse, string expectedOutput)
     {
         var swGenBatches = Stopwatch.StartNew ();
-        int tests = 0;
+        var tests = 0;
 
-        var permutations = GetBatchPermutations (ansiStream,5).ToArray ();
+        string [] [] permutations = GetBatchPermutations (ansiStream, 5).ToArray ();
 
         swGenBatches.Stop ();
         var swRunTest = Stopwatch.StartNew ();
 
-        foreach (var batchSet in permutations)
+        foreach (string [] batchSet in permutations)
         {
-            tIndex = 0;
-            string response1 = string.Empty;
-            string response2 = string.Empty;
+            _tIndex = 0;
+            var response1 = string.Empty;
+            var response2 = string.Empty;
 
             // Register the expected response with the given terminator
             _parser1.ExpectResponse (expectedTerminator, s => response1 = s, null, false);
             _parser2.ExpectResponse (expectedTerminator, s => response2 = s, null, false);
 
             // Process the input
-            StringBuilder actualOutput1 = new StringBuilder ();
-            StringBuilder actualOutput2 = new StringBuilder ();
+            var actualOutput1 = new StringBuilder ();
+            var actualOutput2 = new StringBuilder ();
 
-            foreach (var batch in batchSet)
+            foreach (string batch in batchSet)
             {
-                var output1 = _parser1.ProcessInput (StringToBatch (batch));
+                IEnumerable<Tuple<char, int>> output1 = _parser1.ProcessInput (StringToBatch (batch));
                 actualOutput1.Append (BatchToString (output1));
 
-                var output2 = _parser2.ProcessInput (batch);
+                string output2 = _parser2.ProcessInput (batch);
                 actualOutput2.Append (output2);
             }
 
             // Assert the final output minus the expected response
-            Assert.Equal (expectedOutput, actualOutput1.ToString());
+            Assert.Equal (expectedOutput, actualOutput1.ToString ());
             Assert.Equal (expectedResponse, response1);
             Assert.Equal (expectedOutput, actualOutput2.ToString ());
             Assert.Equal (expectedResponse, response2);
             tests++;
         }
 
-        output.WriteLine ($"Tested {tests} in {swRunTest.ElapsedMilliseconds} ms (gen batches took {swGenBatches.ElapsedMilliseconds} ms)" );
+        output.WriteLine ($"Tested {tests} in {swRunTest.ElapsedMilliseconds} ms (gen batches took {swGenBatches.ElapsedMilliseconds} ms)");
     }
 
-    public static IEnumerable<object []> TestInputSequencesExact_Cases ()
+    public static IEnumerable<object? []> TestInputSequencesExact_Cases ()
     {
         yield return
         [
@@ -153,7 +163,7 @@ public class AnsiResponseParserTests (ITestOutputHelper output)
             null,
             new []
             {
-                new StepExpectation ('\u001b',AnsiResponseParserState.ExpectingEscapeSequence,string.Empty)
+                new StepExpectation ('\u001b', AnsiResponseParserState.ExpectingEscapeSequence, string.Empty)
             }
         ];
 
@@ -163,13 +173,20 @@ public class AnsiResponseParserTests (ITestOutputHelper output)
             'c',
             new []
             {
-                new StepExpectation ('\u001b',AnsiResponseParserState.ExpectingEscapeSequence,string.Empty),
-                new StepExpectation ('H',AnsiResponseParserState.InResponse,string.Empty), // H is known terminator and not expected one so here we release both chars
-                new StepExpectation ('\u001b',AnsiResponseParserState.ExpectingEscapeSequence,"\u001bH"),
-                new StepExpectation ('[',AnsiResponseParserState.InResponse,string.Empty),
-                new StepExpectation ('0',AnsiResponseParserState.InResponse,string.Empty),
-                new StepExpectation ('c',AnsiResponseParserState.Normal,string.Empty,"\u001b[0c"), // c is expected terminator so here we swallow input and populate expected response
-                new StepExpectation ('\u001b',AnsiResponseParserState.ExpectingEscapeSequence,string.Empty),
+                new StepExpectation ('\u001b', AnsiResponseParserState.ExpectingEscapeSequence, string.Empty),
+                new StepExpectation (
+                                     'H',
+                                     AnsiResponseParserState.InResponse,
+                                     string.Empty), // H is known terminator and not expected one so here we release both chars
+                new StepExpectation ('\u001b', AnsiResponseParserState.ExpectingEscapeSequence, "\u001bH"),
+                new StepExpectation ('[', AnsiResponseParserState.InResponse, string.Empty),
+                new StepExpectation ('0', AnsiResponseParserState.InResponse, string.Empty),
+                new StepExpectation (
+                                     'c',
+                                     AnsiResponseParserState.Normal,
+                                     string.Empty,
+                                     "\u001b[0c"), // c is expected terminator so here we swallow input and populate expected response
+                new StepExpectation ('\u001b', AnsiResponseParserState.ExpectingEscapeSequence, string.Empty)
             }
         ];
     }
@@ -177,24 +194,24 @@ public class AnsiResponseParserTests (ITestOutputHelper output)
     public class StepExpectation ()
     {
         /// <summary>
-        /// The input character to feed into the parser at this step of the test
+        ///     The input character to feed into the parser at this step of the test
         /// </summary>
         public char Input { get; }
 
         /// <summary>
-        /// What should the state of the parser be after the <see cref="Input"/>
-        /// is fed in.
+        ///     What should the state of the parser be after the <see cref="Input"/>
+        ///     is fed in.
         /// </summary>
         public AnsiResponseParserState ExpectedStateAfterOperation { get; }
 
         /// <summary>
-        /// If this step should release one or more characters, put them here.
+        ///     If this step should release one or more characters, put them here.
         /// </summary>
         public string ExpectedRelease { get; } = string.Empty;
 
         /// <summary>
-        /// If this step should result in a completing of detection of ANSI response
-        /// then put the expected full response sequence here.
+        ///     If this step should result in a completing of detection of ANSI response
+        ///     then put the expected full response sequence here.
         /// </summary>
         public string ExpectedAnsiResponse { get; } = string.Empty;
 
@@ -202,35 +219,36 @@ public class AnsiResponseParserTests (ITestOutputHelper output)
             char input,
             AnsiResponseParserState expectedStateAfterOperation,
             string expectedRelease = "",
-            string expectedAnsiResponse = "") : this ()
+            string expectedAnsiResponse = ""
+        ) : this ()
         {
             Input = input;
             ExpectedStateAfterOperation = expectedStateAfterOperation;
             ExpectedRelease = expectedRelease;
             ExpectedAnsiResponse = expectedAnsiResponse;
         }
-
     }
 
-
-
-    [MemberData(nameof(TestInputSequencesExact_Cases))]
+    [MemberData (nameof (TestInputSequencesExact_Cases))]
     [Theory]
     public void TestInputSequencesExact (string caseName, char? terminator, IEnumerable<StepExpectation> expectedStates)
     {
         output.WriteLine ("Running test case:" + caseName);
 
         var parser = new AnsiResponseParser ();
-        string response = null;
+        string? response = null;
 
         if (terminator.HasValue)
         {
-            parser.ExpectResponse (terminator.Value.ToString (),(s)=> response = s,null, false);
+            parser.ExpectResponse (terminator.Value.ToString (), s => response = s, null, false);
         }
-        int step= 0;
-        foreach (var state in expectedStates)
+
+        var step = 0;
+
+        foreach (StepExpectation state in expectedStates)
         {
             step++;
+
             // If we expect the response to be detected at this step
             if (!string.IsNullOrWhiteSpace (state.ExpectedAnsiResponse))
             {
@@ -238,9 +256,9 @@ public class AnsiResponseParserTests (ITestOutputHelper output)
                 Assert.Null (response);
             }
 
-            var actual = parser.ProcessInput (state.Input.ToString ());
+            string actual = parser.ProcessInput (state.Input.ToString ());
 
-            Assert.Equal (state.ExpectedRelease,actual);
+            Assert.Equal (state.ExpectedRelease, actual);
             Assert.Equal (state.ExpectedStateAfterOperation, parser.State);
 
             // If we expect the response to be detected at this step
@@ -257,11 +275,11 @@ public class AnsiResponseParserTests (ITestOutputHelper output)
     [Fact]
     public void ReleasesEscapeAfterTimeout ()
     {
-        string input = "\u001b";
-        int i = 0;
+        var input = "\u001b";
+        var i = 0;
 
         // Esc on its own looks like it might be an esc sequence so should be consumed
-        AssertConsumed (input,ref i);
+        AssertConsumed (input, ref i);
 
         // We should know when the state changed
         Assert.Equal (AnsiResponseParserState.ExpectingEscapeSequence, _parser1.State);
@@ -273,24 +291,23 @@ public class AnsiResponseParserTests (ITestOutputHelper output)
         AssertManualReleaseIs (input);
     }
 
-
     [Fact]
-    public void TwoExcapesInARow ()
+    public void TwoEscapesInARow ()
     {
         // Example user presses Esc key then a DAR comes in
-        string input = "\u001b\u001b";
-        int i = 0;
+        var input = "\u001b\u001b";
+        var i = 0;
 
         // First Esc gets grabbed
         AssertConsumed (input, ref i);
 
         // Upon getting the second Esc we should release the first
-        AssertReleased (input, ref i, "\u001b",0);
+        AssertReleased (input, ref i, "\u001b", 0);
 
         // Assume 50ms or something has passed, lets force release as no new content
 
         // It should be the second escape that gets released (i.e. index 1)
-        AssertManualReleaseIs ("\u001b",1);
+        AssertManualReleaseIs ("\u001b", 1);
     }
 
     [Fact]
@@ -298,19 +315,19 @@ public class AnsiResponseParserTests (ITestOutputHelper output)
     {
         var p = new AnsiResponseParser ();
 
-        string responseA = null;
-        string responseB = null;
+        string? responseA = null;
+        string? responseB = null;
 
-        p.ExpectResponse ("z",(r)=>responseA=r, null, false);
+        p.ExpectResponse ("z", r => responseA = r, null, false);
 
         // Some time goes by without us seeing a response
         p.StopExpecting ("z", false);
 
         // Send our new request
-        p.ExpectResponse ("z", (r) => responseB = r, null, false);
+        p.ExpectResponse ("z", r => responseB = r, null, false);
 
         // Because we gave up on getting A, we should expect the response to be to our new request
-        Assert.Empty(p.ProcessInput ("\u001b[<1;2z"));
+        Assert.Empty (p.ProcessInput ("\u001b[<1;2z"));
         Assert.Null (responseA);
         Assert.Equal ("\u001b[<1;2z", responseB);
 
@@ -323,7 +340,6 @@ public class AnsiResponseParserTests (ITestOutputHelper output)
 
         // We now have no outstanding requests (late or otherwise) so new ansi codes should just fall through
         Assert.Equal ("\u001b[111z", p.ProcessInput ("\u001b[111z"));
-
     }
 
     [Fact]
@@ -331,57 +347,61 @@ public class AnsiResponseParserTests (ITestOutputHelper output)
     {
         var p = new AnsiResponseParser ();
 
-        int m = 0;
-        int M = 1;
+        var m = 0;
+        var M = 1;
 
         p.ExpectResponse ("m", _ => m++, null, true);
         p.ExpectResponse ("M", _ => M++, null, true);
 
         // Act - Feed input strings containing ANSI sequences
-        p.ProcessInput ("\u001b[<0;10;10m");  // Should match and increment `m`
-        p.ProcessInput ("\u001b[<0;20;20m");  // Should match and increment `m`
-        p.ProcessInput ("\u001b[<0;30;30M");  // Should match and increment `M`
-        p.ProcessInput ("\u001b[<0;40;40M");  // Should match and increment `M`
-        p.ProcessInput ("\u001b[<0;50;50M");  // Should match and increment `M`
+        p.ProcessInput ("\u001b[<0;10;10m"); // Should match and increment `m`
+        p.ProcessInput ("\u001b[<0;20;20m"); // Should match and increment `m`
+        p.ProcessInput ("\u001b[<0;30;30M"); // Should match and increment `M`
+        p.ProcessInput ("\u001b[<0;40;40M"); // Should match and increment `M`
+        p.ProcessInput ("\u001b[<0;50;50M"); // Should match and increment `M`
 
         // Assert - Verify that counters reflect the expected counts of each terminator
-        Assert.Equal (2, m);  // Expected two `m` responses
-        Assert.Equal (4, M);  // Expected three `M` responses plus the initial value of 1
+        Assert.Equal (2, m); // Expected two `m` responses
+        Assert.Equal (4, M); // Expected three `M` responses plus the initial value of 1
     }
 
     [Fact]
     public void TestPersistentResponses_WithMetadata ()
     {
-        var p = new AnsiResponseParser<int> ();
+        AnsiResponseParser<int> p = new ();
 
-        int m = 0;
+        // ReSharper disable once NotAccessedVariable
+        var m = 0;
 
-        var result = new List<Tuple<char,int>> ();
+        List<Tuple<char, int>> result = new ();
 
-        p.ExpectResponseT ("m", (r) =>
-                                {
-                                    result = r.ToList ();
-                                    m++;
-                                },
-                           null, true);
+        p.ExpectResponseT (
+                           "m",
+                           r =>
+                           {
+                               result = r.ToList ();
+                               m++;
+                           },
+                           null,
+                           true);
 
         // Act - Feed input strings containing ANSI sequences
-        p.ProcessInput (StringToBatch("\u001b[<0;10;10m"));  // Should match and increment `m`
+        p.ProcessInput (StringToBatch ("\u001b[<0;10;10m")); // Should match and increment `m`
 
         // Prepare expected result: 
-        var expected = new List<Tuple<char, int>>
+        List<Tuple<char, int>> expected = new()
         {
-            Tuple.Create('\u001b', 0), // Escape character
-            Tuple.Create('[', 1),
-            Tuple.Create('<', 2),
-            Tuple.Create('0', 3),
-            Tuple.Create(';', 4),
-            Tuple.Create('1', 5),
-            Tuple.Create('0', 6),
-            Tuple.Create(';', 7),
-            Tuple.Create('1', 8),
-            Tuple.Create('0', 9),
-            Tuple.Create('m', 10)
+            Tuple.Create ('\u001b', 0), // Escape character
+            Tuple.Create ('[', 1),
+            Tuple.Create ('<', 2),
+            Tuple.Create ('0', 3),
+            Tuple.Create (';', 4),
+            Tuple.Create ('1', 5),
+            Tuple.Create ('0', 6),
+            Tuple.Create (';', 7),
+            Tuple.Create ('1', 8),
+            Tuple.Create ('0', 9),
+            Tuple.Create ('m', 10)
         };
 
         Assert.Equal (expected.Count, result.Count); // Ensure the count is as expected
@@ -395,7 +415,6 @@ public class AnsiResponseParserTests (ITestOutputHelper output)
         _parser1.UnexpectedResponseHandler = _ => true;
         _parser2.UnknownResponseHandler = _ => true;
 
-
         AssertReleased (
                         "Just te\u001b[<0;0;0M\u001b[3c\u001b[2c\u001b[4cst",
                         "Just test",
@@ -414,19 +433,21 @@ public class AnsiResponseParserTests (ITestOutputHelper output)
     public void UnknownResponses_ParameterShouldMatch ()
     {
         // Track unknown responses passed to the UnexpectedResponseHandler
-        var unknownResponses = new List<string> ();
+        List<string> unknownResponses = new ();
 
         // Set up the UnexpectedResponseHandler to log each unknown response
         _parser1.UnexpectedResponseHandler = r1 =>
-                                          {
-                                              unknownResponses.Add (BatchToString (r1));
-                                              return true; // Return true to swallow unknown responses
-                                          };
+                                             {
+                                                 unknownResponses.Add (BatchToString (r1));
+
+                                                 return true; // Return true to swallow unknown responses
+                                             };
 
         _parser2.UnknownResponseHandler = r2 =>
                                           {
                                               // parsers should be agreeing on what these responses are!
-                                              Assert.Equal(unknownResponses.Last(),r2);
+                                              Assert.Equal (unknownResponses.Last (), r2);
+
                                               return true; // Return true to swallow unknown responses
                                           };
 
@@ -436,7 +457,7 @@ public class AnsiResponseParserTests (ITestOutputHelper output)
                         "Just test");
 
         // Expected unknown responses (ANSI sequences that are unknown)
-        var expectedUnknownResponses = new List<string>
+        List<string> expectedUnknownResponses = new()
         {
             "\u001b[<0;0;0M",
             "\u001b[3c",
@@ -468,19 +489,20 @@ public class AnsiResponseParserTests (ITestOutputHelper output)
         List<MouseEventArgs> mouseEventArgs = new ();
 
         parser.Mouse += (s, e) => mouseEventArgs.Add (e);
-        parser.ExpectResponse ("c", (dar) => foundDar = dar, null, false);
-        var released = parser.ProcessInput ("a" + MOUSE_DOWN + "asdf" + DEVICE_ATTRIBUTE_RESPONSE + "bbcc" + MOUSE_UP + "sss");
+        parser.ExpectResponse ("c", dar => foundDar = dar, null, false);
+        string released = parser.ProcessInput ("a" + MOUSE_DOWN + "asdf" + DEVICE_ATTRIBUTE_RESPONSE + "bbcc" + MOUSE_UP + "sss");
 
         Assert.Equal ("aasdfbbccsss", released);
 
         Assert.Equal (2, mouseEventArgs.Count);
 
         Assert.NotNull (foundDar);
-        Assert.Equal (DEVICE_ATTRIBUTE_RESPONSE,foundDar);
+        Assert.Equal (DEVICE_ATTRIBUTE_RESPONSE, foundDar);
 
         Assert.True (mouseEventArgs [0].IsPressed);
+
         // Mouse positions in ANSI are 1 based so actual Terminal.Gui Screen positions are x-1,y-1
-        Assert.Equal (11,mouseEventArgs [0].Position.X);
+        Assert.Equal (11, mouseEventArgs [0].Position.X);
         Assert.Equal (31, mouseEventArgs [0].Position.Y);
 
         Assert.True (mouseEventArgs [1].IsReleased);
@@ -488,11 +510,9 @@ public class AnsiResponseParserTests (ITestOutputHelper output)
         Assert.Equal (49, mouseEventArgs [1].Position.Y);
     }
 
-
     [Fact]
     public void ParserDetectsKeyboard ()
     {
-
         // ANSI escape sequence for cursor left
         const string LEFT = "\u001b[D";
 
@@ -509,8 +529,8 @@ public class AnsiResponseParserTests (ITestOutputHelper output)
         List<Key> keys = new ();
 
         parser.Keyboard += (s, e) => keys.Add (e);
-        parser.ExpectResponse ("c", (dar) => foundDar = dar, null, false);
-        var released = parser.ProcessInput ("a" + LEFT + "asdf" + DEVICE_ATTRIBUTE_RESPONSE + "bbcc" + SHIFT_UP + "sss");
+        parser.ExpectResponse ("c", dar => foundDar = dar, null, false);
+        string released = parser.ProcessInput ("a" + LEFT + "asdf" + DEVICE_ATTRIBUTE_RESPONSE + "bbcc" + SHIFT_UP + "sss");
 
         Assert.Equal ("aasdfbbccsss", released);
 
@@ -519,7 +539,7 @@ public class AnsiResponseParserTests (ITestOutputHelper output)
         Assert.NotNull (foundDar);
         Assert.Equal (DEVICE_ATTRIBUTE_RESPONSE, foundDar);
 
-        Assert.Equal (Key.CursorLeft,keys [0]);
+        Assert.Equal (Key.CursorLeft, keys [0]);
         Assert.Equal (Key.CursorUp.WithShift, keys [1]);
     }
 
@@ -550,71 +570,81 @@ public class AnsiResponseParserTests (ITestOutputHelper output)
             Key.F4
         ];
 
-
         // These are also F keys
-        yield return [
-                         "\u001b[11~",
-                         Key.F1
-                     ];
-
-        yield return [
-                         "\u001b[12~",
-                         Key.F2
-                     ];
-
-        yield return [
-                         "\u001b[13~",
-                         Key.F3
-                     ];
-
-        yield return [
-                         "\u001b[14~",
-                         Key.F4
-                     ];
-
-        yield return [
-                         "\u001b[15~",
-                         Key.F5
-                     ];
-
-        yield return [
-                         "\u001b[17~",
-                         Key.F6
-                     ];
-
-        yield return [
-                         "\u001b[18~",
-                         Key.F7
-                     ];
-
-        yield return [
-                         "\u001b[19~",
-                         Key.F8
-                     ];
-
-        yield return [
-                         "\u001b[20~",
-                         Key.F9
-                     ];
-
-        yield return [
-                         "\u001b[21~",
-                         Key.F10
-                     ];
-
-        yield return [
-                         "\u001b[23~",
-                         Key.F11
-                     ];
-
-        yield return [
-                         "\u001b[24~",
-                         Key.F12
-                     ];
+        yield return
+        [
+            "\u001b[11~",
+            Key.F1
+        ];
+
+        yield return
+        [
+            "\u001b[12~",
+            Key.F2
+        ];
+
+        yield return
+        [
+            "\u001b[13~",
+            Key.F3
+        ];
+
+        yield return
+        [
+            "\u001b[14~",
+            Key.F4
+        ];
+
+        yield return
+        [
+            "\u001b[15~",
+            Key.F5
+        ];
+
+        yield return
+        [
+            "\u001b[17~",
+            Key.F6
+        ];
+
+        yield return
+        [
+            "\u001b[18~",
+            Key.F7
+        ];
+
+        yield return
+        [
+            "\u001b[19~",
+            Key.F8
+        ];
+
+        yield return
+        [
+            "\u001b[20~",
+            Key.F9
+        ];
+
+        yield return
+        [
+            "\u001b[21~",
+            Key.F10
+        ];
+
+        yield return
+        [
+            "\u001b[23~",
+            Key.F11
+        ];
+
+        yield return
+        [
+            "\u001b[24~",
+            Key.F12
+        ];
     }
 
     [MemberData (nameof (ParserDetects_FunctionKeys_Cases))]
-
     [Theory]
     public void ParserDetects_FunctionKeys (string input, Key expectedKey)
     {
@@ -625,20 +655,18 @@ public class AnsiResponseParserTests (ITestOutputHelper output)
 
         parser.Keyboard += (s, e) => keys.Add (e);
 
-        foreach (var ch in input.ToCharArray ())
+        foreach (char ch in input)
         {
-            parser.ProcessInput (new (ch,1));
+            parser.ProcessInput (new (ch, 1));
         }
-        var k = Assert.Single (keys);
 
-        Assert.Equal (k,expectedKey);
-    }
+        Key k = Assert.Single (keys);
 
-    private Tuple<char, int> [] StringToBatch (string batch)
-    {
-        return batch.Select ((k) => Tuple.Create (k, tIndex++)).ToArray ();
+        Assert.Equal (k, expectedKey);
     }
 
+    private Tuple<char, int> [] StringToBatch (string batch) { return batch.Select (k => Tuple.Create (k, _tIndex++)).ToArray (); }
+
     public static IEnumerable<string []> GetBatchPermutations (string input, int maxDepth = 3)
     {
         // Call the recursive method to generate batches with an initial depth of 0
@@ -657,6 +685,7 @@ public class AnsiResponseParserTests (ITestOutputHelper output)
         if (start >= input.Length)
         {
             yield return new string [0];
+
             yield break;
         }
 
@@ -667,42 +696,44 @@ public class AnsiResponseParserTests (ITestOutputHelper output)
             string batch = input.Substring (start, i - start);
 
             // Recursively get batches from the remaining substring, increasing the depth
-            foreach (var remainingBatches in GenerateBatches (input, i, maxDepth, currentDepth + 1))
+            foreach (string [] remainingBatches in GenerateBatches (input, i, maxDepth, currentDepth + 1))
             {
                 // Combine the current batch with the remaining batches
                 var result = new string [1 + remainingBatches.Length];
                 result [0] = batch;
                 Array.Copy (remainingBatches, 0, result, 1, remainingBatches.Length);
+
                 yield return result;
             }
         }
     }
 
-    private void AssertIgnored (string ansiStream,char expected, ref int i)
+    private void AssertIgnored (string ansiStream, char expected, ref int i)
     {
-        var c2 = ansiStream [i];
-        var c1 = NextChar (ansiStream, ref i);
+        char c2 = ansiStream [i];
+        Tuple<char, int> [] c1 = NextChar (ansiStream, ref i);
 
         // Parser does not grab this key (i.e. driver can continue with regular operations)
-        Assert.Equal ( c1,_parser1.ProcessInput (c1));
-        Assert.Equal (expected,c1.Single().Item1);
+        Assert.Equal (c1, _parser1.ProcessInput (c1));
+        Assert.Equal (expected, c1.Single ().Item1);
 
-        Assert.Equal (c2, _parser2.ProcessInput (c2.ToString()).Single());
-        Assert.Equal (expected, c2 );
+        Assert.Equal (c2, _parser2.ProcessInput (c2.ToString ()).Single ());
+        Assert.Equal (expected, c2);
     }
+
     private void AssertConsumed (string ansiStream, ref int i)
     {
         // Parser grabs this key
-        var c2 = ansiStream [i];
-        var c1 = NextChar (ansiStream, ref i);
+        char c2 = ansiStream [i];
+        Tuple<char, int> [] c1 = NextChar (ansiStream, ref i);
 
-        Assert.Empty (_parser1.ProcessInput(c1));
-        Assert.Empty (_parser2.ProcessInput (c2.ToString()));
+        Assert.Empty (_parser1.ProcessInput (c1));
+        Assert.Empty (_parser2.ProcessInput (c2.ToString ()));
     }
 
     /// <summary>
-    /// Overload that fully exhausts <paramref name="ansiStream"/> and asserts
-    /// that the final released content across whole processing is <paramref name="expectedRelease"/>
+    ///     Overload that fully exhausts <paramref name="ansiStream"/> and asserts
+    ///     that the final released content across whole processing is <paramref name="expectedRelease"/>
     /// </summary>
     /// <param name="ansiStream"></param>
     /// <param name="expectedRelease"></param>
@@ -710,28 +741,27 @@ public class AnsiResponseParserTests (ITestOutputHelper output)
     private void AssertReleased (string ansiStream, string expectedRelease, params int [] expectedTValues)
     {
         var sb = new StringBuilder ();
-        var tValues = new List<int> ();
+        List<int> tValues = new ();
 
-        int i = 0;
+        var i = 0;
 
         while (i < ansiStream.Length)
         {
-            var c2 = ansiStream [i];
-            var c1 = NextChar (ansiStream, ref i);
+            char c2 = ansiStream [i];
+            Tuple<char, int> [] c1 = NextChar (ansiStream, ref i);
 
-            var released1 = _parser1.ProcessInput (c1).ToArray ();
-            tValues.AddRange(released1.Select (kv => kv.Item2));
+            Tuple<char, int> [] released1 = _parser1.ProcessInput (c1).ToArray ();
+            tValues.AddRange (released1.Select (kv => kv.Item2));
 
-
-            var released2 = _parser2.ProcessInput (c2.ToString ());
+            string released2 = _parser2.ProcessInput (c2.ToString ());
 
             // Both parsers should have same chars so release chars consistently with each other
-            Assert.Equal (BatchToString(released1),released2);
+            Assert.Equal (BatchToString (released1), released2);
 
             sb.Append (released2);
         }
 
-        Assert.Equal (expectedRelease, sb.ToString());
+        Assert.Equal (expectedRelease, sb.ToString ());
 
         if (expectedTValues.Length > 0)
         {
@@ -740,46 +770,40 @@ public class AnsiResponseParserTests (ITestOutputHelper output)
     }
 
     /// <summary>
-    /// Asserts that <paramref name="i"/> index of <see cref="ansiStream"/> when consumed will release
-    /// <paramref name="expectedRelease"/>. Results in implicit increment of <paramref name="i"/>.
-    /// <remarks>Note that this does NOT iteratively consume all the stream, only 1 char at <paramref name="i"/></remarks>
+    ///     Asserts that <paramref name="i"/> index of <see cref="ansiStream"/> when consumed will release
+    ///     <paramref name="expectedRelease"/>. Results in implicit increment of <paramref name="i"/>.
+    ///     <remarks>Note that this does NOT iteratively consume all the stream, only 1 char at <paramref name="i"/></remarks>
     /// </summary>
     /// <param name="ansiStream"></param>
     /// <param name="i"></param>
     /// <param name="expectedRelease"></param>
     /// <param name="expectedTValues"></param>
-    private void AssertReleased (string ansiStream, ref int i, string expectedRelease, params int[] expectedTValues)
+    private void AssertReleased (string ansiStream, ref int i, string expectedRelease, params int [] expectedTValues)
     {
-        var c2 = ansiStream [i];
-        var c1 = NextChar (ansiStream, ref i);
+        char c2 = ansiStream [i];
+        Tuple<char, int> [] c1 = NextChar (ansiStream, ref i);
 
         // Parser realizes it has grabbed content that does not belong to an outstanding request
         // Parser returns false to indicate to continue
-        var released1 = _parser1.ProcessInput (c1).ToArray ();
+        Tuple<char, int> [] released1 = _parser1.ProcessInput (c1).ToArray ();
         Assert.Equal (expectedRelease, BatchToString (released1));
 
         if (expectedTValues.Length > 0)
         {
-            Assert.True (expectedTValues.SequenceEqual (released1.Select (kv=>kv.Item2)));
+            Assert.True (expectedTValues.SequenceEqual (released1.Select (kv => kv.Item2)));
         }
 
         Assert.Equal (expectedRelease, _parser2.ProcessInput (c2.ToString ()));
     }
 
-    private string BatchToString (IEnumerable<Tuple<char, int>> processInput)
-    {
-        return new string(processInput.Select (a=>a.Item1).ToArray ());
-    }
+    private string BatchToString (IEnumerable<Tuple<char, int>> processInput) { return new (processInput.Select (a => a.Item1).ToArray ()); }
+
+    private Tuple<char, int> [] NextChar (string ansiStream, ref int i) { return StringToBatch (ansiStream [i++].ToString ()); }
 
-    private Tuple<char,int>[] NextChar (string ansiStream, ref int i)
-    {
-        return  StringToBatch(ansiStream [i++].ToString());
-    }
     private void AssertManualReleaseIs (string expectedRelease, params int [] expectedTValues)
     {
-
         // Consumer is responsible for determining this based on  e.g. after 50ms
-        var released1 = _parser1.Release ().ToArray ();
+        Tuple<char, int> [] released1 = _parser1.Release ().ToArray ();
         Assert.Equal (expectedRelease, BatchToString (released1));
 
         if (expectedTValues.Length > 0)

+ 21 - 22
Tests/UnitTests/ConsoleDrivers/ContentsTests.cs

@@ -1,6 +1,5 @@
 using System.Text;
 using UnitTests;
-using UnitTests;
 using Xunit.Abstractions;
 
 // Alias Console to MockConsole so we don't accidentally use Console
@@ -9,12 +8,12 @@ namespace Terminal.Gui.DriverTests;
 
 public class ContentsTests
 {
-    private readonly ITestOutputHelper output;
+    private readonly ITestOutputHelper _output;
 
     public ContentsTests (ITestOutputHelper output)
     {
         ConsoleDriver.RunningUnitTests = true;
-        this.output = output;
+        _output = output;
     }
 
     [Theory]
@@ -27,10 +26,10 @@ public class ContentsTests
     public void AddStr_Combining_Character_1st_Column (Type driverType)
     {
         var driver = (IConsoleDriver)Activator.CreateInstance (driverType);
-        driver.Init ();
+        driver!.Init ();
         var expected = "\u0301!";
         driver.AddStr ("\u0301!"); // acute accent + exclamation mark
-        DriverAssert.AssertDriverContentsAre (expected, output, driver);
+        DriverAssert.AssertDriverContentsAre (expected, _output, driver);
 
         driver.End ();
     }
@@ -45,48 +44,48 @@ public class ContentsTests
     public void AddStr_With_Combining_Characters (Type driverType)
     {
         var driver = (IConsoleDriver)Activator.CreateInstance (driverType);
-        driver.Init ();
+        driver!.Init ();
 
-        var acuteaccent = new Rune (0x0301); // Combining acute accent (é)
-        string combined = "e" + acuteaccent;
+        var acuteAccent = new Rune (0x0301); // Combining acute accent (é)
+        string combined = "e" + acuteAccent;
         var expected = "é";
 
         driver.AddStr (combined);
-        DriverAssert.AssertDriverContentsAre (expected, output, driver);
+        DriverAssert.AssertDriverContentsAre (expected, _output, driver);
 
         // 3 char combine
         // a + ogonek + acute = <U+0061, U+0328, U+0301> ( ą́ )
-        var ogonek = new Rune (0x0328); // Combining ogonek (a small hook or comma shape)
-        combined = "a" + ogonek + acuteaccent;
-        expected = ("a" + ogonek).Normalize (NormalizationForm.FormC); // See Issue #2616
+        var oGonek = new Rune (0x0328); // Combining ogonek (a small hook or comma shape)
+        combined = "a" + oGonek + acuteAccent;
+        expected = ("a" + oGonek).Normalize (NormalizationForm.FormC); // See Issue #2616
 
         driver.Move (0, 0);
         driver.AddStr (combined);
-        DriverAssert.AssertDriverContentsAre (expected, output, driver);
+        DriverAssert.AssertDriverContentsAre (expected, _output, driver);
 
         // e + ogonek + acute = <U+0061, U+0328, U+0301> ( ę́́ )
-        combined = "e" + ogonek + acuteaccent;
-        expected = ("e" + ogonek).Normalize (NormalizationForm.FormC); // See Issue #2616
+        combined = "e" + oGonek + acuteAccent;
+        expected = ("e" + oGonek).Normalize (NormalizationForm.FormC); // See Issue #2616
 
         driver.Move (0, 0);
         driver.AddStr (combined);
-        DriverAssert.AssertDriverContentsAre (expected, output, driver);
+        DriverAssert.AssertDriverContentsAre (expected, _output, driver);
 
         // i + ogonek + acute = <U+0061, U+0328, U+0301> ( į́́́ )
-        combined = "i" + ogonek + acuteaccent;
-        expected = ("i" + ogonek).Normalize (NormalizationForm.FormC); // See Issue #2616
+        combined = "i" + oGonek + acuteAccent;
+        expected = ("i" + oGonek).Normalize (NormalizationForm.FormC); // See Issue #2616
 
         driver.Move (0, 0);
         driver.AddStr (combined);
-        DriverAssert.AssertDriverContentsAre (expected, output, driver);
+        DriverAssert.AssertDriverContentsAre (expected, _output, driver);
 
         // u + ogonek + acute = <U+0061, U+0328, U+0301> ( ų́́́́ )
-        combined = "u" + ogonek + acuteaccent;
-        expected = ("u" + ogonek).Normalize (NormalizationForm.FormC); // See Issue #2616
+        combined = "u" + oGonek + acuteAccent;
+        expected = ("u" + oGonek).Normalize (NormalizationForm.FormC); // See Issue #2616
 
         driver.Move (0, 0);
         driver.AddStr (combined);
-        DriverAssert.AssertDriverContentsAre (expected, output, driver);
+        DriverAssert.AssertDriverContentsAre (expected, _output, driver);
 
         driver.End ();
     }

+ 4 - 3
Tests/UnitTests/ConsoleDrivers/V2/ApplicationV2Tests.cs

@@ -1,4 +1,5 @@
-using System.Collections.Concurrent;
+#nullable enable
+using System.Collections.Concurrent;
 using Microsoft.Extensions.Logging;
 using Moq;
 
@@ -298,7 +299,7 @@ public class ApplicationV2Tests
 
         v2.Shutdown ();
         v2.Shutdown ();
-        outputMock.Verify(o=>o.Dispose (),Times.Once);
+        outputMock!.Verify(o=>o.Dispose (),Times.Once);
     }
     [Fact]
     public void TestRepeatedInitCalls_WarnsAndIgnores ()
@@ -322,7 +323,7 @@ public class ApplicationV2Tests
                                     It.IsAny<EventId> (),
                                     It.Is<It.IsAnyType> ((v, t) => v.ToString () == "Init called multiple times without shutdown, ignoring."),
                                     It.IsAny<Exception> (),
-                                    It.IsAny<Func<It.IsAnyType, Exception, string>> ())
+                                    It.IsAny<Func<It.IsAnyType, Exception, string>> ()!)
                           ,Times.Exactly (2));
 
         v2.Shutdown ();

+ 171 - 156
Tests/UnitTests/ConsoleDrivers/V2/WindowsInputProcessorTests.cs

@@ -5,67 +5,74 @@ using ButtonState = Terminal.Gui.WindowsConsole.ButtonState;
 using MouseEventRecord = Terminal.Gui.WindowsConsole.MouseEventRecord;
 
 namespace UnitTests.ConsoleDrivers.V2;
+
 public class WindowsInputProcessorTests
 {
-
     [Fact]
     public void Test_ProcessQueue_CapitalHLowerE ()
     {
-        var queue = new ConcurrentQueue<InputRecord> ();
-
-        queue.Enqueue (new  InputRecord()
-        {
-            EventType = WindowsConsole.EventType.Key,
-            KeyEvent = new WindowsConsole.KeyEventRecord ()
-            {
-                bKeyDown = true,
-                UnicodeChar = 'H',
-                dwControlKeyState = WindowsConsole.ControlKeyState.CapslockOn,
-                wVirtualKeyCode = (ConsoleKeyMapping.VK)72,
-                wVirtualScanCode = 35
-            }
-        });
-        queue.Enqueue (new InputRecord ()
-        {
-            EventType = WindowsConsole.EventType.Key,
-            KeyEvent = new WindowsConsole.KeyEventRecord ()
-            {
-                bKeyDown = false,
-                UnicodeChar = 'H',
-                dwControlKeyState = WindowsConsole.ControlKeyState.CapslockOn,
-                wVirtualKeyCode = (ConsoleKeyMapping.VK)72,
-                wVirtualScanCode = 35
-            }
-        });
-        queue.Enqueue (new InputRecord ()
-        {
-            EventType = WindowsConsole.EventType.Key,
-            KeyEvent = new WindowsConsole.KeyEventRecord ()
-            {
-                bKeyDown = true,
-                UnicodeChar = 'i',
-                dwControlKeyState = WindowsConsole.ControlKeyState.NoControlKeyPressed,
-                wVirtualKeyCode = (ConsoleKeyMapping.VK)73,
-                wVirtualScanCode = 23
-            }
-        });
-        queue.Enqueue (new InputRecord ()
-        {
-            EventType = WindowsConsole.EventType.Key,
-            KeyEvent = new WindowsConsole.KeyEventRecord ()
-            {
-                bKeyDown = false,
-                UnicodeChar = 'i',
-                dwControlKeyState = WindowsConsole.ControlKeyState.NoControlKeyPressed,
-                wVirtualKeyCode = (ConsoleKeyMapping.VK)73,
-                wVirtualScanCode = 23
-            }
-        });
+        ConcurrentQueue<InputRecord> queue = new ();
+
+        queue.Enqueue (
+                       new()
+                       {
+                           EventType = WindowsConsole.EventType.Key,
+                           KeyEvent = new()
+                           {
+                               bKeyDown = true,
+                               UnicodeChar = 'H',
+                               dwControlKeyState = WindowsConsole.ControlKeyState.CapslockOn,
+                               wVirtualKeyCode = (ConsoleKeyMapping.VK)72,
+                               wVirtualScanCode = 35
+                           }
+                       });
+
+        queue.Enqueue (
+                       new()
+                       {
+                           EventType = WindowsConsole.EventType.Key,
+                           KeyEvent = new()
+                           {
+                               bKeyDown = false,
+                               UnicodeChar = 'H',
+                               dwControlKeyState = WindowsConsole.ControlKeyState.CapslockOn,
+                               wVirtualKeyCode = (ConsoleKeyMapping.VK)72,
+                               wVirtualScanCode = 35
+                           }
+                       });
+
+        queue.Enqueue (
+                       new()
+                       {
+                           EventType = WindowsConsole.EventType.Key,
+                           KeyEvent = new()
+                           {
+                               bKeyDown = true,
+                               UnicodeChar = 'i',
+                               dwControlKeyState = WindowsConsole.ControlKeyState.NoControlKeyPressed,
+                               wVirtualKeyCode = (ConsoleKeyMapping.VK)73,
+                               wVirtualScanCode = 23
+                           }
+                       });
+
+        queue.Enqueue (
+                       new()
+                       {
+                           EventType = WindowsConsole.EventType.Key,
+                           KeyEvent = new()
+                           {
+                               bKeyDown = false,
+                               UnicodeChar = 'i',
+                               dwControlKeyState = WindowsConsole.ControlKeyState.NoControlKeyPressed,
+                               wVirtualKeyCode = (ConsoleKeyMapping.VK)73,
+                               wVirtualScanCode = 23
+                           }
+                       });
 
         var processor = new WindowsInputProcessor (queue);
 
-        List<Key> ups = new List<Key> ();
-        List<Key> downs = new List<Key> ();
+        List<Key> ups = new ();
+        List<Key> downs = new ();
 
         processor.KeyUp += (s, e) => { ups.Add (e); };
         processor.KeyDown += (s, e) => { downs.Add (e); };
@@ -81,27 +88,27 @@ public class WindowsInputProcessorTests
         Assert.Equal (Key.I, downs [1]);
     }
 
-
     [Fact]
     public void Test_ProcessQueue_Mouse_Move ()
     {
-        var queue = new ConcurrentQueue<InputRecord> ();
-
-        queue.Enqueue (new InputRecord ()
-        {
-            EventType = WindowsConsole.EventType.Mouse,
-            MouseEvent = new WindowsConsole.MouseEventRecord
-            {
-                MousePosition = new WindowsConsole.Coord(32,31),
-                ButtonState = WindowsConsole.ButtonState.NoButtonPressed,
-                ControlKeyState = WindowsConsole.ControlKeyState.NoControlKeyPressed,
-                EventFlags = WindowsConsole.EventFlags.MouseMoved
-            }
-        });
+        ConcurrentQueue<InputRecord> queue = new ();
+
+        queue.Enqueue (
+                       new()
+                       {
+                           EventType = WindowsConsole.EventType.Mouse,
+                           MouseEvent = new()
+                           {
+                               MousePosition = new (32, 31),
+                               ButtonState = ButtonState.NoButtonPressed,
+                               ControlKeyState = WindowsConsole.ControlKeyState.NoControlKeyPressed,
+                               EventFlags = WindowsConsole.EventFlags.MouseMoved
+                           }
+                       });
 
         var processor = new WindowsInputProcessor (queue);
 
-        List<MouseEventArgs> mouseEvents = new List<MouseEventArgs> ();
+        List<MouseEventArgs> mouseEvents = new ();
 
         processor.MouseEvent += (s, e) => { mouseEvents.Add (e); };
 
@@ -109,35 +116,36 @@ public class WindowsInputProcessorTests
 
         processor.ProcessQueue ();
 
-        var s = Assert.Single (mouseEvents);
-        Assert.Equal (s.Flags,MouseFlags.ReportMousePosition);
-        Assert.Equal (s.ScreenPosition,new Point (32,31));
+        MouseEventArgs s = Assert.Single (mouseEvents);
+        Assert.Equal (MouseFlags.ReportMousePosition, s.Flags);
+        Assert.Equal (s.ScreenPosition, new (32, 31));
     }
 
     [Theory]
-    [InlineData(WindowsConsole.ButtonState.Button1Pressed,MouseFlags.Button1Pressed)]
-    [InlineData (WindowsConsole.ButtonState.Button2Pressed, MouseFlags.Button2Pressed)]
-    [InlineData (WindowsConsole.ButtonState.Button3Pressed, MouseFlags.Button3Pressed)]
-    [InlineData (WindowsConsole.ButtonState.Button4Pressed, MouseFlags.Button4Pressed)]
-    internal void Test_ProcessQueue_Mouse_Pressed (WindowsConsole.ButtonState state,MouseFlags expectedFlag )
+    [InlineData (ButtonState.Button1Pressed, MouseFlags.Button1Pressed)]
+    [InlineData (ButtonState.Button2Pressed, MouseFlags.Button2Pressed)]
+    [InlineData (ButtonState.Button3Pressed, MouseFlags.Button3Pressed)]
+    [InlineData (ButtonState.Button4Pressed, MouseFlags.Button4Pressed)]
+    internal void Test_ProcessQueue_Mouse_Pressed (ButtonState state, MouseFlags expectedFlag)
     {
-        var queue = new ConcurrentQueue<InputRecord> ();
-
-        queue.Enqueue (new InputRecord ()
-        {
-            EventType = WindowsConsole.EventType.Mouse,
-            MouseEvent = new WindowsConsole.MouseEventRecord
-            {
-                MousePosition = new WindowsConsole.Coord (32, 31),
-                ButtonState = state,
-                ControlKeyState = WindowsConsole.ControlKeyState.NoControlKeyPressed,
-                EventFlags = WindowsConsole.EventFlags.MouseMoved
-            }
-        });
+        ConcurrentQueue<InputRecord> queue = new ();
+
+        queue.Enqueue (
+                       new()
+                       {
+                           EventType = WindowsConsole.EventType.Mouse,
+                           MouseEvent = new()
+                           {
+                               MousePosition = new (32, 31),
+                               ButtonState = state,
+                               ControlKeyState = WindowsConsole.ControlKeyState.NoControlKeyPressed,
+                               EventFlags = WindowsConsole.EventFlags.MouseMoved
+                           }
+                       });
 
         var processor = new WindowsInputProcessor (queue);
 
-        List<MouseEventArgs> mouseEvents = new List<MouseEventArgs> ();
+        List<MouseEventArgs> mouseEvents = new ();
 
         processor.MouseEvent += (s, e) => { mouseEvents.Add (e); };
 
@@ -145,34 +153,34 @@ public class WindowsInputProcessorTests
 
         processor.ProcessQueue ();
 
-        var s = Assert.Single (mouseEvents);
+        MouseEventArgs s = Assert.Single (mouseEvents);
         Assert.Equal (s.Flags, MouseFlags.ReportMousePosition | expectedFlag);
-        Assert.Equal (s.ScreenPosition, new Point (32, 31));
+        Assert.Equal (s.ScreenPosition, new (32, 31));
     }
 
-
     [Theory]
     [InlineData (100, MouseFlags.WheeledUp)]
-    [InlineData ( -100, MouseFlags.WheeledDown)]
+    [InlineData (-100, MouseFlags.WheeledDown)]
     internal void Test_ProcessQueue_Mouse_Wheel (int wheelValue, MouseFlags expectedFlag)
     {
-        var queue = new ConcurrentQueue<InputRecord> ();
-
-        queue.Enqueue (new InputRecord ()
-        {
-            EventType = WindowsConsole.EventType.Mouse,
-            MouseEvent = new WindowsConsole.MouseEventRecord
-            {
-                MousePosition = new WindowsConsole.Coord (32, 31),
-                ButtonState = (WindowsConsole.ButtonState)wheelValue,
-                ControlKeyState = WindowsConsole.ControlKeyState.NoControlKeyPressed,
-                EventFlags = WindowsConsole.EventFlags.MouseWheeled
-            }
-        });
+        ConcurrentQueue<InputRecord> queue = new ();
+
+        queue.Enqueue (
+                       new()
+                       {
+                           EventType = WindowsConsole.EventType.Mouse,
+                           MouseEvent = new()
+                           {
+                               MousePosition = new (32, 31),
+                               ButtonState = (ButtonState)wheelValue,
+                               ControlKeyState = WindowsConsole.ControlKeyState.NoControlKeyPressed,
+                               EventFlags = WindowsConsole.EventFlags.MouseWheeled
+                           }
+                       });
 
         var processor = new WindowsInputProcessor (queue);
 
-        List<MouseEventArgs> mouseEvents = new List<MouseEventArgs> ();
+        List<MouseEventArgs> mouseEvents = new ();
 
         processor.MouseEvent += (s, e) => { mouseEvents.Add (e); };
 
@@ -180,126 +188,133 @@ public class WindowsInputProcessorTests
 
         processor.ProcessQueue ();
 
-        var s = Assert.Single (mouseEvents);
-        Assert.Equal (s.Flags,expectedFlag);
-        Assert.Equal (s.ScreenPosition, new Point (32, 31));
+        MouseEventArgs s = Assert.Single (mouseEvents);
+        Assert.Equal (s.Flags, expectedFlag);
+        Assert.Equal (s.ScreenPosition, new (32, 31));
     }
 
     public static IEnumerable<object []> MouseFlagTestData ()
     {
         yield return new object []
         {
-            new Tuple<ButtonState, MouseFlags>[]
+            new []
             {
-                Tuple.Create(ButtonState.Button1Pressed, MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition),
-                Tuple.Create(ButtonState.NoButtonPressed, MouseFlags.Button1Released | MouseFlags.ReportMousePosition),
-                Tuple.Create(ButtonState.NoButtonPressed, MouseFlags.ReportMousePosition | MouseFlags.ReportMousePosition)
+                Tuple.Create (ButtonState.Button1Pressed, MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition),
+                Tuple.Create (ButtonState.NoButtonPressed, MouseFlags.Button1Released | MouseFlags.ReportMousePosition),
+                Tuple.Create (ButtonState.NoButtonPressed, MouseFlags.ReportMousePosition | MouseFlags.ReportMousePosition)
             }
         };
 
         yield return new object []
         {
-            new Tuple<ButtonState, MouseFlags>[]
+            new []
             {
-                Tuple.Create ( ButtonState.Button2Pressed, MouseFlags.Button2Pressed  | MouseFlags.ReportMousePosition),
-                Tuple.Create(ButtonState.NoButtonPressed, MouseFlags.Button2Released | MouseFlags.ReportMousePosition),
-                Tuple.Create(ButtonState.NoButtonPressed, MouseFlags.ReportMousePosition | MouseFlags.ReportMousePosition)
+                Tuple.Create (ButtonState.Button2Pressed, MouseFlags.Button2Pressed | MouseFlags.ReportMousePosition),
+                Tuple.Create (ButtonState.NoButtonPressed, MouseFlags.Button2Released | MouseFlags.ReportMousePosition),
+                Tuple.Create (ButtonState.NoButtonPressed, MouseFlags.ReportMousePosition | MouseFlags.ReportMousePosition)
             }
-        }; 
+        };
+
         yield return new object []
         {
-            new Tuple<ButtonState, MouseFlags>[]
+            new []
             {
-                Tuple.Create(ButtonState.Button3Pressed, MouseFlags.Button3Pressed | MouseFlags.ReportMousePosition),
-                Tuple.Create(ButtonState.NoButtonPressed, MouseFlags.Button3Released | MouseFlags.ReportMousePosition),
-                Tuple.Create(ButtonState.NoButtonPressed, MouseFlags.ReportMousePosition | MouseFlags.ReportMousePosition)
+                Tuple.Create (ButtonState.Button3Pressed, MouseFlags.Button3Pressed | MouseFlags.ReportMousePosition),
+                Tuple.Create (ButtonState.NoButtonPressed, MouseFlags.Button3Released | MouseFlags.ReportMousePosition),
+                Tuple.Create (ButtonState.NoButtonPressed, MouseFlags.ReportMousePosition | MouseFlags.ReportMousePosition)
             }
         };
 
         yield return new object []
         {
-            new Tuple<ButtonState, MouseFlags>[]
+            new []
             {
-                Tuple.Create(ButtonState.Button4Pressed, MouseFlags.Button4Pressed | MouseFlags.ReportMousePosition),
-                Tuple.Create(ButtonState.NoButtonPressed, MouseFlags.Button4Released | MouseFlags.ReportMousePosition),
-                Tuple.Create(ButtonState.NoButtonPressed, MouseFlags.ReportMousePosition | MouseFlags.ReportMousePosition)
+                Tuple.Create (ButtonState.Button4Pressed, MouseFlags.Button4Pressed | MouseFlags.ReportMousePosition),
+                Tuple.Create (ButtonState.NoButtonPressed, MouseFlags.Button4Released | MouseFlags.ReportMousePosition),
+                Tuple.Create (ButtonState.NoButtonPressed, MouseFlags.ReportMousePosition | MouseFlags.ReportMousePosition)
             }
         };
 
         yield return new object []
         {
-            new Tuple<ButtonState, MouseFlags>[]
+            new []
             {
-                Tuple.Create(ButtonState.RightmostButtonPressed, MouseFlags.Button3Pressed | MouseFlags.ReportMousePosition),
-                Tuple.Create(ButtonState.NoButtonPressed, MouseFlags.Button3Released | MouseFlags.ReportMousePosition),
-                Tuple.Create(ButtonState.NoButtonPressed, MouseFlags.ReportMousePosition | MouseFlags.ReportMousePosition)
+                Tuple.Create (ButtonState.RightmostButtonPressed, MouseFlags.Button3Pressed | MouseFlags.ReportMousePosition),
+                Tuple.Create (ButtonState.NoButtonPressed, MouseFlags.Button3Released | MouseFlags.ReportMousePosition),
+                Tuple.Create (ButtonState.NoButtonPressed, MouseFlags.ReportMousePosition | MouseFlags.ReportMousePosition)
             }
         };
 
         // Tests for holding down 2 buttons at once and releasing them one after the other
         yield return new object []
         {
-            new Tuple<ButtonState, MouseFlags>[]
+            new []
             {
-                Tuple.Create(ButtonState.Button1Pressed | ButtonState.Button2Pressed, MouseFlags.Button1Pressed | MouseFlags.Button2Pressed | MouseFlags.ReportMousePosition),
-                Tuple.Create(ButtonState.Button1Pressed, MouseFlags.Button1Pressed | MouseFlags.Button2Released | MouseFlags.ReportMousePosition),
-                Tuple.Create(ButtonState.NoButtonPressed, MouseFlags.Button1Released | MouseFlags.ReportMousePosition),
-                Tuple.Create(ButtonState.NoButtonPressed,  MouseFlags.ReportMousePosition)
+                Tuple.Create (
+                              ButtonState.Button1Pressed | ButtonState.Button2Pressed,
+                              MouseFlags.Button1Pressed | MouseFlags.Button2Pressed | MouseFlags.ReportMousePosition),
+                Tuple.Create (ButtonState.Button1Pressed, MouseFlags.Button1Pressed | MouseFlags.Button2Released | MouseFlags.ReportMousePosition),
+                Tuple.Create (ButtonState.NoButtonPressed, MouseFlags.Button1Released | MouseFlags.ReportMousePosition),
+                Tuple.Create (ButtonState.NoButtonPressed, MouseFlags.ReportMousePosition)
             }
         };
 
         yield return new object []
         {
-            new Tuple<ButtonState, MouseFlags>[]
+            new []
             {
-                Tuple.Create(ButtonState.Button3Pressed | ButtonState.Button4Pressed, MouseFlags.Button3Pressed | MouseFlags.Button4Pressed | MouseFlags.ReportMousePosition),
-                Tuple.Create(ButtonState.Button3Pressed, MouseFlags.Button3Pressed | MouseFlags.Button4Released | MouseFlags.ReportMousePosition),
-                Tuple.Create(ButtonState.NoButtonPressed, MouseFlags.Button3Released | MouseFlags.ReportMousePosition),
-                Tuple.Create(ButtonState.NoButtonPressed,  MouseFlags.ReportMousePosition)
+                Tuple.Create (
+                              ButtonState.Button3Pressed | ButtonState.Button4Pressed,
+                              MouseFlags.Button3Pressed | MouseFlags.Button4Pressed | MouseFlags.ReportMousePosition),
+                Tuple.Create (ButtonState.Button3Pressed, MouseFlags.Button3Pressed | MouseFlags.Button4Released | MouseFlags.ReportMousePosition),
+                Tuple.Create (ButtonState.NoButtonPressed, MouseFlags.Button3Released | MouseFlags.ReportMousePosition),
+                Tuple.Create (ButtonState.NoButtonPressed, MouseFlags.ReportMousePosition)
             }
         };
 
         // Test for holding down 2 buttons at once and releasing them simultaneously
         yield return new object []
         {
-            new Tuple<ButtonState, MouseFlags>[]
+            new []
             {
-                Tuple.Create(ButtonState.Button1Pressed | ButtonState.Button2Pressed, MouseFlags.Button1Pressed | MouseFlags.Button2Pressed | MouseFlags.ReportMousePosition),
-                Tuple.Create(ButtonState.NoButtonPressed, MouseFlags.Button1Released | MouseFlags.Button2Released | MouseFlags.ReportMousePosition),
-                Tuple.Create(ButtonState.NoButtonPressed, MouseFlags.ReportMousePosition)
+                Tuple.Create (
+                              ButtonState.Button1Pressed | ButtonState.Button2Pressed,
+                              MouseFlags.Button1Pressed | MouseFlags.Button2Pressed | MouseFlags.ReportMousePosition),
+                Tuple.Create (ButtonState.NoButtonPressed, MouseFlags.Button1Released | MouseFlags.Button2Released | MouseFlags.ReportMousePosition),
+                Tuple.Create (ButtonState.NoButtonPressed, MouseFlags.ReportMousePosition)
             }
         };
 
         // Test that rightmost and button 3 are the same button so 2 states is still only 1 flag
         yield return new object []
         {
-            new Tuple<ButtonState, MouseFlags>[]
+            new []
             {
-                Tuple.Create(ButtonState.Button3Pressed | ButtonState.RightmostButtonPressed, MouseFlags.Button3Pressed | MouseFlags.ReportMousePosition),
+                Tuple.Create (ButtonState.Button3Pressed | ButtonState.RightmostButtonPressed, MouseFlags.Button3Pressed | MouseFlags.ReportMousePosition),
+
                 // Can swap between without raising the released
-                Tuple.Create(ButtonState.Button3Pressed, MouseFlags.Button3Pressed | MouseFlags.ReportMousePosition),
-                Tuple.Create(ButtonState.RightmostButtonPressed, MouseFlags.Button3Pressed | MouseFlags.ReportMousePosition),
+                Tuple.Create (ButtonState.Button3Pressed, MouseFlags.Button3Pressed | MouseFlags.ReportMousePosition),
+                Tuple.Create (ButtonState.RightmostButtonPressed, MouseFlags.Button3Pressed | MouseFlags.ReportMousePosition),
 
                 // Now with neither we get released
-                Tuple.Create(ButtonState.NoButtonPressed, MouseFlags.Button3Released | MouseFlags.ReportMousePosition),
-                Tuple.Create(ButtonState.NoButtonPressed, MouseFlags.ReportMousePosition)
+                Tuple.Create (ButtonState.NoButtonPressed, MouseFlags.Button3Released | MouseFlags.ReportMousePosition),
+                Tuple.Create (ButtonState.NoButtonPressed, MouseFlags.ReportMousePosition)
             }
         };
     }
 
     [Theory]
     [MemberData (nameof (MouseFlagTestData))]
-    internal void MouseFlags_Should_Map_Correctly (Tuple<ButtonState, MouseFlags>[] inputOutputPairs)
+    internal void MouseFlags_Should_Map_Correctly (Tuple<ButtonState, MouseFlags> [] inputOutputPairs)
     {
         var processor = new WindowsInputProcessor (new ());
 
-        foreach (var pair in inputOutputPairs)
+        foreach (Tuple<ButtonState, MouseFlags> pair in inputOutputPairs)
         {
             var mockEvent = new MouseEventRecord { ButtonState = pair.Item1 };
-            var result = processor.ToDriverMouse (mockEvent);
+            MouseEventArgs result = processor.ToDriverMouse (mockEvent);
 
             Assert.Equal (pair.Item2, result.Flags);
         }
     }
 }
-

+ 270 - 271
Tests/UnitTests/Dialogs/DialogTests.cs

@@ -1,5 +1,4 @@
 using UnitTests;
-using UnitTests;
 using Xunit.Abstractions;
 using static Terminal.Gui.Application;
 
@@ -48,7 +47,7 @@ public class DialogTests
             Width = width,
             Height = 1,
             ButtonAlignment = Alignment.Center,
-            Buttons = [new() { Text = btn1Text }]
+            Buttons = [new () { Text = btn1Text }]
         };
 
         // Create with no top or bottom border to simplify testing button layout (no need to account for title etc..)
@@ -76,7 +75,7 @@ public class DialogTests
             Width = width,
             Height = 1,
             ButtonAlignment = Alignment.Fill,
-            Buttons = [new() { Text = btn1Text }]
+            Buttons = [new () { Text = btn1Text }]
         };
 
         // Create with no top or bottom border to simplify testing button layout (no need to account for title etc..)
@@ -103,7 +102,7 @@ public class DialogTests
             Width = width,
             Height = 1,
             ButtonAlignment = Alignment.End,
-            Buttons = [new() { Text = btn1Text }]
+            Buttons = [new () { Text = btn1Text }]
         };
 
         // Create with no top or bottom border to simplify testing button layout (no need to account for title etc..)
@@ -131,7 +130,7 @@ public class DialogTests
             Width = width,
             Height = 1,
             ButtonAlignment = Alignment.Start,
-            Buttons = [new() { Text = btn1Text }]
+            Buttons = [new () { Text = btn1Text }]
         };
 
         // Create with no top or bottom border to simplify testing button layout (no need to account for title etc..)
@@ -180,14 +179,14 @@ public class DialogTests
 
         // Default - Center
         (runstate, Dialog dlg) = BeginButtonTestDialog (
-                                                      title,
-                                                      width,
-                                                      Alignment.Center,
-                                                      new Button { Text = btn1Text },
-                                                      new Button { Text = btn2Text },
-                                                      new Button { Text = btn3Text },
-                                                      new Button { Text = btn4Text }
-                                                     );
+                                                        title,
+                                                        width,
+                                                        Alignment.Center,
+                                                        new Button { Text = btn1Text },
+                                                        new Button { Text = btn2Text },
+                                                        new Button { Text = btn3Text },
+                                                        new Button { Text = btn4Text }
+                                                       );
         DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -197,14 +196,14 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
 
         (runstate, dlg) = BeginButtonTestDialog (
-                                               title,
-                                               width,
-                                               Alignment.Fill,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text },
-                                               new Button { Text = btn3Text },
-                                               new Button { Text = btn4Text }
-                                              );
+                                                 title,
+                                                 width,
+                                                 Alignment.Fill,
+                                                 new Button { Text = btn1Text },
+                                                 new Button { Text = btn2Text },
+                                                 new Button { Text = btn3Text },
+                                                 new Button { Text = btn4Text }
+                                                );
         DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -214,14 +213,14 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
 
         (runstate, dlg) = BeginButtonTestDialog (
-                                               title,
-                                               width,
-                                               Alignment.End,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text },
-                                               new Button { Text = btn3Text },
-                                               new Button { Text = btn4Text }
-                                              );
+                                                 title,
+                                                 width,
+                                                 Alignment.End,
+                                                 new Button { Text = btn1Text },
+                                                 new Button { Text = btn2Text },
+                                                 new Button { Text = btn3Text },
+                                                 new Button { Text = btn4Text }
+                                                );
         DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -231,14 +230,14 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
 
         (runstate, dlg) = BeginButtonTestDialog (
-                                               title,
-                                               width,
-                                               Alignment.Start,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text },
-                                               new Button { Text = btn3Text },
-                                               new Button { Text = btn4Text }
-                                              );
+                                                 title,
+                                                 width,
+                                                 Alignment.Start,
+                                                 new Button { Text = btn1Text },
+                                                 new Button { Text = btn2Text },
+                                                 new Button { Text = btn3Text },
+                                                 new Button { Text = btn4Text }
+                                                );
         DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -275,14 +274,14 @@ public class DialogTests
             $"{Glyphs.VLine} yes {Glyphs.RightBracket}{btn2}{btn3}{Glyphs.LeftBracket} never{Glyphs.VLine}";
 
         (runstate, Dialog dlg) = BeginButtonTestDialog (
-                                                      title,
-                                                      width,
-                                                      Alignment.Center,
-                                                      new Button { Text = btn1Text },
-                                                      new Button { Text = btn2Text },
-                                                      new Button { Text = btn3Text },
-                                                      new Button { Text = btn4Text }
-                                                     );
+                                                        title,
+                                                        width,
+                                                        Alignment.Center,
+                                                        new Button { Text = btn1Text },
+                                                        new Button { Text = btn2Text },
+                                                        new Button { Text = btn3Text },
+                                                        new Button { Text = btn4Text }
+                                                       );
         Assert.Equal (new (width, 1), dlg.Frame.Size);
         DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
@@ -293,14 +292,14 @@ public class DialogTests
             $"{Glyphs.VLine}{Glyphs.LeftBracket} yes {Glyphs.LeftBracket} no {Glyphs.LeftBracket} maybe {Glyphs.LeftBracket} never {Glyphs.RightBracket}{Glyphs.VLine}";
 
         (runstate, dlg) = BeginButtonTestDialog (
-                                               title,
-                                               width,
-                                               Alignment.Fill,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text },
-                                               new Button { Text = btn3Text },
-                                               new Button { Text = btn4Text }
-                                              );
+                                                 title,
+                                                 width,
+                                                 Alignment.Fill,
+                                                 new Button { Text = btn1Text },
+                                                 new Button { Text = btn2Text },
+                                                 new Button { Text = btn3Text },
+                                                 new Button { Text = btn4Text }
+                                                );
         DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -310,14 +309,14 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
 
         (runstate, dlg) = BeginButtonTestDialog (
-                                               title,
-                                               width,
-                                               Alignment.End,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text },
-                                               new Button { Text = btn3Text },
-                                               new Button { Text = btn4Text }
-                                              );
+                                                 title,
+                                                 width,
+                                                 Alignment.End,
+                                                 new Button { Text = btn1Text },
+                                                 new Button { Text = btn2Text },
+                                                 new Button { Text = btn3Text },
+                                                 new Button { Text = btn4Text }
+                                                );
         DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -326,14 +325,14 @@ public class DialogTests
         buttonRow = $"{Glyphs.VLine}{btn1}{btn2}{btn3}{Glyphs.LeftBracket} neve{Glyphs.VLine}";
 
         (runstate, dlg) = BeginButtonTestDialog (
-                                               title,
-                                               width,
-                                               Alignment.Start,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text },
-                                               new Button { Text = btn3Text },
-                                               new Button { Text = btn4Text }
-                                              );
+                                                 title,
+                                                 width,
+                                                 Alignment.Start,
+                                                 new Button { Text = btn1Text },
+                                                 new Button { Text = btn2Text },
+                                                 new Button { Text = btn3Text },
+                                                 new Button { Text = btn4Text }
+                                                );
         DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -369,14 +368,14 @@ public class DialogTests
 
         // Default - Center
         (runstate, Dialog dlg) = BeginButtonTestDialog (
-                                                      title,
-                                                      width,
-                                                      Alignment.Center,
-                                                      new Button { Text = btn1Text },
-                                                      new Button { Text = btn2Text },
-                                                      new Button { Text = btn3Text },
-                                                      new Button { Text = btn4Text }
-                                                     );
+                                                        title,
+                                                        width,
+                                                        Alignment.Center,
+                                                        new Button { Text = btn1Text },
+                                                        new Button { Text = btn2Text },
+                                                        new Button { Text = btn3Text },
+                                                        new Button { Text = btn4Text }
+                                                       );
         DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -386,14 +385,14 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
 
         (runstate, dlg) = BeginButtonTestDialog (
-                                               title,
-                                               width,
-                                               Alignment.Fill,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text },
-                                               new Button { Text = btn3Text },
-                                               new Button { Text = btn4Text }
-                                              );
+                                                 title,
+                                                 width,
+                                                 Alignment.Fill,
+                                                 new Button { Text = btn1Text },
+                                                 new Button { Text = btn2Text },
+                                                 new Button { Text = btn3Text },
+                                                 new Button { Text = btn4Text }
+                                                );
         DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -403,14 +402,14 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
 
         (runstate, dlg) = BeginButtonTestDialog (
-                                               title,
-                                               width,
-                                               Alignment.End,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text },
-                                               new Button { Text = btn3Text },
-                                               new Button { Text = btn4Text }
-                                              );
+                                                 title,
+                                                 width,
+                                                 Alignment.End,
+                                                 new Button { Text = btn1Text },
+                                                 new Button { Text = btn2Text },
+                                                 new Button { Text = btn3Text },
+                                                 new Button { Text = btn4Text }
+                                                );
         DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -420,14 +419,14 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
 
         (runstate, dlg) = BeginButtonTestDialog (
-                                               title,
-                                               width,
-                                               Alignment.Start,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text },
-                                               new Button { Text = btn3Text },
-                                               new Button { Text = btn4Text }
-                                              );
+                                                 title,
+                                                 width,
+                                                 Alignment.Start,
+                                                 new Button { Text = btn1Text },
+                                                 new Button { Text = btn2Text },
+                                                 new Button { Text = btn3Text },
+                                                 new Button { Text = btn4Text }
+                                                );
         DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -465,14 +464,14 @@ public class DialogTests
 
         // Default - Center
         (runstate, Dialog dlg) = BeginButtonTestDialog (
-                                                      title,
-                                                      width,
-                                                      Alignment.Center,
-                                                      new Button { Text = btn1Text },
-                                                      new Button { Text = btn2Text },
-                                                      new Button { Text = btn3Text },
-                                                      new Button { Text = btn4Text }
-                                                     );
+                                                        title,
+                                                        width,
+                                                        Alignment.Center,
+                                                        new Button { Text = btn1Text },
+                                                        new Button { Text = btn2Text },
+                                                        new Button { Text = btn3Text },
+                                                        new Button { Text = btn4Text }
+                                                       );
         DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -482,14 +481,14 @@ public class DialogTests
         Assert.Equal (width, buttonRow.GetColumns ());
 
         (runstate, dlg) = BeginButtonTestDialog (
-                                               title,
-                                               width,
-                                               Alignment.Fill,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text },
-                                               new Button { Text = btn3Text },
-                                               new Button { Text = btn4Text }
-                                              );
+                                                 title,
+                                                 width,
+                                                 Alignment.Fill,
+                                                 new Button { Text = btn1Text },
+                                                 new Button { Text = btn2Text },
+                                                 new Button { Text = btn3Text },
+                                                 new Button { Text = btn4Text }
+                                                );
         DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -499,14 +498,14 @@ public class DialogTests
         Assert.Equal (width, buttonRow.GetColumns ());
 
         (runstate, dlg) = BeginButtonTestDialog (
-                                               title,
-                                               width,
-                                               Alignment.End,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text },
-                                               new Button { Text = btn3Text },
-                                               new Button { Text = btn4Text }
-                                              );
+                                                 title,
+                                                 width,
+                                                 Alignment.End,
+                                                 new Button { Text = btn1Text },
+                                                 new Button { Text = btn2Text },
+                                                 new Button { Text = btn3Text },
+                                                 new Button { Text = btn4Text }
+                                                );
         DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -516,14 +515,14 @@ public class DialogTests
         Assert.Equal (width, buttonRow.GetColumns ());
 
         (runstate, dlg) = BeginButtonTestDialog (
-                                               title,
-                                               width,
-                                               Alignment.Start,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text },
-                                               new Button { Text = btn3Text },
-                                               new Button { Text = btn4Text }
-                                              );
+                                                 title,
+                                                 width,
+                                                 Alignment.Start,
+                                                 new Button { Text = btn1Text },
+                                                 new Button { Text = btn2Text },
+                                                 new Button { Text = btn3Text },
+                                                 new Button { Text = btn4Text }
+                                                );
         DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -550,11 +549,11 @@ public class DialogTests
         d.SetBufferSize (width, 1);
 
         (runstate, Dialog dlg) = BeginButtonTestDialog (
-                                                      title,
-                                                      width,
-                                                      Alignment.Center,
-                                                      new Button { Text = btnText }
-                                                     );
+                                                        title,
+                                                        width,
+                                                        Alignment.Center,
+                                                        new Button { Text = btnText }
+                                                       );
 
         // Center
         DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
@@ -567,11 +566,11 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
 
         (runstate, dlg) = BeginButtonTestDialog (
-                                               title,
-                                               width,
-                                               Alignment.Fill,
-                                               new Button { Text = btnText }
-                                              );
+                                                 title,
+                                                 width,
+                                                 Alignment.Fill,
+                                                 new Button { Text = btnText }
+                                                );
         DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -582,11 +581,11 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
 
         (runstate, dlg) = BeginButtonTestDialog (
-                                               title,
-                                               width,
-                                               Alignment.End,
-                                               new Button { Text = btnText }
-                                              );
+                                                 title,
+                                                 width,
+                                                 Alignment.End,
+                                                 new Button { Text = btnText }
+                                                );
         DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -597,11 +596,11 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
 
         (runstate, dlg) = BeginButtonTestDialog (
-                                               title,
-                                               width,
-                                               Alignment.Start,
-                                               new Button { Text = btnText }
-                                              );
+                                                 title,
+                                                 width,
+                                                 Alignment.Start,
+                                                 new Button { Text = btnText }
+                                                );
         DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -614,11 +613,11 @@ public class DialogTests
         d.SetBufferSize (width, 1);
 
         (runstate, dlg) = BeginButtonTestDialog (
-                                               title,
-                                               width,
-                                               Alignment.Center,
-                                               new Button { Text = btnText }
-                                              );
+                                                 title,
+                                                 width,
+                                                 Alignment.Center,
+                                                 new Button { Text = btnText }
+                                                );
         DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -629,11 +628,11 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
 
         (runstate, dlg) = BeginButtonTestDialog (
-                                               title,
-                                               width,
-                                               Alignment.Fill,
-                                               new Button { Text = btnText }
-                                              );
+                                                 title,
+                                                 width,
+                                                 Alignment.Fill,
+                                                 new Button { Text = btnText }
+                                                );
         DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -644,11 +643,11 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
 
         (runstate, dlg) = BeginButtonTestDialog (
-                                               title,
-                                               width,
-                                               Alignment.End,
-                                               new Button { Text = btnText }
-                                              );
+                                                 title,
+                                                 width,
+                                                 Alignment.End,
+                                                 new Button { Text = btnText }
+                                                );
         DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -659,11 +658,11 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
 
         (runstate, dlg) = BeginButtonTestDialog (
-                                               title,
-                                               width,
-                                               Alignment.Start,
-                                               new Button { Text = btnText }
-                                              );
+                                                 title,
+                                                 width,
+                                                 Alignment.Start,
+                                                 new Button { Text = btnText }
+                                                );
         DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -695,13 +694,13 @@ public class DialogTests
         d.SetBufferSize (buttonRow.Length, 3);
 
         (runstate, Dialog dlg) = BeginButtonTestDialog (
-                                                      title,
-                                                      width,
-                                                      Alignment.Center,
-                                                      new Button { Text = btn1Text },
-                                                      new Button { Text = btn2Text },
-                                                      new Button { Text = btn3Text }
-                                                     );
+                                                        title,
+                                                        width,
+                                                        Alignment.Center,
+                                                        new Button { Text = btn1Text },
+                                                        new Button { Text = btn2Text },
+                                                        new Button { Text = btn3Text }
+                                                       );
         DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -711,13 +710,13 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
 
         (runstate, dlg) = BeginButtonTestDialog (
-                                               title,
-                                               width,
-                                               Alignment.Fill,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text },
-                                               new Button { Text = btn3Text }
-                                              );
+                                                 title,
+                                                 width,
+                                                 Alignment.Fill,
+                                                 new Button { Text = btn1Text },
+                                                 new Button { Text = btn2Text },
+                                                 new Button { Text = btn3Text }
+                                                );
         DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -727,13 +726,13 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
 
         (runstate, dlg) = BeginButtonTestDialog (
-                                               title,
-                                               width,
-                                               Alignment.End,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text },
-                                               new Button { Text = btn3Text }
-                                              );
+                                                 title,
+                                                 width,
+                                                 Alignment.End,
+                                                 new Button { Text = btn1Text },
+                                                 new Button { Text = btn2Text },
+                                                 new Button { Text = btn3Text }
+                                                );
         DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -743,13 +742,13 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
 
         (runstate, dlg) = BeginButtonTestDialog (
-                                               title,
-                                               width,
-                                               Alignment.Start,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text },
-                                               new Button { Text = btn3Text }
-                                              );
+                                                 title,
+                                                 width,
+                                                 Alignment.Start,
+                                                 new Button { Text = btn1Text },
+                                                 new Button { Text = btn2Text },
+                                                 new Button { Text = btn3Text }
+                                                );
         DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -779,12 +778,12 @@ public class DialogTests
         d.SetBufferSize (buttonRow.Length, 3);
 
         (runstate, Dialog dlg) = BeginButtonTestDialog (
-                                                      title,
-                                                      width,
-                                                      Alignment.Center,
-                                                      new Button { Text = btn1Text },
-                                                      new Button { Text = btn2Text }
-                                                     );
+                                                        title,
+                                                        width,
+                                                        Alignment.Center,
+                                                        new Button { Text = btn1Text },
+                                                        new Button { Text = btn2Text }
+                                                       );
         DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -794,12 +793,12 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
 
         (runstate, dlg) = BeginButtonTestDialog (
-                                               title,
-                                               width,
-                                               Alignment.Fill,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text }
-                                              );
+                                                 title,
+                                                 width,
+                                                 Alignment.Fill,
+                                                 new Button { Text = btn1Text },
+                                                 new Button { Text = btn2Text }
+                                                );
         DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -809,12 +808,12 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
 
         (runstate, dlg) = BeginButtonTestDialog (
-                                               title,
-                                               width,
-                                               Alignment.End,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text }
-                                              );
+                                                 title,
+                                                 width,
+                                                 Alignment.End,
+                                                 new Button { Text = btn1Text },
+                                                 new Button { Text = btn2Text }
+                                                );
         DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -824,12 +823,12 @@ public class DialogTests
         Assert.Equal (width, buttonRow.Length);
 
         (runstate, dlg) = BeginButtonTestDialog (
-                                               title,
-                                               width,
-                                               Alignment.Start,
-                                               new Button { Text = btn1Text },
-                                               new Button { Text = btn2Text }
-                                              );
+                                                 title,
+                                                 width,
+                                                 Alignment.Start,
+                                                 new Button { Text = btn1Text },
+                                                 new Button { Text = btn2Text }
+                                                );
         DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -863,8 +862,8 @@ public class DialogTests
         Button button1, button2;
 
         // Default (Center)
-        button1 = new() { Text = btn1Text };
-        button2 = new() { Text = btn2Text };
+        button1 = new () { Text = btn1Text };
+        button2 = new () { Text = btn2Text };
         (runstate, dlg) = BeginButtonTestDialog (title, width, Alignment.Center, button1, button2);
         button1.Visible = false;
         RunIteration (ref runstate, firstIteration);
@@ -875,8 +874,8 @@ public class DialogTests
 
         // Justify
         Assert.Equal (width, buttonRow.Length);
-        button1 = new() { Text = btn1Text };
-        button2 = new() { Text = btn2Text };
+        button1 = new () { Text = btn1Text };
+        button2 = new () { Text = btn2Text };
         (runstate, dlg) = BeginButtonTestDialog (title, width, Alignment.Fill, button1, button2);
         button1.Visible = false;
         RunIteration (ref runstate, firstIteration);
@@ -887,8 +886,8 @@ public class DialogTests
 
         // Right
         Assert.Equal (width, buttonRow.Length);
-        button1 = new() { Text = btn1Text };
-        button2 = new() { Text = btn2Text };
+        button1 = new () { Text = btn1Text };
+        button2 = new () { Text = btn2Text };
         (runstate, dlg) = BeginButtonTestDialog (title, width, Alignment.End, button1, button2);
         button1.Visible = false;
         RunIteration (ref runstate, firstIteration);
@@ -898,8 +897,8 @@ public class DialogTests
 
         // Left
         Assert.Equal (width, buttonRow.Length);
-        button1 = new() { Text = btn1Text };
-        button2 = new() { Text = btn2Text };
+        button1 = new () { Text = btn1Text };
+        button2 = new () { Text = btn2Text };
         (runstate, dlg) = BeginButtonTestDialog (title, width, Alignment.Start, button1, button2);
         button1.Visible = false;
         RunIteration (ref runstate, firstIteration);
@@ -1079,30 +1078,30 @@ public class DialogTests
         string expected = null;
 
         btn1.Accepting += (s, e) =>
-                       {
-                           btn2 = new () { Text = "Show Sub" };
-                           btn3 = new () { Text = "Close" };
-                           btn3.Accepting += (s, e) => RequestStop ();
-
-                           btn2.Accepting += (s, e) =>
-                                          {
-                                              // Don't test MessageBox in Dialog unit tests!
-                                              var subBtn = new Button { Text = "Ok", IsDefault = true };
-                                              var subDlg = new Dialog { Text = "ya", Width = 20, Height = 5, Buttons = [subBtn] };
-                                              subBtn.Accepting += (s, e) => RequestStop (subDlg);
-                                              Run (subDlg);
-                                          };
-
-                           var dlg = new Dialog
-                           {
-                               Buttons = [btn2, btn3],
-                               Width = Dim.Percent (85),
-                               Height = Dim.Percent (85)
-                           };
-
-                           Run (dlg);
-                           dlg.Dispose ();
-                       };
+                          {
+                              btn2 = new () { Text = "Show Sub" };
+                              btn3 = new () { Text = "Close" };
+                              btn3.Accepting += (s, e) => RequestStop ();
+
+                              btn2.Accepting += (s, e) =>
+                                                {
+                                                    // Don't test MessageBox in Dialog unit tests!
+                                                    var subBtn = new Button { Text = "Ok", IsDefault = true };
+                                                    var subDlg = new Dialog { Text = "ya", Width = 20, Height = 5, Buttons = [subBtn] };
+                                                    subBtn.Accepting += (s, e) => RequestStop (subDlg);
+                                                    Run (subDlg);
+                                                };
+
+                              var dlg = new Dialog
+                              {
+                                  Buttons = [btn2, btn3],
+                                  Width = Dim.Percent (85),
+                                  Height = Dim.Percent (85)
+                              };
+
+                              Run (dlg);
+                              dlg.Dispose ();
+                          };
 
         var btn =
             $"{Glyphs.LeftBracket}{Glyphs.LeftDefaultIndicator} Ok {Glyphs.RightDefaultIndicator}{Glyphs.RightBracket}";
@@ -1116,8 +1115,8 @@ public class DialogTests
                          switch (iterations)
                          {
                              case 0:
-                                 Top.SetNeedsLayout();
-                                 Top.SetNeedsDraw();
+                                 Top.SetNeedsLayout ();
+                                 Top.SetNeedsDraw ();
                                  LayoutAndDraw ();
 
                                  break;
@@ -1147,7 +1146,7 @@ public class DialogTests
                                  LayoutAndDraw ();
 
                                  DriverAssert.AssertDriverContentsWithFrameAre (
-                                                                               @$"
+                                                                                @$"
   ┌───────────────────────┐
   │  ┌──────────────────┐ │
   │  │ya                │ │
@@ -1156,8 +1155,8 @@ public class DialogTests
   │  └──────────────────┘ │
   │{Glyphs.LeftBracket} Show Sub {Glyphs.RightBracket} {Glyphs.LeftBracket} Close {Glyphs.RightBracket} │
   └───────────────────────┘",
-                                                                               _output
-                                                                              );
+                                                                                _output
+                                                                               );
 
                                  Assert.False (Top.NewKeyDownEvent (Key.Enter));
 
@@ -1250,14 +1249,14 @@ public class DialogTests
         Assert.Equal (new (expected, expected), d.Frame.Location);
 
         DriverAssert.AssertDriverContentsWithFrameAre (
-                                                      @"
+                                                       @"
      ┌───┐
      │   │
      │   │
      │   │
      └───┘",
-                                                      _output
-                                                     );
+                                                       _output
+                                                      );
         d.Dispose ();
     }
 
@@ -1281,11 +1280,11 @@ public class DialogTests
         d.SetBufferSize (buttonRow.Length, 10);
 
         (runstate, Dialog dlg) = BeginButtonTestDialog (
-                                                      title,
-                                                      width,
-                                                      Alignment.Center,
-                                                      new Button { Text = btnText }
-                                                     );
+                                                        title,
+                                                        width,
+                                                        Alignment.Center,
+                                                        new Button { Text = btnText }
+                                                       );
         DriverAssert.AssertDriverContentsWithFrameAre ($"{buttonRow}", _output);
         End (runstate);
         dlg.Dispose ();
@@ -1376,7 +1375,7 @@ public class DialogTests
 
         RunState runState = Begin (dlg);
 
-        dlg.SetNeedsDraw();
+        dlg.SetNeedsDraw ();
         dlg.SetNeedsLayout ();
         dlg.Layout ();
         dlg.Draw ();

+ 40 - 43
Tests/UnitTests/Dialogs/MessageBoxTests.cs

@@ -1,6 +1,5 @@
 using System.Text;
-using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities;
-using UnitTests;
+using UICatalog;
 using UnitTests;
 using Xunit.Abstractions;
 
@@ -19,7 +18,7 @@ public class MessageBoxTests
 
         var iteration = 0;
 
-        int btnAcceptCount = 0;
+        var btnAcceptCount = 0;
 
         Application.Iteration += (s, a) =>
                                  {
@@ -37,7 +36,7 @@ public class MessageBoxTests
                                              // Tab to btn2
                                              Application.RaiseKeyDownEvent (Key.Tab);
 
-                                             Button btn = Application.Navigation!.GetFocused () as Button;
+                                             var btn = Application.Navigation!.GetFocused () as Button;
 
                                              btn.Accepting += (sender, e) => { btnAcceptCount++; };
 
@@ -102,7 +101,7 @@ public class MessageBoxTests
 
         var iteration = 0;
 
-        int btnAcceptCount = 0;
+        var btnAcceptCount = 0;
 
         Application.Iteration += (s, a) =>
                                  {
@@ -120,7 +119,7 @@ public class MessageBoxTests
                                              // Tab to btn2
                                              Application.RaiseKeyDownEvent (Key.Tab);
 
-                                             Button btn = Application.Navigation!.GetFocused () as Button;
+                                             var btn = Application.Navigation!.GetFocused () as Button;
 
                                              btn.Accepting += (sender, e) => { btnAcceptCount++; };
 
@@ -138,7 +137,6 @@ public class MessageBoxTests
 
         Assert.Equal (1, result);
         Assert.Equal (1, btnAcceptCount);
-
     }
 
     [Theory]
@@ -161,7 +159,7 @@ public class MessageBoxTests
         Dialog.DefaultShadow = ShadowStyle.None;
         Button.DefaultShadow = ShadowStyle.None;
 
-        Rectangle mbFrame = Rectangle.Empty;
+        var mbFrame = Rectangle.Empty;
 
         Application.Iteration += (s, a) =>
                                  {
@@ -224,30 +222,30 @@ public class MessageBoxTests
                                          Application.LayoutAndDraw ();
 
                                          DriverAssert.AssertDriverContentsWithFrameAre (
-                                                                                       @"
+                                                                                        @"
  ╔════════════════╗
  ║ ff ff ff ff ff ║
  ║       ⟦► btn ◄⟧║
  ╚════════════════╝",
-                                                                                       _output
-                                                                                      );
+                                                                                        _output
+                                                                                       );
                                          Application.RequestStop ();
 
                                          // Really long text
-                                         MessageBox.Query (string.Empty, new string ('f', 500), 0, false, "btn");
+                                         MessageBox.Query (string.Empty, new ('f', 500), 0, false, "btn");
                                      }
                                      else if (iterations == 2)
                                      {
                                          Application.LayoutAndDraw ();
 
                                          DriverAssert.AssertDriverContentsWithFrameAre (
-                                                                                       @"
+                                                                                        @"
  ╔════════════════╗
  ║ffffffffffffffff║
  ║       ⟦► btn ◄⟧║
  ╚════════════════╝",
-                                                                                       _output
-                                                                                      );
+                                                                                        _output
+                                                                                       );
                                          Application.RequestStop ();
                                      }
                                  };
@@ -296,7 +294,7 @@ public class MessageBoxTests
                                          Application.LayoutAndDraw ();
 
                                          DriverAssert.AssertDriverContentsWithFrameAre (
-                                                                                       @"
+                                                                                        @"
   ╔══════════════╗
   ║ff ff ff ff ff║
   ║ff ff ff ff ff║
@@ -304,19 +302,19 @@ public class MessageBoxTests
   ║    ff ff     ║
   ║     ⟦► btn ◄⟧║
   ╚══════════════╝",
-                                                                                       _output
-                                                                                      );
+                                                                                        _output
+                                                                                       );
                                          Application.RequestStop ();
 
                                          // Really long text
-                                         MessageBox.Query (string.Empty, new string ('f', 500), 0, true, "btn");
+                                         MessageBox.Query (string.Empty, new ('f', 500), 0, true, "btn");
                                      }
                                      else if (iterations == 2)
                                      {
                                          Application.LayoutAndDraw ();
 
                                          DriverAssert.AssertDriverContentsWithFrameAre (
-                                                                                       @$"
+                                                                                        @"
  ╔════════════════╗
  ║ffffffffffffffff║
  ║ffffffffffffffff║
@@ -326,8 +324,8 @@ public class MessageBoxTests
  ║ffffffffffffffff║
  ║fffffff⟦► btn ◄⟧║
  ╚════════════════╝",
-                                                                                       _output
-                                                                                      );
+                                                                                        _output
+                                                                                       );
                                          Application.RequestStop ();
                                      }
                                  };
@@ -463,8 +461,8 @@ public class MessageBoxTests
                                      if (iterations == 0)
                                      {
                                          MessageBox.Query (
-                                                           title: "",
-                                                           message: UICatalog.UICatalogApp.GetAboutBoxMessage (),
+                                                           "",
+                                                           UICatalogApp.GetAboutBoxMessage (),
                                                            wrapMessage: false,
                                                            buttons: "_Ok"
                                                           );
@@ -475,23 +473,23 @@ public class MessageBoxTests
                                      {
                                          Application.LayoutAndDraw ();
 
-                                         string expectedText = """
-                                                               ┌────────────────────────────────────────────────────────────────────┐
-                                                               │   ╔═══════════════════════════════════════════════════════════╗    │
-                                                               │   ║UI Catalog: A comprehensive sample library and test app for║    │
-                                                               │   ║                                                           ║    │
-                                                               │   ║ _______                  _             _   _____       _  ║    │
-                                                               │   ║|__   __|                (_)           | | / ____|     (_) ║    │
-                                                               │   ║   | | ___ _ __ _ __ ___  _ _ __   __ _| || |  __ _   _ _  ║    │
-                                                               │   ║   | |/ _ \ '__| '_ ` _ \| | '_ \ / _` | || | |_ | | | | | ║    │
-                                                               │   ║   | |  __/ |  | | | | | | | | | | (_| | || |__| | |_| | | ║    │
-                                                               │   ║   |_|\___|_|  |_| |_| |_|_|_| |_|\__,_|_(_)_____|\__,_|_| ║    │
-                                                               │   ║                                                           ║    │
-                                                               │   ║                      v2 - Pre-Alpha                       ║    │
-                                                               │   ║                                                   ⟦► Ok ◄⟧║    │
-                                                               │   ╚═══════════════════════════════════════════════════════════╝    │
-                                                               └────────────────────────────────────────────────────────────────────┘
-                                                               """;
+                                         var expectedText = """
+                                                            ┌────────────────────────────────────────────────────────────────────┐
+                                                            │   ╔═══════════════════════════════════════════════════════════╗    │
+                                                            │   ║UI Catalog: A comprehensive sample library and test app for║    │
+                                                            │   ║                                                           ║    │
+                                                            │   ║ _______                  _             _   _____       _  ║    │
+                                                            │   ║|__   __|                (_)           | | / ____|     (_) ║    │
+                                                            │   ║   | | ___ _ __ _ __ ___  _ _ __   __ _| || |  __ _   _ _  ║    │
+                                                            │   ║   | |/ _ \ '__| '_ ` _ \| | '_ \ / _` | || | |_ | | | | | ║    │
+                                                            │   ║   | |  __/ |  | | | | | | | | | | (_| | || |__| | |_| | | ║    │
+                                                            │   ║   |_|\___|_|  |_| |_| |_|_|_| |_|\__,_|_(_)_____|\__,_|_| ║    │
+                                                            │   ║                                                           ║    │
+                                                            │   ║                      v2 - Pre-Alpha                       ║    │
+                                                            │   ║                                                   ⟦► Ok ◄⟧║    │
+                                                            │   ╚═══════════════════════════════════════════════════════════╝    │
+                                                            └────────────────────────────────────────────────────────────────────┘
+                                                            """;
 
                                          DriverAssert.AssertDriverContentsAre (expectedText, _output);
 
@@ -506,11 +504,10 @@ public class MessageBoxTests
     }
 
     [Theory]
-    [SetupFakeDriver]
     [MemberData (nameof (AcceptingKeys))]
     public void Button_IsDefault_True_Return_His_Index_On_Accepting (Key key)
     {
-        Application.Init ();
+        Application.Init (new FakeDriver ());
 
         Application.Iteration += (_, _) => Assert.True (Application.RaiseKeyDownEvent (key));
         int res = MessageBox.Query ("hey", "IsDefault", "Yes", "No");

+ 1 - 1
Tests/UnitTests/Dialogs/WizardTests.cs

@@ -462,7 +462,7 @@ public class WizardTests ()
         var wizard = new Wizard { Title = title, Width = width, Height = height };
         wizard.AddStep (new() { Title = stepTitle });
 
-        //wizard.LayoutSubviews ();
+        //wizard.LayoutSubViews ();
         var firstIteration = false;
         RunState runstate = Application.Begin (wizard);
         Application.RunIteration (ref runstate, firstIteration);

+ 54 - 55
Tests/UnitTests/Drawing/LineCanvasTests.cs

@@ -1,11 +1,10 @@
 using System.Text;
 using UnitTests;
-using UnitTests;
 using Xunit.Abstractions;
 
 namespace Terminal.Gui.DrawingTests;
 
-public class LineCanvasTests (ITestOutputHelper _output)
+public class LineCanvasTests (ITestOutputHelper output)
 {
     [Theory]
 
@@ -296,7 +295,7 @@ public class LineCanvasTests (ITestOutputHelper _output)
         lc.AddLine (new (x1, y1), len1, o1, s1);
         lc.AddLine (new (x2, y2), len2, o2, s2);
 
-        OutputAssert.AssertEqual (_output, expected, lc.ToString ());
+        OutputAssert.AssertEqual (output, expected, lc.ToString ());
         v.Dispose ();
     }
 
@@ -505,12 +504,12 @@ public class LineCanvasTests (ITestOutputHelper _output)
         Assert.Equal (new (x, y, 4, 2), lc.Bounds);
 
         OutputAssert.AssertEqual (
-                                 _output,
-                                 @"
+                                  output,
+                                  @"
 ╔╡╞╗
 ║  ║",
-                                 $"{Environment.NewLine}{lc}"
-                                );
+                                  $"{Environment.NewLine}{lc}"
+                                 );
     }
 
     [Fact]
@@ -555,12 +554,12 @@ public class LineCanvasTests (ITestOutputHelper _output)
         Assert.Equal (new (x, y, 4, 2), lc.Bounds);
 
         OutputAssert.AssertEqual (
-                                 _output,
-                                 @"
+                                  output,
+                                  @"
 ╔╡╞╗
 ║  ║",
-                                 $"{Environment.NewLine}{lc}"
-                                );
+                                  $"{Environment.NewLine}{lc}"
+                                 );
     }
 
     [Fact]
@@ -598,7 +597,7 @@ public class LineCanvasTests (ITestOutputHelper _output)
 
         // Add a line at 5, 5 that's has length of 1
         canvas.AddLine (new (x, y), 1, orientation, LineStyle.Single);
-        OutputAssert.AssertEqual (_output, $"{expected}", $"{canvas}");
+        OutputAssert.AssertEqual (output, $"{expected}", $"{canvas}");
     }
 
     // X is offset by 2
@@ -655,7 +654,7 @@ public class LineCanvasTests (ITestOutputHelper _output)
         canvas.AddLine (new (x, y), length, orientation, LineStyle.Single);
 
         var result = canvas.ToString ();
-        OutputAssert.AssertEqual (_output, expected, result);
+        OutputAssert.AssertEqual (output, expected, result);
     }
 
     [Fact]
@@ -682,7 +681,7 @@ public class LineCanvasTests (ITestOutputHelper _output)
 
         // Add a line at 0, 0 that's has length of 0
         lc.AddLine (Point.Empty, 0, orientation, LineStyle.Single);
-        OutputAssert.AssertEqual (_output, expected, $"{lc}");
+        OutputAssert.AssertEqual (output, expected, $"{lc}");
     }
 
     [InlineData (Orientation.Horizontal, "┼")]
@@ -703,7 +702,7 @@ public class LineCanvasTests (ITestOutputHelper _output)
 
         // Add a line at 0, 0 that's has length of 0
         lc.AddLine (Point.Empty, 0, orientation, LineStyle.Single);
-        OutputAssert.AssertEqual (_output, expected, $"{lc}");
+        OutputAssert.AssertEqual (output, expected, $"{lc}");
     }
 
     [InlineData (Orientation.Horizontal, "╥")]
@@ -726,7 +725,7 @@ public class LineCanvasTests (ITestOutputHelper _output)
 
         // Add a line at 0, 0 that's has length of 0
         lc.AddLine (Point.Empty, 0, orientation, LineStyle.Single);
-        OutputAssert.AssertEqual (_output, expected, $"{lc}");
+        OutputAssert.AssertEqual (output, expected, $"{lc}");
     }
 
     [Fact]
@@ -742,7 +741,7 @@ public class LineCanvasTests (ITestOutputHelper _output)
             @"
 ┌─
 │ ";
-        OutputAssert.AssertEqual (_output, looksLike, $"{Environment.NewLine}{canvas}");
+        OutputAssert.AssertEqual (output, looksLike, $"{Environment.NewLine}{canvas}");
     }
 
     [Fact]
@@ -769,7 +768,7 @@ public class LineCanvasTests (ITestOutputHelper _output)
 ┣━━━━╋━━━┫
 ┃    ┃   ┃
 ┗━━━━┻━━━┛";
-        DriverAssert.AssertDriverContentsAre (looksLike, _output);
+        DriverAssert.AssertDriverContentsAre (looksLike, output);
         v.Dispose ();
     }
 
@@ -800,7 +799,7 @@ public class LineCanvasTests (ITestOutputHelper _output)
 │    │   │
 ┕━━━━┷━━━┙
 ";
-        DriverAssert.AssertDriverContentsAre (looksLike, _output);
+        DriverAssert.AssertDriverContentsAre (looksLike, output);
         v.Dispose ();
     }
 
@@ -832,7 +831,7 @@ public class LineCanvasTests (ITestOutputHelper _output)
 ┖────┸───┚
 
 ";
-        DriverAssert.AssertDriverContentsAre (looksLike, _output);
+        DriverAssert.AssertDriverContentsAre (looksLike, output);
         v.Dispose ();
     }
 
@@ -850,7 +849,7 @@ public class LineCanvasTests (ITestOutputHelper _output)
             @"
 ┌─
 │ ";
-        OutputAssert.AssertEqual (_output, looksLike, $"{Environment.NewLine}{canvas}");
+        OutputAssert.AssertEqual (output, looksLike, $"{Environment.NewLine}{canvas}");
     }
 
     [Fact]
@@ -880,12 +879,12 @@ public class LineCanvasTests (ITestOutputHelper _output)
         Assert.Equal (2, map.Count);
 
         OutputAssert.AssertEqual (
-                                 _output,
-                                 @"
+                                  output,
+                                  @"
  ─",
-                                 $"{Environment.NewLine}{canvas}"
-                                );
+                                  $"{Environment.NewLine}{canvas}"
+                                 );
     }
 
     [Fact]
@@ -893,7 +892,7 @@ public class LineCanvasTests (ITestOutputHelper _output)
     public void ToString_Empty ()
     {
         var lc = new LineCanvas ();
-        OutputAssert.AssertEqual (_output, string.Empty, lc.ToString ());
+        OutputAssert.AssertEqual (output, string.Empty, lc.ToString ());
     }
 
     //                  012
@@ -912,7 +911,7 @@ public class LineCanvasTests (ITestOutputHelper _output)
     {
         var lc = new LineCanvas ();
         lc.AddLine (new (x, y), 3, Orientation.Horizontal, LineStyle.Double);
-        OutputAssert.AssertEqual (_output, expected, $"{lc}");
+        OutputAssert.AssertEqual (output, expected, $"{lc}");
     }
 
     [InlineData (0, 0, 0, 0, "═══")]
@@ -937,7 +936,7 @@ public class LineCanvasTests (ITestOutputHelper _output)
         lc.AddLine (new (x1, y1), 3, Orientation.Horizontal, LineStyle.Double);
         lc.AddLine (new (x2, y2), 3, Orientation.Horizontal, LineStyle.Double);
 
-        OutputAssert.AssertEqual (_output, expected, $"{lc}");
+        OutputAssert.AssertEqual (output, expected, $"{lc}");
     }
 
     //		[Fact, SetupFakeDriver]
@@ -997,7 +996,7 @@ public class LineCanvasTests (ITestOutputHelper _output)
 
         v.Draw ();
 
-        DriverAssert.AssertDriverContentsAre (expected, _output);
+        DriverAssert.AssertDriverContentsAre (expected, output);
         v.Dispose ();
     }
 
@@ -1016,7 +1015,7 @@ public class LineCanvasTests (ITestOutputHelper _output)
             @"    
 ┌─
 │";
-        DriverAssert.AssertDriverContentsAre (looksLike, _output);
+        DriverAssert.AssertDriverContentsAre (looksLike, output);
         v.Dispose ();
     }
 
@@ -1039,7 +1038,7 @@ public class LineCanvasTests (ITestOutputHelper _output)
 ──
 │";
-        DriverAssert.AssertDriverContentsAre (looksLike, _output);
+        DriverAssert.AssertDriverContentsAre (looksLike, output);
         v.Dispose ();
     }
 
@@ -1057,7 +1056,7 @@ public class LineCanvasTests (ITestOutputHelper _output)
         var looksLike =
             @"    
 ──";
-        DriverAssert.AssertDriverContentsAre (looksLike, _output);
+        DriverAssert.AssertDriverContentsAre (looksLike, output);
         v.Dispose ();
     }
 
@@ -1073,7 +1072,7 @@ public class LineCanvasTests (ITestOutputHelper _output)
         var looksLike =
             @" 
 ══";
-        DriverAssert.AssertDriverContentsAre (looksLike, _output);
+        DriverAssert.AssertDriverContentsAre (looksLike, output);
         v.Dispose ();
     }
 
@@ -1092,7 +1091,7 @@ public class LineCanvasTests (ITestOutputHelper _output)
             @"    
 │";
-        DriverAssert.AssertDriverContentsAre (looksLike, _output);
+        DriverAssert.AssertDriverContentsAre (looksLike, output);
         v.Dispose ();
     }
 
@@ -1109,7 +1108,7 @@ public class LineCanvasTests (ITestOutputHelper _output)
             @"    
 ║";
-        DriverAssert.AssertDriverContentsAre (looksLike, _output);
+        DriverAssert.AssertDriverContentsAre (looksLike, output);
         v.Dispose ();
     }
 
@@ -1137,7 +1136,7 @@ public class LineCanvasTests (ITestOutputHelper _output)
 ╠════╬═══╣
 ║    ║   ║
 ╚════╩═══╝";
-        DriverAssert.AssertDriverContentsAre (looksLike, _output);
+        DriverAssert.AssertDriverContentsAre (looksLike, output);
         v.Dispose ();
     }
 
@@ -1168,7 +1167,7 @@ public class LineCanvasTests (ITestOutputHelper _output)
 │    │   │
 ╘════╧═══╛
 ";
-        DriverAssert.AssertDriverContentsAre (looksLike, _output);
+        DriverAssert.AssertDriverContentsAre (looksLike, output);
         v.Dispose ();
     }
 
@@ -1205,7 +1204,7 @@ public class LineCanvasTests (ITestOutputHelper _output)
 ├────┼───┤
 │    │   │
 ╰────┴───╯";
-        DriverAssert.AssertDriverContentsAre (looksLike, _output);
+        DriverAssert.AssertDriverContentsAre (looksLike, output);
         v.Dispose ();
     }
 
@@ -1237,7 +1236,7 @@ public class LineCanvasTests (ITestOutputHelper _output)
 ╙────╨───╜
 
 ";
-        DriverAssert.AssertDriverContentsAre (looksLike, _output);
+        DriverAssert.AssertDriverContentsAre (looksLike, output);
         v.Dispose ();
     }
 
@@ -1264,7 +1263,7 @@ public class LineCanvasTests (ITestOutputHelper _output)
 ├────┼───┤
 │    │   │
 └────┴───┘";
-        OutputAssert.AssertEqual (_output, looksLike, $"{Environment.NewLine}{canvas}");
+        OutputAssert.AssertEqual (output, looksLike, $"{Environment.NewLine}{canvas}");
     }
 
     [Fact]
@@ -1302,7 +1301,7 @@ public class LineCanvasTests (ITestOutputHelper _output)
         var looksLike = @"
 ╔╡╞══╗
 ║    ║";
-        OutputAssert.AssertEqual (_output, looksLike, $"{Environment.NewLine}{lc}");
+        OutputAssert.AssertEqual (output, looksLike, $"{Environment.NewLine}{lc}");
     }
 
     [Fact]
@@ -1407,20 +1406,20 @@ public class LineCanvasTests (ITestOutputHelper _output)
         LineCanvas canvasCopy = canvas = new ();
 
         v.DrawComplete += (s, e) =>
-                                 {
-                                     v.FillRect (v.Viewport);
-
-                                     foreach (KeyValuePair<Point, Rune> p in canvasCopy.GetMap ())
-                                     {
-                                         v.AddRune (
-                                                    offsetX + p.Key.X,
-                                                    offsetY + p.Key.Y,
-                                                    p.Value
-                                                   );
-                                     }
-
-                                     canvasCopy.Clear ();
-                                 };
+                          {
+                              v.FillRect (v.Viewport);
+
+                              foreach (KeyValuePair<Point, Rune> p in canvasCopy.GetMap ())
+                              {
+                                  v.AddRune (
+                                             offsetX + p.Key.X,
+                                             offsetY + p.Key.Y,
+                                             p.Value
+                                            );
+                              }
+
+                              canvasCopy.Clear ();
+                          };
 
         return v;
     }

+ 18 - 20
Tests/UnitTests/Drawing/RulerTests.cs

@@ -1,5 +1,4 @@
 using UnitTests;
-using UnitTests;
 using Xunit.Abstractions;
 
 namespace Terminal.Gui.DrawingTests;
@@ -51,33 +50,33 @@ public class RulerTests
         r.Draw (Point.Empty);
 
         DriverAssert.AssertDriverContentsWithFrameAre (
-                                                      @"
+                                                       @"
 |123456789|1234",
-                                                      _output
-                                                     );
+                                                       _output
+                                                      );
 
         // Postive offset
         r.Draw (new (1, 1));
 
         DriverAssert.AssertDriverContentsAre (
-                                                      @"
+                                              @"
 |123456789|1234
  |123456789|1234
 ",
-                                                      _output
-                                                     );
+                                              _output
+                                             );
 
         // Negative offset
         r.Draw (new (-1, 3));
 
         DriverAssert.AssertDriverContentsAre (
-                                             @"
+                                              @"
 |123456789|1234
  |123456789|1234
 123456789|1234
 ",
-                                             _output
-                                            );
+                                              _output
+                                             );
     }
 
     [Fact]
@@ -92,7 +91,7 @@ public class RulerTests
         r.Draw (Point.Empty);
 
         DriverAssert.AssertDriverContentsWithFrameAre (
-                                                      @"
+                                                       @"
 -
 1
 2
@@ -108,13 +107,13 @@ public class RulerTests
 2
 3
 4",
-                                                      _output
-                                                     );
+                                                       _output
+                                                      );
 
         r.Draw (new (1, 1));
 
         DriverAssert.AssertDriverContentsWithFrameAre (
-                                                      @"
+                                                       @"
 - 
 1-
 21
@@ -131,14 +130,14 @@ public class RulerTests
 32
 43
  4",
-                                                      _output
-                                                     );
+                                                       _output
+                                                      );
 
         // Negative offset
         r.Draw (new (2, -1));
 
         DriverAssert.AssertDriverContentsWithFrameAre (
-                                                      @"
+                                                       @"
 - 1
 1-2
 213
@@ -155,9 +154,8 @@ public class RulerTests
 324
 43 
  4 ",
-                                                      _output
-                                                     );
-
+                                                       _output
+                                                      );
     }
 
     [Fact]

+ 84 - 85
Tests/UnitTests/Drawing/StraightLineExtensionsTests.cs

@@ -1,5 +1,4 @@
 using UnitTests;
-using UnitTests;
 using Xunit.Abstractions;
 
 namespace Terminal.Gui.DrawingTests;
@@ -12,136 +11,136 @@ public class StraightLineExtensionsTests (ITestOutputHelper output)
     {
         var lc = new LineCanvas ();
         lc.AddLine (Point.Empty, 10, Orientation.Horizontal, LineStyle.Single);
-        lc.AddLine (new Point (9, 0), 5, Orientation.Vertical, LineStyle.Single);
-        lc.AddLine (new Point (9, 4), -10, Orientation.Horizontal, LineStyle.Single);
-        lc.AddLine (new Point (0, 4), -5, Orientation.Vertical, LineStyle.Single);
+        lc.AddLine (new (9, 0), 5, Orientation.Vertical, LineStyle.Single);
+        lc.AddLine (new (9, 4), -10, Orientation.Horizontal, LineStyle.Single);
+        lc.AddLine (new (0, 4), -5, Orientation.Vertical, LineStyle.Single);
 
         OutputAssert.AssertEqual (
-                                 output,
-                                 @"
+                                  output,
+                                  @"
 ┌────────┐
 │        │
 │        │
 │        │
 └────────┘",
-                                 $"{Environment.NewLine}{lc}"
-                                );
+                                  $"{Environment.NewLine}{lc}"
+                                 );
         IReadOnlyCollection<StraightLine> origLines = lc.Lines;
 
-        lc = new LineCanvas (origLines.Exclude (Point.Empty, 10, Orientation.Horizontal));
+        lc = new (origLines.Exclude (Point.Empty, 10, Orientation.Horizontal));
 
         OutputAssert.AssertEqual (
-                                 output,
-                                 @"
+                                  output,
+                                  @"
 │        │
 │        │
 │        │
 └────────┘",
-                                 $"{Environment.NewLine}{lc}"
-                                );
+                                  $"{Environment.NewLine}{lc}"
+                                 );
 
-        lc = new LineCanvas (origLines.Exclude (new Point (0, 1), 10, Orientation.Horizontal));
+        lc = new (origLines.Exclude (new (0, 1), 10, Orientation.Horizontal));
 
         OutputAssert.AssertEqual (
-                                 output,
-                                 @"
+                                  output,
+                                  @"
 ┌────────┐
           
 │        │
 │        │
 └────────┘",
-                                 $"{Environment.NewLine}{lc}"
-                                );
+                                  $"{Environment.NewLine}{lc}"
+                                 );
 
-        lc = new LineCanvas (origLines.Exclude (new Point (0, 2), 10, Orientation.Horizontal));
+        lc = new (origLines.Exclude (new (0, 2), 10, Orientation.Horizontal));
 
         OutputAssert.AssertEqual (
-                                 output,
-                                 @"
+                                  output,
+                                  @"
 ┌────────┐
 │        │
           
 │        │
 └────────┘",
-                                 $"{Environment.NewLine}{lc}"
-                                );
+                                  $"{Environment.NewLine}{lc}"
+                                 );
 
-        lc = new LineCanvas (origLines.Exclude (new Point (0, 3), 10, Orientation.Horizontal));
+        lc = new (origLines.Exclude (new (0, 3), 10, Orientation.Horizontal));
 
         OutputAssert.AssertEqual (
-                                 output,
-                                 @"
+                                  output,
+                                  @"
 ┌────────┐
 │        │
 │        │
           
 └────────┘",
-                                 $"{Environment.NewLine}{lc}"
-                                );
+                                  $"{Environment.NewLine}{lc}"
+                                 );
 
-        lc = new LineCanvas (origLines.Exclude (new Point (0, 4), 10, Orientation.Horizontal));
+        lc = new (origLines.Exclude (new (0, 4), 10, Orientation.Horizontal));
 
         OutputAssert.AssertEqual (
-                                 output,
-                                 @"
+                                  output,
+                                  @"
 ┌────────┐
 │        │
 │        │
 │        │",
-                                 $"{Environment.NewLine}{lc}"
-                                );
+                                  $"{Environment.NewLine}{lc}"
+                                 );
 
-        lc = new LineCanvas (origLines.Exclude (Point.Empty, 10, Orientation.Vertical));
+        lc = new (origLines.Exclude (Point.Empty, 10, Orientation.Vertical));
 
         OutputAssert.AssertEqual (
-                                 output,
-                                 @"
+                                  output,
+                                  @"
 ────────┐
 ────────┘",
-                                 $"{Environment.NewLine}{lc}"
-                                );
+                                  $"{Environment.NewLine}{lc}"
+                                 );
 
-        lc = new LineCanvas (origLines.Exclude (new Point (1, 0), 10, Orientation.Vertical));
+        lc = new (origLines.Exclude (new (1, 0), 10, Orientation.Vertical));
 
         OutputAssert.AssertEqual (
-                                 output,
-                                 @"
+                                  output,
+                                  @"
 ┌ ───────┐
 │        │
 │        │
 │        │
 └ ───────┘",
-                                 $"{Environment.NewLine}{lc}"
-                                );
+                                  $"{Environment.NewLine}{lc}"
+                                 );
 
-        lc = new LineCanvas (origLines.Exclude (new Point (8, 0), 10, Orientation.Vertical));
+        lc = new (origLines.Exclude (new (8, 0), 10, Orientation.Vertical));
 
         OutputAssert.AssertEqual (
-                                 output,
-                                 @"
+                                  output,
+                                  @"
 ┌─────── ┐
 │        │
 │        │
 │        │
 └─────── ┘",
-                                 $"{Environment.NewLine}{lc}"
-                                );
+                                  $"{Environment.NewLine}{lc}"
+                                 );
 
-        lc = new LineCanvas (origLines.Exclude (new Point (9, 0), 10, Orientation.Vertical));
+        lc = new (origLines.Exclude (new (9, 0), 10, Orientation.Vertical));
 
         OutputAssert.AssertEqual (
-                                 output,
-                                 @"
+                                  output,
+                                  @"
 ┌────────
 └────────",
-                                 $"{Environment.NewLine}{lc}"
-                                );
+                                  $"{Environment.NewLine}{lc}"
+                                 );
     }
 
     #region Parallel Tests
@@ -151,12 +150,12 @@ public class StraightLineExtensionsTests (ITestOutputHelper output)
     public void TestExcludeParallel_HorizontalLines_LeftOnly ()
     {
         // x=1 to x=10
-        var l1 = new StraightLine (new Point (1, 2), 10, Orientation.Horizontal, LineStyle.Single);
+        var l1 = new StraightLine (new (1, 2), 10, Orientation.Horizontal, LineStyle.Single);
 
         StraightLine [] after = new [] { l1 }
 
                                 // exclude x=3 to x=103
-                                .Exclude (new Point (3, 2), 100, Orientation.Horizontal)
+                                .Exclude (new (3, 2), 100, Orientation.Horizontal)
                                 .ToArray ();
 
         // x=1 to x=2
@@ -170,12 +169,12 @@ public class StraightLineExtensionsTests (ITestOutputHelper output)
     public void TestExcludeParallel_HorizontalLines_RightOnly ()
     {
         // x=1 to x=10
-        var l1 = new StraightLine (new Point (1, 2), 10, Orientation.Horizontal, LineStyle.Single);
+        var l1 = new StraightLine (new (1, 2), 10, Orientation.Horizontal, LineStyle.Single);
 
         StraightLine [] after = new [] { l1 }
 
                                 // exclude x=0 to x=2
-                                .Exclude (new Point (0, 2), 3, Orientation.Horizontal)
+                                .Exclude (new (0, 2), 3, Orientation.Horizontal)
                                 .ToArray ();
 
         // x=3 to x=10
@@ -190,12 +189,12 @@ public class StraightLineExtensionsTests (ITestOutputHelper output)
     public void TestExcludeParallel_HorizontalLines_HorizontalSplit ()
     {
         // x=1 to x=10
-        var l1 = new StraightLine (new Point (1, 2), 10, Orientation.Horizontal, LineStyle.Single);
+        var l1 = new StraightLine (new (1, 2), 10, Orientation.Horizontal, LineStyle.Single);
 
         StraightLine [] after = new [] { l1 }
 
                                 // exclude x=4 to x=5
-                                .Exclude (new Point (4, 2), 2, Orientation.Horizontal)
+                                .Exclude (new (4, 2), 2, Orientation.Horizontal)
                                 .ToArray ();
 
         // x=1 to x=3,
@@ -218,12 +217,12 @@ public class StraightLineExtensionsTests (ITestOutputHelper output)
     public void TestExcludeParallel_HorizontalLines_CoverCompletely ()
     {
         // x=1 to x=10
-        var l1 = new StraightLine (new Point (1, 2), 10, Orientation.Horizontal, LineStyle.Single);
+        var l1 = new StraightLine (new (1, 2), 10, Orientation.Horizontal, LineStyle.Single);
 
         StraightLine [] after = new [] { l1 }
 
                                 // exclude x=4 to x=5
-                                .Exclude (new Point (1, 2), 10, Orientation.Horizontal)
+                                .Exclude (new (1, 2), 10, Orientation.Horizontal)
                                 .ToArray ();
         Assert.Empty (after);
     }
@@ -233,12 +232,12 @@ public class StraightLineExtensionsTests (ITestOutputHelper output)
     public void TestExcludeParallel_VerticalLines_TopOnly ()
     {
         // y=1 to y=10
-        var l1 = new StraightLine (new Point (2, 1), 10, Orientation.Vertical, LineStyle.Single);
+        var l1 = new StraightLine (new (2, 1), 10, Orientation.Vertical, LineStyle.Single);
 
         StraightLine [] after = new [] { l1 }
 
                                 // exclude y=3 to y=103
-                                .Exclude (new Point (2, 3), 100, Orientation.Vertical)
+                                .Exclude (new (2, 3), 100, Orientation.Vertical)
                                 .ToArray ();
 
         // y=1 to y=2
@@ -252,12 +251,12 @@ public class StraightLineExtensionsTests (ITestOutputHelper output)
     public void TestExcludeParallel_HorizontalLines_BottomOnly ()
     {
         // y=1 to y=10
-        var l1 = new StraightLine (new Point (2, 1), 10, Orientation.Vertical, LineStyle.Single);
+        var l1 = new StraightLine (new (2, 1), 10, Orientation.Vertical, LineStyle.Single);
 
         StraightLine [] after = new [] { l1 }
 
                                 // exclude y=0 to y=2
-                                .Exclude (new Point (2, 0), 3, Orientation.Vertical)
+                                .Exclude (new (2, 0), 3, Orientation.Vertical)
                                 .ToArray ();
 
         // y=3 to y=10
@@ -272,12 +271,12 @@ public class StraightLineExtensionsTests (ITestOutputHelper output)
     public void TestExcludeParallel_VerticalLines_VerticalSplit ()
     {
         // y=1 to y=10
-        var l1 = new StraightLine (new Point (2, 1), 10, Orientation.Vertical, LineStyle.Single);
+        var l1 = new StraightLine (new (2, 1), 10, Orientation.Vertical, LineStyle.Single);
 
         StraightLine [] after = new [] { l1 }
 
                                 // exclude y=4 to y=5
-                                .Exclude (new Point (2, 4), 2, Orientation.Vertical)
+                                .Exclude (new (2, 4), 2, Orientation.Vertical)
                                 .ToArray ();
 
         // y=1 to y=3,
@@ -300,12 +299,12 @@ public class StraightLineExtensionsTests (ITestOutputHelper output)
     public void TestExcludeParallel_VerticalLines_CoverCompletely ()
     {
         // y=1 to y=10
-        var l1 = new StraightLine (new Point (2, 1), 10, Orientation.Vertical, LineStyle.Single);
+        var l1 = new StraightLine (new (2, 1), 10, Orientation.Vertical, LineStyle.Single);
 
         StraightLine [] after = new [] { l1 }
 
                                 // exclude y=4 to y=5
-                                .Exclude (new Point (2, 1), 10, Orientation.Vertical)
+                                .Exclude (new (2, 1), 10, Orientation.Vertical)
                                 .ToArray ();
         Assert.Empty (after);
     }
@@ -319,12 +318,12 @@ public class StraightLineExtensionsTests (ITestOutputHelper output)
     public void TestExcludePerpendicular_HorizontalLine_VerticalExclusion_Splits ()
     {
         // x=1 to x=10
-        var l1 = new StraightLine (new Point (1, 2), 10, Orientation.Horizontal, LineStyle.Single);
+        var l1 = new StraightLine (new (1, 2), 10, Orientation.Horizontal, LineStyle.Single);
 
         StraightLine [] after = new [] { l1 }
 
                                 // exclude x=3 y=0-10
-                                .Exclude (new Point (3, 0), 10, Orientation.Vertical)
+                                .Exclude (new (3, 0), 10, Orientation.Vertical)
                                 .ToArray ();
 
         // x=1 to x=2,
@@ -347,12 +346,12 @@ public class StraightLineExtensionsTests (ITestOutputHelper output)
     public void TestExcludePerpendicular_HorizontalLine_VerticalExclusion_ClipLeft ()
     {
         // x=1 to x=10
-        var l1 = new StraightLine (new Point (1, 2), 10, Orientation.Horizontal, LineStyle.Single);
+        var l1 = new StraightLine (new (1, 2), 10, Orientation.Horizontal, LineStyle.Single);
 
         StraightLine [] after = new [] { l1 }
 
                                 // exclude x=1 y=0-10
-                                .Exclude (new Point (1, 0), 10, Orientation.Vertical)
+                                .Exclude (new (1, 0), 10, Orientation.Vertical)
                                 .ToArray ();
 
         // x=2 to x=10,
@@ -368,12 +367,12 @@ public class StraightLineExtensionsTests (ITestOutputHelper output)
     public void TestExcludePerpendicular_HorizontalLine_VerticalExclusion_ClipRight ()
     {
         // x=1 to x=10
-        var l1 = new StraightLine (new Point (1, 2), 10, Orientation.Horizontal, LineStyle.Single);
+        var l1 = new StraightLine (new (1, 2), 10, Orientation.Horizontal, LineStyle.Single);
 
         StraightLine [] after = new [] { l1 }
 
                                 // exclude x=10 y=0-10
-                                .Exclude (new Point (10, 0), 10, Orientation.Vertical)
+                                .Exclude (new (10, 0), 10, Orientation.Vertical)
                                 .ToArray ();
 
         // x=1 to x=9,
@@ -389,7 +388,7 @@ public class StraightLineExtensionsTests (ITestOutputHelper output)
     public void TestExcludePerpendicular_HorizontalLine_VerticalExclusion_MissLeft ()
     {
         // x=1 to x=10
-        var l1 = new StraightLine (new Point (1, 2), 10, Orientation.Horizontal, LineStyle.Single);
+        var l1 = new StraightLine (new (1, 2), 10, Orientation.Horizontal, LineStyle.Single);
 
         StraightLine [] after = new [] { l1 }
 
@@ -406,12 +405,12 @@ public class StraightLineExtensionsTests (ITestOutputHelper output)
     public void TestExcludePerpendicular_HorizontalLine_VerticalExclusion_MissRight ()
     {
         // x=1 to x=10
-        var l1 = new StraightLine (new Point (1, 2), 10, Orientation.Horizontal, LineStyle.Single);
+        var l1 = new StraightLine (new (1, 2), 10, Orientation.Horizontal, LineStyle.Single);
 
         StraightLine [] after = new [] { l1 }
 
                                 // exclude x=11 y=0-10
-                                .Exclude (new Point (11, 0), 10, Orientation.Vertical)
+                                .Exclude (new (11, 0), 10, Orientation.Vertical)
                                 .ToArray ();
 
         // Exclusion line is too far to the right so hits nothing
@@ -423,12 +422,12 @@ public class StraightLineExtensionsTests (ITestOutputHelper output)
     public void TestExcludePerpendicular_VerticalLine_HorizontalExclusion_ClipTop ()
     {
         // y=1 to y=10
-        var l1 = new StraightLine (new Point (2, 1), 10, Orientation.Vertical, LineStyle.Single);
+        var l1 = new StraightLine (new (2, 1), 10, Orientation.Vertical, LineStyle.Single);
 
         StraightLine [] after = new [] { l1 }
 
                                 // exclude y=1 x=0-10
-                                .Exclude (new Point (0, 1), 10, Orientation.Horizontal)
+                                .Exclude (new (0, 1), 10, Orientation.Horizontal)
                                 .ToArray ();
 
         // y=2 to y=10,
@@ -444,12 +443,12 @@ public class StraightLineExtensionsTests (ITestOutputHelper output)
     public void TestExcludePerpendicular_VerticalLine_HorizontalExclusion_ClipBottom ()
     {
         // y=1 to y=10
-        var l1 = new StraightLine (new Point (2, 1), 10, Orientation.Vertical, LineStyle.Single);
+        var l1 = new StraightLine (new (2, 1), 10, Orientation.Vertical, LineStyle.Single);
 
         StraightLine [] after = new [] { l1 }
 
                                 // exclude y=10 x=0-10
-                                .Exclude (new Point (0, 10), 10, Orientation.Horizontal)
+                                .Exclude (new (0, 10), 10, Orientation.Horizontal)
                                 .ToArray ();
 
         // y=1 to y=9,
@@ -465,7 +464,7 @@ public class StraightLineExtensionsTests (ITestOutputHelper output)
     public void TestExcludePerpendicular_VerticalLine_HorizontalExclusion_MissTop ()
     {
         // y=1 to y=10
-        var l1 = new StraightLine (new Point (2, 1), 10, Orientation.Vertical, LineStyle.Single);
+        var l1 = new StraightLine (new (2, 1), 10, Orientation.Vertical, LineStyle.Single);
 
         StraightLine [] after = new [] { l1 }
 
@@ -482,12 +481,12 @@ public class StraightLineExtensionsTests (ITestOutputHelper output)
     public void TestExcludePerpendicular_VerticalLine_HorizontalExclusion_MissBottom ()
     {
         // y=1 to y=10
-        var l1 = new StraightLine (new Point (2, 1), 10, Orientation.Vertical, LineStyle.Single);
+        var l1 = new StraightLine (new (2, 1), 10, Orientation.Vertical, LineStyle.Single);
 
         StraightLine [] after = new [] { l1 }
 
                                 // exclude y=11 x=0-10
-                                .Exclude (new Point (0, 11), 10, Orientation.Horizontal)
+                                .Exclude (new (0, 11), 10, Orientation.Horizontal)
                                 .ToArray ();
 
         // Exclusion line is too far to the right so hits nothing

+ 51 - 52
Tests/UnitTests/Drawing/ThicknessTests.cs

@@ -1,9 +1,9 @@
 using System.Text;
 using UnitTests;
-using UnitTests;
 using Xunit.Abstractions;
 
 namespace Terminal.Gui.DrawingTests;
+
 public class ThicknessTests (ITestOutputHelper output)
 {
     [Fact]
@@ -15,28 +15,28 @@ public class ThicknessTests (ITestOutputHelper output)
         var r = new Rectangle (5, 5, 40, 15);
 
         Application.Driver?.FillRect (
-                                     new Rectangle (0, 0, Application.Driver!.Cols, Application.Driver!.Rows),
-                                     (Rune)' '
-                                    );
+                                      new (0, 0, Application.Driver!.Cols, Application.Driver!.Rows),
+                                      (Rune)' '
+                                     );
         t.Draw (r, ViewDiagnosticFlags.Thickness, "Test");
 
         DriverAssert.AssertDriverContentsWithFrameAre (
-                                                      @"
+                                                       @"
        Test (Left=0,Top=0,Right=0,Bottom=0)",
-                                                      output
-                                                     );
+                                                       output
+                                                      );
 
-        t = new Thickness (1, 1, 1, 1);
-        r = new Rectangle (5, 5, 40, 15);
+        t = new (1, 1, 1, 1);
+        r = new (5, 5, 40, 15);
 
         Application.Driver?.FillRect (
-                                     new Rectangle (0, 0, Application.Driver!.Cols, Application.Driver!.Rows),
-                                     (Rune)' '
-                                    );
+                                      new (0, 0, Application.Driver!.Cols, Application.Driver!.Rows),
+                                      (Rune)' '
+                                     );
         t.Draw (r, ViewDiagnosticFlags.Thickness, "Test");
 
         DriverAssert.AssertDriverContentsWithFrameAre (
-                                                      @"
+                                                       @"
      TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
      T                                      T
      T                                      T
@@ -52,20 +52,20 @@ public class ThicknessTests (ITestOutputHelper output)
      T                                      T
      T                                      T
      TTTest (Left=1,Top=1,Right=1,Bottom=1)TT",
-                                                      output
-                                                     );
+                                                       output
+                                                      );
 
-        t = new Thickness (1, 2, 3, 4);
-        r = new Rectangle (5, 5, 40, 15);
+        t = new (1, 2, 3, 4);
+        r = new (5, 5, 40, 15);
 
         Application.Driver?.FillRect (
-                                     new Rectangle (0, 0, Application.Driver!.Cols, Application.Driver!.Rows),
-                                     (Rune)' '
-                                    );
+                                      new (0, 0, Application.Driver!.Cols, Application.Driver!.Rows),
+                                      (Rune)' '
+                                     );
         t.Draw (r, ViewDiagnosticFlags.Thickness, "Test");
 
         DriverAssert.AssertDriverContentsWithFrameAre (
-                                                      @"
+                                                       @"
      TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
      TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
      T                                    TTT
@@ -81,20 +81,20 @@ public class ThicknessTests (ITestOutputHelper output)
      TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
      TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
      TTTest (Left=1,Top=2,Right=3,Bottom=4)TT",
-                                                      output
-                                                     );
+                                                       output
+                                                      );
 
-        t = new Thickness (-1, 1, 1, 1);
-        r = new Rectangle (5, 5, 40, 15);
+        t = new (-1, 1, 1, 1);
+        r = new (5, 5, 40, 15);
 
         Application.Driver?.FillRect (
-                                     new Rectangle (0, 0, Application.Driver!.Cols, Application.Driver!.Rows),
-                                     (Rune)' '
-                                    );
+                                      new (0, 0, Application.Driver!.Cols, Application.Driver!.Rows),
+                                      (Rune)' '
+                                     );
         t.Draw (r, ViewDiagnosticFlags.Thickness, "Test");
 
         DriverAssert.AssertDriverContentsWithFrameAre (
-                                                      @"
+                                                       @"
      TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
                                             T
                                             T
@@ -110,8 +110,8 @@ public class ThicknessTests (ITestOutputHelper output)
                                             T
                                             T
      TTest (Left=-1,Top=1,Right=1,Bottom=1)TT",
-                                                      output
-                                                     );
+                                                       output
+                                                      );
     }
 
     [Fact]
@@ -133,7 +133,7 @@ public class ThicknessTests (ITestOutputHelper output)
         t.Draw (r, ViewDiagnosticFlags.Ruler, "Test");
 
         DriverAssert.AssertDriverContentsAre (
-                                             @"
+                                              @"
 ┌───────────────────────────────────────────┐
 │                                           │
 │                                           │
@@ -154,17 +154,17 @@ public class ThicknessTests (ITestOutputHelper output)
 │                                           │
 │                                           │
 └───────────────────────────────────────────┘",
-                                             output
-                                            );
+                                              output
+                                             );
 
-        t = new Thickness (1, 1, 1, 1);
-        r = new Rectangle (1, 1, 40, 15);
+        t = new (1, 1, 1, 1);
+        r = new (1, 1, 40, 15);
         top.SetNeedsDraw ();
         Application.RunIteration (ref rs);
-        t.Draw (r, ViewDiagnosticFlags.Ruler,  "Test");
+        t.Draw (r, ViewDiagnosticFlags.Ruler, "Test");
 
         DriverAssert.AssertDriverContentsAre (
-                                             @"
+                                              @"
 ┌───────────────────────────────────────────┐
 │|123456789|123456789|123456789|123456789   │
 │1                                      1   │
@@ -185,17 +185,17 @@ public class ThicknessTests (ITestOutputHelper output)
 │                                           │
 │                                           │
 └───────────────────────────────────────────┘",
-                                             output
-                                            );
+                                              output
+                                             );
 
-        t = new Thickness (1, 2, 3, 4);
-        r = new Rectangle (2, 2, 40, 15);
+        t = new (1, 2, 3, 4);
+        r = new (2, 2, 40, 15);
         top.SetNeedsDraw ();
         Application.RunIteration (ref rs);
-        t.Draw (r, ViewDiagnosticFlags.Ruler,  "Test");
+        t.Draw (r, ViewDiagnosticFlags.Ruler, "Test");
 
         DriverAssert.AssertDriverContentsWithFrameAre (
-                                                      @"
+                                                       @"
 ┌───────────────────────────────────────────┐
 │                                           │
 │ |123456789|123456789|123456789|123456789  │
@@ -216,17 +216,17 @@ public class ThicknessTests (ITestOutputHelper output)
 │                                           │
 │                                           │
 └───────────────────────────────────────────┘",
-                                                      output
-                                                     );
+                                                       output
+                                                      );
 
-        t = new Thickness (-1, 1, 1, 1);
-        r = new Rectangle (5, 5, 40, 15);
+        t = new (-1, 1, 1, 1);
+        r = new (5, 5, 40, 15);
         top.SetNeedsDraw ();
         Application.RunIteration (ref rs);
         t.Draw (r, ViewDiagnosticFlags.Ruler, "Test");
 
         DriverAssert.AssertDriverContentsWithFrameAre (
-                                                      @"
+                                                       @"
 ┌───────────────────────────────────────────┐
 │                                           │
 │                                           │
@@ -247,9 +247,8 @@ public class ThicknessTests (ITestOutputHelper output)
 │                                           2
 │                                           3
 └────|123456789|123456789|123456789|123456789",
-                                                      output
-                                                     );
+                                                       output
+                                                      );
         top.Dispose ();
     }
-
 }

+ 6 - 6
Tests/UnitTests/FileServices/FileDialogTests.cs

@@ -33,7 +33,7 @@ public class FileDialogTests ()
     public void DirectTyping_Allowed ()
     {
         FileDialog dlg = GetInitializedFileDialog ();
-        TextField tf = dlg.Subviews.OfType<TextField> ().First (t => t.HasFocus);
+        TextField tf = dlg.SubViews.OfType<TextField> ().First (t => t.HasFocus);
         tf.ClearAllSelection ();
         tf.CursorPosition = tf.Text.Length;
         Assert.True (tf.HasFocus);
@@ -321,7 +321,7 @@ public class FileDialogTests ()
     {
         FileDialog dlg = GetInitializedFileDialog ();
 
-        View tf = dlg.Subviews.FirstOrDefault (t => t.HasFocus);
+        View tf = dlg.SubViews.FirstOrDefault (t => t.HasFocus);
         Assert.NotNull (tf);
         Assert.IsType<TextField> (tf);
         dlg.Dispose ();
@@ -793,9 +793,9 @@ public class FileDialogTests ()
         switch (part)
         {
             case FileDialogPart.Path:
-                return dlg.Subviews.OfType<TextField> ().ElementAt (0);
+                return dlg.SubViews.OfType<TextField> ().ElementAt (0);
             case FileDialogPart.SearchField:
-                return dlg.Subviews.OfType<TextField> ().ElementAt (1);
+                return dlg.SubViews.OfType<TextField> ().ElementAt (1);
             default:
                 throw new ArgumentOutOfRangeException (nameof (part), part, null);
         }
@@ -803,8 +803,8 @@ public class FileDialogTests ()
 
     private TableView GetTableView (FileDialog dlg)
     {
-        var tile = dlg.Subviews.OfType<TileView> ().Single ();
-        return (TableView)tile.Tiles.ElementAt (1).ContentView.Subviews.ElementAt(0);
+        var tile = dlg.SubViews.OfType<TileView> ().Single ();
+        return (TableView)tile.Tiles.ElementAt (1).ContentView.SubViews.ElementAt(0);
     }
 
     private enum FileDialogPart

+ 154 - 3
Tests/UnitTests/TestsAllViews.cs

@@ -1,5 +1,6 @@
 #nullable enable
-
+using System.Drawing;
+using System.Reflection;
 using Terminal.Gui;
 
 namespace UnitTests;
@@ -9,13 +10,23 @@ namespace UnitTests;
 /// </summary>
 public class TestsAllViews
 {
+    /// <summary>
+    ///     Gets all view types.
+    /// </summary>
     public static IEnumerable<object []> AllViewTypes =>
         typeof (View).Assembly
                      .GetTypes ()
-                     .Where (type => type.IsClass && !type.IsAbstract && type.IsPublic && (type.IsSubclassOf (typeof (View)) || type == typeof (View)))
+                     .Where (
+                             type => type is { IsClass: true, IsAbstract: false, IsPublic: true }
+                                     && (type.IsSubclassOf (typeof (View)) || type == typeof (View)))
                      .Select (type => new object [] { type });
 
-    public static View CreateInstanceIfNotGeneric (Type type)
+    /// <summary>
+    ///    Creates an instance of a view if it is not a generic type.
+    /// </summary>
+    /// <param name="type"></param>
+    /// <returns></returns>
+    public static View? CreateInstanceIfNotGeneric (Type type)
     {
         if (type.IsGenericType)
         {
@@ -25,4 +36,144 @@ public class TestsAllViews
 
         return Activator.CreateInstance (type) as View;
     }
+
+    /// <summary>
+    ///     Gets a list of all view classes.
+    /// </summary>
+    /// <returns></returns>
+    public static List<Type> GetAllViewClasses ()
+    {
+        return typeof (View).Assembly.GetTypes ()
+                            .Where (
+                                    myType => myType is { IsClass: true, IsAbstract: false, IsPublic: true }
+                                              && myType.IsSubclassOf (typeof (View))
+                                   )
+                            .ToList ();
+    }
+
+    /// <summary>
+    ///     Creates a view from a type.
+    /// </summary>
+    /// <param name="type">The type.</param>
+    /// <param name="ctor">The constructor to call.</param>
+    /// <returns></returns>
+    public static View? CreateViewFromType (Type type, ConstructorInfo ctor)
+    {
+        View? viewType = null;
+
+        if (type is { IsGenericType: true, IsTypeDefinition: true })
+        {
+            List<Type> gTypes = new ();
+
+            foreach (Type args in type.GetGenericArguments ())
+            {
+                gTypes.Add (typeof (object));
+            }
+
+            type = type.MakeGenericType (gTypes.ToArray ());
+
+            Assert.IsType (type, (View)Activator.CreateInstance (type)!);
+        }
+        else
+        {
+            ParameterInfo [] paramsInfo = ctor.GetParameters ();
+            Type paramType;
+            List<object> pTypes = new ();
+
+            if (type.IsGenericType)
+            {
+                foreach (Type args in type.GetGenericArguments ())
+                {
+                    paramType = args.GetType ();
+
+                    if (args.Name == "T")
+                    {
+                        pTypes.Add (typeof (object));
+                    }
+                    else
+                    {
+                        AddArguments (paramType, pTypes);
+                    }
+                }
+            }
+
+            foreach (ParameterInfo p in paramsInfo)
+            {
+                paramType = p.ParameterType;
+
+                if (p.HasDefaultValue)
+                {
+                    pTypes.Add (p.DefaultValue!);
+                }
+                else
+                {
+                    AddArguments (paramType, pTypes);
+                }
+            }
+
+            if (type is { IsGenericType: true, IsTypeDefinition: false })
+            {
+                viewType = Activator.CreateInstance (type) as View;
+            }
+            else
+            {
+                viewType = (View)ctor.Invoke (pTypes.ToArray ());
+            }
+
+            Assert.IsType (type, viewType);
+        }
+
+        return viewType;
+    }
+
+    private static void AddArguments (Type paramType, List<object> pTypes)
+    {
+        if (paramType == typeof (Rectangle))
+        {
+            pTypes.Add (Rectangle.Empty);
+        }
+        else if (paramType == typeof (string))
+        {
+            pTypes.Add (string.Empty);
+        }
+        else if (paramType == typeof (int))
+        {
+            pTypes.Add (0);
+        }
+        else if (paramType == typeof (bool))
+        {
+            pTypes.Add (true);
+        }
+        else if (paramType.Name == "IList")
+        {
+            pTypes.Add (new List<object> ());
+        }
+        else if (paramType.Name == "View")
+        {
+            var top = new Toplevel ();
+            var view = new View ();
+            top.Add (view);
+            pTypes.Add (view);
+        }
+        else if (paramType.Name == "View[]")
+        {
+            pTypes.Add (new View [] { });
+        }
+        else if (paramType.Name == "Stream")
+        {
+            pTypes.Add (new MemoryStream ());
+        }
+        else if (paramType.Name == "String")
+        {
+            pTypes.Add (string.Empty);
+        }
+        else if (paramType.Name == "TreeView`1[T]")
+        {
+            pTypes.Add (string.Empty);
+        }
+        else
+        {
+            pTypes.Add (null!);
+        }
+    }
 }

+ 37 - 38
Tests/UnitTests/Text/AutocompleteTests.cs

@@ -1,6 +1,5 @@
 using System.Text.RegularExpressions;
 using UnitTests;
-using UnitTests;
 using Xunit.Abstractions;
 
 namespace Terminal.Gui.TextTests;
@@ -26,87 +25,87 @@ public class AutocompleteTests (ITestOutputHelper output)
         for (var i = 0; i < 7; i++)
         {
             Assert.True (tv.NewKeyDownEvent (Key.CursorRight));
-            top.SetNeedsDraw();
+            top.SetNeedsDraw ();
             Application.RunIteration (ref rs);
 
             if (i < 4 || i > 5)
             {
                 DriverAssert.AssertDriverContentsWithFrameAre (
-                                                              @"
+                                                               @"
 This a long line and against TextView.",
-                                                              output
-                                                             );
+                                                               output
+                                                              );
             }
             else
             {
                 DriverAssert.AssertDriverContentsWithFrameAre (
-                                                              @"
+                                                               @"
 This a long line and against TextView.
      and                              
      against                          ",
-                                                              output
-                                                             );
+                                                               output
+                                                              );
             }
         }
 
         Assert.True (
                      tv.NewMouseEvent (
-                                       new() { Position = new (6, 0), Flags = MouseFlags.Button1Pressed }
+                                       new () { Position = new (6, 0), Flags = MouseFlags.Button1Pressed }
                                       )
                     );
         top.SetNeedsDraw ();
         Application.RunIteration (ref rs);
 
         DriverAssert.AssertDriverContentsWithFrameAre (
-                                                      @"
+                                                       @"
 This a long line and against TextView.
      and                              
      against                          ",
-                                                      output
-                                                     );
+                                                       output
+                                                      );
 
         Assert.True (tv.NewKeyDownEvent (Key.G));
         top.SetNeedsDraw ();
         Application.RunIteration (ref rs);
 
         DriverAssert.AssertDriverContentsWithFrameAre (
-                                                      @"
+                                                       @"
 This ag long line and against TextView.
      against                           ",
-                                                      output
-                                                     );
+                                                       output
+                                                      );
 
         Assert.True (tv.NewKeyDownEvent (Key.CursorLeft));
         top.SetNeedsDraw ();
         Application.RunIteration (ref rs);
 
         DriverAssert.AssertDriverContentsWithFrameAre (
-                                                      @"
+                                                       @"
 This ag long line and against TextView.
      against                           ",
-                                                      output
-                                                     );
+                                                       output
+                                                      );
 
         Assert.True (tv.NewKeyDownEvent (Key.CursorLeft));
         top.SetNeedsDraw ();
         Application.RunIteration (ref rs);
 
         DriverAssert.AssertDriverContentsWithFrameAre (
-                                                      @"
+                                                       @"
 This ag long line and against TextView.
      against                           ",
-                                                      output
-                                                     );
+                                                       output
+                                                      );
 
         Assert.True (tv.NewKeyDownEvent (Key.CursorLeft));
         top.SetNeedsDraw ();
         Application.RunIteration (ref rs);
 
         DriverAssert.AssertDriverContentsWithFrameAre (
-                                                      @"
+                                                       @"
 This ag long line and against TextView.",
-                                                      output
-                                                     );
+                                                       output
+                                                      );
 
         for (var i = 0; i < 3; i++)
         {
@@ -115,11 +114,11 @@ This ag long line and against TextView.",
             Application.RunIteration (ref rs);
 
             DriverAssert.AssertDriverContentsWithFrameAre (
-                                                          @"
+                                                           @"
 This ag long line and against TextView.
      against                           ",
-                                                          output
-                                                         );
+                                                           output
+                                                          );
         }
 
         Assert.True (tv.NewKeyDownEvent (Key.Backspace));
@@ -127,33 +126,33 @@ This ag long line and against TextView.
         Application.RunIteration (ref rs);
 
         DriverAssert.AssertDriverContentsWithFrameAre (
-                                                      @"
+                                                       @"
 This a long line and against TextView.
      and                              
      against                          ",
-                                                      output
-                                                     );
+                                                       output
+                                                      );
 
         Assert.True (tv.NewKeyDownEvent (Key.N));
         top.SetNeedsDraw ();
         Application.RunIteration (ref rs);
 
         DriverAssert.AssertDriverContentsWithFrameAre (
-                                                      @"
+                                                       @"
 This an long line and against TextView.
      and                               ",
-                                                      output
-                                                     );
+                                                       output
+                                                      );
 
         Assert.True (tv.NewKeyDownEvent (Key.CursorRight));
         top.SetNeedsDraw ();
         Application.RunIteration (ref rs);
 
         DriverAssert.AssertDriverContentsWithFrameAre (
-                                                      @"
+                                                       @"
 This an long line and against TextView.",
-                                                      output
-                                                     );
+                                                       output
+                                                      );
         top.Dispose ();
     }
 
@@ -257,7 +256,7 @@ This an long line and against TextView.",
         var ac = new TextViewAutocomplete ();
 
         ((SingleWordSuggestionGenerator)ac.SuggestionGenerator).AllSuggestions =
-            new() { "fish", "const", "Cobble" };
+            new () { "fish", "const", "Cobble" };
 
         var tv = new TextView ();
         tv.InsertText ("co");
@@ -285,7 +284,7 @@ This an long line and against TextView.",
         Assert.Same (Colors.ColorSchemes ["Menu"], tv.Autocomplete.ColorScheme);
 
         // allocate a new custom scheme
-        tv.Autocomplete.ColorScheme = new()
+        tv.Autocomplete.ColorScheme = new ()
         {
             Normal = new (Color.Black, Color.Blue), Focus = new (Color.Black, Color.Cyan)
         };

+ 10 - 12
Tests/UnitTests/Text/TextFormatterTests.cs

@@ -1,5 +1,4 @@
 using System.Text;
-using UnitTests;
 using UICatalog;
 using UnitTests;
 using Xunit.Abstractions;
@@ -13,7 +12,6 @@ public class TextFormatterTests
     public TextFormatterTests (ITestOutputHelper output) { _output = output; }
     private readonly ITestOutputHelper _output;
 
-
     public static IEnumerable<object []> CMGlyphs =>
         new List<object []> { new object [] { $"{Glyphs.LeftBracket} Say Hello 你 {Glyphs.RightBracket}", 16, 15 } };
 
@@ -3954,22 +3952,22 @@ ssb
         Assert.False (tf.FillRemaining);
 
         DriverAssert.AssertDriverContentsWithFrameAre (
-                                                      @"
+                                                       @"
  Test          
  Test long     
  Test long long",
-                                                      _output);
+                                                       _output);
 
         DriverAssert.AssertDriverAttributesAre (
-                                               @"
+                                                @"
 000000000000000000000
 011110000000000000000
 011111111100000000000
 011111111111111000000
 000000000000000000000",
-                                               _output,
-                                               null,
-                                               attrs);
+                                                _output,
+                                                null,
+                                                attrs);
 
         tf.FillRemaining = true;
 
@@ -3979,15 +3977,15 @@ ssb
                  attrs [2]);
 
         DriverAssert.AssertDriverAttributesAre (
-                                               @"
+                                                @"
 000000000000000000000
 011111111111111111110
 011111111111111111110
 011111111111111111110
 000000000000000000000",
-                                               _output,
-                                               null,
-                                               attrs);
+                                                _output,
+                                                null,
+                                                attrs);
     }
 
     [SetupFakeDriver]

+ 0 - 1
Tests/UnitTests/UnitTests.csproj

@@ -60,7 +60,6 @@
 	<ItemGroup>
 		<Folder Include="Input\Keyboard\" />
 		<Folder Include="Input\Mouse\" />
-		<Folder Include="View\Orientation\" />
 	</ItemGroup>
 	<PropertyGroup Label="FineCodeCoverage">
 		<Enabled>

+ 2 - 3
Tests/UnitTests/View/Adornment/BorderTests.cs

@@ -1,5 +1,4 @@
 using UnitTests;
-using UnitTests;
 using Xunit.Abstractions;
 
 namespace Terminal.Gui.ViewTests;
@@ -17,7 +16,7 @@ public class BorderTests (ITestOutputHelper output)
         var view = new View { Title = "A", Height = 2, Width = 5 };
         superView.Add (view);
 
-        view.Border.Thickness = new (0, 1, 0, 0);
+        view.Border!.Thickness = new (0, 1, 0, 0);
         view.Border.LineStyle = LineStyle.Single;
 
         view.ColorScheme = new ()
@@ -838,7 +837,7 @@ public class BorderTests (ITestOutputHelper output)
 │ ┊ ┊
 └─┴┄┘")]
     [SetupFakeDriver]
-    public void SuperViewRendersLineCanvas_No_Subviews_AutoJoinsLines (bool superViewRendersLineCanvas, string expected)
+    public void SuperViewRendersLineCanvas_No_SubViews_AutoJoinsLines (bool superViewRendersLineCanvas, string expected)
     {
         View superView = new View ()
         {

+ 1 - 2
Tests/UnitTests/View/Adornment/MarginTests.cs

@@ -1,5 +1,4 @@
 using UnitTests;
-using UnitTests;
 using Xunit.Abstractions;
 
 namespace Terminal.Gui.ViewTests;
@@ -13,7 +12,7 @@ public class MarginTests (ITestOutputHelper output)
         ((FakeDriver)Application.Driver!).SetBufferSize (5, 5);
 
         var view = new View { Height = 3, Width = 3 };
-        view.Margin.Diagnostics = ViewDiagnosticFlags.Thickness;
+        view.Margin!.Diagnostics = ViewDiagnosticFlags.Thickness;
         view.Margin.Thickness = new (1);
 
         Application.Top = new Toplevel ();

+ 1 - 2
Tests/UnitTests/View/Adornment/PaddingTests.cs

@@ -1,5 +1,4 @@
 using UnitTests;
-using UnitTests;
 using Xunit.Abstractions;
 
 namespace Terminal.Gui.ViewTests;
@@ -12,7 +11,7 @@ public class PaddingTests (ITestOutputHelper output)
     {
         ((FakeDriver)Application.Driver!).SetBufferSize (5, 5);
         var view = new View { Height = 3, Width = 3 };
-        view.Padding.Thickness = new (1);
+        view.Padding!.Thickness = new (1);
         view.Padding.Diagnostics = ViewDiagnosticFlags.Thickness;
 
         view.ColorScheme = new()

+ 37 - 0
Tests/UnitTests/View/Adornment/ShadowStyletests.cs → Tests/UnitTests/View/Adornment/ShadowStyleTests.cs

@@ -124,4 +124,41 @@ public class ShadowStyleTests (ITestOutputHelper output)
         view.Dispose ();
         Application.ResetState (true);
     }
+
+
+    [Theory]
+    [InlineData (ShadowStyle.None, 0, 0, 0, 0)]
+    [InlineData (ShadowStyle.Opaque, 1, 0, 0, 1)]
+    [InlineData (ShadowStyle.Transparent, 1, 0, 0, 1)]
+    public void ShadowStyle_Button1Pressed_Causes_Movement (ShadowStyle style, int expectedLeft, int expectedTop, int expectedRight, int expectedBottom)
+    {
+        var superView = new View
+        {
+            Height = 10, Width = 10
+        };
+
+        View view = new ()
+        {
+            Width = Dim.Auto (),
+            Height = Dim.Auto (),
+            Text = "0123",
+            HighlightStyle = HighlightStyle.Pressed,
+            ShadowStyle = style,
+            CanFocus = true
+        };
+
+        superView.Add (view);
+        superView.BeginInit ();
+        superView.EndInit ();
+
+        Thickness origThickness = view.Margin!.Thickness;
+        view.NewMouseEvent (new () { Flags = MouseFlags.Button1Pressed, Position = new (0, 0) });
+        Assert.Equal (new (expectedLeft, expectedTop, expectedRight, expectedBottom), view.Margin.Thickness);
+
+        view.NewMouseEvent (new () { Flags = MouseFlags.Button1Released, Position = new (0, 0) });
+        Assert.Equal (origThickness, view.Margin.Thickness);
+
+        // Button1Pressed, Button1Released cause Application.MouseGrabView to be set
+        Application.ResetState (true);
+    }
 }

+ 5 - 6
Tests/UnitTests/View/Draw/AllViewsDrawTests.cs

@@ -1,10 +1,9 @@
 using UnitTests;
-using UnitTests;
 using Xunit.Abstractions;
 
 namespace Terminal.Gui.LayoutTests;
 
-public class AllViewsDrawTests (ITestOutputHelper _output) : TestsAllViews
+public class AllViewsDrawTests (ITestOutputHelper output) : TestsAllViews
 {
     [Theory]
     [SetupFakeDriver] // Required for spinner view that wants to register timeouts
@@ -19,12 +18,12 @@ public class AllViewsDrawTests (ITestOutputHelper _output) : TestsAllViews
 
         if (view == null)
         {
-            _output.WriteLine ($"Ignoring {viewType} - It's a Generic");
+            output.WriteLine ($"Ignoring {viewType} - It's a Generic");
 
             return;
         }
 
-        _output.WriteLine ($"Testing {viewType}");
+        output.WriteLine ($"Testing {viewType}");
 
         if (view is IDesignable designable)
         {
@@ -35,10 +34,10 @@ public class AllViewsDrawTests (ITestOutputHelper _output) : TestsAllViews
         view.DrawComplete += (s, e) => drawCompleteCount++;
 
         var layoutStartedCount = 0;
-        view.SubviewLayout += (s, e) => layoutStartedCount++;
+        view.SubViewLayout += (s, e) => layoutStartedCount++;
 
         var layoutCompleteCount = 0;
-        view.SubviewsLaidOut += (s, e) => layoutCompleteCount++;
+        view.SubViewsLaidOut += (s, e) => layoutCompleteCount++;
 
         view.SetNeedsLayout ();
         view.Layout ();

+ 51 - 53
Tests/UnitTests/View/Draw/ClearViewportTests.cs

@@ -1,38 +1,36 @@
 #nullable enable
 using Moq;
 using UnitTests;
-using UnitTests;
 using Xunit.Abstractions;
 
 namespace Terminal.Gui.ViewTests;
 
 [Trait ("Category", "Output")]
-public class ClearViewportTests (ITestOutputHelper _output)
+public class ClearViewportTests (ITestOutputHelper output)
 {
     public class TestableView : View
     {
         public bool TestOnClearingViewport () { return OnClearingViewport (); }
 
-        public int OnClearingViewportCalled { get; set; } = 0;
-        public bool CancelOnClearingViewport { get; set;  }
+        public int OnClearingViewportCalled { get; set; }
+        public bool CancelOnClearingViewport { get; set; }
+
         protected override bool OnClearingViewport ()
         {
             OnClearingViewportCalled++;
+
             return CancelOnClearingViewport;
         }
 
-        public int OnClearedViewportCalled { get; set; } = 0;
-        protected override void OnClearedViewport ()
-        {
-            OnClearedViewportCalled++;
-        }
+        public int OnClearedViewportCalled { get; set; }
+        protected override void OnClearedViewport () { OnClearedViewportCalled++; }
     }
 
     [Fact]
     public void DoClearViewport_ViewportIsTransparent_DoesNotClear ()
     {
         // Arrange
-        Mock<TestableView> view = new Mock<TestableView> { CallBase = true };
+        Mock<TestableView> view = new () { CallBase = true };
         view.Object.ViewportSettings = ViewportSettings.Transparent;
 
         // Act
@@ -47,7 +45,7 @@ public class ClearViewportTests (ITestOutputHelper _output)
     public void DoClearViewport_OnClearingViewportReturnsTrue_DoesNotClear ()
     {
         // Arrange
-        Mock<TestableView> view = new Mock<TestableView> { CallBase = true };
+        Mock<TestableView> view = new () { CallBase = true };
         view.Object.CancelOnClearingViewport = true;
 
         // Act
@@ -61,7 +59,7 @@ public class ClearViewportTests (ITestOutputHelper _output)
     public void DoClearViewport_ClearingViewportEventCancelled_DoesNotClear ()
     {
         // Arrange
-        Mock<TestableView> view = new Mock<TestableView> { CallBase = true };
+        Mock<TestableView> view = new () { CallBase = true };
         view.Object.ClearingViewport += (sender, e) => e.Cancel = true;
 
         // Act
@@ -75,7 +73,7 @@ public class ClearViewportTests (ITestOutputHelper _output)
     public void DoClearViewport_ClearsViewport ()
     {
         // Arrange
-        Mock<TestableView> view = new Mock<TestableView> { CallBase = true };
+        Mock<TestableView> view = new () { CallBase = true };
 
         // Act
         view.Object.DoClearViewport ();
@@ -88,7 +86,7 @@ public class ClearViewportTests (ITestOutputHelper _output)
     public void DoClearViewport_RaisesClearingViewportEvent ()
     {
         // Arrange
-        Mock<TestableView> view = new Mock<TestableView> { CallBase = true };
+        Mock<TestableView> view = new () { CallBase = true };
         var eventRaised = false;
         view.Object.ClearingViewport += (sender, e) => eventRaised = true;
 
@@ -115,37 +113,37 @@ public class ClearViewportTests (ITestOutputHelper _output)
         superView.Add (view);
         superView.BeginInit ();
         superView.EndInit ();
-        superView.LayoutSubviews ();
+        superView.LayoutSubViews ();
 
         superView.Draw ();
 
         DriverAssert.AssertDriverContentsWithFrameAre (
-                                                      @"
+                                                       @"
  ┌─┐
  │X│
  └─┘",
-                                                      _output);
+                                                       output);
 
         // On Draw exit the view is excluded from the clip, so this will do nothing.
         view.ClearViewport ();
 
         DriverAssert.AssertDriverContentsWithFrameAre (
-                                                      @"
+                                                       @"
  ┌─┐
  │X│
  └─┘",
-                                                      _output);
+                                                       output);
 
         View.SetClipToScreen ();
 
         view.ClearViewport ();
 
         DriverAssert.AssertDriverContentsWithFrameAre (
-                                                      @"
+                                                       @"
  ┌─┐
  │ │
  └─┘",
-                                                      _output);
+                                                       output);
     }
 
     [Fact]
@@ -165,25 +163,25 @@ public class ClearViewportTests (ITestOutputHelper _output)
         superView.Add (view);
         superView.BeginInit ();
         superView.EndInit ();
-        superView.LayoutSubviews ();
+        superView.LayoutSubViews ();
 
         superView.Draw ();
 
         DriverAssert.AssertDriverContentsWithFrameAre (
-                                                      @"
+                                                       @"
  ┌─┐
  │X│
  └─┘",
-                                                      _output);
+                                                       output);
         View.SetClipToScreen ();
         view.ClearViewport ();
 
         DriverAssert.AssertDriverContentsWithFrameAre (
-                                                      @"
+                                                       @"
  ┌─┐
  │ │
  └─┘",
-                                                      _output);
+                                                       output);
     }
 
     [Fact]
@@ -194,7 +192,7 @@ public class ClearViewportTests (ITestOutputHelper _output)
 
         view.DrawingContent += (s, e) =>
                                {
-                                   Region savedClip = view.AddViewportToClip ();
+                                   Region? savedClip = view.AddViewportToClip ();
 
                                    for (var row = 0; row < view.Viewport.Height; row++)
                                    {
@@ -228,7 +226,7 @@ public class ClearViewportTests (ITestOutputHelper _output)
 "
             ;
 
-        Rectangle pos = DriverAssert.AssertDriverContentsWithFrameAre (expected, _output);
+        Rectangle pos = DriverAssert.AssertDriverContentsWithFrameAre (expected, output);
         Assert.Equal (new (0, 0, 20, 10), pos);
 
         view.FillRect (view.Viewport);
@@ -247,7 +245,7 @@ public class ClearViewportTests (ITestOutputHelper _output)
 "
             ;
 
-        pos = DriverAssert.AssertDriverContentsWithFrameAre (expected, _output);
+        pos = DriverAssert.AssertDriverContentsWithFrameAre (expected, output);
         top.Dispose ();
     }
 
@@ -259,7 +257,7 @@ public class ClearViewportTests (ITestOutputHelper _output)
 
         view.DrawingContent += (s, e) =>
                                {
-                                   Region savedClip = view.AddViewportToClip ();
+                                   Region? savedClip = view.AddViewportToClip ();
 
                                    for (var row = 0; row < view.Viewport.Height; row++)
                                    {
@@ -293,7 +291,7 @@ public class ClearViewportTests (ITestOutputHelper _output)
 "
             ;
 
-        Rectangle pos = DriverAssert.AssertDriverContentsWithFrameAre (expected, _output);
+        Rectangle pos = DriverAssert.AssertDriverContentsWithFrameAre (expected, output);
         Assert.Equal (new (0, 0, 20, 10), pos);
 
         view.FillRect (view.Viewport);
@@ -311,7 +309,7 @@ public class ClearViewportTests (ITestOutputHelper _output)
 └──────────────────┘
 ";
 
-        pos = DriverAssert.AssertDriverContentsWithFrameAre (expected, _output);
+        pos = DriverAssert.AssertDriverContentsWithFrameAre (expected, output);
 
         top.Dispose ();
     }
@@ -353,39 +351,39 @@ public class ClearViewportTests (ITestOutputHelper _output)
         }
 
         DriverAssert.AssertDriverContentsWithFrameAre (
-                                                      @"
+                                                       @"
 cccccccccccccccccccc",
-                                                      _output
-                                                     );
+                                                       output
+                                                      );
 
         Attribute [] attributes =
         {
-            Colors.ColorSchemes ["TopLevel"].Normal,
-            Colors.ColorSchemes ["Base"].Normal,
-            Colors.ColorSchemes ["Base"].Focus
+            Colors.ColorSchemes ["TopLevel"]!.Normal,
+            Colors.ColorSchemes ["Base"]!.Normal,
+            Colors.ColorSchemes ["Base"]!.Focus
         };
 
         if (label)
         {
             DriverAssert.AssertDriverAttributesAre (
-                                                   @"
+                                                    @"
 111111111111111111110
 111111111111111111110",
-                                                   _output,
-                                                   Application.Driver,
-                                                   attributes
-                                                  );
+                                                    output,
+                                                    Application.Driver,
+                                                    attributes
+                                                   );
         }
         else
         {
             DriverAssert.AssertDriverAttributesAre (
-                                                   @"
+                                                    @"
 222222222222222222220
 111111111111111111110",
-                                                   _output,
-                                                   Application.Driver,
-                                                   attributes
-                                                  );
+                                                    output,
+                                                    Application.Driver,
+                                                    attributes
+                                                   );
         }
 
         if (label)
@@ -398,13 +396,13 @@ cccccccccccccccccccc",
             Application.LayoutAndDraw ();
 
             DriverAssert.AssertDriverAttributesAre (
-                                                   @"
+                                                    @"
 222222222222222222220
 111111111111111111110",
-                                                   _output,
-                                                   Application.Driver,
-                                                   attributes
-                                                  );
+                                                    output,
+                                                    Application.Driver,
+                                                    attributes
+                                                   );
         }
 
         Application.End (runState);

+ 1 - 1
Tests/UnitTests/View/Draw/ClipTests.cs

@@ -79,7 +79,7 @@ public class ClipTests (ITestOutputHelper _output)
         superView.Add (view);
         superView.BeginInit ();
         superView.EndInit ();
-        superView.LayoutSubviews ();
+        superView.LayoutSubViews ();
 
         superView.Draw ();
 

+ 44 - 44
Tests/UnitTests/View/Draw/DrawTests.cs

@@ -6,7 +6,7 @@ using Xunit.Abstractions;
 namespace Terminal.Gui.ViewTests;
 
 [Trait ("Category", "Output")]
-public class DrawTests (ITestOutputHelper _output)
+public class DrawTests (ITestOutputHelper output)
 {
 
     [Fact]
@@ -41,9 +41,9 @@ public class DrawTests (ITestOutputHelper _output)
                                       │豈      │
                                       └────────┘
                                       """;
-        DriverAssert.AssertDriverContentsWithFrameAre (expectedOutput, _output);
+        DriverAssert.AssertDriverContentsWithFrameAre (expectedOutput, output);
 
-        DriverAssert.AssertDriverContentsAre (expectedOutput, _output);
+        DriverAssert.AssertDriverContentsAre (expectedOutput, output);
 
         // This test has nothing to do with color - removing as it is not relevant and fragile
         top.Dispose ();
@@ -91,7 +91,7 @@ public class DrawTests (ITestOutputHelper _output)
                                                       s     
                                                       t     
                                                       """,
-                                                      _output
+                                                      output
                                                      );
 
         DriverAssert.AssertDriverAttributesAre (
@@ -105,7 +105,7 @@ public class DrawTests (ITestOutputHelper _output)
                                                0
                                                0
                                                """,
-                                               _output,
+                                               output,
                                                Application.Driver,
                                                Colors.ColorSchemes ["Base"]!.Normal
                                               );
@@ -133,7 +133,7 @@ public class DrawTests (ITestOutputHelper _output)
                                                       ┌┐
                                                       └┘
                                                       """,
-                                                      _output
+                                                      output
                                                      );
     }
 
@@ -152,7 +152,7 @@ public class DrawTests (ITestOutputHelper _output)
 
         view.Draw ();
 
-        DriverAssert.AssertDriverContentsWithFrameAre ("──", _output);
+        DriverAssert.AssertDriverContentsWithFrameAre ("──", output);
     }
 
     [Fact]
@@ -176,7 +176,7 @@ public class DrawTests (ITestOutputHelper _output)
                                                       """,
-                                                      _output
+                                                      output
                                                      );
     }
 
@@ -201,7 +201,7 @@ public class DrawTests (ITestOutputHelper _output)
                                                       """,
-                                                      _output
+                                                      output
                                                      );
     }
 
@@ -223,7 +223,7 @@ public class DrawTests (ITestOutputHelper _output)
 
         DriverAssert.AssertDriverContentsWithFrameAre (
                                                       "││",
-                                                      _output
+                                                      output
                                                      );
     }
 
@@ -300,7 +300,7 @@ public class DrawTests (ITestOutputHelper _output)
                                                        3V
                                                        4i
                                                       """,
-                                                      _output
+                                                      output
                                                      );
 
         content.X = -1;
@@ -315,12 +315,12 @@ public class DrawTests (ITestOutputHelper _output)
                                                        V
                                                        i
                                                       """,
-                                                      _output
+                                                      output
                                                      );
 
         content.X = -2;
         Application.LayoutAndDraw ();
-        DriverAssert.AssertDriverContentsWithFrameAre (@"", _output);
+        DriverAssert.AssertDriverContentsWithFrameAre (@"", output);
 
         content.X = 0;
         content.Y = -1;
@@ -335,7 +335,7 @@ public class DrawTests (ITestOutputHelper _output)
                                                        4i
                                                        5e
                                                       """,
-                                                      _output
+                                                      output
                                                      );
 
         content.Y = -6;
@@ -350,7 +350,7 @@ public class DrawTests (ITestOutputHelper _output)
                                                        9 
                                                        0 
                                                       """,
-                                                      _output
+                                                      output
                                                      );
 
         content.Y = -19;
@@ -361,17 +361,17 @@ public class DrawTests (ITestOutputHelper _output)
                                                       
                                                        9
                                                       """,
-                                                      _output
+                                                      output
                                                      );
 
         content.Y = -20;
         Application.LayoutAndDraw ();
-        DriverAssert.AssertDriverContentsWithFrameAre ("", _output);
+        DriverAssert.AssertDriverContentsWithFrameAre ("", output);
 
         content.X = -2;
         content.Y = 0;
         Application.LayoutAndDraw ();
-        DriverAssert.AssertDriverContentsWithFrameAre ("", _output);
+        DriverAssert.AssertDriverContentsWithFrameAre ("", output);
         top.Dispose ();
     }
 
@@ -407,7 +407,7 @@ public class DrawTests (ITestOutputHelper _output)
 
         // BUGBUG: v2 - it's bogus to reference .Frame before BeginInit. And why is the clip being set anyway???
 
-        top.SubviewsLaidOut += Top_LayoutComplete;
+        top.SubViewsLaidOut += Top_LayoutComplete;
         Application.Begin (top);
 
         Application.LayoutAndDraw ();
@@ -417,7 +417,7 @@ public class DrawTests (ITestOutputHelper _output)
                                                        01234
                                                        subVi
                                                       """,
-                                                      _output
+                                                      output
                                                      );
 
         content.X = -1;
@@ -429,7 +429,7 @@ public class DrawTests (ITestOutputHelper _output)
                                                        12345
                                                        ubVie
                                                       """,
-                                                      _output
+                                                      output
                                                      );
 
         content.Y = -1;
@@ -440,17 +440,17 @@ public class DrawTests (ITestOutputHelper _output)
                                                       
                                                        ubVie
                                                       """,
-                                                      _output
+                                                      output
                                                      );
 
         content.Y = -2;
         Application.LayoutAndDraw ();
-        DriverAssert.AssertDriverContentsWithFrameAre ("", _output);
+        DriverAssert.AssertDriverContentsWithFrameAre ("", output);
 
         content.X = -20;
         content.Y = 0;
         Application.LayoutAndDraw ();
-        DriverAssert.AssertDriverContentsWithFrameAre ("", _output);
+        DriverAssert.AssertDriverContentsWithFrameAre ("", output);
         top.Dispose ();
 
         return;
@@ -507,7 +507,7 @@ public class DrawTests (ITestOutputHelper _output)
                                                        3V
                                                        4i
                                                       """,
-                                                      _output
+                                                      output
                                                      );
 
         content.X = -1;
@@ -522,12 +522,12 @@ public class DrawTests (ITestOutputHelper _output)
                                                        V
                                                        i
                                                       """,
-                                                      _output
+                                                      output
                                                      );
 
         content.X = -2;
         Application.LayoutAndDraw ();
-        DriverAssert.AssertDriverContentsWithFrameAre (@"", _output);
+        DriverAssert.AssertDriverContentsWithFrameAre (@"", output);
 
         content.X = 0;
         content.Y = -1;
@@ -542,7 +542,7 @@ public class DrawTests (ITestOutputHelper _output)
                                                        4i
                                                        5e
                                                       """,
-                                                      _output
+                                                      output
                                                      );
 
         content.Y = -6;
@@ -557,7 +557,7 @@ public class DrawTests (ITestOutputHelper _output)
                                                        9 
                                                        0 
                                                       """,
-                                                      _output
+                                                      output
                                                      );
 
         content.Y = -19;
@@ -568,17 +568,17 @@ public class DrawTests (ITestOutputHelper _output)
                                                       
                                                        9
                                                       """,
-                                                      _output
+                                                      output
                                                      );
 
         content.Y = -20;
         Application.LayoutAndDraw ();
-        DriverAssert.AssertDriverContentsWithFrameAre ("", _output);
+        DriverAssert.AssertDriverContentsWithFrameAre ("", output);
 
         content.X = -2;
         content.Y = 0;
         Application.LayoutAndDraw ();
-        DriverAssert.AssertDriverContentsWithFrameAre ("", _output);
+        DriverAssert.AssertDriverContentsWithFrameAre ("", output);
         top.Dispose ();
     }
 
@@ -591,7 +591,7 @@ public class DrawTests (ITestOutputHelper _output)
         var view = new View { Width = 10, Height = 1 };
         view.DrawHotString (expected, Attribute.Default, Attribute.Default);
 
-        DriverAssert.AssertDriverContentsWithFrameAre (expected, _output);
+        DriverAssert.AssertDriverContentsWithFrameAre (expected, output);
     }
 
     // TODO: The tests below that use Label should use View instead.
@@ -626,9 +626,9 @@ public class DrawTests (ITestOutputHelper _output)
                        │𝔹       │
                        └────────┘
                        """;
-        DriverAssert.AssertDriverContentsWithFrameAre (expected, _output);
+        DriverAssert.AssertDriverContentsWithFrameAre (expected, output);
 
-        DriverAssert.AssertDriverContentsAre (expected, _output);
+        DriverAssert.AssertDriverContentsAre (expected, output);
         top.Dispose ();
 
         // This test has nothing to do with color - removing as it is not relevant and fragile
@@ -695,7 +695,7 @@ At 0,0
   A text with some long width
    and also with two lines.  "
         ,
-                                                      _output
+                                                      output
                                                      );
 
         view.Frame = new (3, 3, 10, 1);
@@ -711,7 +711,7 @@ At 0,0
              
              
    A text wit",
-                                                      _output
+                                                      output
                                                      );
         Application.End (runState);
         top.Dispose ();
@@ -744,7 +744,7 @@ At 0,0
   A text with some long width
    and also with two lines.  "
         ,
-                                                      _output
+                                                      output
                                                      );
 
         view.X = 3;
@@ -764,7 +764,7 @@ At 0,0
              
    A text wit"
         ,
-                                                      _output
+                                                      output
                                                      );
         Application.End (runState);
         top.Dispose ();
@@ -796,7 +796,7 @@ At 0,0
   A text with some long width
    and also with two lines.  "
         ,
-                                                      _output
+                                                      output
                                                      );
 
         view.Frame = new (1, 1, 10, 1);
@@ -810,7 +810,7 @@ At 0,0
 At 0,0     
  A text wit"
         ,
-                                                      _output
+                                                      output
                                                      );
         Application.End (runState);
         top.Dispose ();
@@ -843,7 +843,7 @@ At 0,0
   A text with some long width
    and also with two lines.  "
         ,
-                                                      _output
+                                                      output
                                                      );
 
         view.X = 1;
@@ -862,7 +862,7 @@ At 0,0
 At 0,0     
  A text wit"
         ,
-                                                      _output
+                                                      output
                                                      );
         Application.End (runState);
         top.Dispose ();
@@ -873,7 +873,7 @@ At 0,0
         public bool IsKeyDown { get; set; }
         public bool IsKeyPress { get; set; }
         public bool IsKeyUp { get; set; }
-        public override string Text { get; set; }
+        public override string Text { get; set; } = null!;
 
         protected override bool OnDrawingContent ()
         {

+ 4 - 4
Tests/UnitTests/View/Draw/NeedsDrawTests.cs

@@ -39,13 +39,13 @@ public class NeedsDrawTests ()
 
         RunState runState = Application.Begin (top);
 
-        top.SubviewsLaidOut += (s, e) => { Assert.Equal (new (0, 0, 80, 25), top._needsDrawRect); };
+        top.SubViewsLaidOut += (s, e) => { Assert.Equal (new (0, 0, 80, 25), top._needsDrawRect); };
 
-        frame.SubviewsLaidOut += (s, e) => { Assert.Equal (new (0, 0, 40, 8), frame._needsDrawRect); };
+        frame.SubViewsLaidOut += (s, e) => { Assert.Equal (new (0, 0, 40, 8), frame._needsDrawRect); };
 
-        label.SubviewsLaidOut += (s, e) => { Assert.Equal (new (0, 0, 38, 1), label._needsDrawRect); };
+        label.SubViewsLaidOut += (s, e) => { Assert.Equal (new (0, 0, 38, 1), label._needsDrawRect); };
 
-        view.SubviewsLaidOut += (s, e) => { Assert.Equal (new (0, 0, 13, 1), view._needsDrawRect); };
+        view.SubViewsLaidOut += (s, e) => { Assert.Equal (new (0, 0, 13, 1), view._needsDrawRect); };
 
         Assert.Equal (new (0, 0, 80, 25), top.Frame);
         Assert.Equal (new (20, 8, 40, 8), frame.Frame);

+ 4 - 6
Tests/UnitTests/View/Draw/TransparentTests.cs

@@ -1,13 +1,11 @@
 #nullable enable
-using System.Text;
-using UnitTests;
 using UnitTests;
 using Xunit.Abstractions;
 
 namespace Terminal.Gui.ViewTests;
 
 [Trait ("Category", "Output")]
-public class TransparentTests (ITestOutputHelper _output)
+public class TransparentTests (ITestOutputHelper output)
 {
     [Fact]
     [SetupFakeDriver]
@@ -50,13 +48,13 @@ public class TransparentTests (ITestOutputHelper _output)
 ░┌─────────────┐░░░░
 ░│Sub░░░░░░░░░░│░░░░
 ░└─────────────┘░░░░
-░░░░░░░░░░░░░░░░░░░░", _output);
+░░░░░░░░░░░░░░░░░░░░", output);
     }
 
     [Fact]
     [SetupFakeDriver]
 
-    public void Transparent_Subview_Occludes ()
+    public void Transparent_SubView_Occludes ()
     {
         var super = new View
         {
@@ -104,6 +102,6 @@ public class TransparentTests (ITestOutputHelper _output)
 ░┌─────────────┐░░░░
 ░│░░░subSub░░░░│░░░░
 ░└─────────────┘░░░░
-░░░░░░░░░░░░░░░░░░░░", _output);
+░░░░░░░░░░░░░░░░░░░░", output);
     }
 }

+ 1 - 1
Tests/UnitTests/View/Layout/Dim.Tests.cs

@@ -175,7 +175,7 @@ public class DimTests
                        w.Width = 200;
                        Assert.True (t.NeedsLayout);
                        w.Height = 200;
-                       t.LayoutSubviews ();
+                       t.LayoutSubViews ();
 
                        Assert.Equal ("Absolute(200)", w.Width.ToString ());
                        Assert.Equal ("Absolute(200)", w.Height.ToString ());

+ 4 - 5
Tests/UnitTests/View/Layout/LayoutTests.cs

@@ -1,10 +1,9 @@
 using UnitTests;
-using UnitTests;
 using Xunit.Abstractions;
 
 namespace Terminal.Gui.LayoutTests;
 
-public class LayoutTests (ITestOutputHelper _output) : TestsAllViews
+public class LayoutTests (ITestOutputHelper output) : TestsAllViews
 {
     [Theory]
     [SetupFakeDriver] // Required for spinner view that wants to register timeouts
@@ -19,7 +18,7 @@ public class LayoutTests (ITestOutputHelper _output) : TestsAllViews
 
         if (view == null)
         {
-            _output.WriteLine ($"Ignoring {viewType} - It's a Generic");
+            output.WriteLine ($"Ignoring {viewType} - It's a Generic");
 
             return;
         }
@@ -33,10 +32,10 @@ public class LayoutTests (ITestOutputHelper _output) : TestsAllViews
         view.DrawingContent += (s, e) => drawContentCount++;
 
         var layoutStartedCount = 0;
-        view.SubviewLayout += (s, e) => layoutStartedCount++;
+        view.SubViewLayout += (s, e) => layoutStartedCount++;
 
         var layoutCompleteCount = 0;
-        view.SubviewsLaidOut += (s, e) => layoutCompleteCount++;
+        view.SubViewsLaidOut += (s, e) => layoutCompleteCount++;
 
         view.SetNeedsLayout ();
         view.SetNeedsDraw();

+ 1 - 8
Tests/UnitTests/View/Layout/Pos.AnchorEndTests.cs

@@ -1,15 +1,9 @@
 using UnitTests;
-using UnitTests;
-using Xunit.Abstractions;
-using static Terminal.Gui.Dim;
-using static Terminal.Gui.Pos;
 
 namespace Terminal.Gui.LayoutTests;
 
-public class PosAnchorEndTests (ITestOutputHelper output)
+public class PosAnchorEndTests ()
 {
-    
-
     // TODO: This actually a SetRelativeLayout/LayoutSubViews test and should be moved
     // TODO: A new test that calls SetRelativeLayout directly is needed.
     [Fact]
@@ -72,5 +66,4 @@ public class PosAnchorEndTests (ITestOutputHelper output)
     //    Application.End (rs);
     //    top.Dispose ();
     //}
-
 }

+ 0 - 1
Tests/UnitTests/View/Layout/Pos.CenterTests.cs

@@ -1,5 +1,4 @@
 using UnitTests;
-using UnitTests;
 using Xunit.Abstractions;
 using static Terminal.Gui.Dim;
 using static Terminal.Gui.Pos;

+ 1 - 1
Tests/UnitTests/View/Layout/Pos.CombineTests.cs

@@ -98,7 +98,7 @@ public class PosCombineTests (ITestOutputHelper output)
         f.X = Pos.X (Application.Top) + Pos.X (v2) - Pos.X (v1);
         f.Y = Pos.Y (Application.Top) + Pos.Y (v2) - Pos.Y (v1);
 
-        Application.Top.SubviewsLaidOut += (s, e) =>
+        Application.Top.SubViewsLaidOut += (s, e) =>
         {
             Assert.Equal (0, Application.Top.Frame.X);
             Assert.Equal (0, Application.Top.Frame.Y);

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません