From 0732a9e6da034b6121dc719c78d8177b6ff77897 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 23 Dec 2021 18:08:44 +0900 Subject: [PATCH 1/2] Update framework --- osu.Android.props | 2 +- osu.Game/osu.Game.csproj | 2 +- osu.iOS.props | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Android.props b/osu.Android.props index ca4d88a8a7..4f0125bed2 100644 --- a/osu.Android.props +++ b/osu.Android.props @@ -52,7 +52,7 @@ - + diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index c538f55e89..565f78e2d4 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -36,7 +36,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/osu.iOS.props b/osu.iOS.props index 5cc1857dfe..bdb3b0b149 100644 --- a/osu.iOS.props +++ b/osu.iOS.props @@ -60,7 +60,7 @@ - + @@ -83,7 +83,7 @@ - + From 10405908440576b576cc4c5063d3e6d190d1aa32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 23 Dec 2021 10:33:17 +0100 Subject: [PATCH 2/2] Add cancellation support to game-side `IResourceStore`s --- osu.Game.Tests/Gameplay/TestSceneStoryboardSamples.cs | 4 +++- .../Rulesets/TestSceneDrawableRulesetDependencies.cs | 3 ++- osu.Game/IO/Archives/ArchiveReader.cs | 5 +++-- osu.Game/Localisation/ResourceManagerLocalisationStore.cs | 3 ++- osu.Game/Rulesets/UI/DrawableRulesetDependencies.cs | 3 ++- osu.Game/Tests/Beatmaps/HitObjectSampleTest.cs | 3 ++- osu.Game/Tests/Visual/OsuTestScene.cs | 3 ++- 7 files changed, 16 insertions(+), 8 deletions(-) diff --git a/osu.Game.Tests/Gameplay/TestSceneStoryboardSamples.cs b/osu.Game.Tests/Gameplay/TestSceneStoryboardSamples.cs index 3aab28886e..28915b2c4a 100644 --- a/osu.Game.Tests/Gameplay/TestSceneStoryboardSamples.cs +++ b/osu.Game.Tests/Gameplay/TestSceneStoryboardSamples.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using System.Threading; using System.Threading.Tasks; using NUnit.Framework; using osu.Framework.Audio; @@ -184,7 +185,8 @@ namespace osu.Game.Tests.Gameplay public byte[] Get(string name) => name == resourceName ? TestResources.GetStore().Get("Resources/Samples/test-sample.mp3") : null; - public Task GetAsync(string name) => name == resourceName ? TestResources.GetStore().GetAsync("Resources/Samples/test-sample.mp3") : null; + public Task GetAsync(string name, CancellationToken cancellationToken = default) + => name == resourceName ? TestResources.GetStore().GetAsync("Resources/Samples/test-sample.mp3", cancellationToken) : null; public Stream GetStream(string name) => name == resourceName ? TestResources.GetStore().GetStream("Resources/Samples/test-sample.mp3") : null; diff --git a/osu.Game.Tests/Rulesets/TestSceneDrawableRulesetDependencies.cs b/osu.Game.Tests/Rulesets/TestSceneDrawableRulesetDependencies.cs index c357fccd27..20439ac969 100644 --- a/osu.Game.Tests/Rulesets/TestSceneDrawableRulesetDependencies.cs +++ b/osu.Game.Tests/Rulesets/TestSceneDrawableRulesetDependencies.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Threading; using System.Threading.Tasks; using NUnit.Framework; using osu.Framework.Allocation; @@ -114,7 +115,7 @@ namespace osu.Game.Tests.Rulesets public Sample Get(string name) => null; - public Task GetAsync(string name) => null; + public Task GetAsync(string name, CancellationToken cancellationToken = default) => null; public Stream GetStream(string name) => null; diff --git a/osu.Game/IO/Archives/ArchiveReader.cs b/osu.Game/IO/Archives/ArchiveReader.cs index 679ab40402..f787534e2d 100644 --- a/osu.Game/IO/Archives/ArchiveReader.cs +++ b/osu.Game/IO/Archives/ArchiveReader.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; +using System.Threading; using System.Threading.Tasks; using osu.Framework.IO.Stores; @@ -33,7 +34,7 @@ namespace osu.Game.IO.Archives public virtual byte[] Get(string name) => GetAsync(name).Result; - public async Task GetAsync(string name) + public async Task GetAsync(string name, CancellationToken cancellationToken = default) { using (Stream input = GetStream(name)) { @@ -41,7 +42,7 @@ namespace osu.Game.IO.Archives return null; byte[] buffer = new byte[input.Length]; - await input.ReadAsync(buffer).ConfigureAwait(false); + await input.ReadAsync(buffer, cancellationToken).ConfigureAwait(false); return buffer; } } diff --git a/osu.Game/Localisation/ResourceManagerLocalisationStore.cs b/osu.Game/Localisation/ResourceManagerLocalisationStore.cs index 82dc0ad110..0fb85e4a19 100644 --- a/osu.Game/Localisation/ResourceManagerLocalisationStore.cs +++ b/osu.Game/Localisation/ResourceManagerLocalisationStore.cs @@ -7,6 +7,7 @@ using System.Globalization; using System.IO; using System.Linq; using System.Resources; +using System.Threading; using System.Threading.Tasks; using osu.Framework.Localisation; @@ -75,7 +76,7 @@ namespace osu.Game.Localisation } } - public Task GetAsync(string lookup) + public Task GetAsync(string lookup, CancellationToken cancellationToken = default) { return Task.FromResult(Get(lookup)); } diff --git a/osu.Game/Rulesets/UI/DrawableRulesetDependencies.cs b/osu.Game/Rulesets/UI/DrawableRulesetDependencies.cs index e49e515d2e..aacb8dbe83 100644 --- a/osu.Game/Rulesets/UI/DrawableRulesetDependencies.cs +++ b/osu.Game/Rulesets/UI/DrawableRulesetDependencies.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Threading; using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Audio; @@ -115,7 +116,7 @@ namespace osu.Game.Rulesets.UI public Sample Get(string name) => primary.Get(name) ?? fallback.Get(name); - public Task GetAsync(string name) => primary.GetAsync(name) ?? fallback.GetAsync(name); + public Task GetAsync(string name, CancellationToken cancellationToken = default) => primary.GetAsync(name, cancellationToken) ?? fallback.GetAsync(name, cancellationToken); public Stream GetStream(string name) => primary.GetStream(name) ?? fallback.GetStream(name); diff --git a/osu.Game/Tests/Beatmaps/HitObjectSampleTest.cs b/osu.Game/Tests/Beatmaps/HitObjectSampleTest.cs index f919edecf7..27d1de83ec 100644 --- a/osu.Game/Tests/Beatmaps/HitObjectSampleTest.cs +++ b/osu.Game/Tests/Beatmaps/HitObjectSampleTest.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using System.Threading; using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Audio; @@ -166,7 +167,7 @@ namespace osu.Game.Tests.Beatmaps return Array.Empty(); } - public Task GetAsync(string name) + public Task GetAsync(string name, CancellationToken cancellationToken = default) { markLookup(name); return Task.FromResult(Array.Empty()); diff --git a/osu.Game/Tests/Visual/OsuTestScene.cs b/osu.Game/Tests/Visual/OsuTestScene.cs index 7bc63a8c26..1b2c1e72c4 100644 --- a/osu.Game/Tests/Visual/OsuTestScene.cs +++ b/osu.Game/Tests/Visual/OsuTestScene.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; +using System.Threading; using System.Threading.Tasks; using JetBrains.Annotations; using osu.Framework.Allocation; @@ -352,7 +353,7 @@ namespace osu.Game.Tests.Visual public Track Get(string name) => throw new NotImplementedException(); - public Task GetAsync(string name) => throw new NotImplementedException(); + public Task GetAsync(string name, CancellationToken cancellationToken = default) => throw new NotImplementedException(); public Stream GetStream(string name) => throw new NotImplementedException();