Browse Source

WIP: fixing nullability issues.

Tig 4 weeks ago
parent
commit
81cc071a6e
100 changed files with 41 additions and 205 deletions
  1. 3 3
      Examples/UICatalog/Scenarios/Themes.cs
  2. 1 3
      Terminal.Gui/App/Application.Keyboard.cs
  3. 1 1
      Terminal.Gui/App/ApplicationImpl.Run.cs
  4. 0 2
      Terminal.Gui/App/CWP/CWPEventHelper.cs
  5. 0 2
      Terminal.Gui/App/CWP/CWPWorkflowHelper.cs
  6. 0 2
      Terminal.Gui/App/CWP/CancelEventArgs.cs
  7. 0 2
      Terminal.Gui/App/CWP/EventArgs.cs
  8. 0 2
      Terminal.Gui/App/CWP/ResultEventArgs.cs
  9. 0 2
      Terminal.Gui/App/CWP/ValueChangedEventArgs.cs
  10. 0 2
      Terminal.Gui/App/CWP/ValueChangingEventArgs.cs
  11. 1 3
      Terminal.Gui/App/Clipboard/Clipboard.cs
  12. 0 3
      Terminal.Gui/App/Clipboard/ClipboardProcessRunner.cs
  13. 0 1
      Terminal.Gui/App/Clipboard/IClipboard.cs
  14. 0 2
      Terminal.Gui/App/Keyboard/IKeyboard.cs
  15. 0 4
      Terminal.Gui/App/Keyboard/KeyboardImpl.cs
  16. 0 4
      Terminal.Gui/App/MainLoop/ApplicationMainLoop.cs
  17. 0 2
      Terminal.Gui/App/MainLoop/IApplicationMainLoop.cs
  18. 0 1
      Terminal.Gui/App/MainLoop/IMainLoopCoordinator.cs
  19. 2 2
      Terminal.Gui/App/MainLoop/MainLoopCoordinator.cs
  20. 0 2
      Terminal.Gui/App/Mouse/IMouseGrabHandler.cs
  21. 0 2
      Terminal.Gui/App/Mouse/MouseGrabHandler.cs
  22. 1 1
      Terminal.Gui/App/SessionToken.cs
  23. 0 2
      Terminal.Gui/App/Timeout/ITimedEvents.cs
  24. 1 3
      Terminal.Gui/App/Timeout/TimedEvents.cs
  25. 1 2
      Terminal.Gui/App/Timeout/Timeout.cs
  26. 0 1
      Terminal.Gui/App/Timeout/TimeoutEventArgs.cs
  27. 0 1
      Terminal.Gui/App/Toplevel/IToplevelTransitionManager.cs
  28. 0 4
      Terminal.Gui/App/Toplevel/ToplevelTransitionManager.cs
  29. 2 2
      Terminal.Gui/Configuration/AttributeJsonConverter.cs
  30. 1 1
      Terminal.Gui/Configuration/ColorJsonConverter.cs
  31. 1 0
      Terminal.Gui/Configuration/ConcurrentDictionaryJsonConverter.cs
  32. 2 1
      Terminal.Gui/Configuration/DictionaryJsonConverter.cs
  33. 2 1
      Terminal.Gui/Configuration/KeyCodeJsonConverter.cs
  34. 1 1
      Terminal.Gui/Configuration/KeyJsonConverter.cs
  35. 1 1
      Terminal.Gui/Configuration/RuneJsonConverter.cs
  36. 1 1
      Terminal.Gui/Drawing/Color/AnsiColorCode.cs
  37. 0 3
      Terminal.Gui/Drawing/Color/AnsiColorNameResolver.cs
  38. 0 1
      Terminal.Gui/Drawing/Color/Color.ColorName.cs
  39. 0 3
      Terminal.Gui/Drawing/Color/ColorModel.cs
  40. 0 1
      Terminal.Gui/Drawing/Color/ColorQuantizer.cs
  41. 0 1
      Terminal.Gui/Drawing/Color/IColorDistance.cs
  42. 0 3
      Terminal.Gui/Drawing/Color/IColorNameResolver.cs
  43. 0 3
      Terminal.Gui/Drawing/Color/MultiStandardColorNameResolver.cs
  44. 0 1
      Terminal.Gui/Drawing/Color/StandardColor.cs
  45. 0 2
      Terminal.Gui/Drawing/Color/StandardColors.cs
  46. 0 3
      Terminal.Gui/Drawing/Color/StandardColorsNameResolver.cs
  47. 0 1
      Terminal.Gui/Drawing/LineCanvas/IntersectionDefinition.cs
  48. 0 1
      Terminal.Gui/Drawing/LineCanvas/IntersectionRuneType.cs
  49. 0 1
      Terminal.Gui/Drawing/LineCanvas/IntersectionType.cs
  50. 3 4
      Terminal.Gui/Drawing/LineCanvas/StraightLineExtensions.cs
  51. 0 1
      Terminal.Gui/Drawing/Quant/EuclideanColorDistance.cs
  52. 0 1
      Terminal.Gui/Drawing/Quant/IPaletteBuilder.cs
  53. 8 12
      Terminal.Gui/Drawing/Quant/PopularityPaletteWithThreshold.cs
  54. 0 1
      Terminal.Gui/Drawing/Sixel/SixelEncoder.cs
  55. 2 2
      Terminal.Gui/Drawing/Sixel/SixelSupportDetector.cs
  56. 0 1
      Terminal.Gui/Drawing/Sixel/SixelSupportResult.cs
  57. 1 2
      Terminal.Gui/Drawing/Sixel/SixelToRender.cs
  58. 0 2
      Terminal.Gui/Drivers/AnsiHandling/AnsiEscapeSequence.cs
  59. 0 3
      Terminal.Gui/Drivers/AnsiHandling/AnsiEscapeSequenceRequest.cs
  60. 0 2
      Terminal.Gui/Drivers/AnsiHandling/AnsiMouseParser.cs
  61. 0 2
      Terminal.Gui/Drivers/AnsiHandling/AnsiRequestScheduler.cs
  62. 0 2
      Terminal.Gui/Drivers/AnsiHandling/AnsiResponseExpectation.cs
  63. 0 3
      Terminal.Gui/Drivers/AnsiHandling/AnsiResponseParser.cs
  64. 0 1
      Terminal.Gui/Drivers/AnsiHandling/AnsiResponseParserState.cs
  65. 0 2
      Terminal.Gui/Drivers/AnsiHandling/EscSeqUtils/EscSeqReqStatus.cs
  66. 0 3
      Terminal.Gui/Drivers/AnsiHandling/EscSeqUtils/EscSeqRequests.cs
  67. 0 2
      Terminal.Gui/Drivers/AnsiHandling/GenericHeld.cs
  68. 0 2
      Terminal.Gui/Drivers/AnsiHandling/IAnsiResponseParser.cs
  69. 0 2
      Terminal.Gui/Drivers/AnsiHandling/IHeld.cs
  70. 0 2
      Terminal.Gui/Drivers/AnsiHandling/Keyboard/AnsiKeyboardParser.cs
  71. 0 3
      Terminal.Gui/Drivers/AnsiHandling/Keyboard/AnsiKeyboardParserPattern.cs
  72. 0 2
      Terminal.Gui/Drivers/AnsiHandling/Keyboard/CsiCursorPattern.cs
  73. 0 2
      Terminal.Gui/Drivers/AnsiHandling/Keyboard/CsiKeyPattern.cs
  74. 0 2
      Terminal.Gui/Drivers/AnsiHandling/Keyboard/EscAsAltPattern.cs
  75. 0 2
      Terminal.Gui/Drivers/AnsiHandling/Keyboard/Ss3Pattern.cs
  76. 0 2
      Terminal.Gui/Drivers/AnsiHandling/ReasonCannotSend.cs
  77. 0 2
      Terminal.Gui/Drivers/AnsiHandling/StringHeld.cs
  78. 0 1
      Terminal.Gui/Drivers/DotNetDriver/INetInput.cs
  79. 0 2
      Terminal.Gui/Drivers/DotNetDriver/NetComponentFactory.cs
  80. 0 2
      Terminal.Gui/Drivers/DotNetDriver/NetInput.cs
  81. 0 1
      Terminal.Gui/Drivers/DotNetDriver/NetInputProcessor.cs
  82. 0 1
      Terminal.Gui/Drivers/DotNetDriver/NetKeyConverter.cs
  83. 0 3
      Terminal.Gui/Drivers/DotNetDriver/NetOutput.cs
  84. 0 2
      Terminal.Gui/Drivers/DotNetDriver/NetWinVTConsole.cs
  85. 0 2
      Terminal.Gui/Drivers/FakeDriver/FakeClipboard.cs
  86. 0 2
      Terminal.Gui/Drivers/FakeDriver/FakeInput.cs
  87. 0 1
      Terminal.Gui/Drivers/UnixDriver/IUnixInput.cs
  88. 0 2
      Terminal.Gui/Drivers/UnixDriver/UnixComponentFactory.cs
  89. 0 2
      Terminal.Gui/Drivers/UnixDriver/UnixInput.cs
  90. 0 1
      Terminal.Gui/Drivers/UnixDriver/UnixInputProcessor.cs
  91. 0 3
      Terminal.Gui/Drivers/UnixDriver/UnixKeyConverter.cs
  92. 1 2
      Terminal.Gui/Drivers/UnixDriver/UnixOutput.cs
  93. 0 2
      Terminal.Gui/Drivers/WindowsDriver/ClipboardImpl.cs
  94. 0 1
      Terminal.Gui/Drivers/WindowsDriver/IWindowsInput.cs
  95. 0 2
      Terminal.Gui/Drivers/WindowsDriver/WindowsComponentFactory.cs
  96. 0 2
      Terminal.Gui/Drivers/WindowsDriver/WindowsInput.cs
  97. 0 2
      Terminal.Gui/Drivers/WindowsDriver/WindowsInputProcessor.cs
  98. 0 3
      Terminal.Gui/Drivers/WindowsDriver/WindowsKeyConverter.cs
  99. 0 2
      Terminal.Gui/Drivers/WindowsDriver/WindowsOutput.cs
  100. 4 4
      Terminal.Gui/FileServices/DefaultSearchMatcher.cs

