Skip to content

Commit 938428d

Browse files
committed
Resolve new nullability warnings
1 parent dd045f8 commit 938428d

File tree

5 files changed

+11
-6
lines changed

5 files changed

+11
-6
lines changed

osu.Game/Graphics/UserInterface/DrawableStatefulMenuItem.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ protected override bool OnMouseDown(MouseDownEvent e)
3737
private partial class ToggleTextContainer : TextContainer
3838
{
3939
private readonly StatefulMenuItem menuItem;
40-
private readonly Bindable<object> state;
40+
private readonly Bindable<object?> state;
4141
private readonly SpriteIcon stateIcon;
4242

4343
public ToggleTextContainer(StatefulMenuItem menuItem)
@@ -61,7 +61,7 @@ protected override void LoadComplete()
6161
state.BindValueChanged(updateState, true);
6262
}
6363

64-
private void updateState(ValueChangedEvent<object> state)
64+
private void updateState(ValueChangedEvent<object?> state)
6565
{
6666
var icon = menuItem.GetIconForState(state.NewValue);
6767

osu.Game/Graphics/UserInterface/StatefulMenuItem.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ protected StatefulMenuItem(LocalisableString text, Func<object?, object?>? chang
5353
/// </summary>
5454
/// <param name="state">The state to retrieve the relevant icon for.</param>
5555
/// <returns>The icon to be displayed for <paramref name="state"/>.</returns>
56-
public abstract IconUsage? GetIconForState(object state);
56+
public abstract IconUsage? GetIconForState(object? state);
5757
}
5858

5959
public abstract class StatefulMenuItem<T> : StatefulMenuItem
@@ -97,7 +97,7 @@ protected StatefulMenuItem(LocalisableString text, Func<T, T>? changeStateFunc,
9797
State.BindValueChanged(state => base.State.Value = state.NewValue);
9898
}
9999

100-
public sealed override IconUsage? GetIconForState(object state) => GetIconForState((T)state);
100+
public sealed override IconUsage? GetIconForState(object? state) => GetIconForState((T)state!);
101101

102102
/// <summary>
103103
/// Retrieves the icon to be displayed for a state.

osu.Game/Screens/Edit/Setup/ColoursSection.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ protected override void LoadComplete()
6666
syncingColours = true;
6767

6868
comboColours.Colours.Clear();
69-
comboColours.Colours.AddRange(Beatmap.BeatmapSkin?.ComboColours);
69+
comboColours.Colours.AddRange(Beatmap.BeatmapSkin?.ComboColours ?? []);
7070

7171
syncingColours = false;
7272
});

osu.Game/Screens/OnlinePlay/Match/DrawableMatchRoom.cs

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System;
55
using System.ComponentModel;
6+
using System.Diagnostics;
67
using osu.Framework.Allocation;
78
using osu.Framework.Bindables;
89
using osu.Framework.Graphics;
@@ -38,6 +39,10 @@ public DrawableMatchRoom(Room room, bool allowEdit = true)
3839
{
3940
this.allowEdit = allowEdit;
4041

42+
// Roslyn sees required non-nullable property as nullable in constructor,
43+
// as it can't see the implementation provides a fallback.
44+
Debug.Assert(SelectedItem != null);
45+
4146
base.SelectedItem.BindTo(SelectedItem);
4247
}
4348

osu.Game/Screens/Select/SongSelect.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ private void bindBindables()
994994

995995
selectedMods.BindValueChanged(_ =>
996996
{
997-
if (decoupledRuleset.Value.Equals(rulesetNoDebounce))
997+
if (decoupledRuleset.Value?.Equals(rulesetNoDebounce) ?? false)
998998
advancedStats.Mods.Value = selectedMods.Value;
999999
}, true);
10001000

0 commit comments

Comments
 (0)