Przeglądaj źródła

Fixed nullable warnings

Tig 1 rok temu
rodzic
commit
2e0a9a7c68

+ 1 - 1
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"
                 // This occurs when there are multiple overlapped "tops"
                 // E.g. "Mdi" - in the Background Worker Scenario
                 // 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);
                 view = View.FindDeepestView (top, mouseEvent.Position);
 
 
                 if (view is { } && view != OverlappedTop && top != Current && top is { })
                 if (view is { } && view != OverlappedTop && top != Current && top is { })

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

@@ -19,7 +19,7 @@ namespace Terminal.Gui;
 public static partial class Application
 public static partial class Application
 {
 {
     /// <summary>Gets all cultures supported by the application without the invariant language.</summary>
     /// <summary>Gets all cultures supported by the application without the invariant language.</summary>
-    public static List<CultureInfo> SupportedCultures { get; private set; }
+    public static List<CultureInfo>? SupportedCultures { get; private set; }
 
 
     internal static List<CultureInfo> GetSupportedCultures ()
     internal static List<CultureInfo> GetSupportedCultures ()
     {
     {
@@ -257,7 +257,7 @@ public static partial class Application
 
 
             foreach (Toplevel? t in savedToplevels)
             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)
                     lock (_topLevels)
                     {
                     {

+ 3 - 3
Terminal.Gui/View/Layout/ViewLayout.cs

@@ -344,7 +344,7 @@ public partial class View
             if (found is { })
             if (found is { })
             {
             {
                 start = found;
                 start = found;
-                viewportOffset = found.Parent.Frame.Location;
+                viewportOffset = found.Parent?.Frame.Location ?? Point.Empty;
             }
             }
 
 
             int startOffsetX = currentLocation.X - (start.Frame.X + viewportOffset.X);
             int startOffsetX = currentLocation.X - (start.Frame.X + viewportOffset.X);
@@ -796,7 +796,7 @@ public partial class View
                 //}
                 //}
                 if (dv.Target != this)
                 if (dv.Target != this)
                 {
                 {
-                    nEdges.Add ((dv.Target, from));
+                    nEdges.Add ((dv.Target!, from));
                 }
                 }
 
 
                 return;
                 return;
@@ -819,7 +819,7 @@ public partial class View
                 //}
                 //}
                 if (pv.Target != this)
                 if (pv.Target != this)
                 {
                 {
-                    nEdges.Add ((pv.Target, from));
+                    nEdges.Add ((pv.Target!, from));
                 }
                 }
 
 
                 return;
                 return;

+ 2 - 1
Terminal.sln.DotSettings

@@ -1,4 +1,4 @@
-<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
+<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
 	<s:String x:Key="/Default/CodeEditing/GenerateMemberBody/AccessorImplementationKind/@EntryValue">BackingField</s:String>
 	<s:String x:Key="/Default/CodeEditing/GenerateMemberBody/AccessorImplementationKind/@EntryValue">BackingField</s:String>
 	<s:String x:Key="/Default/CodeEditing/GenerateMemberBody/DocumentationGenerationKind/@EntryValue">Inherit</s:String>
 	<s:String x:Key="/Default/CodeEditing/GenerateMemberBody/DocumentationGenerationKind/@EntryValue">Inherit</s:String>
 	<s:Boolean x:Key="/Default/CodeEditing/GenerateMemberBody/PlaceBackingFieldAboveProperty/@EntryValue">True</s:Boolean>
 	<s:Boolean x:Key="/Default/CodeEditing/GenerateMemberBody/PlaceBackingFieldAboveProperty/@EntryValue">True</s:Boolean>
@@ -390,6 +390,7 @@
 	<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=53eecf85_002Dd821_002D40e8_002Dac97_002Dfdb734542b84/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Instance" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Instance fields (not private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;Kind Name="READONLY_FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
 	<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=53eecf85_002Dd821_002D40e8_002Dac97_002Dfdb734542b84/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Instance" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Instance fields (not private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;Kind Name="READONLY_FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
 	<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=70345118_002D4b40_002D4ece_002D937c_002Dbbeb7a0b2e70/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Static fields (not private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
 	<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=70345118_002D4b40_002D4ece_002D937c_002Dbbeb7a0b2e70/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Static fields (not private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
 	<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=a0b4bc4d_002Dd13b_002D4a37_002Db37e_002Dc9c6864e4302/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Any" AccessRightKinds="Any" Description="Types and namespaces"&gt;&lt;ElementKinds&gt;&lt;Kind Name="NAMESPACE" /&gt;&lt;Kind Name="CLASS" /&gt;&lt;Kind Name="STRUCT" /&gt;&lt;Kind Name="ENUM" /&gt;&lt;Kind Name="DELEGATE" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb"&gt;&lt;ExtraRule Prefix="" Suffix="" Style="AaBb_AaBb" /&gt;&lt;/Policy&gt;&lt;/Policy&gt;</s:String>
 	<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=a0b4bc4d_002Dd13b_002D4a37_002Db37e_002Dc9c6864e4302/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Any" AccessRightKinds="Any" Description="Types and namespaces"&gt;&lt;ElementKinds&gt;&lt;Kind Name="NAMESPACE" /&gt;&lt;Kind Name="CLASS" /&gt;&lt;Kind Name="STRUCT" /&gt;&lt;Kind Name="ENUM" /&gt;&lt;Kind Name="DELEGATE" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb"&gt;&lt;ExtraRule Prefix="" Suffix="" Style="AaBb_AaBb" /&gt;&lt;/Policy&gt;&lt;/Policy&gt;</s:String>
+	<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=a4f433b8_002Dabcd_002D4e55_002Da08f_002D82e78cef0f0c/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Any" AccessRightKinds="Any" Description="Local constants"&gt;&lt;ElementKinds&gt;&lt;Kind Name="LOCAL_CONSTANT" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /&gt;&lt;/Policy&gt;</s:String>
 	<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=c873eafb_002Dd57f_002D481d_002D8c93_002D77f6863c2f88/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Static readonly fields (not private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="READONLY_FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
 	<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=c873eafb_002Dd57f_002D481d_002D8c93_002D77f6863c2f88/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Static readonly fields (not private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="READONLY_FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
 	<s:Boolean x:Key="/Default/Environment/InjectedLayers/FileInjectedLayer/=A92AB40A0394A342A0BE0D83FEEA5DBF/@KeyIndexDefined">True</s:Boolean>
 	<s:Boolean x:Key="/Default/Environment/InjectedLayers/FileInjectedLayer/=A92AB40A0394A342A0BE0D83FEEA5DBF/@KeyIndexDefined">True</s:Boolean>
 	<s:String x:Key="/Default/Environment/InjectedLayers/FileInjectedLayer/=A92AB40A0394A342A0BE0D83FEEA5DBF/RelativePath/@EntryValue">..\Terminal.sln.ToDo.DotSettings</s:String>
 	<s:String x:Key="/Default/Environment/InjectedLayers/FileInjectedLayer/=A92AB40A0394A342A0BE0D83FEEA5DBF/RelativePath/@EntryValue">..\Terminal.sln.ToDo.DotSettings</s:String>

+ 5 - 5
UICatalog/UICatalog.cs

@@ -666,7 +666,7 @@ internal class UICatalogApp
 
 
             MiIsMouseDisabled!.Checked = Application.IsMouseDisabled;
             MiIsMouseDisabled!.Checked = Application.IsMouseDisabled;
 
 
-            Application.Top.SetNeedsDisplay ();
+            Application.Top!.SetNeedsDisplay ();
         }
         }
 
 
         public MenuItem []? CreateThemeMenuItems ()
         public MenuItem []? CreateThemeMenuItems ()
@@ -835,7 +835,7 @@ internal class UICatalogApp
                                    }
                                    }
 
 
                                    Diagnostics = _diagnosticFlags;
                                    Diagnostics = _diagnosticFlags;
-                                   Application.Top.SetNeedsDisplay ();
+                                   Application.Top!.SetNeedsDisplay ();
                                };
                                };
                 menuItems.Add (item);
                 menuItems.Add (item);
             }
             }
@@ -1061,7 +1061,7 @@ internal class UICatalogApp
                                                 ShowStatusBar = StatusBar.Visible;
                                                 ShowStatusBar = StatusBar.Visible;
 
 
                                                 int height = StatusBar.Visible ? 1 : 0;
                                                 int height = StatusBar.Visible ? 1 : 0;
-                                                CategoryList.Height = Dim.Fill (height);
+                                                CategoryList!.Height = Dim.Fill (height);
                                                 ScenarioList.Height = Dim.Fill (height);
                                                 ScenarioList.Height = Dim.Fill (height);
 
 
                                                 // ContentPane.Height = Dim.Fill (height);
                                                 // ContentPane.Height = Dim.Fill (height);
@@ -1071,7 +1071,7 @@ internal class UICatalogApp
             }
             }
 
 
             Loaded -= LoadedHandler;
             Loaded -= LoadedHandler;
