diff --git a/osu.Framework.Tests/Audio/AudioCollectionManagerTest.cs b/osu.Framework.Tests/Audio/AudioCollectionManagerTest.cs index 8db58c235..5a6236eef 100644 --- a/osu.Framework.Tests/Audio/AudioCollectionManagerTest.cs +++ b/osu.Framework.Tests/Audio/AudioCollectionManagerTest.cs @@ -33,7 +33,7 @@ namespace osu.Framework.Tests.Audio Assert.IsTrue(updateLoopStarted.Wait(10000)); - Assert.DoesNotThrow(() => manager.Dispose()); + Assert.DoesNotThrow(manager.Dispose); thread.Dispose(); } diff --git a/osu.Framework.Tests/Dependencies/Reflection/CachedAttributeTest.cs b/osu.Framework.Tests/Dependencies/Reflection/CachedAttributeTest.cs index ee6de70e5..1dd3c724c 100644 --- a/osu.Framework.Tests/Dependencies/Reflection/CachedAttributeTest.cs +++ b/osu.Framework.Tests/Dependencies/Reflection/CachedAttributeTest.cs @@ -155,7 +155,7 @@ namespace osu.Framework.Tests.Dependencies.Reflection [Test] public void TestGetValueNullInternal() { - Assert.AreEqual(default(int), new DependencyContainer().GetValue()); + Assert.AreEqual(0, new DependencyContainer().GetValue()); } /// diff --git a/osu.Framework.Tests/Dependencies/Reflection/ResolvedAttributeTest.cs b/osu.Framework.Tests/Dependencies/Reflection/ResolvedAttributeTest.cs index e46fd5bd6..894e838ba 100644 --- a/osu.Framework.Tests/Dependencies/Reflection/ResolvedAttributeTest.cs +++ b/osu.Framework.Tests/Dependencies/Reflection/ResolvedAttributeTest.cs @@ -216,7 +216,7 @@ namespace osu.Framework.Tests.Dependencies.Reflection { var dependencies = new DependencyContainer(); - toCache?.ForEach(o => dependencies.Cache(o)); + toCache?.ForEach(dependencies.Cache); return dependencies; } diff --git a/osu.Framework.Tests/Dependencies/SourceGeneration/CachedAttributeTest.cs b/osu.Framework.Tests/Dependencies/SourceGeneration/CachedAttributeTest.cs index ac928cc1e..ac2c8068d 100644 --- a/osu.Framework.Tests/Dependencies/SourceGeneration/CachedAttributeTest.cs +++ b/osu.Framework.Tests/Dependencies/SourceGeneration/CachedAttributeTest.cs @@ -152,7 +152,7 @@ namespace osu.Framework.Tests.Dependencies.SourceGeneration [Test] public void TestGetValueNullInternal() { - Assert.AreEqual(default(int), new DependencyContainer().GetValue()); + Assert.AreEqual(0, new DependencyContainer().GetValue()); } /// diff --git a/osu.Framework.Tests/Dependencies/SourceGeneration/ResolvedAttributeTest.cs b/osu.Framework.Tests/Dependencies/SourceGeneration/ResolvedAttributeTest.cs index fa15a2d1d..5ef379576 100644 --- a/osu.Framework.Tests/Dependencies/SourceGeneration/ResolvedAttributeTest.cs +++ b/osu.Framework.Tests/Dependencies/SourceGeneration/ResolvedAttributeTest.cs @@ -213,7 +213,7 @@ namespace osu.Framework.Tests.Dependencies.SourceGeneration { var dependencies = new DependencyContainer(); - toCache?.ForEach(o => dependencies.Cache(o)); + toCache?.ForEach(dependencies.Cache); return dependencies; } diff --git a/osu.Framework.Tests/IO/TestLogging.cs b/osu.Framework.Tests/IO/TestLogging.cs index 090ffcf9f..42088d786 100644 --- a/osu.Framework.Tests/IO/TestLogging.cs +++ b/osu.Framework.Tests/IO/TestLogging.cs @@ -106,7 +106,7 @@ namespace osu.Framework.Tests.IO for (int i = 0; i < fireCount; i++) game.Schedule(() => throw new TestException()); - game.Schedule(() => game.Exit()); + game.Schedule(game.Exit); host.Run(game); } diff --git a/osu.Framework.Tests/IO/TestWebRequest.cs b/osu.Framework.Tests/IO/TestWebRequest.cs index d2207bed0..7dd680bdd 100644 --- a/osu.Framework.Tests/IO/TestWebRequest.cs +++ b/osu.Framework.Tests/IO/TestWebRequest.cs @@ -270,7 +270,7 @@ namespace osu.Framework.Tests.IO bool hasThrown = false; request.Failed += exception => hasThrown = exception != null; - request.Started += () => request.Abort(); + request.Started += request.Abort; if (async) Assert.DoesNotThrowAsync(() => request.PerformAsync()); @@ -388,7 +388,7 @@ namespace osu.Framework.Tests.IO bool hasThrown = false; request.Failed += exception => hasThrown = exception != null; - request.Started += () => cancellationSource.Cancel(); + request.Started += cancellationSource.Cancel; Assert.DoesNotThrowAsync(() => request.PerformAsync(cancellationSource.Token)); diff --git a/osu.Framework.Tests/Platform/GameHostSuspendTest.cs b/osu.Framework.Tests/Platform/GameHostSuspendTest.cs index 24760ec1e..9868ead27 100644 --- a/osu.Framework.Tests/Platform/GameHostSuspendTest.cs +++ b/osu.Framework.Tests/Platform/GameHostSuspendTest.cs @@ -71,7 +71,7 @@ namespace osu.Framework.Tests.Platform // check that scheduler doesn't process while suspended.. completed.Reset(); - game.Schedule(() => completed.Set()); + game.Schedule(completed.Set); Assert.IsFalse(completed.Wait(timeout / 10)); // ..and does after resume. diff --git a/osu.Framework.Tests/Platform/HeadlessGameHostTest.cs b/osu.Framework.Tests/Platform/HeadlessGameHostTest.cs index 61f95372b..b23795243 100644 --- a/osu.Framework.Tests/Platform/HeadlessGameHostTest.cs +++ b/osu.Framework.Tests/Platform/HeadlessGameHostTest.cs @@ -68,7 +68,7 @@ namespace osu.Framework.Tests.Platform var task = Task.Factory.StartNew(() => { var game = new TestGame(); - game.Scheduler.Add(() => host.Exit()); + game.Scheduler.Add(host.Exit); host.Run(game); diff --git a/osu.Framework.Tests/Platform/UserStorageLookupTest.cs b/osu.Framework.Tests/Platform/UserStorageLookupTest.cs index 0b0923828..1a14e8132 100644 --- a/osu.Framework.Tests/Platform/UserStorageLookupTest.cs +++ b/osu.Framework.Tests/Platform/UserStorageLookupTest.cs @@ -129,7 +129,7 @@ namespace osu.Framework.Tests.Platform private static void runHost(StorageLookupHeadlessGameHost host) { TestGame game = new TestGame(); - game.Schedule(() => game.Exit()); + game.Schedule(game.Exit); host.Run(game); } diff --git a/osu.Framework.Tests/Threading/ThreadedTaskSchedulerTest.cs b/osu.Framework.Tests/Threading/ThreadedTaskSchedulerTest.cs index a76840e84..f77b0cb47 100644 --- a/osu.Framework.Tests/Threading/ThreadedTaskSchedulerTest.cs +++ b/osu.Framework.Tests/Threading/ThreadedTaskSchedulerTest.cs @@ -32,7 +32,7 @@ namespace osu.Framework.Tests.Threading { Interlocked.Increment(ref runCount); Thread.Sleep(100); - }, default, TaskCreationOptions.HideScheduler, taskScheduler); + }, CancellationToken.None, TaskCreationOptions.HideScheduler, taskScheduler); } } @@ -55,7 +55,7 @@ namespace osu.Framework.Tests.Threading { while (!exited.IsSet) Thread.Sleep(100); - }, default, TaskCreationOptions.HideScheduler, taskScheduler); + }, CancellationToken.None, TaskCreationOptions.HideScheduler, taskScheduler); } exited.Set(); @@ -76,7 +76,7 @@ namespace osu.Framework.Tests.Threading Task.Run(async () => { // ReSharper disable once AccessToDisposedClosure - await Task.Factory.StartNew(() => { run.Set(); }, default, TaskCreationOptions.HideScheduler, taskScheduler).ConfigureAwait(false); + await Task.Factory.StartNew(run.Set, CancellationToken.None, TaskCreationOptions.HideScheduler, taskScheduler).ConfigureAwait(false); exited.Set(); }); @@ -90,10 +90,7 @@ namespace osu.Framework.Tests.Threading { ThreadedTaskScheduler scheduler = new ThreadedTaskScheduler(1, string.Empty); - Thread disposeThread = new Thread(() => - { - scheduler.Dispose(); - }) + Thread disposeThread = new Thread(scheduler.Dispose) { IsBackground = true }; diff --git a/osu.Framework.Tests/Visual/Input/TestSceneKeyBindingContainer.cs b/osu.Framework.Tests/Visual/Input/TestSceneKeyBindingContainer.cs index 7d322201f..801994147 100644 --- a/osu.Framework.Tests/Visual/Input/TestSceneKeyBindingContainer.cs +++ b/osu.Framework.Tests/Visual/Input/TestSceneKeyBindingContainer.cs @@ -65,8 +65,8 @@ namespace osu.Framework.Tests.Visual.Input { Child = new TestKeyBindingReceptor { - Pressed = a => pressedActions.Add(a), - Released = a => releasedActions.Add(a) + Pressed = pressedActions.Add, + Released = releasedActions.Add } }; }); @@ -99,8 +99,8 @@ namespace osu.Framework.Tests.Visual.Input { Child = new TestKeyBindingReceptor { - Pressed = a => pressedActions.Add(a), - Released = a => releasedActions.Add(a) + Pressed = pressedActions.Add, + Released = releasedActions.Add } }; }); @@ -135,8 +135,8 @@ namespace osu.Framework.Tests.Visual.Input { Child = new TestKeyBindingReceptor { - Pressed = a => pressedActions.Add(a), - Released = a => releasedActions.Add(a) + Pressed = pressedActions.Add, + Released = releasedActions.Add }, } }; @@ -178,8 +178,8 @@ namespace osu.Framework.Tests.Visual.Input }, new TestKeyBindingReceptor { - Pressed = a => pressedActions.Add(a), - Released = a => releasedActions.Add(a) + Pressed = pressedActions.Add, + Released = releasedActions.Add } } }; @@ -438,8 +438,8 @@ namespace osu.Framework.Tests.Visual.Input { Child = receptor = new TestKeyBindingReceptor { - Pressed = a => pressedActions.Add(a), - Released = a => releasedActions.Add(a) + Pressed = pressedActions.Add, + Released = releasedActions.Add } }; }); diff --git a/osu.Framework.Tests/Visual/UserInterface/TestSceneScreenStack.cs b/osu.Framework.Tests/Visual/UserInterface/TestSceneScreenStack.cs index c55e83a9c..023ba4907 100644 --- a/osu.Framework.Tests/Visual/UserInterface/TestSceneScreenStack.cs +++ b/osu.Framework.Tests/Visual/UserInterface/TestSceneScreenStack.cs @@ -300,18 +300,18 @@ namespace osu.Framework.Tests.Visual.UserInterface }; AddStep("push screen1", () => stack.Push(screen1)); - AddUntilStep("ensure current", () => screen1.IsCurrentScreen()); + AddUntilStep("ensure current", screen1.IsCurrentScreen); AddStep("preload screen2", () => LoadComponentAsync(screen2)); AddUntilStep("wait for load", () => screen2.LoadState == LoadState.Ready); AddStep("push screen2", () => screen1.Push(screen2)); - AddUntilStep("ensure current", () => screen2.IsCurrentScreen()); + AddUntilStep("ensure current", screen2.IsCurrentScreen); - AddStep("exit screen2", () => screen2.Exit()); + AddStep("exit screen2", screen2.Exit); AddUntilStep("ensure exited", () => !screen2.IsCurrentScreen()); - AddStep("push screen2", () => screen1.Exit()); + AddStep("push screen2", screen1.Exit); AddUntilStep("ensure exited", () => !screen1.IsCurrentScreen()); AddAssert("order is correct", () => order.SequenceEqual(order.OrderBy(i => i))); diff --git a/osu.Framework/Allocation/CachedModelDependencyContainer.cs b/osu.Framework/Allocation/CachedModelDependencyContainer.cs index 12f37dbe8..ad1716b83 100644 --- a/osu.Framework/Allocation/CachedModelDependencyContainer.cs +++ b/osu.Framework/Allocation/CachedModelDependencyContainer.cs @@ -74,7 +74,7 @@ namespace osu.Framework.Allocation private TModel createChildShadowModel() { var result = new TModel(); - updateShadowModel(result, default, shadowModel); + updateShadowModel(result, null, shadowModel); return result; } diff --git a/osu.Framework/Allocation/ObjectHandle.cs b/osu.Framework/Allocation/ObjectHandle.cs index c66b02edc..5d4d1ba69 100644 --- a/osu.Framework/Allocation/ObjectHandle.cs +++ b/osu.Framework/Allocation/ObjectHandle.cs @@ -64,7 +64,7 @@ namespace osu.Framework.Allocation { if (!handle.IsAllocated) { - target = default; + target = null; return false; } @@ -80,7 +80,7 @@ namespace osu.Framework.Allocation { } - target = default; + target = null; return false; } diff --git a/osu.Framework/Audio/AudioManager.cs b/osu.Framework/Audio/AudioManager.cs index 616c26f11..03aa7b668 100644 --- a/osu.Framework/Audio/AudioManager.cs +++ b/osu.Framework/Audio/AudioManager.cs @@ -267,7 +267,7 @@ namespace osu.Framework.Audio /// Channels removed from this fall back to the global . /// /// An identifier displayed on the audio mixer visualiser. - public AudioMixer CreateAudioMixer(string identifier = default) => + public AudioMixer CreateAudioMixer(string identifier = null) => createAudioMixer(SampleMixer, !string.IsNullOrEmpty(identifier) ? identifier : $"user #{Interlocked.Increment(ref userMixerID)}"); private AudioMixer createAudioMixer(AudioMixer fallbackMixer, string identifier) diff --git a/osu.Framework/Audio/Mixing/Bass/BassAudioMixer.cs b/osu.Framework/Audio/Mixing/Bass/BassAudioMixer.cs index a36778f49..8b703b486 100644 --- a/osu.Framework/Audio/Mixing/Bass/BassAudioMixer.cs +++ b/osu.Framework/Audio/Mixing/Bass/BassAudioMixer.cs @@ -236,7 +236,7 @@ namespace osu.Framework.Audio.Mixing.Bass /// The callback function which should be invoked with the sync. /// User instance data to pass to the callback function. /// If successful, then the new synchroniser's handle is returned, else 0 is returned. Use to get the error code. - public int ChannelSetSync(IBassAudioChannel channel, SyncFlags type, long parameter, SyncProcedure procedure, IntPtr user = default) + public int ChannelSetSync(IBassAudioChannel channel, SyncFlags type, long parameter, SyncProcedure procedure, IntPtr user = 0) => BassMix.ChannelSetSync(channel.Handle, type, parameter, procedure, user); /// diff --git a/osu.Framework/Bindables/BindableLong.cs b/osu.Framework/Bindables/BindableLong.cs index 63f2b5416..2ad16f0b1 100644 --- a/osu.Framework/Bindables/BindableLong.cs +++ b/osu.Framework/Bindables/BindableLong.cs @@ -5,7 +5,7 @@ namespace osu.Framework.Bindables { public class BindableLong : BindableNumber { - public BindableLong(long defaultValue = default) + public BindableLong(long defaultValue = 0) : base(defaultValue) { } diff --git a/osu.Framework/Graphics/OpenGL/Textures/GLTexture.cs b/osu.Framework/Graphics/OpenGL/Textures/GLTexture.cs index a5ba2c591..5688d1504 100644 --- a/osu.Framework/Graphics/OpenGL/Textures/GLTexture.cs +++ b/osu.Framework/Graphics/OpenGL/Textures/GLTexture.cs @@ -479,7 +479,7 @@ namespace osu.Framework.Graphics.OpenGL.Textures var rgbaColour = new Rgba32(new Vector4(initialisationColour.Value.R, initialisationColour.Value.G, initialisationColour.Value.B, initialisationColour.Value.A)); // it is faster to initialise without a background specification if transparent black is all that's required. - using var image = initialisationColour == default + using var image = initialisationColour == null ? new Image(width, height) : new Image(width, height, rgbaColour); diff --git a/osu.Framework/Graphics/Veldrid/Textures/VeldridTexture.cs b/osu.Framework/Graphics/Veldrid/Textures/VeldridTexture.cs index 8e50c8f5c..000fb5c55 100644 --- a/osu.Framework/Graphics/Veldrid/Textures/VeldridTexture.cs +++ b/osu.Framework/Graphics/Veldrid/Textures/VeldridTexture.cs @@ -503,7 +503,7 @@ namespace osu.Framework.Graphics.Veldrid.Textures var rgbaColour = new Rgba32(new Vector4(initialisationColour.Value.R, initialisationColour.Value.G, initialisationColour.Value.B, initialisationColour.Value.A)); // it is faster to initialise without a background specification if transparent black is all that's required. - using var image = initialisationColour == default + using var image = initialisationColour == null ? new Image(width, height) : new Image(width, height, rgbaColour); diff --git a/osu.Framework/Graphics/Veldrid/VeldridExtensions.cs b/osu.Framework/Graphics/Veldrid/VeldridExtensions.cs index 272452a14..b8564a1bc 100644 --- a/osu.Framework/Graphics/Veldrid/VeldridExtensions.cs +++ b/osu.Framework/Graphics/Veldrid/VeldridExtensions.cs @@ -351,12 +351,12 @@ namespace osu.Framework.Graphics.Veldrid var info = device.GetD3D11Info(); var dxgiAdapter = MarshallingHelpers.FromPointer(info.Adapter).AsNonNull(); - var d3d11Device = MarshallingHelpers.FromPointer(info.Device).AsNonNull(); + var d3D11Device = MarshallingHelpers.FromPointer(info.Device).AsNonNull(); maxTextureSize = ID3D11Resource.MaximumTexture2DSize; Logger.Log($@"Direct3D 11 Initialized - Direct3D 11 Feature Level: {d3d11Device.FeatureLevel.ToString().Replace("Level_", string.Empty).Replace("_", ".")} + Direct3D 11 Feature Level: {d3D11Device.FeatureLevel.ToString().Replace("Level_", string.Empty).Replace("_", ".")} Direct3D 11 Adapter: {dxgiAdapter.Description.Description} Direct3D 11 Dedicated Video Memory: {dxgiAdapter.Description.DedicatedVideoMemory / 1024 / 1024} MB Direct3D 11 Dedicated System Memory: {dxgiAdapter.Description.DedicatedSystemMemory / 1024 / 1024} MB diff --git a/osu.Framework/IO/Stores/ResourceStore.cs b/osu.Framework/IO/Stores/ResourceStore.cs index 27309d9de..28e6a6744 100644 --- a/osu.Framework/IO/Stores/ResourceStore.cs +++ b/osu.Framework/IO/Stores/ResourceStore.cs @@ -97,7 +97,7 @@ namespace osu.Framework.IO.Stores } } - return default; + return null; } /// @@ -122,7 +122,7 @@ namespace osu.Framework.IO.Stores } } - return default; + return null; } public Stream GetStream(string name) diff --git a/osu.Framework/Lists/WeakList_ValidItemsEnumerator.cs b/osu.Framework/Lists/WeakList_ValidItemsEnumerator.cs index f65b112eb..bfe9d586b 100644 --- a/osu.Framework/Lists/WeakList_ValidItemsEnumerator.cs +++ b/osu.Framework/Lists/WeakList_ValidItemsEnumerator.cs @@ -25,7 +25,7 @@ namespace osu.Framework.Lists this.weakList = weakList; currentItemIndex = weakList.listStart - 1; // The first MoveNext() should bring the iterator to the start - Current = default!; + Current = null!; } public bool MoveNext() @@ -55,7 +55,7 @@ namespace osu.Framework.Lists public void Reset() { currentItemIndex = weakList.listStart - 1; - Current = default!; + Current = null!; } public T Current { get; private set; } @@ -64,7 +64,7 @@ namespace osu.Framework.Lists public void Dispose() { - Current = default!; + Current = null!; } } } diff --git a/osu.Framework/Platform/SDL2/SDL2Window_Windowing.cs b/osu.Framework/Platform/SDL2/SDL2Window_Windowing.cs index e1ff94121..f48ee9824 100644 --- a/osu.Framework/Platform/SDL2/SDL2Window_Windowing.cs +++ b/osu.Framework/Platform/SDL2/SDL2Window_Windowing.cs @@ -739,7 +739,7 @@ namespace osu.Framework.Platform.SDL2 return true; } - maximized = default; + maximized = false; return false; } diff --git a/osu.Framework/Platform/SDL3/SDL3Window_Windowing.cs b/osu.Framework/Platform/SDL3/SDL3Window_Windowing.cs index 16718594b..c7bf9b8c5 100644 --- a/osu.Framework/Platform/SDL3/SDL3Window_Windowing.cs +++ b/osu.Framework/Platform/SDL3/SDL3Window_Windowing.cs @@ -682,7 +682,7 @@ namespace osu.Framework.Platform.SDL3 } } - index = default; + index = 0; return false; } @@ -770,7 +770,7 @@ namespace osu.Framework.Platform.SDL3 return true; } - maximized = default; + maximized = false; return false; } diff --git a/osu.Framework/Platform/Windows/Native/WindowsNativeSleep.cs b/osu.Framework/Platform/Windows/Native/WindowsNativeSleep.cs index e47d95a5b..88d301dc4 100644 --- a/osu.Framework/Platform/Windows/Native/WindowsNativeSleep.cs +++ b/osu.Framework/Platform/Windows/Native/WindowsNativeSleep.cs @@ -39,7 +39,7 @@ namespace osu.Framework.Platform.Windows.Native if (waitableTimer == IntPtr.Zero) return false; // Not sure if we want to fall back to Thread.Sleep on failure here, needs further investigation. - if (Execution.SetWaitableTimerEx(waitableTimer, Execution.CreateFileTime(duration), 0, null, default, IntPtr.Zero, 0)) + if (Execution.SetWaitableTimerEx(waitableTimer, Execution.CreateFileTime(duration), 0, null, 0, IntPtr.Zero, 0)) { Execution.WaitForSingleObject(waitableTimer, Execution.INFINITE); return true; diff --git a/osu.Framework/Utils/CircularArcProperties.cs b/osu.Framework/Utils/CircularArcProperties.cs index 28ec4fddc..377e276d8 100644 --- a/osu.Framework/Utils/CircularArcProperties.cs +++ b/osu.Framework/Utils/CircularArcProperties.cs @@ -41,10 +41,10 @@ namespace osu.Framework.Utils if (Precision.AlmostEquals(0, (b.Y - a.Y) * (c.X - a.X) - (b.X - a.X) * (c.Y - a.Y))) { IsValid = false; - ThetaStart = default; - ThetaRange = default; - Direction = default; - Radius = default; + ThetaStart = 0; + ThetaRange = 0; + Direction = 0; + Radius = 0; Centre = default; return; }