+ 3 - 3
Examples/UICatalog/Scenarios/Themes.cs

@@ -160,11 +160,11 @@ public sealed class Themes : Scenario
                                                             TabStop = TabBehavior.TabStop
                                                         };
 
-                                                        allViewsView.FocusedChanged += (s, args) =>
+                                                        allViewsView.FocusedChanged += (s, a) =>
                                                                                        {
                                                                                            allViewsView.Title =
-                                                                                               $"All Views - Focused: {args.NewFocused.Title}";
-                                                                                           viewPropertiesEditor.ViewToEdit = args.NewFocused.SubViews.ElementAt(0);
+                                                                                               $"All Views - Focused: {a.NewFocused?.Title}";
+                                                                                           viewPropertiesEditor.ViewToEdit = a.NewFocused?.SubViews.ElementAt(0);
 
                                                                                        };
                                                         appWindow.Add (allViewsView);

+ 1 - 3
Terminal.Gui/App/Application.Keyboard.cs

@@ -1,6 +1,4 @@
-#nullable enable
-
-namespace Terminal.Gui.App;
+namespace Terminal.Gui.App;
 
 public static partial class Application // Keyboard handling
 {

+ 1 - 1
Terminal.Gui/App/ApplicationImpl.Run.cs

@@ -232,7 +232,7 @@ public partial class ApplicationImpl
             ApplicationPopover.HideWithQuitCommand (visiblePopover);
         }
 
