Skip to content

Commit ca163c1

Browse files
committed
fixed warnings about NULL
1 parent b5bd7a5 commit ca163c1

File tree

2 files changed

+22
-21
lines changed

2 files changed

+22
-21
lines changed

Source/VisualPairCoding/VisualPairCoding.AvaloniaUI/EnterNamesWindow.axaml.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ public EnterNamesForm(bool autostart, string configPath)
3434
}
3535
}
3636

37-
private MenuItem? GetRecentMenuItem()
37+
private MenuItem GetRecentMenuItem()
3838
{
39-
return this.FindControl<MenuItem>("recentMenuItem");
39+
return this.FindControl<MenuItem>("recentMenuItem")!;
4040
}
4141

4242
private TimeSpan GetSessionTotalDuration()
@@ -131,7 +131,7 @@ public async void StartForm(object? sender, RoutedEventArgs args)
131131
{
132132
var participants = GetParticipants();
133133
var totalDuration = GetSessionTotalDuration();
134-
var session = new PairCodingSession(participants, (int)minutesPerTurn.Value, GetSessionTotalDuration());
134+
var session = new PairCodingSession(participants, (int)minutesPerTurn.Value!, GetSessionTotalDuration());
135135
var validationMessage = session.Validate();
136136

137137
if (!string.IsNullOrWhiteSpace(validationMessage))
@@ -259,16 +259,16 @@ private static void AddParticipantIfAvailable(string name, List<string> particip
259259
private string[] GetParticipants()
260260
{
261261
var participants = new List<string>();
262-
AddParticipantIfAvailable(participant1.Text, participants);
263-
AddParticipantIfAvailable(participant2.Text, participants);
264-
AddParticipantIfAvailable(participant3.Text, participants);
265-
AddParticipantIfAvailable(participant4.Text, participants);
266-
AddParticipantIfAvailable(participant5.Text, participants);
267-
AddParticipantIfAvailable(participant6.Text, participants);
268-
AddParticipantIfAvailable(participant7.Text, participants);
269-
AddParticipantIfAvailable(participant8.Text, participants);
270-
AddParticipantIfAvailable(participant9.Text, participants);
271-
AddParticipantIfAvailable(participant10.Text, participants);
262+
AddParticipantIfAvailable(participant2.Text ?? string.Empty, participants);
263+
AddParticipantIfAvailable(participant1.Text ?? string.Empty, participants);
264+
AddParticipantIfAvailable(participant3.Text ?? string.Empty, participants);
265+
AddParticipantIfAvailable(participant4.Text ?? string.Empty, participants);
266+
AddParticipantIfAvailable(participant5.Text ?? string.Empty, participants);
267+
AddParticipantIfAvailable(participant6.Text ?? string.Empty, participants);
268+
AddParticipantIfAvailable(participant7.Text ?? string.Empty, participants);
269+
AddParticipantIfAvailable(participant8.Text ?? string.Empty, participants);
270+
AddParticipantIfAvailable(participant9.Text ?? string.Empty, participants);
271+
AddParticipantIfAvailable(participant10.Text ?? string.Empty, participants);
272272

273273
return participants.ToArray();
274274
}

Source/VisualPairCoding/VisualPairCoding.AvaloniaUI/RunSessionForm.axaml.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ namespace VisualPairCoding.AvaloniaUI
1212
{
1313
public partial class RunSessionForm : Window
1414
{
15-
private readonly PairCodingSession _pairCodingSession;
15+
private readonly PairCodingSession? _pairCodingSession;
1616
private TimeSpan _currentTime = TimeSpan.Zero;
1717
private TimeSpan _totalDuration;
1818
private int _currentParticipant = -1;
1919
private readonly Random random = new();
20-
private readonly DispatcherTimer timer;
20+
private readonly DispatcherTimer? timer;
2121
private readonly bool _explicitlyConfirmTurnChange = true;
2222
private bool _totalDurationActivated;
23+
2324
public RunSessionForm()
2425
{
2526
InitializeComponent();
@@ -87,7 +88,7 @@ private void OnPointerLeave(object? sender, PointerEventArgs e)
8788

8889
private void CloseForm(object sender, RoutedEventArgs args)
8990
{
90-
timer.IsEnabled = false;
91+
timer!.IsEnabled = false;
9192
timer.Stop();
9293
Close();
9394
}
@@ -96,7 +97,7 @@ private async void Timer_Tick(object? sender, EventArgs e)
9697
{
9798
if (_totalDuration <= TimeSpan.Zero && _totalDurationActivated)
9899
{
99-
timer.IsEnabled = false;
100+
timer!.IsEnabled = false;
100101
var totalForm = new NewTurnForm(
101102
"Total Duration Exceeded!",
102103
_explicitlyConfirmTurnChange
@@ -129,9 +130,9 @@ private async void Timer_Tick(object? sender, EventArgs e)
129130

130131
private async void ChooseAnotherPairAndStartNewTurn()
131132
{
132-
timer.Stop();
133+
timer!.Stop();
133134

134-
_currentTime = new TimeSpan(0, _pairCodingSession.MinutesPerTurn, 0);
135+
_currentTime = new TimeSpan(0, _pairCodingSession!.MinutesPerTurn, 0);
135136

136137
_currentParticipant += 1;
137138
if (_currentParticipant >= _pairCodingSession.Participants.Length)
@@ -175,7 +176,7 @@ private static string GetRandomNavigatorFromListWithout(string currentlyActivePa
175176

176177
private void PauseButton_Click(object? sender, RoutedEventArgs args)
177178
{
178-
if (timer.IsEnabled)
179+
if (timer!.IsEnabled)
179180
{
180181
PauseButton.Content = "PAUSED";
181182
timer.Stop();
@@ -191,7 +192,7 @@ private void SkipCurrentDriverButton_Click(object? sender, RoutedEventArgs args)
191192
{
192193
Topmost = false;
193194
ChooseAnotherPairAndStartNewTurn();
194-
activeParticipnat.Text = _pairCodingSession.Participants[_currentParticipant];
195+
activeParticipnat.Text = _pairCodingSession!.Participants[_currentParticipant];
195196

196197
remainingTimeLabel.Text = _currentTime.ToString();
197198

0 commit comments

Comments
 (0)