diff --git a/osu.Framework.Tests/Visual/UserInterface/TestSceneScreenStack.cs b/osu.Framework.Tests/Visual/UserInterface/TestSceneScreenStack.cs
index 7fc25442f6..7474f18455 100644
--- a/osu.Framework.Tests/Visual/UserInterface/TestSceneScreenStack.cs
+++ b/osu.Framework.Tests/Visual/UserInterface/TestSceneScreenStack.cs
@@ -1099,7 +1099,7 @@ public override void OnEntering(ScreenTransitionEvent e)
if (shouldTakeOutLease)
{
- DummyBindable.BindTo(((TestScreen)e.Last).DummyBindable);
+ DummyBindable.BindTo(((TestScreen)e.Last!).DummyBindable);
LeasedCopy = DummyBindable.BeginLease(true);
}
diff --git a/osu.Framework/Graphics/UserInterface/Menu.cs b/osu.Framework/Graphics/UserInterface/Menu.cs
index a4e29179aa..cc7823d39e 100644
--- a/osu.Framework/Graphics/UserInterface/Menu.cs
+++ b/osu.Framework/Graphics/UserInterface/Menu.cs
@@ -496,7 +496,7 @@ private void menuItemClicked(DrawableMenuItem item)
}
// Check if there is a sub menu to display
- if (item.Item.Items?.Count == 0)
+ if (item.Item.Items.Count == 0)
{
// This item must have attempted to invoke an action - close all menus if item allows
if (item.CloseMenuOnClick)
@@ -625,7 +625,7 @@ private void closeFromChild(MenuItem source)
{
if (IsHovered || (parentMenu?.IsHovered ?? false)) return;
- if (triggeringItem?.Item.Items?.Contains(source) ?? triggeringItem == null)
+ if (triggeringItem?.Item.Items.Contains(source) ?? triggeringItem == null)
{
Close();
parentMenu?.closeFromChild(triggeringItem?.Item);
@@ -834,7 +834,7 @@ public MenuItemState State
///
protected bool IsActionable => hasSubmenu || (!Item.Action.Disabled && Item.Action.Value != null);
- private bool hasSubmenu => Item.Items?.Count > 0;
+ private bool hasSubmenu => Item.Items.Count > 0;
///
/// Called after the is modified or the hover state changes.
@@ -892,7 +892,7 @@ protected override bool OnClick(ClickEvent e)
if (!IsActionable)
return true;
- Item.Action.Value.Invoke();
+ Item.Action.Value?.Invoke();
Clicked?.Invoke(this);
return true;
}
diff --git a/osu.Framework/IO/Stores/FontStore.cs b/osu.Framework/IO/Stores/FontStore.cs
index 6893c247df..0ad9094bc3 100644
--- a/osu.Framework/IO/Stores/FontStore.cs
+++ b/osu.Framework/IO/Stores/FontStore.cs
@@ -6,6 +6,7 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading.Tasks;
+using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics.Rendering;
using osu.Framework.Graphics.Textures;
using osu.Framework.Logging;
@@ -142,7 +143,7 @@ public ITexturedCharacterGlyph Get(string fontName, char character)
foreach (var store in glyphStores)
{
if ((string.IsNullOrEmpty(fontName) || fontName == store.FontName) && store.HasGlyph(character))
- return namespacedGlyphCache[key] = new TexturedCharacterGlyph(store.Get(character), Get(textureName), 1 / ScaleAdjust);
+ return namespacedGlyphCache[key] = new TexturedCharacterGlyph(store.Get(character).AsNonNull(), Get(textureName), 1 / ScaleAdjust);
}
foreach (var store in nestedFontStores)
diff --git a/osu.Framework/Input/Events/FocusEvent.cs b/osu.Framework/Input/Events/FocusEvent.cs
index 2bee21d3e0..2c7fba00f0 100644
--- a/osu.Framework/Input/Events/FocusEvent.cs
+++ b/osu.Framework/Input/Events/FocusEvent.cs
@@ -16,7 +16,7 @@ public class FocusEvent : UIEvent
///
public readonly Drawable? PreviouslyFocused;
- public FocusEvent(InputState state, Drawable previouslyFocused)
+ public FocusEvent(InputState state, Drawable? previouslyFocused)
: base(state)
{
PreviouslyFocused = previouslyFocused;
diff --git a/osu.Framework/Input/PassThroughInputManager.cs b/osu.Framework/Input/PassThroughInputManager.cs
index f905ce5b46..014fa8afd9 100644
--- a/osu.Framework/Input/PassThroughInputManager.cs
+++ b/osu.Framework/Input/PassThroughInputManager.cs
@@ -3,6 +3,7 @@
#nullable disable
+using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Graphics;
@@ -181,13 +182,13 @@ protected virtual void SyncInputState(InputState state)
new TouchInput(touchStateDifference.deactivated, false).Apply(CurrentState, this);
new TouchInput(touchStateDifference.activated, true).Apply(CurrentState, this);
- new JoystickButtonInput(state?.Joystick?.Buttons, CurrentState.Joystick.Buttons).Apply(CurrentState, this);
- new JoystickAxisInput(state?.Joystick?.GetAxes()).Apply(CurrentState, this);
+ new JoystickButtonInput(state?.Joystick?.Buttons ?? new ButtonStates(), CurrentState.Joystick.Buttons).Apply(CurrentState, this);
+ new JoystickAxisInput(state?.Joystick?.GetAxes() ?? Array.Empty()).Apply(CurrentState, this);
- new MidiKeyInput(state?.Midi, CurrentState.Midi).Apply(CurrentState, this);
+ new MidiKeyInput(state?.Midi ?? new MidiState(), CurrentState.Midi).Apply(CurrentState, this);
- new TabletPenButtonInput(state?.Tablet.PenButtons, CurrentState.Tablet.PenButtons).Apply(CurrentState, this);
- new TabletAuxiliaryButtonInput(state?.Tablet.AuxiliaryButtons, CurrentState.Tablet.AuxiliaryButtons).Apply(CurrentState, this);
+ new TabletPenButtonInput(state?.Tablet.PenButtons ?? new ButtonStates(), CurrentState.Tablet.PenButtons).Apply(CurrentState, this);
+ new TabletAuxiliaryButtonInput(state?.Tablet.AuxiliaryButtons ?? new ButtonStates(), CurrentState.Tablet.AuxiliaryButtons).Apply(CurrentState, this);
}
}
}
diff --git a/osu.Framework/Screens/ScreenTransitionEvent.cs b/osu.Framework/Screens/ScreenTransitionEvent.cs
index 052dc5a442..e2d4309a19 100644
--- a/osu.Framework/Screens/ScreenTransitionEvent.cs
+++ b/osu.Framework/Screens/ScreenTransitionEvent.cs
@@ -11,14 +11,14 @@ public class ScreenTransitionEvent
///
/// The which has been transitioned from.
///
- public IScreen Last { get; }
+ public IScreen? Last { get; }
///
/// The which has been transitioned to.
///
public IScreen Next { get; }
- public ScreenTransitionEvent(IScreen last, IScreen next)
+ public ScreenTransitionEvent(IScreen? last, IScreen next)
{
Last = last;
Next = next;
diff --git a/osu.Framework/Testing/Drawables/Steps/ToggleStepButton.cs b/osu.Framework/Testing/Drawables/Steps/ToggleStepButton.cs
index a702e357e4..5d2b7d8857 100644
--- a/osu.Framework/Testing/Drawables/Steps/ToggleStepButton.cs
+++ b/osu.Framework/Testing/Drawables/Steps/ToggleStepButton.cs
@@ -9,7 +9,7 @@ namespace osu.Framework.Testing.Drawables.Steps
{
public partial class ToggleStepButton : StepButton
{
- private readonly Action reloadCallback;
+ private readonly Action? reloadCallback;
private static readonly Color4 off_colour = Color4.Red;
private static readonly Color4 on_colour = Color4.YellowGreen;
@@ -17,7 +17,7 @@ public partial class ToggleStepButton : StepButton
public override int RequiredRepetitions => 2;
- public ToggleStepButton(Action reloadCallback)
+ public ToggleStepButton(Action? reloadCallback)
{
this.reloadCallback = reloadCallback;
Action = clickAction;
@@ -28,7 +28,7 @@ private void clickAction()
{
State = !State;
Light.FadeColour(State ? on_colour : off_colour);
- reloadCallback.Invoke(State);
+ reloadCallback?.Invoke(State);
if (!State)
Success();
diff --git a/osu.Framework/Text/TextBuilder.cs b/osu.Framework/Text/TextBuilder.cs
index 7adb636f48..012410812f 100644
--- a/osu.Framework/Text/TextBuilder.cs
+++ b/osu.Framework/Text/TextBuilder.cs
@@ -356,9 +356,9 @@ private bool tryCreateGlyph(char character, out TextBuilderGlyph glyph)
private ITexturedCharacterGlyph getTexturedGlyph(char character)
{
return store.Get(font.FontName, character)
- ?? store.Get(null, character)
+ ?? store.Get(string.Empty, character)
?? store.Get(font.FontName, fallbackCharacter)
- ?? store.Get(null, fallbackCharacter);
+ ?? store.Get(string.Empty, fallbackCharacter);
}
}
}