From 2e0a9a7c688f822adec71c98a6205a17d5c65f6f Mon Sep 17 00:00:00 2001 From: Tig Date: Mon, 22 Jul 2024 16:59:10 -0600 Subject: [PATCH] Fixed nullable warnings --- Terminal.Gui/Application/Application.Mouse.cs | 2 +- Terminal.Gui/Application/Application.cs | 4 ++-- Terminal.Gui/View/Layout/ViewLayout.cs | 6 +++--- Terminal.sln.DotSettings | 3 ++- UICatalog/UICatalog.cs | 10 +++++----- UnitTests/ConsoleDrivers/ClipRegionTests.cs | 4 ++-- 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Terminal.Gui/Application/Application.Mouse.cs b/Terminal.Gui/Application/Application.Mouse.cs index 4d3fb6129..7cad055d5 100644 --- a/Terminal.Gui/Application/Application.Mouse.cs +++ b/Terminal.Gui/Application/Application.Mouse.cs @@ -195,7 +195,7 @@ public static partial class Application // Mouse handling { // This occurs when there are multiple overlapped "tops" // E.g. "Mdi" - in the Background Worker Scenario - View? top = FindDeepestTop (Top, mouseEvent.Position); + View? top = FindDeepestTop (Top!, mouseEvent.Position); view = View.FindDeepestView (top, mouseEvent.Position); if (view is { } && view != OverlappedTop && top != Current && top is { }) diff --git a/Terminal.Gui/Application/Application.cs b/Terminal.Gui/Application/Application.cs index 1561413e9..c8aa2536a 100644 --- a/Terminal.Gui/Application/Application.cs +++ b/Terminal.Gui/Application/Application.cs @@ -19,7 +19,7 @@ namespace Terminal.Gui; public static partial class Application { /// Gets all cultures supported by the application without the invariant language. - public static List SupportedCultures { get; private set; } + public static List? SupportedCultures { get; private set; } internal static List GetSupportedCultures () { @@ -257,7 +257,7 @@ public static partial class Application foreach (Toplevel? t in savedToplevels) { - if (!t.Modal && t != Current && t != top && t != savedToplevels [index]) + if (!t!.Modal && t != Current && t != top && t != savedToplevels [index]) { lock (_topLevels) { diff --git a/Terminal.Gui/View/Layout/ViewLayout.cs b/Terminal.Gui/View/Layout/ViewLayout.cs index 637d1f0ca..4e2531745 100644 --- a/Terminal.Gui/View/Layout/ViewLayout.cs +++ b/Terminal.Gui/View/Layout/ViewLayout.cs @@ -344,7 +344,7 @@ public partial class View if (found is { }) { start = found; - viewportOffset = found.Parent.Frame.Location; + viewportOffset = found.Parent?.Frame.Location ?? Point.Empty; } int startOffsetX = currentLocation.X - (start.Frame.X + viewportOffset.X); @@ -796,7 +796,7 @@ public partial class View //} if (dv.Target != this) { - nEdges.Add ((dv.Target, from)); + nEdges.Add ((dv.Target!, from)); } return; @@ -819,7 +819,7 @@ public partial class View //} if (pv.Target != this) { - nEdges.Add ((pv.Target, from)); + nEdges.Add ((pv.Target!, from)); } return; diff --git a/Terminal.sln.DotSettings b/Terminal.sln.DotSettings index e83ed7026..bf87e5ea9 100644 --- a/Terminal.sln.DotSettings +++ b/Terminal.sln.DotSettings @@ -1,4 +1,4 @@ - + BackingField Inherit True @@ -390,6 +390,7 @@ <Policy><Descriptor Staticness="Instance" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Instance fields (not private)"><ElementKinds><Kind Name="FIELD" /><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /></Policy> <Policy><Descriptor Staticness="Static" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Static fields (not private)"><ElementKinds><Kind Name="FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /></Policy> <Policy><Descriptor Staticness="Any" AccessRightKinds="Any" Description="Types and namespaces"><ElementKinds><Kind Name="NAMESPACE" /><Kind Name="CLASS" /><Kind Name="STRUCT" /><Kind Name="ENUM" /><Kind Name="DELEGATE" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb"><ExtraRule Prefix="" Suffix="" Style="AaBb_AaBb" /></Policy></Policy> + <Policy><Descriptor Staticness="Any" AccessRightKinds="Any" Description="Local constants"><ElementKinds><Kind Name="LOCAL_CONSTANT" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /></Policy> <Policy><Descriptor Staticness="Static" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Static readonly fields (not private)"><ElementKinds><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /></Policy> True ..\Terminal.sln.ToDo.DotSettings diff --git a/UICatalog/UICatalog.cs b/UICatalog/UICatalog.cs index dd4184cb4..f9ac4a503 100644 --- a/UICatalog/UICatalog.cs +++ b/UICatalog/UICatalog.cs @@ -666,7 +666,7 @@ internal class UICatalogApp MiIsMouseDisabled!.Checked = Application.IsMouseDisabled; - Application.Top.SetNeedsDisplay (); + Application.Top!.SetNeedsDisplay (); } public MenuItem []? CreateThemeMenuItems () @@ -835,7 +835,7 @@ internal class UICatalogApp } Diagnostics = _diagnosticFlags; - Application.Top.SetNeedsDisplay (); + Application.Top!.SetNeedsDisplay (); }; menuItems.Add (item); } @@ -1061,7 +1061,7 @@ internal class UICatalogApp ShowStatusBar = StatusBar.Visible; int height = StatusBar.Visible ? 1 : 0; - CategoryList.Height = Dim.Fill (height); + CategoryList!.Height = Dim.Fill (height); ScenarioList.Height = Dim.Fill (height); // ContentPane.Height = Dim.Fill (height); @@ -1071,7 +1071,7 @@ internal class UICatalogApp } Loaded -= LoadedHandler; - CategoryList.EnsureSelectedItemVisible (); + CategoryList!.EnsureSelectedItemVisible (); ScenarioList.EnsureSelectedCellIsVisible (); } @@ -1082,7 +1082,7 @@ internal class UICatalogApp if (_selectedScenario is null) { // Save selected item state - _cachedCategoryIndex = CategoryList.SelectedItem; + _cachedCategoryIndex = CategoryList!.SelectedItem; _cachedScenarioIndex = ScenarioList.SelectedRow; // Create new instance of scenario (even though Scenarios contains instances) diff --git a/UnitTests/ConsoleDrivers/ClipRegionTests.cs b/UnitTests/ConsoleDrivers/ClipRegionTests.cs index 8a90f2e4d..73eff741d 100644 --- a/UnitTests/ConsoleDrivers/ClipRegionTests.cs +++ b/UnitTests/ConsoleDrivers/ClipRegionTests.cs @@ -7,12 +7,12 @@ namespace Terminal.Gui.DriverTests; public class ClipRegionTests { - private readonly ITestOutputHelper output; + private readonly ITestOutputHelper _output; public ClipRegionTests (ITestOutputHelper output) { ConsoleDriver.RunningUnitTests = true; - this.output = output; + this._output = output; } [Theory]