diff --git a/osu.Game.Tests/Models/DisplayStringTest.cs b/osu.Game.Tests/Models/DisplayStringTest.cs index 95af21eb5f..2d0bda88e4 100644 --- a/osu.Game.Tests/Models/DisplayStringTest.cs +++ b/osu.Game.Tests/Models/DisplayStringTest.cs @@ -29,9 +29,9 @@ namespace osu.Game.Tests.Models { var mock = new Mock(); - mock.Setup(m => m.Metadata!.Artist).Returns("artist"); - mock.Setup(m => m.Metadata!.Title).Returns("title"); - mock.Setup(m => m.Metadata!.Author.Username).Returns("author"); + mock.Setup(m => m.Metadata.Artist).Returns("artist"); + mock.Setup(m => m.Metadata.Title).Returns("title"); + mock.Setup(m => m.Metadata.Author.Username).Returns("author"); Assert.That(mock.Object.GetDisplayString(), Is.EqualTo("artist - title (author)")); } @@ -41,9 +41,9 @@ namespace osu.Game.Tests.Models { var mock = new Mock(); - mock.Setup(m => m.Metadata!.Artist).Returns("artist"); - mock.Setup(m => m.Metadata!.Title).Returns("title"); - mock.Setup(m => m.Metadata!.Author.Username).Returns(string.Empty); + mock.Setup(m => m.Metadata.Artist).Returns("artist"); + mock.Setup(m => m.Metadata.Title).Returns("title"); + mock.Setup(m => m.Metadata.Author.Username).Returns(string.Empty); Assert.That(mock.Object.GetDisplayString(), Is.EqualTo("artist - title")); } diff --git a/osu.Game/Beatmaps/BeatmapSetInfo.cs b/osu.Game/Beatmaps/BeatmapSetInfo.cs index 998bc6f16c..71bca48c2c 100644 --- a/osu.Game/Beatmaps/BeatmapSetInfo.cs +++ b/osu.Game/Beatmaps/BeatmapSetInfo.cs @@ -94,7 +94,7 @@ namespace osu.Game.Beatmaps #region Implementation of IBeatmapSetInfo - IBeatmapMetadataInfo IBeatmapSetInfo.Metadata => Metadata; + IBeatmapMetadataInfo IBeatmapSetInfo.Metadata => Metadata ?? Beatmaps.FirstOrDefault()?.Metadata ?? new BeatmapMetadata(); IEnumerable IBeatmapSetInfo.Beatmaps => Beatmaps; IEnumerable IBeatmapSetInfo.Files => Files; diff --git a/osu.Game/Beatmaps/IBeatmapSetInfo.cs b/osu.Game/Beatmaps/IBeatmapSetInfo.cs index 67f38397d4..aa114c8472 100644 --- a/osu.Game/Beatmaps/IBeatmapSetInfo.cs +++ b/osu.Game/Beatmaps/IBeatmapSetInfo.cs @@ -22,7 +22,7 @@ namespace osu.Game.Beatmaps /// /// The best-effort metadata representing this set. In the case metadata differs between contained beatmaps, one is arbitrarily chosen. /// - IBeatmapMetadataInfo? Metadata { get; } + IBeatmapMetadataInfo Metadata { get; } /// /// All beatmaps contained in this set. diff --git a/osu.Game/Extensions/ModelExtensions.cs b/osu.Game/Extensions/ModelExtensions.cs index aaf87385c8..9f00d21383 100644 --- a/osu.Game/Extensions/ModelExtensions.cs +++ b/osu.Game/Extensions/ModelExtensions.cs @@ -42,7 +42,7 @@ namespace osu.Game.Extensions switch (model) { case IBeatmapSetInfo beatmapSetInfo: - result = beatmapSetInfo.Metadata?.GetDisplayTitle(); + result = beatmapSetInfo.Metadata.GetDisplayTitle(); break; case IBeatmapInfo beatmapInfo: diff --git a/osu.Game/Models/RealmBeatmapSet.cs b/osu.Game/Models/RealmBeatmapSet.cs index da75978977..ff39bcf13e 100644 --- a/osu.Game/Models/RealmBeatmapSet.cs +++ b/osu.Game/Models/RealmBeatmapSet.cs @@ -26,7 +26,7 @@ namespace osu.Game.Models public DateTimeOffset DateAdded { get; set; } - public IBeatmapMetadataInfo? Metadata => Beatmaps.FirstOrDefault()?.Metadata; + public IBeatmapMetadataInfo Metadata => Beatmaps.FirstOrDefault()?.Metadata ?? new RealmBeatmapMetadata(); public IList Beatmaps { get; } = null!; @@ -62,7 +62,7 @@ namespace osu.Game.Models return ID == other.ID; } - public override string ToString() => Metadata?.GetDisplayString() ?? base.ToString(); + public override string ToString() => Metadata.GetDisplayString(); public bool Equals(IBeatmapSetInfo? other) => other is RealmBeatmapSet b && Equals(b);