-            CategoryList.EnsureSelectedItemVisible ();
+            CategoryList!.EnsureSelectedItemVisible ();
             ScenarioList.EnsureSelectedCellIsVisible ();
             ScenarioList.EnsureSelectedCellIsVisible ();
         }
         }
 
 
@@ -1082,7 +1082,7 @@ internal class UICatalogApp
             if (_selectedScenario is null)
             if (_selectedScenario is null)
             {
             {
                 // Save selected item state
                 // Save selected item state
-                _cachedCategoryIndex = CategoryList.SelectedItem;
+                _cachedCategoryIndex = CategoryList!.SelectedItem;
                 _cachedScenarioIndex = ScenarioList.SelectedRow;
                 _cachedScenarioIndex = ScenarioList.SelectedRow;
 
 
                 // Create new instance of scenario (even though Scenarios contains instances)
                 // Create new instance of scenario (even though Scenarios contains instances)

+ 2 - 2
UnitTests/ConsoleDrivers/ClipRegionTests.cs

@@ -7,12 +7,12 @@ namespace Terminal.Gui.DriverTests;
 
 
 public class ClipRegionTests
 public class ClipRegionTests
 {
 {
-    private readonly ITestOutputHelper output;
+    private readonly ITestOutputHelper _output;
 
 
     public ClipRegionTests (ITestOutputHelper output)
     public ClipRegionTests (ITestOutputHelper output)
     {
     {
         ConsoleDriver.RunningUnitTests = true;
         ConsoleDriver.RunningUnitTests = true;
-        this.output = output;
+        this._output = output;
     }
     }
 
 
     [Theory]
     [Theory]