-        sessionToken.Toplevel.OnUnloaded ();
+        sessionToken.Toplevel?.OnUnloaded ();
 
         // End the Session
         // First, take it off the Toplevel Stack

+ 0 - 2
Terminal.Gui/App/CWP/CWPEventHelper.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 namespace Terminal.Gui.App;
 
 using System;

+ 0 - 2
Terminal.Gui/App/CWP/CWPWorkflowHelper.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 namespace Terminal.Gui.App;
 
 using System;

+ 0 - 2
Terminal.Gui/App/CWP/CancelEventArgs.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 using System.ComponentModel;
 
 namespace Terminal.Gui.App;

+ 0 - 2
Terminal.Gui/App/CWP/EventArgs.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 namespace Terminal.Gui.App;
 
 #pragma warning disable CS1711

+ 0 - 2
Terminal.Gui/App/CWP/ResultEventArgs.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 namespace Terminal.Gui.App;
 
 using System;

+ 0 - 2
Terminal.Gui/App/CWP/ValueChangedEventArgs.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 namespace Terminal.Gui.App;
 
 /// <summary>

+ 0 - 2
Terminal.Gui/App/CWP/ValueChangingEventArgs.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 namespace Terminal.Gui.App;
 
 /// <summary>

+ 1 - 3
Terminal.Gui/App/Clipboard/Clipboard.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 namespace Terminal.Gui.App;
 
 /// <summary>Provides cut, copy, and paste support for the OS clipboard.</summary>
@@ -32,7 +30,7 @@ public static class Clipboard
                 if (IsSupported)
                 {
                     // throw new InvalidOperationException ($"{Application.Driver?.GetType ().Name}.GetClipboardData returned null instead of string.Empty");
-                    string? clipData = Application.Driver?.Clipboard?.GetClipboardData () ?? string.Empty;
+                    string clipData = Application.Driver?.Clipboard?.GetClipboardData () ?? string.Empty;
 
                     _contents = clipData;
                 }

+ 0 - 3
Terminal.Gui/App/Clipboard/ClipboardProcessRunner.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 using System.Diagnostics;
 
 namespace Terminal.Gui.App;
@@ -46,7 +44,6 @@ internal static class ClipboardProcessRunner
             CreateNoWindow = true
         };
 
-        TaskCompletionSource<bool> eventHandled = new ();
         process.Start ();
 
         if (!string.IsNullOrEmpty (input))

+ 0 - 1
Terminal.Gui/App/Clipboard/IClipboard.cs

@@ -1,4 +1,3 @@
-#nullable disable
 namespace Terminal.Gui.App;
 
 /// <summary>Definition to interact with the OS clipboard.</summary>

+ 0 - 2
Terminal.Gui/App/Keyboard/IKeyboard.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 namespace Terminal.Gui.App;
 
 /// <summary>

+ 0 - 4
Terminal.Gui/App/Keyboard/KeyboardImpl.cs

@@ -1,7 +1,3 @@
-#nullable disable
-#nullable enable
-using System.Diagnostics;
-
 namespace Terminal.Gui.App;
 
 /// <summary>

+ 0 - 4
Terminal.Gui/App/MainLoop/ApplicationMainLoop.cs

@@ -1,9 +1,5 @@
-#nullable disable
-#nullable enable
-using System;
 using System.Collections.Concurrent;
 using System.Diagnostics;
-using Terminal.Gui.Drivers;
 
 namespace Terminal.Gui.App;
 

+ 0 - 2
Terminal.Gui/App/MainLoop/IApplicationMainLoop.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 using System.Collections.Concurrent;
 
 namespace Terminal.Gui.App;

+ 0 - 1
Terminal.Gui/App/MainLoop/IMainLoopCoordinator.cs

