Fixed nullable warnings 7

This commit is contained in:
Tig
2024-07-24 15:09:48 -06:00
parent ff47aa29b9
commit 022050db73
27 changed files with 263 additions and 244 deletions

View File

@@ -527,8 +527,8 @@ public class Buttons : Scenario
}
_value = value;
_number.Text = _value.ToString ();
ValueChanged?.Invoke (this, new (ref _value));
_number.Text = _value.ToString ()!;
ValueChanged?.Invoke (this, new (in _value));
}
}

View File

@@ -205,7 +205,7 @@ public class ListViewWithSelection : Scenario
/// <inheritdoc />
public event NotifyCollectionChangedEventHandler CollectionChanged;
public int Count => Scenarios != null ? Scenarios.Count : 0;
public int Count => Scenarios?.Count ?? 0;
public int Length { get; private set; }
public bool SuspendCollectionChangedEvent { get => throw new System.NotImplementedException (); set => throw new System.NotImplementedException (); }

View File

@@ -1,5 +1,6 @@
using System;
using Terminal.Gui;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace UICatalog.Scenarios;
@@ -64,14 +65,17 @@ public class MenuBarScenario : Scenario
menuBar.Key = KeyCode.F9;
menuBar.Title = "TestMenuBar";
bool fnAction (string s)
bool FnAction (string s)
{
_lastAction.Text = s;
return true;
}
// Declare a variable for the function
Func<string, bool> fnActionVariable = FnAction;
menuBar.EnableForDesign ((Func<string, bool>)fnAction);
menuBar.EnableForDesign (ref fnActionVariable);
menuBar.MenuOpening += (s, e) =>
{

View File

@@ -104,7 +104,7 @@ internal class UICatalogApp
// If no driver is provided, the default driver is used.
Option<string> driverOption = new Option<string> ("--driver", "The ConsoleDriver to use.").FromAmong (
Application.GetDriverTypes ()
.Select (d => d.Name)
.Select (d => d!.Name)
.ToArray ()
);