diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index ccfc888032..e7e7ba5fe7 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -126,12 +126,6 @@ jobs:
with:
dotnet-version: "6.0.x"
- # macOS agents recently have empty NuGet config files, resulting in restore failures,
- # see https://github.com/actions/virtual-environments/issues/5768
- # Add the global nuget package source manually for now.
- - name: Setup NuGet.Config
- run: echo '' > ~/.config/NuGet/NuGet.Config
-
# Contrary to seemingly any other msbuild, msbuild running on macOS/Mono
# cannot accept .sln(f) files as arguments.
# Build just the iOS framework project for now.
diff --git a/SampleGame.Android/SampleGameActivity.cs b/SampleGame.Android/SampleGameActivity.cs
index 25b3c0c134..bdb800d5da 100644
--- a/SampleGame.Android/SampleGameActivity.cs
+++ b/SampleGame.Android/SampleGameActivity.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using Android.App;
using osu.Framework;
using osu.Framework.Android;
diff --git a/osu-framework.sln.DotSettings b/osu-framework.sln.DotSettings
index 6c41a91352..7071a978cb 100644
--- a/osu-framework.sln.DotSettings
+++ b/osu-framework.sln.DotSettings
@@ -801,6 +801,16 @@ See the LICENCE file in the repository root for full licence text.
<Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ TrueTrueTrueTrue
diff --git a/osu.Framework.Android/AndroidGameActivity.cs b/osu.Framework.Android/AndroidGameActivity.cs
index 2b82ce55ad..774ad6f1b5 100644
--- a/osu.Framework.Android/AndroidGameActivity.cs
+++ b/osu.Framework.Android/AndroidGameActivity.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using Android.App;
using Android.Content;
using Android.Content.PM;
@@ -11,7 +9,7 @@
using Android.Views;
using ManagedBass;
using osu.Framework.Bindables;
-using Debug = System.Diagnostics.Debug;
+using osu.Framework.Extensions.ObjectExtensions;
namespace osu.Framework.Android
{
@@ -43,22 +41,17 @@ public abstract class AndroidGameActivity : Activity
///
public SystemUiFlags UIVisibilityFlags
{
- get
- {
- Debug.Assert(Window != null);
- return (SystemUiFlags)Window.DecorView.SystemUiVisibility;
- }
+ get => (SystemUiFlags)Window.AsNonNull().DecorView.SystemUiVisibility;
set
{
- Debug.Assert(Window != null);
systemUiFlags = value;
- Window.DecorView.SystemUiVisibility = (StatusBarVisibility)value;
+ Window.AsNonNull().DecorView.SystemUiVisibility = (StatusBarVisibility)value;
}
}
private SystemUiFlags systemUiFlags;
- private AndroidGameView gameView;
+ private AndroidGameView gameView = null!;
public override void OnTrimMemory([GeneratedEnum] TrimMemory level)
{
@@ -66,7 +59,7 @@ public override void OnTrimMemory([GeneratedEnum] TrimMemory level)
gameView.Host?.Collect();
}
- protected override void OnCreate(Bundle savedInstanceState)
+ protected override void OnCreate(Bundle? savedInstanceState)
{
// The default current directory on android is '/'.
// On some devices '/' maps to the app data directory. On others it maps to the root of the internal storage.
@@ -79,11 +72,9 @@ protected override void OnCreate(Bundle savedInstanceState)
UIVisibilityFlags = SystemUiFlags.LayoutFlags | SystemUiFlags.ImmersiveSticky | SystemUiFlags.HideNavigation | SystemUiFlags.Fullscreen;
- Debug.Assert(Window != null);
-
// Firing up the on-screen keyboard (eg: interacting with textboxes) may cause the UI visibility flags to be altered thus showing the navigation bar and potentially the status bar
// This sets back the UI flags to hidden once the interaction with the on-screen keyboard has finished.
- Window.DecorView.SystemUiVisibilityChange += (_, e) =>
+ Window.AsNonNull().DecorView.SystemUiVisibilityChange += (_, e) =>
{
if ((SystemUiFlags)e.Visibility != systemUiFlags)
{
@@ -93,8 +84,7 @@ protected override void OnCreate(Bundle savedInstanceState)
if (Build.VERSION.SdkInt >= BuildVersionCodes.P)
{
- Debug.Assert(Window.Attributes != null);
- Window.Attributes.LayoutInDisplayCutoutMode = LayoutInDisplayCutoutMode.ShortEdges;
+ Window.AsNonNull().Attributes.AsNonNull().LayoutInDisplayCutoutMode = LayoutInDisplayCutoutMode.ShortEdges;
}
gameView.HostStarted += host =>
@@ -104,9 +94,9 @@ protected override void OnCreate(Bundle savedInstanceState)
RunOnUiThread(() =>
{
if (!allow.NewValue)
- Window.AddFlags(WindowManagerFlags.KeepScreenOn);
+ Window?.AddFlags(WindowManagerFlags.KeepScreenOn);
else
- Window.ClearFlags(WindowManagerFlags.KeepScreenOn);
+ Window?.ClearFlags(WindowManagerFlags.KeepScreenOn);
});
}, true);
};
@@ -141,17 +131,17 @@ public override void OnBackPressed()
// On some devices and keyboard combinations the OnKeyDown event does not propagate the key event to the view.
// Here it is done manually to ensure that the keys actually land in the view.
- public override bool OnKeyDown([GeneratedEnum] Keycode keyCode, KeyEvent e)
+ public override bool OnKeyDown([GeneratedEnum] Keycode keyCode, KeyEvent? e)
{
return gameView.OnKeyDown(keyCode, e);
}
- public override bool OnKeyUp([GeneratedEnum] Keycode keyCode, KeyEvent e)
+ public override bool OnKeyUp([GeneratedEnum] Keycode keyCode, KeyEvent? e)
{
return gameView.OnKeyUp(keyCode, e);
}
- public override bool OnKeyLongPress([GeneratedEnum] Keycode keyCode, KeyEvent e)
+ public override bool OnKeyLongPress([GeneratedEnum] Keycode keyCode, KeyEvent? e)
{
return gameView.OnKeyLongPress(keyCode, e);
}
diff --git a/osu.Framework.Android/AndroidGameHost.cs b/osu.Framework.Android/AndroidGameHost.cs
index 5b92e12ccc..d69ee62775 100644
--- a/osu.Framework.Android/AndroidGameHost.cs
+++ b/osu.Framework.Android/AndroidGameHost.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using System.Collections.Generic;
using System.IO;
using Android.App;
@@ -11,6 +9,7 @@
using osu.Framework.Android.Graphics.Video;
using osu.Framework.Android.Input;
using osu.Framework.Configuration;
+using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics.Textures;
using osu.Framework.Graphics.Video;
using osu.Framework.Input;
@@ -65,7 +64,7 @@ protected override IEnumerable CreateAvailableInputHandlers() =>
public override IEnumerable UserStoragePaths => new[]
{
// not null as internal "external storage" is always available.
- Application.Context.GetExternalFilesDir(string.Empty)!.ToString(),
+ Application.Context.GetExternalFilesDir(string.Empty).AsNonNull().ToString(),
};
public override bool OpenFileExternally(string filename) => false;
diff --git a/osu.Framework.Android/AndroidGameView.cs b/osu.Framework.Android/AndroidGameView.cs
index c0b1967732..15886a19e2 100644
--- a/osu.Framework.Android/AndroidGameView.cs
+++ b/osu.Framework.Android/AndroidGameView.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using System;
using Android.Content;
using Android.Graphics;
@@ -15,19 +13,19 @@
using osu.Framework.Android.Input;
using osu.Framework.Logging;
using osu.Framework.Bindables;
+using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Platform;
using osuTK.Graphics;
-using Debug = System.Diagnostics.Debug;
namespace osu.Framework.Android
{
public class AndroidGameView : osuTK.Android.AndroidGameView
{
- public AndroidGameHost Host { get; private set; }
+ public AndroidGameHost? Host { get; private set; }
- public AndroidGameActivity Activity { get; }
+ public AndroidGameActivity Activity { get; } = null!;
public BindableSafeArea SafeAreaPadding { get; } = new BindableSafeArea();
@@ -62,9 +60,9 @@ public bool PointerCapture
}
}
- private readonly Game game;
+ private readonly Game game = null!;
- private InputMethodManager inputMethodManager;
+ private InputMethodManager? inputMethodManager;
///
/// Whether is active.
@@ -128,8 +126,10 @@ public bool OnCommitText(string text)
return false;
}
- public override bool OnKeyDown([GeneratedEnum] Keycode keyCode, KeyEvent e)
+ public override bool OnKeyDown([GeneratedEnum] Keycode keyCode, KeyEvent? e)
{
+ if (e == null) return base.OnKeyDown(keyCode, e);
+
switch (keyCode)
{
// Do not consume Volume keys, so the system can handle them
@@ -151,14 +151,18 @@ public override bool OnKeyDown([GeneratedEnum] Keycode keyCode, KeyEvent e)
}
}
- public override bool OnKeyLongPress([GeneratedEnum] Keycode keyCode, KeyEvent e)
+ public override bool OnKeyLongPress([GeneratedEnum] Keycode keyCode, KeyEvent? e)
{
+ if (e == null) return base.OnKeyLongPress(keyCode, e);
+
KeyLongPress?.Invoke(keyCode, e);
return true;
}
- public override bool OnKeyUp([GeneratedEnum] Keycode keyCode, KeyEvent e)
+ public override bool OnKeyUp([GeneratedEnum] Keycode keyCode, KeyEvent? e)
{
+ if (e == null) return base.OnKeyUp(keyCode, e);
+
KeyUp?.Invoke(keyCode, e);
return true;
}
@@ -206,12 +210,10 @@ private bool handleException(Exception ex)
///
private void updateSafeArea()
{
- Debug.Assert(Display != null);
-
// compute the usable screen area.
var screenSize = new Point();
- Display.GetRealSize(screenSize);
+ Display.AsNonNull().GetRealSize(screenSize);
var screenArea = new RectangleI(0, 0, screenSize.X, screenSize.Y);
var usableScreenArea = screenArea;
@@ -257,8 +259,10 @@ private void updateSafeArea()
public override bool OnCheckIsTextEditor() => textInputActive;
/// null to disable input methods
- public override IInputConnection OnCreateInputConnection(EditorInfo outAttrs)
+ public override IInputConnection? OnCreateInputConnection(EditorInfo? outAttrs)
{
+ if (outAttrs == null) throw new ArgumentNullException(nameof(outAttrs));
+
// Properly disable native input methods so that the software keyboard doesn't unexpectedly open.
// Eg. when pressing keys on a hardware keyboard.
if (!textInputActive)
@@ -274,7 +278,7 @@ internal void StartTextInput()
textInputActive = true;
Activity.RunOnUiThread(() =>
{
- inputMethodManager.RestartInput(this); // this syncs the Android input method state with `OnCreateInputConnection()`.
+ inputMethodManager?.RestartInput(this); // this syncs the Android input method state with `OnCreateInputConnection()`.
RequestFocus();
inputMethodManager?.ShowSoftInput(this, 0);
});
@@ -285,7 +289,7 @@ internal void StopTextInput()
textInputActive = false;
Activity.RunOnUiThread(() =>
{
- inputMethodManager.RestartInput(this);
+ inputMethodManager?.RestartInput(this);
inputMethodManager?.HideSoftInputFromWindow(WindowToken, HideSoftInputFlags.None);
ClearFocus();
});
@@ -316,27 +320,27 @@ public override void SwapBuffers()
///
/// Invoked on a key down event.
///
- public new event Action KeyDown;
+ public new event Action? KeyDown;
///
/// Invoked on a key up event.
///
- public new event Action KeyUp;
+ public new event Action? KeyUp;
///
/// Invoked on a key long press event.
///
- public event Action KeyLongPress;
+ public event Action? KeyLongPress;
///
/// Invoked when text is committed by an .
///
- public event Action CommitText;
+ public event Action? CommitText;
///
/// Invoked when the has been started on the .
///
- public event Action HostStarted;
+ public event Action? HostStarted;
#endregion
}
diff --git a/osu.Framework.Android/AndroidGameWindow.cs b/osu.Framework.Android/AndroidGameWindow.cs
index 9232c01acc..8a80387045 100644
--- a/osu.Framework.Android/AndroidGameWindow.cs
+++ b/osu.Framework.Android/AndroidGameWindow.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using System;
using System.Collections.Generic;
using osu.Framework.Bindables;
@@ -29,7 +27,7 @@ public override Platform.WindowState WindowState
set { }
}
- public event Action CursorStateChanged;
+ public event Action? CursorStateChanged;
public override CursorState CursorState
{
diff --git a/osu.Framework.Android/AndroidStorage.cs b/osu.Framework.Android/AndroidStorage.cs
index ff8db9559e..6b88be723b 100644
--- a/osu.Framework.Android/AndroidStorage.cs
+++ b/osu.Framework.Android/AndroidStorage.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using osu.Framework.Platform;
namespace osu.Framework.Android
diff --git a/osu.Framework.Android/Graphics/Textures/AndroidTextureLoaderStore.cs b/osu.Framework.Android/Graphics/Textures/AndroidTextureLoaderStore.cs
index 2a2211c982..1f1730db4c 100644
--- a/osu.Framework.Android/Graphics/Textures/AndroidTextureLoaderStore.cs
+++ b/osu.Framework.Android/Graphics/Textures/AndroidTextureLoaderStore.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using System;
using System.IO;
using Android.Graphics;
diff --git a/osu.Framework.Android/Graphics/Video/AndroidVideoDecoder.cs b/osu.Framework.Android/Graphics/Video/AndroidVideoDecoder.cs
index c3011bd12f..1fb151b2e5 100644
--- a/osu.Framework.Android/Graphics/Video/AndroidVideoDecoder.cs
+++ b/osu.Framework.Android/Graphics/Video/AndroidVideoDecoder.cs
@@ -1,17 +1,15 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using System;
using System.Collections.Generic;
-using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using Android.Runtime;
using FFmpeg.AutoGen;
using osu.Framework.Extensions.EnumExtensions;
+using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics.Video;
using osu.Framework.Logging;
@@ -151,11 +149,9 @@ public AndroidVideoDecoder(Stream videoStream)
const string java_vm_field_name = "java_vm";
var jvmPtrInfo = typeof(JNIEnv).GetField(java_vm_field_name, BindingFlags.NonPublic | BindingFlags.Static);
- object jvmPtrObj = jvmPtrInfo?.GetValue(null);
-
- Debug.Assert(jvmPtrObj != null);
+ object? jvmPtrObj = jvmPtrInfo?.GetValue(null);
- int result = av_jni_set_java_vm((void*)(IntPtr)jvmPtrObj, null);
+ int result = av_jni_set_java_vm((void*)(IntPtr)jvmPtrObj.AsNonNull(), null);
if (result < 0)
throw new InvalidOperationException($"Couldn't pass Java VM handle to FFmpeg: ${result}");
}
diff --git a/osu.Framework.Android/Input/AndroidInputConnection.cs b/osu.Framework.Android/Input/AndroidInputConnection.cs
index 3c20157993..1bcdee1fb9 100644
--- a/osu.Framework.Android/Input/AndroidInputConnection.cs
+++ b/osu.Framework.Android/Input/AndroidInputConnection.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using Android.Views;
using Android.Views.InputMethods;
using Java.Lang;
@@ -11,40 +9,43 @@ namespace osu.Framework.Android.Input
{
internal class AndroidInputConnection : BaseInputConnection
{
- public AndroidGameView TargetView { get; set; }
+ private readonly AndroidGameView targetView;
public AndroidInputConnection(AndroidGameView targetView, bool fullEditor)
: base(targetView, fullEditor)
{
- TargetView = targetView;
+ this.targetView = targetView;
}
- public override bool CommitText(ICharSequence text, int newCursorPosition)
+ public override bool CommitText(ICharSequence? text, int newCursorPosition)
{
- if (text.Length() != 0)
+ if (text?.Length() > 0)
{
- TargetView.OnCommitText(text.ToString());
+ targetView.OnCommitText(text.ToString());
return true;
}
return base.CommitText(text, newCursorPosition);
}
- public override bool SendKeyEvent(KeyEvent e)
+ public override bool SendKeyEvent(KeyEvent? e)
{
+ if (e == null)
+ return base.SendKeyEvent(e);
+
switch (e.Action)
{
case KeyEventActions.Down:
- TargetView?.OnKeyDown(e.KeyCode, e);
+ targetView.OnKeyDown(e.KeyCode, e);
return true;
case KeyEventActions.Up:
- TargetView?.OnKeyUp(e.KeyCode, e);
+ targetView.OnKeyUp(e.KeyCode, e);
return true;
case KeyEventActions.Multiple:
- TargetView?.OnKeyDown(e.KeyCode, e);
- TargetView?.OnKeyUp(e.KeyCode, e);
+ targetView.OnKeyDown(e.KeyCode, e);
+ targetView.OnKeyUp(e.KeyCode, e);
return true;
}
diff --git a/osu.Framework.Android/Input/AndroidInputExtensions.cs b/osu.Framework.Android/Input/AndroidInputExtensions.cs
index 550e5008bc..dd3860029f 100644
--- a/osu.Framework.Android/Input/AndroidInputExtensions.cs
+++ b/osu.Framework.Android/Input/AndroidInputExtensions.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using System;
using System.Collections.Generic;
using Android.Views;
diff --git a/osu.Framework.Android/Properties/AssemblyInfo.cs b/osu.Framework.Android/Properties/AssemblyInfo.cs
index 587c7bb43e..16db49e197 100644
--- a/osu.Framework.Android/Properties/AssemblyInfo.cs
+++ b/osu.Framework.Android/Properties/AssemblyInfo.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using System.Runtime.CompilerServices;
using Android;
using Android.App;
diff --git a/osu.Framework.Benchmarks/BenchmarkAggregateBindable.cs b/osu.Framework.Benchmarks/BenchmarkAggregateBindable.cs
index 0fb3de4e28..3e01b96c66 100644
--- a/osu.Framework.Benchmarks/BenchmarkAggregateBindable.cs
+++ b/osu.Framework.Benchmarks/BenchmarkAggregateBindable.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using BenchmarkDotNet.Attributes;
using osu.Framework.Bindables;
diff --git a/osu.Framework.Benchmarks/BenchmarkBeginAbsoluteSequence.cs b/osu.Framework.Benchmarks/BenchmarkBeginAbsoluteSequence.cs
index 26d73f880c..dfdfc81582 100644
--- a/osu.Framework.Benchmarks/BenchmarkBeginAbsoluteSequence.cs
+++ b/osu.Framework.Benchmarks/BenchmarkBeginAbsoluteSequence.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using BenchmarkDotNet.Attributes;
using NUnit.Framework;
using osu.Framework.Graphics;
@@ -16,7 +14,7 @@ namespace osu.Framework.Benchmarks
[MemoryDiagnoser]
public class BenchmarkBeginAbsoluteSequence : GameBenchmark
{
- private TestGame game;
+ private TestGame game = null!;
[Test]
[Benchmark]
@@ -106,9 +104,9 @@ public void VeryNestedRecursive()
private class TestGame : Game
{
- public Container Flat;
- public Container VeryNested;
- public Container SlightlyNested;
+ public Container Flat = null!;
+ public Container VeryNested = null!;
+ public Container SlightlyNested = null!;
protected override void LoadComplete()
{
diff --git a/osu.Framework.Benchmarks/BenchmarkBindableInstantiation.cs b/osu.Framework.Benchmarks/BenchmarkBindableInstantiation.cs
index aa165f4fc2..be5c1cd988 100644
--- a/osu.Framework.Benchmarks/BenchmarkBindableInstantiation.cs
+++ b/osu.Framework.Benchmarks/BenchmarkBindableInstantiation.cs
@@ -1,11 +1,10 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using System;
using BenchmarkDotNet.Attributes;
using osu.Framework.Bindables;
+using osu.Framework.Extensions.ObjectExtensions;
namespace osu.Framework.Benchmarks
{
@@ -21,14 +20,14 @@ public class BenchmarkBindableInstantiation
[Benchmark(Baseline = true)]
public Bindable GetBoundCopyOld() => new BindableOld().GetBoundCopy();
- private class BindableOld : Bindable
+ private class BindableOld : Bindable where T : notnull
{
- public BindableOld(T defaultValue = default)
+ public BindableOld(T defaultValue = default!)
: base(defaultValue)
{
}
- protected override Bindable CreateInstance() => (BindableOld)Activator.CreateInstance(GetType(), Value);
+ protected override Bindable CreateInstance() => (BindableOld)Activator.CreateInstance(GetType(), Value).AsNonNull();
}
}
}
diff --git a/osu.Framework.Benchmarks/BenchmarkBindableList.cs b/osu.Framework.Benchmarks/BenchmarkBindableList.cs
index 1b8646ee0d..6154505ffa 100644
--- a/osu.Framework.Benchmarks/BenchmarkBindableList.cs
+++ b/osu.Framework.Benchmarks/BenchmarkBindableList.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using BenchmarkDotNet.Attributes;
using osu.Framework.Bindables;
diff --git a/osu.Framework.Benchmarks/BenchmarkButtonInput.cs b/osu.Framework.Benchmarks/BenchmarkButtonInput.cs
index 73d7012aa9..e101a85442 100644
--- a/osu.Framework.Benchmarks/BenchmarkButtonInput.cs
+++ b/osu.Framework.Benchmarks/BenchmarkButtonInput.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using System.Collections.Generic;
using BenchmarkDotNet.Attributes;
using osu.Framework.Input.StateChanges;
diff --git a/osu.Framework.Benchmarks/BenchmarkButtonStates.cs b/osu.Framework.Benchmarks/BenchmarkButtonStates.cs
index cf85a9f368..7e29887be9 100644
--- a/osu.Framework.Benchmarks/BenchmarkButtonStates.cs
+++ b/osu.Framework.Benchmarks/BenchmarkButtonStates.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using BenchmarkDotNet.Attributes;
using osu.Framework.Input.States;
using osuTK.Input;
diff --git a/osu.Framework.Benchmarks/BenchmarkCompositeDrawableAllocations.cs b/osu.Framework.Benchmarks/BenchmarkCompositeDrawableAllocations.cs
index 7f14d3e91c..0513c02066 100644
--- a/osu.Framework.Benchmarks/BenchmarkCompositeDrawableAllocations.cs
+++ b/osu.Framework.Benchmarks/BenchmarkCompositeDrawableAllocations.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using BenchmarkDotNet.Attributes;
using NUnit.Framework;
using osu.Framework.Graphics;
@@ -13,7 +11,7 @@ namespace osu.Framework.Benchmarks
{
public class BenchmarkCompositeDrawableAllocations : GameBenchmark
{
- private TestGame game;
+ private TestGame game = null!;
[Test]
[Benchmark]
@@ -65,7 +63,7 @@ protected override void Update()
{
base.Update();
- Drawable drawable = null;
+ Drawable? drawable = null;
switch (Mode)
{
diff --git a/osu.Framework.Benchmarks/BenchmarkDependencyContainer.cs b/osu.Framework.Benchmarks/BenchmarkDependencyContainer.cs
index 96cf5b37c8..5cab656f7b 100644
--- a/osu.Framework.Benchmarks/BenchmarkDependencyContainer.cs
+++ b/osu.Framework.Benchmarks/BenchmarkDependencyContainer.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using System.Threading;
using BenchmarkDotNet.Attributes;
using JetBrains.Annotations;
@@ -20,9 +18,9 @@ namespace osu.Framework.Benchmarks
{
public class BenchmarkDependencyContainer : GameBenchmark
{
- private Game game;
- private TestBdlReceiver bdlReceiver;
- private TestCachedReceiver cachedReceiver;
+ private Game game = null!;
+ private TestBdlReceiver bdlReceiver = null!;
+ private TestCachedReceiver cachedReceiver = null!;
public override void SetUp()
{
@@ -65,13 +63,13 @@ private void load(Game game, TextureStore textures, AudioManager audio)
private class TestCachedReceiver : Drawable
{
[Resolved]
- private GameHost host { get; set; }
+ private GameHost host { get; set; } = null!;
[Resolved]
- private FrameworkConfigManager frameworkConfigManager { get; set; }
+ private FrameworkConfigManager frameworkConfigManager { get; set; } = null!;
[Resolved]
- private FrameworkDebugConfigManager frameworkDebugConfigManager { get; set; }
+ private FrameworkDebugConfigManager frameworkDebugConfigManager { get; set; } = null!;
}
private class TestGame : Game
diff --git a/osu.Framework.Benchmarks/BenchmarkDrawableAudioWrapper.cs b/osu.Framework.Benchmarks/BenchmarkDrawableAudioWrapper.cs
index 896a4624e3..bd71549745 100644
--- a/osu.Framework.Benchmarks/BenchmarkDrawableAudioWrapper.cs
+++ b/osu.Framework.Benchmarks/BenchmarkDrawableAudioWrapper.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using BenchmarkDotNet.Attributes;
using NUnit.Framework;
using osu.Framework.Graphics;
@@ -39,7 +37,7 @@ private class TestGame : Game
public bool TransferBetween { get; set; }
- private AudioContainer lastContainer;
+ private AudioContainer? lastContainer;
protected override void LoadComplete()
{
diff --git a/osu.Framework.Benchmarks/BenchmarkDrawableLoad.cs b/osu.Framework.Benchmarks/BenchmarkDrawableLoad.cs
index b016dd1c4a..441dbebd88 100644
--- a/osu.Framework.Benchmarks/BenchmarkDrawableLoad.cs
+++ b/osu.Framework.Benchmarks/BenchmarkDrawableLoad.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using BenchmarkDotNet.Attributes;
using NUnit.Framework;
using osu.Framework.Graphics;
@@ -16,7 +14,7 @@ namespace osu.Framework.Benchmarks
[MemoryDiagnoser]
public class BenchmarkDrawableLoad : GameBenchmark
{
- private TestGame game;
+ private TestGame game = null!;
private const int nesting_level = 100;
diff --git a/osu.Framework.Benchmarks/BenchmarkEnum.cs b/osu.Framework.Benchmarks/BenchmarkEnum.cs
index 5089c162ab..530bc6b07b 100644
--- a/osu.Framework.Benchmarks/BenchmarkEnum.cs
+++ b/osu.Framework.Benchmarks/BenchmarkEnum.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using System;
using BenchmarkDotNet.Attributes;
using osu.Framework.Extensions.EnumExtensions;
diff --git a/osu.Framework.Benchmarks/BenchmarkFillFlowContainerAllocations.cs b/osu.Framework.Benchmarks/BenchmarkFillFlowContainerAllocations.cs
index abba9cf137..28ce812b67 100644
--- a/osu.Framework.Benchmarks/BenchmarkFillFlowContainerAllocations.cs
+++ b/osu.Framework.Benchmarks/BenchmarkFillFlowContainerAllocations.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using System.Collections.Generic;
using BenchmarkDotNet.Attributes;
using osu.Framework.Graphics;
@@ -14,7 +12,7 @@ namespace osu.Framework.Benchmarks
{
public class BenchmarkFillFlowContainerAllocations : GameBenchmark
{
- private TestGame game;
+ private TestGame game = null!;
[Benchmark]
public void MultipleComputeLayoutPositions()
diff --git a/osu.Framework.Benchmarks/BenchmarkFontLoading.cs b/osu.Framework.Benchmarks/BenchmarkFontLoading.cs
index b044a5d3e8..a98a26fbb4 100644
--- a/osu.Framework.Benchmarks/BenchmarkFontLoading.cs
+++ b/osu.Framework.Benchmarks/BenchmarkFontLoading.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using System;
using System.Diagnostics;
using System.Reflection;
@@ -18,8 +16,8 @@ namespace osu.Framework.Benchmarks
{
public class BenchmarkFontLoading : BenchmarkTest
{
- private NamespacedResourceStore baseResources;
- private TemporaryNativeStorage sharedTemp;
+ private NamespacedResourceStore baseResources = null!;
+ private TemporaryNativeStorage sharedTemp = null!;
public override void SetUp()
{
@@ -32,7 +30,7 @@ public override void SetUp()
[OneTimeTearDown]
public void TearDown()
{
- sharedTemp?.Dispose();
+ sharedTemp.Dispose();
}
[Params(1, 10, 100, 1000, 10000)]
@@ -93,7 +91,7 @@ private void runFor(GlyphStore store)
{
foreach (var p in props)
{
- object propValue = p.GetValue(null);
+ object? propValue = p.GetValue(null);
Debug.Assert(propValue != null);
var icon = (IconUsage)propValue;
diff --git a/osu.Framework.Benchmarks/BenchmarkHashing.cs b/osu.Framework.Benchmarks/BenchmarkHashing.cs
index bd4d99d0bc..5bff2e9be0 100644
--- a/osu.Framework.Benchmarks/BenchmarkHashing.cs
+++ b/osu.Framework.Benchmarks/BenchmarkHashing.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using System;
using System.IO;
using BenchmarkDotNet.Attributes;
@@ -14,7 +12,7 @@ namespace osu.Framework.Benchmarks
public class BenchmarkHashing
{
private const string test_string = @"A string with reasonable length";
- private MemoryStream memoryStream;
+ private MemoryStream memoryStream = null!;
[Benchmark]
public string StringMD5() => test_string.ComputeMD5Hash();
diff --git a/osu.Framework.Benchmarks/BenchmarkInterpolation.cs b/osu.Framework.Benchmarks/BenchmarkInterpolation.cs
index 2cdf9e7a24..962a6f23bc 100644
--- a/osu.Framework.Benchmarks/BenchmarkInterpolation.cs
+++ b/osu.Framework.Benchmarks/BenchmarkInterpolation.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using BenchmarkDotNet.Attributes;
using osu.Framework.Graphics;
using osu.Framework.Utils;
diff --git a/osu.Framework.Benchmarks/BenchmarkInvalidationWithManyNotAlive.cs b/osu.Framework.Benchmarks/BenchmarkInvalidationWithManyNotAlive.cs
index fe2249954f..6a65844709 100644
--- a/osu.Framework.Benchmarks/BenchmarkInvalidationWithManyNotAlive.cs
+++ b/osu.Framework.Benchmarks/BenchmarkInvalidationWithManyNotAlive.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using BenchmarkDotNet.Attributes;
using NUnit.Framework;
using osu.Framework.Graphics;
diff --git a/osu.Framework.Benchmarks/BenchmarkLocalisableDescription.cs b/osu.Framework.Benchmarks/BenchmarkLocalisableDescription.cs
index e66f177536..db694e29c2 100644
--- a/osu.Framework.Benchmarks/BenchmarkLocalisableDescription.cs
+++ b/osu.Framework.Benchmarks/BenchmarkLocalisableDescription.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using BenchmarkDotNet.Attributes;
using osu.Framework.Extensions;
using osu.Framework.Localisation;
@@ -11,7 +9,7 @@ namespace osu.Framework.Benchmarks
{
public class BenchmarkLocalisableDescription
{
- private LocalisableString[] descriptions;
+ private LocalisableString[] descriptions = null!;
[Params(1, 10, 100, 1000)]
public int Times { get; set; }
diff --git a/osu.Framework.Benchmarks/BenchmarkLocalisableString.cs b/osu.Framework.Benchmarks/BenchmarkLocalisableString.cs
index 61f20cd73d..d04220cc87 100644
--- a/osu.Framework.Benchmarks/BenchmarkLocalisableString.cs
+++ b/osu.Framework.Benchmarks/BenchmarkLocalisableString.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using System;
using BenchmarkDotNet.Attributes;
using osu.Framework.Localisation;
@@ -12,8 +10,8 @@ namespace osu.Framework.Benchmarks
[MemoryDiagnoser]
public class BenchmarkLocalisableString
{
- private string string1;
- private string string2;
+ private string string1 = null!;
+ private string string2 = null!;
private LocalisableString localisableString1;
private LocalisableString localisableString2;
private LocalisableString romanisableString1;
diff --git a/osu.Framework.Benchmarks/BenchmarkLocalisedBindableString.cs b/osu.Framework.Benchmarks/BenchmarkLocalisedBindableString.cs
index f30d696e05..5d5813704e 100644
--- a/osu.Framework.Benchmarks/BenchmarkLocalisedBindableString.cs
+++ b/osu.Framework.Benchmarks/BenchmarkLocalisedBindableString.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using System;
using BenchmarkDotNet.Attributes;
using osu.Framework.Configuration;
@@ -14,8 +12,8 @@ namespace osu.Framework.Benchmarks
[MemoryDiagnoser]
public class BenchmarkLocalisedBindableString
{
- private LocalisationManager manager;
- private TemporaryNativeStorage storage;
+ private LocalisationManager manager = null!;
+ private TemporaryNativeStorage storage = null!;
[GlobalSetup]
public void GlobalSetup()
diff --git a/osu.Framework.Benchmarks/BenchmarkLogger.cs b/osu.Framework.Benchmarks/BenchmarkLogger.cs
index 995ce3e5ba..1b9c7fa1fe 100644
--- a/osu.Framework.Benchmarks/BenchmarkLogger.cs
+++ b/osu.Framework.Benchmarks/BenchmarkLogger.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using System;
using BenchmarkDotNet.Attributes;
using osu.Framework.Logging;
diff --git a/osu.Framework.Benchmarks/BenchmarkMakeChildAlive.cs b/osu.Framework.Benchmarks/BenchmarkMakeChildAlive.cs
index c3de3a815c..15ecd14833 100644
--- a/osu.Framework.Benchmarks/BenchmarkMakeChildAlive.cs
+++ b/osu.Framework.Benchmarks/BenchmarkMakeChildAlive.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using BenchmarkDotNet.Attributes;
using NUnit.Framework;
using osu.Framework.Graphics;
diff --git a/osu.Framework.Benchmarks/BenchmarkManySpinningBoxes.cs b/osu.Framework.Benchmarks/BenchmarkManySpinningBoxes.cs
index ac93ee34eb..12e6be556d 100644
--- a/osu.Framework.Benchmarks/BenchmarkManySpinningBoxes.cs
+++ b/osu.Framework.Benchmarks/BenchmarkManySpinningBoxes.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using BenchmarkDotNet.Attributes;
using NUnit.Framework;
using osu.Framework.Graphics;
@@ -15,7 +13,7 @@ namespace osu.Framework.Benchmarks
{
public class BenchmarkManySpinningBoxes : GameBenchmark
{
- private TestGame game;
+ private TestGame game = null!;
[Test]
[Benchmark]
@@ -49,7 +47,7 @@ public void RunFrameWithAutoSizeDuration()
private class TestGame : Game
{
- public Container MainContent;
+ public Container MainContent = null!;
protected override void LoadComplete()
{
diff --git a/osu.Framework.Benchmarks/BenchmarkScheduler.cs b/osu.Framework.Benchmarks/BenchmarkScheduler.cs
new file mode 100644
index 0000000000..4ac44dc3cc
--- /dev/null
+++ b/osu.Framework.Benchmarks/BenchmarkScheduler.cs
@@ -0,0 +1,60 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using BenchmarkDotNet.Attributes;
+using osu.Framework.Threading;
+
+namespace osu.Framework.Benchmarks
+{
+ public class BenchmarkScheduler : BenchmarkTest
+ {
+ private Scheduler scheduler = null!;
+ private Scheduler schedulerWithEveryUpdate = null!;
+ private Scheduler schedulerWithManyDelayed = null!;
+
+ public override void SetUp()
+ {
+ base.SetUp();
+
+ scheduler = new Scheduler();
+
+ schedulerWithEveryUpdate = new Scheduler();
+ schedulerWithEveryUpdate.AddDelayed(() => { }, 0, true);
+
+ schedulerWithManyDelayed = new Scheduler();
+ for (int i = 0; i < 1000; i++)
+ schedulerWithManyDelayed.AddDelayed(() => { }, int.MaxValue);
+ }
+
+ [Benchmark]
+ public void UpdateEmptyScheduler()
+ {
+ for (int i = 0; i < 1000; i++)
+ scheduler.Update();
+ }
+
+ [Benchmark]
+ public void UpdateSchedulerWithManyDelayed()
+ {
+ for (int i = 0; i < 1000; i++)
+ schedulerWithManyDelayed.Update();
+ }
+
+ [Benchmark]
+ public void UpdateSchedulerWithEveryUpdate()
+ {
+ for (int i = 0; i < 1000; i++)
+ schedulerWithEveryUpdate.Update();
+ }
+
+ [Benchmark]
+ public void UpdateSchedulerWithManyAdded()
+ {
+ for (int i = 0; i < 1000; i++)
+ {
+ scheduler.Add(() => { });
+ scheduler.Update();
+ }
+ }
+ }
+}
diff --git a/osu.Framework.Benchmarks/BenchmarkScreenExtensions.cs b/osu.Framework.Benchmarks/BenchmarkScreenExtensions.cs
index 684ca8a838..f9553e7d6e 100644
--- a/osu.Framework.Benchmarks/BenchmarkScreenExtensions.cs
+++ b/osu.Framework.Benchmarks/BenchmarkScreenExtensions.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using BenchmarkDotNet.Attributes;
using NUnit.Framework;
using osu.Framework.Screens;
@@ -11,7 +9,7 @@ namespace osu.Framework.Benchmarks
{
public class BenchmarkScreenExtensions : GameBenchmark
{
- private Screen testScreen;
+ private Screen testScreen = null!;
[Test]
[Benchmark]
diff --git a/osu.Framework.Benchmarks/BenchmarkSlimReadOnlyCollection.cs b/osu.Framework.Benchmarks/BenchmarkSlimReadOnlyCollection.cs
index 339f985484..db94774d36 100644
--- a/osu.Framework.Benchmarks/BenchmarkSlimReadOnlyCollection.cs
+++ b/osu.Framework.Benchmarks/BenchmarkSlimReadOnlyCollection.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using System.Collections.Generic;
using BenchmarkDotNet.Attributes;
using osu.Framework.Extensions.ListExtensions;
diff --git a/osu.Framework.Benchmarks/BenchmarkSpinningParentWithManyAlive.cs b/osu.Framework.Benchmarks/BenchmarkSpinningParentWithManyAlive.cs
index 8827a829e1..681ed781f7 100644
--- a/osu.Framework.Benchmarks/BenchmarkSpinningParentWithManyAlive.cs
+++ b/osu.Framework.Benchmarks/BenchmarkSpinningParentWithManyAlive.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using BenchmarkDotNet.Attributes;
using NUnit.Framework;
using osu.Framework.Graphics;
diff --git a/osu.Framework.Benchmarks/BenchmarkStreamExtensions.cs b/osu.Framework.Benchmarks/BenchmarkStreamExtensions.cs
index b292a8f713..575109e5be 100644
--- a/osu.Framework.Benchmarks/BenchmarkStreamExtensions.cs
+++ b/osu.Framework.Benchmarks/BenchmarkStreamExtensions.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using System;
using System.IO;
using BenchmarkDotNet.Attributes;
@@ -13,7 +11,7 @@ namespace osu.Framework.Benchmarks
[MemoryDiagnoser]
public class BenchmarkStreamExtensions
{
- private MemoryStream memoryStream;
+ private MemoryStream memoryStream = null!;
[Params(100, 10000, 1000000)]
public int Length { get; set; }
diff --git a/osu.Framework.Benchmarks/BenchmarkTabletDriver.cs b/osu.Framework.Benchmarks/BenchmarkTabletDriver.cs
index 03598936f2..68218d22fd 100644
--- a/osu.Framework.Benchmarks/BenchmarkTabletDriver.cs
+++ b/osu.Framework.Benchmarks/BenchmarkTabletDriver.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
#if NET6_0
using BenchmarkDotNet.Attributes;
using osu.Framework.Input.Handlers.Tablet;
@@ -11,7 +9,7 @@ namespace osu.Framework.Benchmarks
{
public class BenchmarkTabletDriver : BenchmarkTest
{
- private TabletDriver driver;
+ private TabletDriver driver = null!;
public override void SetUp()
{
diff --git a/osu.Framework.Benchmarks/BenchmarkTest.cs b/osu.Framework.Benchmarks/BenchmarkTest.cs
index a80ce57576..f2b65a4e22 100644
--- a/osu.Framework.Benchmarks/BenchmarkTest.cs
+++ b/osu.Framework.Benchmarks/BenchmarkTest.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using NUnit.Framework;
diff --git a/osu.Framework.Benchmarks/BenchmarkTextBuilder.cs b/osu.Framework.Benchmarks/BenchmarkTextBuilder.cs
index e6f85cf0d2..4a40634bd4 100644
--- a/osu.Framework.Benchmarks/BenchmarkTextBuilder.cs
+++ b/osu.Framework.Benchmarks/BenchmarkTextBuilder.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using System.Threading.Tasks;
using BenchmarkDotNet.Attributes;
using osu.Framework.Graphics.Sprites;
@@ -15,7 +13,7 @@ public class BenchmarkTextBuilder
{
private readonly ITexturedGlyphLookupStore store = new TestStore();
- private TextBuilder textBuilder;
+ private TextBuilder textBuilder = null!;
[Benchmark]
public void AddCharacters() => initialiseBuilder(false);
diff --git a/osu.Framework.Benchmarks/BenchmarkTransform.cs b/osu.Framework.Benchmarks/BenchmarkTransform.cs
index dfc4bbda0a..e6a62ae8da 100644
--- a/osu.Framework.Benchmarks/BenchmarkTransform.cs
+++ b/osu.Framework.Benchmarks/BenchmarkTransform.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using System;
using BenchmarkDotNet.Attributes;
using osu.Framework.Graphics;
@@ -15,7 +13,7 @@ namespace osu.Framework.Benchmarks
{
public class BenchmarkTransform : BenchmarkTest
{
- private Drawable target;
+ private Drawable target = null!;
public override void SetUp()
{
diff --git a/osu.Framework.Benchmarks/BenchmarkTransformUpdate.cs b/osu.Framework.Benchmarks/BenchmarkTransformUpdate.cs
index 6bebf443a6..90e0d34bdd 100644
--- a/osu.Framework.Benchmarks/BenchmarkTransformUpdate.cs
+++ b/osu.Framework.Benchmarks/BenchmarkTransformUpdate.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using BenchmarkDotNet.Attributes;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
@@ -13,7 +11,8 @@ namespace osu.Framework.Benchmarks
{
public class BenchmarkTransformUpdate : BenchmarkTest
{
- private TestBox target;
+ private TestBox target = null!;
+ private TestBox targetNoTransforms = null!;
public override void SetUp()
{
@@ -23,7 +22,8 @@ public override void SetUp()
ManualClock clock;
- target = new TestBox { Clock = new FramedClock(clock = new ManualClock()) };
+ targetNoTransforms = new TestBox { Clock = new FramedClock(clock = new ManualClock()) };
+ target = new TestBox { Clock = new FramedClock(clock) };
// transform one target member over a long period
target.RotateTo(360, transforms_count * 2);
@@ -36,6 +36,13 @@ public override void SetUp()
target.Clock.ProcessFrame();
}
+ [Benchmark]
+ public void UpdateTransformsWithNonePresent()
+ {
+ for (int i = 0; i < 10000; i++)
+ targetNoTransforms.UpdateTransforms();
+ }
+
[Benchmark]
public void UpdateTransformsWithManyPresent()
{
diff --git a/osu.Framework.Benchmarks/BenchmarkWeakList.cs b/osu.Framework.Benchmarks/BenchmarkWeakList.cs
index 7afdc6bbae..54ab24df70 100644
--- a/osu.Framework.Benchmarks/BenchmarkWeakList.cs
+++ b/osu.Framework.Benchmarks/BenchmarkWeakList.cs
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-#nullable disable
-
using System;
using System.Linq;
using BenchmarkDotNet.Attributes;
@@ -16,7 +14,7 @@ public class BenchmarkWeakList : BenchmarkTest
public int ItemCount { get; set; }
private readonly object[] objects = new object[1000];
- private WeakList