Fix `APIBeatmapSet.Beatmaps` being `IEnumerable`, causing stupid issues

This commit is contained in:
Dean Herbert 2021-11-04 16:44:05 +09:00
parent 84d36cbae7
commit 5a078da4d9
9 changed files with 15 additions and 20 deletions

View File

@ -91,7 +91,7 @@ private void load()
HasVideo = true,
HasStoryboard = true,
Covers = new BeatmapSetOnlineCovers(),
Beatmaps = new List<APIBeatmap>
Beatmaps = new[]
{
new APIBeatmap
{
@ -128,7 +128,7 @@ private static APIBeatmapSet getManyDifficultiesBeatmapSet(int count)
HasVideo = true,
HasStoryboard = true,
Covers = new BeatmapSetOnlineCovers(),
Beatmaps = beatmaps,
Beatmaps = beatmaps.ToArray(),
};
}

View File

@ -21,7 +21,7 @@ public class TestSceneDifficultySpectrumDisplay : OsuTestScene
{
RulesetID = difficulty.rulesetId,
StarRating = difficulty.stars
}).ToList()
}).ToArray()
};
[Test]

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
@ -37,7 +36,7 @@ public void TestMultipleRulesetsBeatmapSet()
{
selector.BeatmapSet = new APIBeatmapSet
{
Beatmaps = enabledRulesets.Select(r => new APIBeatmap { RulesetID = r.OnlineID }).ToList()
Beatmaps = enabledRulesets.Select(r => new APIBeatmap { RulesetID = r.OnlineID }).ToArray()
};
});
@ -55,7 +54,7 @@ public void TestSingleRulesetBeatmapSet()
{
selector.BeatmapSet = new APIBeatmapSet
{
Beatmaps = new List<APIBeatmap>
Beatmaps = new[]
{
new APIBeatmap
{
@ -71,10 +70,7 @@ public void TestSingleRulesetBeatmapSet()
[Test]
public void TestEmptyBeatmapSet()
{
AddStep("load empty beatmapset", () => selector.BeatmapSet = new APIBeatmapSet
{
Beatmaps = new List<APIBeatmap>()
});
AddStep("load empty beatmapset", () => selector.BeatmapSet = new APIBeatmapSet());
AddAssert("no ruleset selected", () => selector.SelectedTab == null);
AddAssert("all rulesets disabled", () => selector.TabContainer.TabItems.All(t => !t.Enabled.Value));

View File

@ -71,7 +71,7 @@ public void TestLocalBeatmaps()
Ratings = Enumerable.Range(0, 11).ToArray(),
HasStoryboard = true,
Covers = new BeatmapSetOnlineCovers(),
Beatmaps = new List<APIBeatmap>
Beatmaps = new[]
{
new APIBeatmap
{
@ -145,7 +145,7 @@ public void TestMultipleRulesets()
var set = getBeatmapSet();
set.Beatmaps = beatmaps;
set.Beatmaps = beatmaps.ToArray();
overlay.ShowBeatmapSet(set);
});
@ -211,7 +211,7 @@ private APIBeatmapSet createManyDifficultiesBeatmapSet()
});
}
set.Beatmaps = beatmaps;
set.Beatmaps = beatmaps.ToArray();
return set;
}

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
@ -46,7 +45,7 @@ public void TestMetrics()
static APIBeatmapSet createSet() => new APIBeatmapSet
{
Beatmaps = new List<APIBeatmap>
Beatmaps = new[]
{
new APIBeatmap
{

View File

@ -90,7 +90,7 @@ private void load(RulesetStore rulesets)
HasVideo = true,
HasStoryboard = true,
Covers = new BeatmapSetOnlineCovers(),
Beatmaps = new List<APIBeatmap>
Beatmaps = new[]
{
new APIBeatmap
{
@ -129,7 +129,7 @@ APIBeatmapSet getManyDifficultiesBeatmapSet()
HasVideo = true,
HasStoryboard = true,
Covers = new BeatmapSetOnlineCovers(),
Beatmaps = beatmaps,
Beatmaps = beatmaps.ToArray(),
};
}
}

View File

@ -119,7 +119,7 @@ public string AuthorString
public string Tags { get; set; } = string.Empty;
[JsonProperty(@"beatmaps")]
public IEnumerable<APIBeatmap> Beatmaps { get; set; } = Array.Empty<APIBeatmap>();
public APIBeatmap[] Beatmaps { get; set; } = Array.Empty<APIBeatmap>();
public virtual BeatmapSetInfo ToBeatmapSet(RulesetStore rulesets)
{

View File

@ -147,7 +147,7 @@ protected List<DifficultyIcon> GetDifficultyIcons(OsuColour colours)
{
var icons = new List<DifficultyIcon>();
if (SetInfo.Beatmaps.Count() > maximum_difficulty_icons)
if (SetInfo.Beatmaps.Length > maximum_difficulty_icons)
{
foreach (var ruleset in SetInfo.Beatmaps.Select(b => b.Ruleset).Distinct())
icons.Add(new GroupedDifficultyIcon(SetInfo.Beatmaps.Where(b => b.RulesetID == ruleset.OnlineID).ToList(), ruleset, this is ListBeatmapPanel ? Color4.White : colours.Gray5));

View File

@ -280,7 +280,7 @@ protected override Task<APIBeatmapSet> GetOnlineBeatmapSet(int beatmapId, Cancel
var apiSet = new APIBeatmapSet
{
OnlineID = set.OnlineID,
Beatmaps = set.Beatmaps.Select(b => new APIBeatmap { OnlineID = b.OnlineID })
Beatmaps = set.Beatmaps.Select(b => new APIBeatmap { OnlineID = b.OnlineID }).ToArray(),
};
return Task.FromResult(apiSet);