@@ -1,4 +1,3 @@
-#nullable disable
 namespace Terminal.Gui.App;
 
 /// <summary>

+ 2 - 2
Terminal.Gui/App/MainLoop/MainLoopCoordinator.cs

@@ -1,5 +1,5 @@
-#nullable disable
-using System.Collections.Concurrent;
+#nullable disable
+using System.Collections.Concurrent;
 
 namespace Terminal.Gui.App;
 

+ 0 - 2
Terminal.Gui/App/Mouse/IMouseGrabHandler.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 namespace Terminal.Gui.App;
 
 /// <summary>

+ 0 - 2
Terminal.Gui/App/Mouse/MouseGrabHandler.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 namespace Terminal.Gui.App;
 
 /// <summary>

+ 1 - 1
Terminal.Gui/App/SessionToken.cs

@@ -10,7 +10,7 @@ public class SessionToken : IDisposable
     public SessionToken (Toplevel view) { Toplevel = view; }
 
     /// <summary>The <see cref="Toplevel"/> belonging to this <see cref="SessionToken"/>.</summary>
-    public Toplevel Toplevel { get; internal set; }
+    public Toplevel? Toplevel { get; internal set; }
 
     /// <summary>Releases all resource used by the <see cref="SessionToken"/> object.</summary>
     /// <remarks>Call <see cref="Dispose()"/> when you are finished using the <see cref="SessionToken"/>.</remarks>

+ 0 - 2
Terminal.Gui/App/Timeout/ITimedEvents.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 namespace Terminal.Gui.App;
 
 /// <summary>

+ 1 - 3
Terminal.Gui/App/Timeout/TimedEvents.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 using System.Diagnostics;
 
 namespace Terminal.Gui.App;
