1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-06 08:22:56 +08:00

Update some other missed incorrect null/empty usages

This commit is contained in:
Dean Herbert 2021-11-04 14:50:39 +09:00
parent 1e73b09e57
commit d1e6d1cb98
7 changed files with 14 additions and 14 deletions

View File

@ -53,7 +53,7 @@ namespace osu.Game.Tests.Editing.Checks
public void TestMissing() public void TestMissing()
{ {
// While this is a problem, it is out of scope for this check and is caught by a different one. // While this is a problem, it is out of scope for this check and is caught by a different one.
beatmap.Metadata.BackgroundFile = null; beatmap.Metadata.BackgroundFile = string.Empty;
var context = getContext(null, System.Array.Empty<byte>()); var context = getContext(null, System.Array.Empty<byte>());
Assert.That(check.Run(context), Is.Empty); Assert.That(check.Run(context), Is.Empty);

View File

@ -65,7 +65,7 @@ namespace osu.Game.Tests.Editing.Checks
[Test] [Test]
public void TestBackgroundNotSet() public void TestBackgroundNotSet()
{ {
beatmap.Metadata.BackgroundFile = null; beatmap.Metadata.BackgroundFile = string.Empty;
var context = new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap)); var context = new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap));
var issues = check.Run(context).ToList(); var issues = check.Run(context).ToList();

View File

@ -189,7 +189,7 @@ namespace osu.Game.Tests.NonVisual.Filtering
public void TestCriteriaMatchingArtistWithNullUnicodeName(string artistName, bool filtered) public void TestCriteriaMatchingArtistWithNullUnicodeName(string artistName, bool filtered)
{ {
var exampleBeatmapInfo = getExampleBeatmap(); var exampleBeatmapInfo = getExampleBeatmap();
exampleBeatmapInfo.Metadata.ArtistUnicode = null; exampleBeatmapInfo.Metadata.ArtistUnicode = string.Empty;
var criteria = new FilterCriteria var criteria = new FilterCriteria
{ {

View File

@ -23,10 +23,10 @@ namespace osu.Game.Tests.Visual.Editing
AddStep("set metadata", () => AddStep("set metadata", () =>
{ {
editorBeatmap.Metadata.Artist = "Example Artist"; editorBeatmap.Metadata.Artist = "Example Artist";
editorBeatmap.Metadata.ArtistUnicode = null; editorBeatmap.Metadata.ArtistUnicode = string.Empty;
editorBeatmap.Metadata.Title = "Example Title"; editorBeatmap.Metadata.Title = "Example Title";
editorBeatmap.Metadata.TitleUnicode = null; editorBeatmap.Metadata.TitleUnicode = string.Empty;
}); });
createSection(); createSection();
@ -44,10 +44,10 @@ namespace osu.Game.Tests.Visual.Editing
AddStep("set metadata", () => AddStep("set metadata", () =>
{ {
editorBeatmap.Metadata.ArtistUnicode = "*なみりん"; editorBeatmap.Metadata.ArtistUnicode = "*なみりん";
editorBeatmap.Metadata.Artist = null; editorBeatmap.Metadata.Artist = string.Empty;
editorBeatmap.Metadata.TitleUnicode = "コイシテイク・プラネット"; editorBeatmap.Metadata.TitleUnicode = "コイシテイク・プラネット";
editorBeatmap.Metadata.Title = null; editorBeatmap.Metadata.Title = string.Empty;
}); });
createSection(); createSection();
@ -86,10 +86,10 @@ namespace osu.Game.Tests.Visual.Editing
AddStep("set metadata", () => AddStep("set metadata", () =>
{ {
editorBeatmap.Metadata.ArtistUnicode = "*なみりん"; editorBeatmap.Metadata.ArtistUnicode = "*なみりん";
editorBeatmap.Metadata.Artist = null; editorBeatmap.Metadata.Artist = string.Empty;
editorBeatmap.Metadata.TitleUnicode = "コイシテイク・プラネット"; editorBeatmap.Metadata.TitleUnicode = "コイシテイク・プラネット";
editorBeatmap.Metadata.Title = null; editorBeatmap.Metadata.Title = string.Empty;
}); });
createSection(); createSection();

View File

@ -54,7 +54,7 @@ namespace osu.Game.Tests.Visual.Gameplay
ScoreInfo = { BeatmapInfo = gameplayState.Beatmap.BeatmapInfo } ScoreInfo = { BeatmapInfo = gameplayState.Beatmap.BeatmapInfo }
}) })
{ {
ScreenSpaceToGamefield = pos => recordingManager.ToLocalSpace(pos) ScreenSpaceToGamefield = pos => recordingManager?.ToLocalSpace(pos) ?? Vector2.Zero,
}, },
Child = new Container Child = new Container
{ {
@ -84,7 +84,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{ {
ReplayInputHandler = new TestFramedReplayInputHandler(replay) ReplayInputHandler = new TestFramedReplayInputHandler(replay)
{ {
GamefieldToScreenSpace = pos => playbackManager.ToScreenSpace(pos), GamefieldToScreenSpace = pos => playbackManager?.ToScreenSpace(pos) ?? Vector2.Zero,
}, },
Child = new Container Child = new Container
{ {

View File

@ -142,7 +142,7 @@ namespace osu.Game.Screens.Select.Carousel
}, },
new OsuSpriteText new OsuSpriteText
{ {
Text = $"{(beatmapInfo.Metadata ?? beatmapInfo.BeatmapSet.Metadata).Author.Username}", Text = $"{(beatmapInfo.Metadata ?? beatmapInfo.BeatmapSet.Metadata).Author?.Username ?? string.Empty}",
Font = OsuFont.GetFont(italics: true), Font = OsuFont.GetFont(italics: true),
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft Origin = Anchor.BottomLeft

View File

@ -77,8 +77,8 @@ namespace osu.Game.Storyboards
{ {
get get
{ {
string backgroundPath = BeatmapInfo.BeatmapSet?.Metadata?.BackgroundFile?.ToLowerInvariant(); string backgroundPath = BeatmapInfo.BeatmapSet?.Metadata?.BackgroundFile.ToLowerInvariant();
if (backgroundPath == null) if (string.IsNullOrEmpty(backgroundPath))
return false; return false;
return GetLayer("Background").Elements.Any(e => e.Path.ToLowerInvariant() == backgroundPath); return GetLayer("Background").Elements.Any(e => e.Path.ToLowerInvariant() == backgroundPath);