Fix some null inspections

This commit is contained in:
Dean Herbert 2022-01-04 14:35:18 +09:00
parent 667cdb2475
commit 3811bd8520
9 changed files with 14 additions and 18 deletions

View File

@ -744,7 +744,7 @@ public void TestDifficultyIconSelectingForDifferentRuleset()
AddUntilStep("Check ruleset changed to mania", () => Ruleset.Value.OnlineID == 3);
AddAssert("Selected beatmap still same set", () => songSelect.Carousel.SelectedBeatmapInfo.BeatmapSet.OnlineID == previousSetID);
AddAssert("Selected beatmap still same set", () => songSelect.Carousel.SelectedBeatmapInfo.BeatmapSet?.OnlineID == previousSetID);
AddAssert("Selected beatmap is mania", () => Beatmap.Value.BeatmapInfo.Ruleset.OnlineID == 3);
}
@ -760,7 +760,7 @@ public void TestGroupedDifficultyIconSelecting()
AddStep("import huge difficulty count map", () =>
{
var usableRulesets = rulesets.AvailableRulesets.Where(r => r.OnlineID != 2).ToArray();
imported = manager.Import(TestResources.CreateTestBeatmapSetInfo(50, usableRulesets)).GetResultSafely().Value;
imported = manager.Import(TestResources.CreateTestBeatmapSetInfo(50, usableRulesets)).GetResultSafely()?.Value;
});
AddStep("select the first beatmap of import", () => Beatmap.Value = manager.GetWorkingBeatmap(imported.Beatmaps.First()));

View File

@ -85,11 +85,7 @@ public virtual WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo)
if (beatmapInfo?.BeatmapSet == null)
return DefaultBeatmap;
WorkingBeatmap working = null;
working = new BeatmapManagerWorkingBeatmap(beatmapInfo, this);
return working;
return new BeatmapManagerWorkingBeatmap(beatmapInfo, this);
}
#region IResourceStorageProvider

View File

@ -173,7 +173,7 @@ private Drawable[] createContent(int index, ScoreInfo score)
{
Text = score.MaxCombo.ToLocalisableString(@"0\x"),
Font = OsuFont.GetFont(size: text_size),
Colour = score.MaxCombo == score.BeatmapInfo?.MaxCombo ? highAccuracyColour : Color4.White
Colour = score.MaxCombo == score.BeatmapInfo.MaxCombo ? highAccuracyColour : Color4.White
}
};

View File

@ -42,7 +42,7 @@ public IEnumerable<Issue> Run(BeatmapVerifierContext context)
foreach (string filename in videoPaths)
{
string storagePath = beatmapSet.GetPathForFile(filename);
string storagePath = beatmapSet?.GetPathForFile(filename);
if (storagePath == null)
{

View File

@ -40,7 +40,7 @@ public class IssueList : CompositeDrawable
private void load(OverlayColourProvider colours)
{
generalVerifier = new BeatmapVerifier();
rulesetVerifier = beatmap.BeatmapInfo.Ruleset?.CreateInstance().CreateBeatmapVerifier();
rulesetVerifier = beatmap.BeatmapInfo.Ruleset.CreateInstance().CreateBeatmapVerifier();
context = new BeatmapVerifierContext(beatmap, workingBeatmap.Value, verify.InterpretedDifficulty.Value);
verify.InterpretedDifficulty.BindValueChanged(difficulty => context.InterpretedDifficulty = difficulty.NewValue);

View File

@ -20,7 +20,7 @@ private void load(BeatmapManager beatmapManager)
public BeatmapDeleteDialog(BeatmapSetInfo beatmap)
{
BodyText = $@"{beatmap.Metadata?.Artist} - {beatmap.Metadata?.Title}";
BodyText = $@"{beatmap.Metadata.Artist} - {beatmap.Metadata.Title}";
Icon = FontAwesome.Regular.TrashAlt;
HeaderText = @"Confirm deletion of";

View File

@ -63,16 +63,16 @@ public override int CompareTo(FilterCriteria criteria, CarouselItem other)
{
default:
case SortMode.Artist:
return string.Compare(BeatmapSet.Metadata?.Artist, otherSet.BeatmapSet.Metadata?.Artist, StringComparison.OrdinalIgnoreCase);
return string.Compare(BeatmapSet.Metadata.Artist, otherSet.BeatmapSet.Metadata.Artist, StringComparison.OrdinalIgnoreCase);
case SortMode.Title:
return string.Compare(BeatmapSet.Metadata?.Title, otherSet.BeatmapSet.Metadata?.Title, StringComparison.OrdinalIgnoreCase);
return string.Compare(BeatmapSet.Metadata.Title, otherSet.BeatmapSet.Metadata.Title, StringComparison.OrdinalIgnoreCase);
case SortMode.Author:
return string.Compare(BeatmapSet.Metadata?.Author.Username, otherSet.BeatmapSet.Metadata?.Author.Username, StringComparison.OrdinalIgnoreCase);
return string.Compare(BeatmapSet.Metadata.Author.Username, otherSet.BeatmapSet.Metadata.Author.Username, StringComparison.OrdinalIgnoreCase);
case SortMode.Source:
return string.Compare(BeatmapSet.Metadata?.Source, otherSet.BeatmapSet.Metadata?.Source, StringComparison.OrdinalIgnoreCase);
return string.Compare(BeatmapSet.Metadata.Source, otherSet.BeatmapSet.Metadata.Source, StringComparison.OrdinalIgnoreCase);
case SortMode.DateAdded:
return otherSet.BeatmapSet.DateAdded.CompareTo(BeatmapSet.DateAdded);

View File

@ -142,7 +142,7 @@ private void load(BeatmapManager manager, SongSelect songSelect)
},
new OsuSpriteText
{
Text = $"{(beatmapInfo.Metadata ?? beatmapInfo.BeatmapSet.Metadata).Author.Username}",
Text = $"{beatmapInfo.Metadata.Author.Username}",
Font = OsuFont.GetFont(italics: true),
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft

View File

@ -41,13 +41,13 @@ private void load()
{
new OsuSpriteText
{
Text = new RomanisableString(beatmapSet.Metadata?.TitleUnicode, beatmapSet.Metadata?.Title),
Text = new RomanisableString(beatmapSet.Metadata.TitleUnicode, beatmapSet.Metadata.Title),
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 22, italics: true),
Shadow = true,
},
new OsuSpriteText
{
Text = new RomanisableString(beatmapSet.Metadata?.ArtistUnicode, beatmapSet.Metadata?.Artist),
Text = new RomanisableString(beatmapSet.Metadata.ArtistUnicode, beatmapSet.Metadata.Artist),
Font = OsuFont.GetFont(weight: FontWeight.SemiBold, size: 17, italics: true),
Shadow = true,
},