@@ -203,7 +201,7 @@ public class TimedEvents : ITimedEvents
         {
             if (k < now)
             {
-                if (timeout.Callback ())
+                if (timeout.Callback! ())
                 {
                     AddTimeout (timeout.Span, timeout);
                 }

+ 1 - 2
Terminal.Gui/App/Timeout/Timeout.cs

@@ -1,4 +1,3 @@
-#nullable disable
 namespace Terminal.Gui.App;
 
 /// <summary>
@@ -21,7 +20,7 @@ public class Timeout
     ///     rescheduled and invoked again after the same interval.
     ///     If the callback returns <see langword="false"/>, the timeout will be removed and not invoked again.
     /// </value>
-    public Func<bool> Callback { get; set; }
+    public Func<bool>? Callback { get; set; }
 
     /// <summary>
     ///     Gets or sets the time interval to wait before invoking the <see cref="Callback"/>.

+ 0 - 1
Terminal.Gui/App/Timeout/TimeoutEventArgs.cs

@@ -1,4 +1,3 @@
-#nullable disable
 namespace Terminal.Gui.App;
 
 /// <summary><see cref="EventArgs"/> for timeout events (e.g. <see cref="TimedEvents.Added"/>)</summary>

+ 0 - 1
Terminal.Gui/App/Toplevel/IToplevelTransitionManager.cs

@@ -1,4 +1,3 @@
-#nullable disable
 namespace Terminal.Gui.App;
 
 /// <summary>

+ 0 - 4
Terminal.Gui/App/Toplevel/ToplevelTransitionManager.cs

@@ -1,7 +1,3 @@
-#nullable disable
-#nullable enable
-using Terminal.Gui.Drivers;
-
 namespace Terminal.Gui.App;
 
 /// <summary>

+ 2 - 2
Terminal.Gui/Configuration/AttributeJsonConverter.cs

@@ -9,7 +9,7 @@ namespace Terminal.Gui.Configuration;
 
 internal class AttributeJsonConverter : JsonConverter<Attribute>
 {
-    private static AttributeJsonConverter _instance;
+    private static AttributeJsonConverter? _instance;
 
     /// <summary></summary>
     public static AttributeJsonConverter Instance
@@ -63,7 +63,7 @@ internal class AttributeJsonConverter : JsonConverter<Attribute>
                 throw new JsonException ($"{propertyName}: Unexpected token when parsing Attribute: {reader.TokenType}.");
             }
 
-            propertyName = reader.GetString ();
+            propertyName = reader.GetString ()!;
             reader.Read ();
             var property = $"\"{reader.GetString ()}\"";
 

+ 1 - 1
Terminal.Gui/Configuration/ColorJsonConverter.cs

@@ -15,7 +15,7 @@ namespace Terminal.Gui.Configuration;
 /// </summary>
 internal class ColorJsonConverter : JsonConverter<Color>
 {
-    private static ColorJsonConverter _instance;
+    private static ColorJsonConverter? _instance;
 
     /// <summary>Singleton</summary>
     public static ColorJsonConverter Instance

+ 1 - 0
Terminal.Gui/Configuration/ConcurrentDictionaryJsonConverter.cs

@@ -1,3 +1,4 @@
+#nullable disable
 using System.Collections.Concurrent;
 using System.Diagnostics.CodeAnalysis;
 using System.Text.Json;

+ 2 - 1
Terminal.Gui/Configuration/DictionaryJsonConverter.cs

@@ -1,4 +1,5 @@
-using System.Diagnostics.CodeAnalysis;
+#nullable disable
+using System.Diagnostics.CodeAnalysis;
 using System.Text.Json;
 using System.Text.Json.Serialization;
 

+ 2 - 1
Terminal.Gui/Configuration/KeyCodeJsonConverter.cs

@@ -1,4 +1,5 @@
-using System.Text.Json;
+#nullable disable
+using System.Text.Json;
 using System.Text.Json.Serialization;
 
 namespace Terminal.Gui.Configuration;

+ 1 - 1
Terminal.Gui/Configuration/KeyJsonConverter.cs

@@ -9,7 +9,7 @@ public class KeyJsonConverter : JsonConverter<Key>
     /// <inheritdoc/>
     public override Key Read (ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
     {
-        return Key.TryParse (reader.GetString (), out Key key) ? key : Key.Empty;
+        return Key.TryParse (reader.GetString ()!, out Key key) ? key : Key.Empty;
     }
 
     /// <inheritdoc/>

+ 1 - 1
Terminal.Gui/Configuration/RuneJsonConverter.cs

@@ -26,7 +26,7 @@ internal class RuneJsonConverter : JsonConverter<Rune>
         {
             case JsonTokenType.String:
                 {
-                    string value = reader.GetString ();
+                    string? value = reader.GetString ();
                     int first = RuneExtensions.MaxUnicodeCodePoint + 1;
                     int second = RuneExtensions.MaxUnicodeCodePoint + 1;
 

+ 1 - 1
Terminal.Gui/Drawing/Color/AnsiColorCode.cs

@@ -1,4 +1,4 @@
-#nullable disable
+// ReSharper disable InconsistentNaming
 namespace Terminal.Gui.Drawing;
 
 /// <summary>

+ 0 - 3
Terminal.Gui/Drawing/Color/AnsiColorNameResolver.cs

@@ -1,6 +1,3 @@
-#nullable disable
-#nullable enable
-
 using System.Collections.Immutable;
 using System.Diagnostics.CodeAnalysis;
 

+ 0 - 1
Terminal.Gui/Drawing/Color/Color.ColorName.cs

@@ -1,4 +1,3 @@
-#nullable disable
 namespace Terminal.Gui.Drawing;
 
 /// <summary>

+ 0 - 3
Terminal.Gui/Drawing/Color/ColorModel.cs

@@ -1,6 +1,3 @@
-#nullable disable
-#nullable enable
-
 namespace Terminal.Gui.Drawing;
 
 /// <summary>

+ 0 - 1
Terminal.Gui/Drawing/Color/ColorQuantizer.cs

@@ -1,4 +1,3 @@
-#nullable disable
 using System.Collections.Concurrent;
 
 namespace Terminal.Gui.Drawing;

+ 0 - 1
Terminal.Gui/Drawing/Color/IColorDistance.cs

@@ -1,4 +1,3 @@
-#nullable disable
 namespace Terminal.Gui.Drawing;
 
 /// <summary>

+ 0 - 3
Terminal.Gui/Drawing/Color/IColorNameResolver.cs

@@ -1,6 +1,3 @@
-#nullable disable
-#nullable enable
-
 using System.Diagnostics.CodeAnalysis;
 
 namespace Terminal.Gui.Drawing;

+ 0 - 3
Terminal.Gui/Drawing/Color/MultiStandardColorNameResolver.cs

@@ -1,6 +1,3 @@
-#nullable disable
-#nullable enable
-
 using System.Collections.Frozen;
 using System.Collections.Immutable;
 using System.Diagnostics.CodeAnalysis;

+ 0 - 1
Terminal.Gui/Drawing/Color/StandardColor.cs

@@ -1,4 +1,3 @@
-#nullable disable
 namespace Terminal.Gui.Drawing;
 
 /// <summary>

+ 0 - 2
Terminal.Gui/Drawing/Color/StandardColors.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 using System.Collections.Frozen;
 using System.Collections.Immutable;
 using System.Diagnostics.CodeAnalysis;

+ 0 - 3
Terminal.Gui/Drawing/Color/StandardColorsNameResolver.cs

@@ -1,6 +1,3 @@
-#nullable disable
-#nullable enable
-
 using System.Diagnostics.CodeAnalysis;
 
 namespace Terminal.Gui.Drawing;

+ 0 - 1
Terminal.Gui/Drawing/LineCanvas/IntersectionDefinition.cs

@@ -1,4 +1,3 @@
-#nullable disable
 namespace Terminal.Gui.Drawing;
 
 internal class IntersectionDefinition

+ 0 - 1
Terminal.Gui/Drawing/LineCanvas/IntersectionRuneType.cs

@@ -1,4 +1,3 @@
-#nullable disable
 namespace Terminal.Gui.Drawing;
 
 /// <summary>The type of Rune that we will use before considering double width, curved borders etc</summary>

+ 0 - 1
Terminal.Gui/Drawing/LineCanvas/IntersectionType.cs

@@ -1,4 +1,3 @@
-#nullable disable
 namespace Terminal.Gui.Drawing;
 
 internal enum IntersectionType

+ 3 - 4
Terminal.Gui/Drawing/LineCanvas/StraightLineExtensions.cs

@@ -1,5 +1,4 @@
-#nullable disable
-
+
 namespace Terminal.Gui.Drawing;
 
 /// <summary>Extension methods for <see cref="StraightLine"/> (including collections).</summary>
@@ -188,7 +187,7 @@ public static class StraightLineExtensions
     {
         if (length == 0)
         {
-            throw new ArgumentException ("0 length lines are not supported", nameof (length));
+            throw new ArgumentException (@"0 length lines are not supported", nameof (length));
         }
 
         int sub = length > 0 ? 1 : -1;
@@ -221,7 +220,7 @@ public static class StraightLineExtensions
     {
         if (length == 0)
         {
-            throw new ArgumentException ("0 length lines are not supported", nameof (length));
+            throw new ArgumentException (@"0 length lines are not supported", nameof (length));
         }
 
         int sub = length > 0 ? 1 : -1;

+ 0 - 1
Terminal.Gui/Drawing/Quant/EuclideanColorDistance.cs

@@ -1,4 +1,3 @@
-#nullable disable
 namespace Terminal.Gui.Drawing;
 
 /// <summary>

+ 0 - 1
Terminal.Gui/Drawing/Quant/IPaletteBuilder.cs

@@ -1,4 +1,3 @@
-#nullable disable
 namespace Terminal.Gui.Drawing;
 
 /// <summary>

+ 8 - 12
Terminal.Gui/Drawing/Quant/PopularityPaletteWithThreshold.cs

@@ -1,9 +1,9 @@
-#nullable disable
-
+namespace Terminal.Gui.Drawing;
+
 /// <summary>
 ///     Simple fast palette building algorithm which uses the frequency that a color is seen
-///     to determine whether it will appear in the final palette. Includes a threshold where
-///     by colors will be considered 'the same'. This reduces the chance of under represented
+///     to determine whether it will appear in the final palette. Includes a threshold whereby
+///     colors will be considered 'the same'. This reduces the chance of underrepresented
 ///     colors being missed completely.
 /// </summary>
 public class PopularityPaletteWithThreshold : IPaletteBuilder
@@ -23,11 +23,11 @@ public class PopularityPaletteWithThreshold : IPaletteBuilder
     }
 
     /// <inheritdoc/>
-    public List<Color> BuildPalette (List<Color> colors, int maxColors)
+    public List<Color> BuildPalette (List<Color>? colors, int maxColors)
     {
-        if (colors == null || colors.Count == 0 || maxColors <= 0)
+        if (colors is null || colors.Count == 0 || maxColors <= 0)
         {
-            return new ();
+            return [];
         }
 
         // Step 1: Build the histogram of colors (count occurrences)
@@ -35,14 +35,10 @@ public class PopularityPaletteWithThreshold : IPaletteBuilder
 
         foreach (Color color in colors)
         {
-            if (colorHistogram.ContainsKey (color))
+            if (!colorHistogram.TryAdd (color, 1))
             {
                 colorHistogram [color]++;
             }
-            else
-            {
-                colorHistogram [color] = 1;
-            }
         }
 
         // If we already have fewer or equal colors than the limit, no need to merge

+ 0 - 1
Terminal.Gui/Drawing/Sixel/SixelEncoder.cs

@@ -1,4 +1,3 @@
-#nullable disable
 // This code is based on existing implementations of sixel algorithm in MIT licensed open source libraries
 // node-sixel (Typescript) - https://github.com/jerch/node-sixel/tree/master/src
 // Copyright (c) 2019, Joerg Breitbart @license MIT

+ 2 - 2
Terminal.Gui/Drawing/Sixel/SixelSupportDetector.cs

@@ -1,5 +1,5 @@
-#nullable disable
-using System.Text.RegularExpressions;
+#nullable disable
+using System.Text.RegularExpressions;
 
 namespace Terminal.Gui.Drawing;
 

+ 0 - 1
Terminal.Gui/Drawing/Sixel/SixelSupportResult.cs

@@ -1,4 +1,3 @@
-#nullable disable
 namespace Terminal.Gui.Drawing;
 
 /// <summary>

+ 1 - 2
Terminal.Gui/Drawing/Sixel/SixelToRender.cs

@@ -1,4 +1,3 @@
-#nullable disable
 namespace Terminal.Gui.Drawing;
 
 /// <summary>
@@ -11,7 +10,7 @@ public class SixelToRender
     ///     gets or sets the encoded sixel data. Use <see cref="SixelEncoder"/> to convert bitmaps
     ///     into encoded sixel data.
     /// </summary>
-    public string SixelData { get; set; }
+    public string? SixelData { get; set; }
 
     /// <summary>
     ///     gets or sets where to move the cursor to before outputting the <see cref="SixelData"/>.

+ 0 - 2
Terminal.Gui/Drivers/AnsiHandling/AnsiEscapeSequence.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 namespace Terminal.Gui.Drivers;
 
 /// <summary>

+ 0 - 3
Terminal.Gui/Drivers/AnsiHandling/AnsiEscapeSequenceRequest.cs

@@ -1,6 +1,3 @@
-#nullable disable
-#nullable enable
-
 namespace Terminal.Gui.Drivers;
 
 /// <summary>

+ 0 - 2
Terminal.Gui/Drivers/AnsiHandling/AnsiMouseParser.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 using System.Text.RegularExpressions;
 
 namespace Terminal.Gui.Drivers;

+ 0 - 2
Terminal.Gui/Drivers/AnsiHandling/AnsiRequestScheduler.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 using System.Collections.Concurrent;
 
 namespace Terminal.Gui.Drivers;

+ 0 - 2
Terminal.Gui/Drivers/AnsiHandling/AnsiResponseExpectation.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 namespace Terminal.Gui.Drivers;
 
 internal record AnsiResponseExpectation (string? Terminator, Action<IHeld> Response, Action? Abandoned)

+ 0 - 3
Terminal.Gui/Drivers/AnsiHandling/AnsiResponseParser.cs

@@ -1,6 +1,3 @@
-#nullable disable
-#nullable enable
-
 using Microsoft.Extensions.Logging;
 
 namespace Terminal.Gui.Drivers;

+ 0 - 1
Terminal.Gui/Drivers/AnsiHandling/AnsiResponseParserState.cs

@@ -1,4 +1,3 @@
-#nullable disable
 namespace Terminal.Gui.Drivers;
 
 /// <summary>

+ 0 - 2
Terminal.Gui/Drivers/AnsiHandling/EscSeqUtils/EscSeqReqStatus.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 namespace Terminal.Gui.Drivers;
 
 /// <summary>

+ 0 - 3
Terminal.Gui/Drivers/AnsiHandling/EscSeqUtils/EscSeqRequests.cs

@@ -1,6 +1,3 @@
-#nullable disable
-#nullable enable
-
 namespace Terminal.Gui.Drivers;
 
 /// <summary>

+ 0 - 2
Terminal.Gui/Drivers/AnsiHandling/GenericHeld.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 namespace Terminal.Gui.Drivers;
 
 /// <summary>

+ 0 - 2
Terminal.Gui/Drivers/AnsiHandling/IAnsiResponseParser.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 namespace Terminal.Gui.Drivers;
 
 /// <summary>

+ 0 - 2
Terminal.Gui/Drivers/AnsiHandling/IHeld.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 namespace Terminal.Gui.Drivers;
 
 /// <summary>

+ 0 - 2
Terminal.Gui/Drivers/AnsiHandling/Keyboard/AnsiKeyboardParser.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 namespace Terminal.Gui.Drivers;
 
 /// <summary>

+ 0 - 3
Terminal.Gui/Drivers/AnsiHandling/Keyboard/AnsiKeyboardParserPattern.cs

@@ -1,6 +1,3 @@
-#nullable disable
-#nullable enable
-
 namespace Terminal.Gui.Drivers;
 
 /// <summary>

+ 0 - 2
Terminal.Gui/Drivers/AnsiHandling/Keyboard/CsiCursorPattern.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 using System.Text.RegularExpressions;
 
 namespace Terminal.Gui.Drivers;

+ 0 - 2
Terminal.Gui/Drivers/AnsiHandling/Keyboard/CsiKeyPattern.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 using System.Text.RegularExpressions;
 
 namespace Terminal.Gui.Drivers;

+ 0 - 2
Terminal.Gui/Drivers/AnsiHandling/Keyboard/EscAsAltPattern.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 using System.Text.RegularExpressions;
 
 namespace Terminal.Gui.Drivers;

+ 0 - 2
Terminal.Gui/Drivers/AnsiHandling/Keyboard/Ss3Pattern.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 using System.Text.RegularExpressions;
 
 namespace Terminal.Gui.Drivers;

+ 0 - 2
Terminal.Gui/Drivers/AnsiHandling/ReasonCannotSend.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 namespace Terminal.Gui.Drivers;
 
 internal enum ReasonCannotSend

+ 0 - 2
Terminal.Gui/Drivers/AnsiHandling/StringHeld.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 namespace Terminal.Gui.Drivers;
 
 /// <summary>

+ 0 - 1
Terminal.Gui/Drivers/DotNetDriver/INetInput.cs

@@ -1,4 +1,3 @@
-#nullable disable
 namespace Terminal.Gui.Drivers;
 
 /// <summary>

+ 0 - 2
Terminal.Gui/Drivers/DotNetDriver/NetComponentFactory.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 using System.Collections.Concurrent;
 
 namespace Terminal.Gui.Drivers;

+ 0 - 2
Terminal.Gui/Drivers/DotNetDriver/NetInput.cs

@@ -1,6 +1,4 @@
 #nullable disable
-using Microsoft.Extensions.Logging;
-
 namespace Terminal.Gui.Drivers;
 
 /// <summary>

+ 0 - 1
Terminal.Gui/Drivers/DotNetDriver/NetInputProcessor.cs

@@ -1,4 +1,3 @@
-#nullable disable
 using System.Collections.Concurrent;
 
 namespace Terminal.Gui.Drivers;

+ 0 - 1
Terminal.Gui/Drivers/DotNetDriver/NetKeyConverter.cs

@@ -1,4 +1,3 @@
-#nullable disable
 namespace Terminal.Gui.Drivers;
 
 /// <summary>

+ 0 - 3
Terminal.Gui/Drivers/DotNetDriver/NetOutput.cs

@@ -1,6 +1,3 @@
-#nullable disable
-using Microsoft.Extensions.Logging;
-
 namespace Terminal.Gui.Drivers;
 
 /// <summary>

+ 0 - 2
Terminal.Gui/Drivers/DotNetDriver/NetWinVTConsole.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 using System.Runtime.InteropServices;
 
 namespace Terminal.Gui.Drivers;

+ 0 - 2
Terminal.Gui/Drivers/FakeDriver/FakeClipboard.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 namespace Terminal.Gui.Drivers;
 
 /// <summary>

+ 0 - 2
Terminal.Gui/Drivers/FakeDriver/FakeInput.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 using System.Collections.Concurrent;
 
 namespace Terminal.Gui.Drivers;

+ 0 - 1
Terminal.Gui/Drivers/UnixDriver/IUnixInput.cs

@@ -1,4 +1,3 @@
-#nullable disable
 namespace Terminal.Gui.Drivers;
 
 /// <summary>

+ 0 - 2
Terminal.Gui/Drivers/UnixDriver/UnixComponentFactory.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 using System.Collections.Concurrent;
 
 namespace Terminal.Gui.Drivers;

+ 0 - 2
Terminal.Gui/Drivers/UnixDriver/UnixInput.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 using System.Runtime.InteropServices;
 
 // ReSharper disable IdentifierTypo

+ 0 - 1
Terminal.Gui/Drivers/UnixDriver/UnixInputProcessor.cs

@@ -1,4 +1,3 @@
-#nullable disable
 using System.Collections.Concurrent;
 
 namespace Terminal.Gui.Drivers;

+ 0 - 3
Terminal.Gui/Drivers/UnixDriver/UnixKeyConverter.cs

@@ -1,6 +1,3 @@
-#nullable disable
-#nullable enable
-
 namespace Terminal.Gui.Drivers;
 
 /// <summary>

+ 1 - 2
Terminal.Gui/Drivers/UnixDriver/UnixOutput.cs

@@ -1,5 +1,4 @@
-#nullable disable
-#nullable enable   
+
 using System.Runtime.InteropServices;
 using Microsoft.Win32.SafeHandles;
 

+ 0 - 2
Terminal.Gui/Drivers/WindowsDriver/ClipboardImpl.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 using System.ComponentModel;
 using System.Runtime.InteropServices;
 

+ 0 - 1
Terminal.Gui/Drivers/WindowsDriver/IWindowsInput.cs

@@ -1,4 +1,3 @@
-#nullable disable
 namespace Terminal.Gui.Drivers;
 
 /// <summary>

+ 0 - 2
Terminal.Gui/Drivers/WindowsDriver/WindowsComponentFactory.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 using System.Collections.Concurrent;
 
 namespace Terminal.Gui.Drivers;

+ 0 - 2
Terminal.Gui/Drivers/WindowsDriver/WindowsInput.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 using System.Runtime.InteropServices;
 using Microsoft.Extensions.Logging;
 using static Terminal.Gui.Drivers.WindowsConsole;

+ 0 - 2
Terminal.Gui/Drivers/WindowsDriver/WindowsInputProcessor.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 using System.Collections.Concurrent;
 
 namespace Terminal.Gui.Drivers;

+ 0 - 3
Terminal.Gui/Drivers/WindowsDriver/WindowsKeyConverter.cs

@@ -1,6 +1,3 @@
-#nullable disable
-#nullable enable
-
 namespace Terminal.Gui.Drivers;
 
 /// <summary>

+ 0 - 2
Terminal.Gui/Drivers/WindowsDriver/WindowsOutput.cs

@@ -1,5 +1,3 @@
-#nullable disable
-#nullable enable
 using System.ComponentModel;
 using System.Runtime.InteropServices;
 using Microsoft.Extensions.Logging;

+ 4 - 4
Terminal.Gui/FileServices/DefaultSearchMatcher.cs

@@ -4,8 +4,8 @@ namespace Terminal.Gui.FileServices;
 
 internal class DefaultSearchMatcher : ISearchMatcher
 {
-    private string [] terms;
-    public void Initialize (string terms) { this.terms = terms.Split (new [] { " " }, StringSplitOptions.RemoveEmptyEntries); }
+    private string []? _terms;
+    public void Initialize (string terms) { _terms = terms.Split ([" "], StringSplitOptions.RemoveEmptyEntries); }
 
     public bool IsMatch (IFileSystemInfo f)
     {
@@ -15,10 +15,10 @@ internal class DefaultSearchMatcher : ISearchMatcher
         return
 
             // At least one term must match the file name only e.g. "my" in "myfile.csv"
-            terms.Any (t => f.Name.IndexOf (t, StringComparison.OrdinalIgnoreCase) >= 0)
+            _terms!.Any (t => f.Name.IndexOf (t, StringComparison.OrdinalIgnoreCase) >= 0)
             &&
 
             // All terms must exist in full path e.g. "dos my" can match "c:\documents\myfile.csv"
-            terms.All (t => f.FullName.IndexOf (t, StringComparison.OrdinalIgnoreCase) >= 0);
+            _terms!.All (t => f.FullName.IndexOf (t, StringComparison.OrdinalIgnoreCase) >= 0);
     }
 }

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