Clear out nullable warnings

This commit is contained in:
Jens True 2022-05-01 22:29:00 +02:00
parent 300377e7ca
commit 660b5a8e49
5 changed files with 25 additions and 17 deletions

@ -40,9 +40,11 @@ namespace Tidstagning
{
get
{
if (Assembly.GetExecutingAssembly().GetName().Version != null)
Version? version = Assembly.GetExecutingAssembly().GetName().Version;
if (version is not null)
{
return Assembly.GetExecutingAssembly().GetName().Version.ToString();
return version.ToString();
}
else
{

@ -12,10 +12,6 @@ namespace Tidstagning
{
public partial class ConfigUI : Form
{
private String OnCommand = "";
private String OffCommand = "";
public ConfigUI()
{
InitializeComponent();

@ -77,7 +77,8 @@ namespace Tidstagning
if (e.RowIndex >= 0 && e.ColumnIndex == grid.Columns["DNF"].Index)
{
entries[e.RowIndex].DNF();
liste.WriteDNF(entries[e.RowIndex]);
if(liste is not null)
liste.WriteDNF(entries[e.RowIndex]);
grid.ClearSelection();
grid.CurrentCell = null;
@ -86,13 +87,15 @@ namespace Tidstagning
if (e.RowIndex >= 0 && e.ColumnIndex == grid.Columns["Complete"].Index)
{
entries[e.RowIndex].Complete();
liste.WriteComplete(entries[e.RowIndex]);
if(liste is not null)
liste.WriteComplete(entries[e.RowIndex]);
grid.ClearSelection();
grid.CurrentCell = null;
entries.RemoveAt(e.RowIndex);
horn.Sound((uint)numericSignalLength.Value);
if(horn is not null)
horn.Sound((uint)numericSignalLength.Value);
}
grid.Refresh();
}
@ -113,7 +116,8 @@ namespace Tidstagning
if (checkStartProcedure.Checked)
{
liste.Write("Automatisk Start Procedure er aktiv.");
startprocedure.setObjects(horn, liste);
if(horn is not null)
startprocedure.setObjects(horn, liste);
}
else
{
@ -126,8 +130,11 @@ namespace Tidstagning
{
btnStop.Enabled = false;
btnStart.Enabled = true;
liste.WriteFooter();
liste.Close();
if (liste is not null)
{
liste.WriteFooter();
liste.Close();
}
checkStartProcedure.Enabled = true;
flowLayoutPanelConfiguration.Enabled = true;
}
@ -140,7 +147,8 @@ namespace Tidstagning
private void btnTest_Click(object sender, EventArgs e)
{
horn.Sound((uint)numericSignalLength.Value);
if(horn is not null)
horn.Sound((uint)numericSignalLength.Value);
}
private void Clock_Tick(object sender, EventArgs e)
@ -154,7 +162,7 @@ namespace Tidstagning
private void comboComport_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboComport.Items.Count != 0)
if (comboComport is not null && comboComport.Items.Count != 0 && comboComport.SelectedItem is not null)
{
horn = new Relay(comboComport.SelectedItem.ToString());
Properties.Settings.Default.ComPort = comboComport.SelectedItem.ToString();

@ -5,9 +5,8 @@ using System.Windows.Forms;
namespace Tidstagning
{
static class Program
class Program
{
public class Options
{
[Option('c', "config", Required = false, HelpText = "Enable configuration menu.")]
@ -20,7 +19,6 @@ namespace Tidstagning
CommandLine.Parser.Default.ParseArguments<Options>(args)
.WithParsed(RunOptions)
.WithNotParsed(HandleParseError);
}
static void RunOptions(Options opts)
{

@ -24,6 +24,10 @@
<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.9.0-preview1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0-preview.3.22175.4" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="7.0.0-preview.3.22175.4" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0-preview.3.22175.4" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0-preview.3.22175.4" />
<PackageReference Include="System.IO.Ports" Version="7.0.0-preview.3.22175.4" />
</ItemGroup>