From 3b151b06f59653efe74dcbeddc55e49f5708cd16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=82=BA=E4=BB=80=E9=BA=BC?= Date: Fri, 8 Jul 2022 19:20:19 +0800 Subject: [PATCH 01/19] Some params in the karaoke skin should not be null. --- osu.Game.Rulesets.Karaoke/Edit/Lyrics/LyricEditorSkin.cs | 8 +++----- osu.Game.Rulesets.Karaoke/Skinning/DefaultKaraokeSkin.cs | 4 ++-- osu.Game.Rulesets.Karaoke/Skinning/KaraokeBeatmapSkin.cs | 2 +- osu.Game.Rulesets.Karaoke/Skinning/KaraokeSkin.cs | 8 ++++---- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/LyricEditorSkin.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/LyricEditorSkin.cs index 6100d5596..9177fbdb0 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/LyricEditorSkin.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/LyricEditorSkin.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System; using System.Collections.Generic; using JetBrains.Annotations; @@ -36,13 +34,13 @@ public class LyricEditorSkin : KaraokeSkin InstantiationInfo = typeof(DefaultKaraokeSkin).GetInvariantInstantiationInfo(), }; - public LyricEditorSkin(IStorageResourceProvider resources) + public LyricEditorSkin(IStorageResourceProvider? resources) : this(CreateInfo(), resources) { } [UsedImplicitly(ImplicitUseKindFlags.InstantiatedWithFixedConstructorSignature)] - public LyricEditorSkin(SkinInfo skin, IStorageResourceProvider resources) + public LyricEditorSkin(SkinInfo skin, IStorageResourceProvider? resources) : base(skin, resources) { DefaultElement[ElementType.LyricConfig] = LyricConfig.CreateDefault(); @@ -73,7 +71,7 @@ public LyricEditorSkin(SkinInfo skin, IStorageResourceProvider resources) FontSize = 26; } - protected LyricConfig LyricConfig => DefaultElement[ElementType.LyricConfig] as LyricConfig; + protected LyricConfig LyricConfig => (LyricConfig)DefaultElement[ElementType.LyricConfig]; public float FontSize { diff --git a/osu.Game.Rulesets.Karaoke/Skinning/DefaultKaraokeSkin.cs b/osu.Game.Rulesets.Karaoke/Skinning/DefaultKaraokeSkin.cs index 6af642957..41277eb76 100644 --- a/osu.Game.Rulesets.Karaoke/Skinning/DefaultKaraokeSkin.cs +++ b/osu.Game.Rulesets.Karaoke/Skinning/DefaultKaraokeSkin.cs @@ -23,13 +23,13 @@ public class DefaultKaraokeSkin : KaraokeSkin InstantiationInfo = typeof(DefaultKaraokeSkin).GetInvariantInstantiationInfo() }; - public DefaultKaraokeSkin(IStorageResourceProvider resources) + public DefaultKaraokeSkin(IStorageResourceProvider? resources) : this(CreateInfo(), resources) { } [UsedImplicitly(ImplicitUseKindFlags.InstantiatedWithFixedConstructorSignature)] - public DefaultKaraokeSkin(SkinInfo skin, IStorageResourceProvider resources) + public DefaultKaraokeSkin(SkinInfo skin, IStorageResourceProvider? resources) : base(skin, resources) { DefaultElement[ElementType.LyricConfig] = LyricConfig.CreateDefault(); diff --git a/osu.Game.Rulesets.Karaoke/Skinning/KaraokeBeatmapSkin.cs b/osu.Game.Rulesets.Karaoke/Skinning/KaraokeBeatmapSkin.cs index e2ebb8521..4f10506cc 100644 --- a/osu.Game.Rulesets.Karaoke/Skinning/KaraokeBeatmapSkin.cs +++ b/osu.Game.Rulesets.Karaoke/Skinning/KaraokeBeatmapSkin.cs @@ -28,7 +28,7 @@ public class KaraokeBeatmapSkin : KaraokeSkin public readonly List Groups = new(); public readonly List DefaultMappingRoles = new(); - public KaraokeBeatmapSkin(SkinInfo skin, IStorageResourceProvider resources, IResourceStore? storage = null) + public KaraokeBeatmapSkin(SkinInfo skin, IStorageResourceProvider? resources, IResourceStore? storage = null) : base(skin, resources, storage) { SkinInfo.PerformRead(s => diff --git a/osu.Game.Rulesets.Karaoke/Skinning/KaraokeSkin.cs b/osu.Game.Rulesets.Karaoke/Skinning/KaraokeSkin.cs index b798369b2..941cefb33 100644 --- a/osu.Game.Rulesets.Karaoke/Skinning/KaraokeSkin.cs +++ b/osu.Game.Rulesets.Karaoke/Skinning/KaraokeSkin.cs @@ -42,9 +42,9 @@ public class KaraokeSkin : Skin private readonly Bindable bindableColumnHeight = new(DefaultColumnBackground.COLUMN_HEIGHT); private readonly Bindable bindableColumnSpacing = new(ScrollingNotePlayfield.COLUMN_SPACING); - private readonly IStorageResourceProvider resources; + private readonly IStorageResourceProvider? resources; - public KaraokeSkin(SkinInfo skin, IStorageResourceProvider resources, IResourceStore? storage = null) + public KaraokeSkin(SkinInfo skin, IStorageResourceProvider? resources, IResourceStore? storage = null) : base(skin, resources, storage) { this.resources = resources; @@ -87,7 +87,7 @@ protected JsonSerializerSettings CreateJsonSerializerSettings(params JsonConvert protected string? GetElementStringContentFromSkinInfo(SkinInfo skinInfo, string filename) { // should get by file name if files is namespace resource store. - var files = resources.Files; + var files = resources?.Files; if (files == null) return null; @@ -114,7 +114,7 @@ protected JsonSerializerSettings CreateJsonSerializerSettings(params JsonConvert } public override ISample? GetSample(ISampleInfo sampleInfo) - => sampleInfo.LookupNames.Select(lookup => resources.AudioManager.Samples.Get(lookup)).FirstOrDefault(sample => sample != null); + => sampleInfo.LookupNames.Select(lookup => resources?.AudioManager.Samples.Get(lookup)).FirstOrDefault(sample => sample != null); public override Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => null; From 2b9b3e2aac99f188b5320fd66ea5392aac9b75dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=82=BA=E4=BB=80=E9=BA=BC?= Date: Fri, 8 Jul 2022 19:23:10 +0800 Subject: [PATCH 02/19] Use string.empty instead. --- .../Editor/TestSceneInvalidLyricToolTip.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneInvalidLyricToolTip.cs b/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneInvalidLyricToolTip.cs index 7048f971b..5f28e5b46 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneInvalidLyricToolTip.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneInvalidLyricToolTip.cs @@ -101,7 +101,7 @@ public void TestRubyTagInvalidLyric() { StartIndex = 2, EndIndex = 3, - Text = null, + Text = string.Empty, } } } @@ -153,7 +153,7 @@ public void TestRomajiTagInvalidLyric() { StartIndex = 2, EndIndex = 3, - Text = null, + Text = string.Empty, } } } From 0631bb424b76728f923e4661ae0ac2a1ed0d7288 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=82=BA=E4=BB=80=E9=BA=BC?= Date: Fri, 8 Jul 2022 19:30:50 +0800 Subject: [PATCH 03/19] Remove the nullable disable check and fix the api broken. --- .../Editor/TestSceneInvalidLyricToolTip.cs | 39 ++++++++++++++----- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneInvalidLyricToolTip.cs b/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneInvalidLyricToolTip.cs index 5f28e5b46..8cf788c49 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneInvalidLyricToolTip.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneInvalidLyricToolTip.cs @@ -1,12 +1,11 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System.Collections.Generic; using NUnit.Framework; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; +using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit.Checks.Components; using osu.Game.Rulesets.Karaoke.Edit.Checks.Components; using osu.Game.Rulesets.Karaoke.Edit.Components.Cursor; @@ -18,7 +17,7 @@ namespace osu.Game.Rulesets.Karaoke.Tests.Editor [TestFixture] public class TestSceneInvalidLyricToolTip : OsuTestScene { - private InvalidLyricToolTip toolTip; + private InvalidLyricToolTip toolTip = null!; [SetUp] public void SetUp() => Schedule(() => @@ -197,9 +196,9 @@ public void TestTimeTagInvalidLyric() } })); - setTooltip("missing start time-tag", new TestTimeTagIssue(null, true)); - setTooltip("missing end time-tag", new TestTimeTagIssue(null, false, true)); - setTooltip("missing start and end time-tag", new TestTimeTagIssue(null, true, true)); + setTooltip("missing start time-tag", new TestTimeTagIssue(new Dictionary(), true)); + setTooltip("missing end time-tag", new TestTimeTagIssue(new Dictionary(), false, true)); + setTooltip("missing start and end time-tag", new TestTimeTagIssue(new Dictionary(), true, true)); } [Test] @@ -281,10 +280,30 @@ private void setTooltip(string testName, params Issue[] issues) }); } + internal class Check : ICheck + { + public IEnumerable Run(BeatmapVerifierContext context) + { + throw new System.NotImplementedException(); + } + + public CheckMetadata Metadata { get; } = null!; + + public IEnumerable PossibleTemplates { get; } = null!; + } + + internal class TestIssueTemplate : IssueTemplate + { + public TestIssueTemplate() + : base(new Check(), IssueType.Error, string.Empty) + { + } + } + internal class TestLyricTimeIssue : LyricTimeIssue { public TestLyricTimeIssue(TimeInvalid[] invalidLyricTime) - : base(new Lyric(), null, invalidLyricTime) + : base(new Lyric(), new TestIssueTemplate(), invalidLyricTime) { } } @@ -292,7 +311,7 @@ public TestLyricTimeIssue(TimeInvalid[] invalidLyricTime) internal class TestRubyTagIssue : RubyTagIssue { public TestRubyTagIssue(Dictionary invalidRubyTags) - : base(new Lyric(), null, invalidRubyTags) + : base(new Lyric(), new TestIssueTemplate(), invalidRubyTags) { } } @@ -300,7 +319,7 @@ public TestRubyTagIssue(Dictionary invalidRubyTags) internal class TestRomajiTagIssue : RomajiTagIssue { public TestRomajiTagIssue(Dictionary invalidRomajiTags) - : base(new Lyric(), null, invalidRomajiTags) + : base(new Lyric(), new TestIssueTemplate(), invalidRomajiTags) { } } @@ -308,7 +327,7 @@ public TestRomajiTagIssue(Dictionary invalidRomaj internal class TestTimeTagIssue : TimeTagIssue { public TestTimeTagIssue(Dictionary invalidTimeTags, bool missingStartTimeTag = false, bool missingEndTimeTag = false) - : base(new Lyric(), null, invalidTimeTags, missingStartTimeTag, missingEndTimeTag) + : base(new Lyric(), new TestIssueTemplate(), invalidTimeTags, missingStartTimeTag, missingEndTimeTag) { } } From adf2033cca3b53b49225065dc134f648f13aa39d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=82=BA=E4=BB=80=E9=BA=BC?= Date: Fri, 8 Jul 2022 19:34:27 +0800 Subject: [PATCH 04/19] Remove nullable disable annotation in other test cases. --- .../Editor/KaraokeEditorScreenTestScene.cs | 2 -- osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneEditor.cs | 2 -- .../Editor/TestSceneEditorMenuBar.cs | 2 -- .../Editor/TestSceneGeneratorConfigDialog.cs | 2 -- .../Editor/TestSceneKaraokeEditor.cs | 6 ++---- .../Editor/TestSceneLayoutToolTip.cs | 4 +--- .../Editor/TestSceneLyricEditorScreen.cs | 8 +++----- .../Editor/TestSceneLyricImporter.cs | 4 +--- .../Editor/TestSceneSetupScreen.cs | 2 -- .../Editor/TestSceneSingerScreen.cs | 8 +++----- .../Editor/TestSceneTimeTagTooltip.cs | 4 +--- .../Editor/TestSceneTranslateScreen.cs | 6 ++---- 12 files changed, 13 insertions(+), 37 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke.Tests/Editor/KaraokeEditorScreenTestScene.cs b/osu.Game.Rulesets.Karaoke.Tests/Editor/KaraokeEditorScreenTestScene.cs index 77e196ee3..b7f16254e 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Editor/KaraokeEditorScreenTestScene.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Editor/KaraokeEditorScreenTestScene.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System; using osu.Framework.Allocation; using osu.Framework.Graphics; diff --git a/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneEditor.cs b/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneEditor.cs index 85e38e5b9..e8406d947 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneEditor.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneEditor.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using NUnit.Framework; using osu.Game.Beatmaps; using osu.Game.Rulesets.Karaoke.Tests.Beatmaps; diff --git a/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneEditorMenuBar.cs b/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneEditorMenuBar.cs index c97a21bd1..1ceda3684 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneEditorMenuBar.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneEditorMenuBar.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Bindables; diff --git a/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneGeneratorConfigDialog.cs b/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneGeneratorConfigDialog.cs index 6bdb0e3d3..87c8ed65c 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneGeneratorConfigDialog.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneGeneratorConfigDialog.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System; using NUnit.Framework; using osu.Framework.Allocation; diff --git a/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneKaraokeEditor.cs b/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneKaraokeEditor.cs index 923dd85a3..db6f12c5c 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneKaraokeEditor.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneKaraokeEditor.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -31,8 +29,8 @@ public class TestSceneKaraokeEditor : ScreenTestScene protected override KaraokeEditor CreateScreen() => new(); - private DialogOverlay dialogOverlay; - private LyricCheckerManager lyricCheckerManager; + private DialogOverlay dialogOverlay = null!; + private LyricCheckerManager lyricCheckerManager = null!; public TestSceneKaraokeEditor() { diff --git a/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneLayoutToolTip.cs b/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneLayoutToolTip.cs index f6a8cd523..b3e1c4e25 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneLayoutToolTip.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneLayoutToolTip.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System; using System.Collections.Generic; using NUnit.Framework; @@ -19,7 +17,7 @@ namespace osu.Game.Rulesets.Karaoke.Tests.Editor public class TestSceneLayoutToolTip : OsuTestScene { private readonly ISkin skin = new DefaultKaraokeSkin(null); - private LayoutToolTip toolTip; + private LayoutToolTip toolTip = null!; [SetUp] public void SetUp() => Schedule(() => diff --git a/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneLyricEditorScreen.cs b/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneLyricEditorScreen.cs index 6d112817c..1a1fe1d84 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneLyricEditorScreen.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneLyricEditorScreen.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System; using System.Linq; using NUnit.Framework; @@ -31,9 +29,9 @@ public class TestSceneLyricEditorScreen : KaraokeEditorScreenTestScene new(); - private DialogOverlay dialogOverlay; - private LyricsProvider lyricsProvider; - private LyricCheckerManager lyricCheckManager; + private DialogOverlay dialogOverlay = null!; + private LyricsProvider lyricsProvider = null!; + private LyricCheckerManager lyricCheckManager = null!; [BackgroundDependencyLoader] private void load() diff --git a/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneLyricImporter.cs b/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneLyricImporter.cs index eb98f88d4..f74e41350 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneLyricImporter.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneLyricImporter.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System; using System.IO; using System.Linq; @@ -39,7 +37,7 @@ protected override TestLyricImporter CreateScreen() return new TestLyricImporter(new FileInfo(temp)); } - private DialogOverlay dialogOverlay; + private DialogOverlay dialogOverlay = null!; public TestSceneLyricImporter() { diff --git a/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneSetupScreen.cs b/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneSetupScreen.cs index 2497a8be5..062196af7 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneSetupScreen.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneSetupScreen.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics.Containers; diff --git a/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneSingerScreen.cs b/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneSingerScreen.cs index ceeee057e..c9e6f33b7 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneSingerScreen.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneSingerScreen.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System.Collections.Generic; using NUnit.Framework; using osu.Framework.Allocation; @@ -64,9 +62,9 @@ protected override KaraokeBeatmap CreateBeatmap() return karaokeBeatmap; } - private DialogOverlay dialogOverlay; - private LyricsProvider lyricsProvider; - private KaraokeBeatmapResourcesProvider karaokeBeatmapResourcesProvider; + private DialogOverlay dialogOverlay = null!; + private LyricsProvider lyricsProvider = null!; + private KaraokeBeatmapResourcesProvider karaokeBeatmapResourcesProvider = null!; [BackgroundDependencyLoader] private void load() diff --git a/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneTimeTagTooltip.cs b/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneTimeTagTooltip.cs index 594d85b57..accf6578b 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneTimeTagTooltip.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneTimeTagTooltip.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using NUnit.Framework; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; @@ -15,7 +13,7 @@ namespace osu.Game.Rulesets.Karaoke.Tests.Editor [TestFixture] public class TestSceneTimeTagTooltip : OsuTestScene { - private TimeTagTooltip toolTip; + private TimeTagTooltip toolTip = null!; [SetUp] public void SetUp() => Schedule(() => diff --git a/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneTranslateScreen.cs b/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneTranslateScreen.cs index d0d68b976..b7c15c7e1 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneTranslateScreen.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneTranslateScreen.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System.Collections.Generic; using System.Globalization; using NUnit.Framework; @@ -37,8 +35,8 @@ protected override KaraokeBeatmap CreateBeatmap() return karaokeBeatmap; } - private DialogOverlay dialogOverlay; - private LyricsProvider lyricsProvider; + private DialogOverlay dialogOverlay = null!; + private LyricsProvider lyricsProvider = null!; [BackgroundDependencyLoader] private void load() From 3af22475ab4f11e5aa207b5f9ef6fa098ca7240f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=82=BA=E4=BB=80=E9=BA=BC?= Date: Fri, 8 Jul 2022 19:35:48 +0800 Subject: [PATCH 05/19] Remove un-need namespace. --- osu.Game.Rulesets.Karaoke/Skinning/MappingRoles/MappingRole.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game.Rulesets.Karaoke/Skinning/MappingRoles/MappingRole.cs b/osu.Game.Rulesets.Karaoke/Skinning/MappingRoles/MappingRole.cs index be334f309..f90388edd 100644 --- a/osu.Game.Rulesets.Karaoke/Skinning/MappingRoles/MappingRole.cs +++ b/osu.Game.Rulesets.Karaoke/Skinning/MappingRoles/MappingRole.cs @@ -1,7 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -using System; using osu.Game.Rulesets.Karaoke.Objects; using osu.Game.Rulesets.Karaoke.Skinning.Elements; From 2d6606733230479b08b330575f5a4cb94568bb4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=82=BA=E4=BB=80=E9=BA=BC?= Date: Fri, 8 Jul 2022 19:36:38 +0800 Subject: [PATCH 06/19] This parameter should always not to be null. --- osu.Game.Rulesets.Karaoke/Mods/KaraokeModFlashlight.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Mods/KaraokeModFlashlight.cs b/osu.Game.Rulesets.Karaoke/Mods/KaraokeModFlashlight.cs index e2e680a66..b0fb1f151 100644 --- a/osu.Game.Rulesets.Karaoke/Mods/KaraokeModFlashlight.cs +++ b/osu.Game.Rulesets.Karaoke/Mods/KaraokeModFlashlight.cs @@ -3,7 +3,6 @@ using System; using System.Linq; -using JetBrains.Annotations; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; @@ -88,8 +87,8 @@ protected override void Update() flashlightProperties.Validate(); } - [BackgroundDependencyLoader(true)] - private void load([NotNull] IScrollingInfo scrollingInfo) + [BackgroundDependencyLoader] + private void load(IScrollingInfo scrollingInfo) { direction.BindTo(scrollingInfo.Direction); direction.BindValueChanged(OnDirectionChanged, true); From 28444b4b73f336ad9f5db0c9cb887ce040d2ec46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=82=BA=E4=BB=80=E9=BA=BC?= Date: Fri, 8 Jul 2022 19:41:50 +0800 Subject: [PATCH 07/19] Remove the nullable disable annotation and fix the suggestion by rider. --- .../Screens/Skin/Layout/PreviewSection.cs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Screens/Skin/Layout/PreviewSection.cs b/osu.Game.Rulesets.Karaoke/Screens/Skin/Layout/PreviewSection.cs index c60a56e25..f16090855 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Skin/Layout/PreviewSection.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Skin/Layout/PreviewSection.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System; using System.Collections.Generic; using System.ComponentModel; @@ -25,9 +23,9 @@ namespace osu.Game.Rulesets.Karaoke.Screens.Skin.Layout { internal class PreviewSection : LayoutSection { - private LabelledEnumDropdown previewRatioDropdown; - private LabelledEnumDropdown previewSampleDropdown; - private StyleLabelledDropdown previewStyleDropdown; + private LabelledEnumDropdown previewRatioDropdown = null!; + private LabelledEnumDropdown previewSampleDropdown = null!; + private StyleLabelledDropdown previewStyleDropdown = null!; protected override LocalisableString Title => "Preview (Won't be saved)"; @@ -74,7 +72,7 @@ private void load(LayoutManager manager) }, true); } - private Lyric getLyricSampleBySelection(PreviewSample previewSample) => + private Lyric? getLyricSampleBySelection(PreviewSample previewSample) => previewSample switch { PreviewSample.SampleSmall => createDefaultLyric("@カラオケ", @@ -115,7 +113,7 @@ private Lyric getLyricSampleBySelection(PreviewSample previewSample) => _ => null }; - private Lyric createDefaultLyric(string text, string[] ruby, string[] romaji, string translate) + private Lyric createDefaultLyric(string text, IEnumerable ruby, IEnumerable romaji, string translate) { double startTime = Time.Current; const double duration = 1000000; @@ -128,8 +126,8 @@ private Lyric createDefaultLyric(string text, string[] ruby, string[] romaji, st writer.WriteLine("[HitObjects]"); writer.WriteLine(text); - ruby?.ForEach(x => writer.WriteLine(x)); - romaji?.ForEach(x => writer.WriteLine(x)); + ruby.ForEach(x => writer.WriteLine(x)); + romaji.ForEach(x => writer.WriteLine(x)); writer.WriteLine("end"); writer.Flush(); From 13d66414dedded1f12547447092e968ba1b0b94a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=82=BA=E4=BB=80=E9=BA=BC?= Date: Fri, 8 Jul 2022 19:43:10 +0800 Subject: [PATCH 08/19] Fix the change by how BaseGeneratorTest did. --- .../Editor/Generator/BaseDetectorTest.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke.Tests/Editor/Generator/BaseDetectorTest.cs b/osu.Game.Rulesets.Karaoke.Tests/Editor/Generator/BaseDetectorTest.cs index 264684935..7de48608a 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Editor/Generator/BaseDetectorTest.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Editor/Generator/BaseDetectorTest.cs @@ -11,13 +11,11 @@ namespace osu.Game.Rulesets.Karaoke.Tests.Editor.Generator public abstract class BaseDetectorTest where TDetector : class, ILyricPropertyDetector where TConfig : new() { - protected static TConfig GeneratorConfig(params string[] properties) + protected static TConfig GeneratorConfig(params string?[] properties) { var config = new TConfig(); - if (properties == null) - return config; - foreach (string propertyName in properties) + foreach (string? propertyName in properties) { if (propertyName == null) continue; From 962e4b23084ef55f9d3525e75f2f71d027c5a36b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=82=BA=E4=BB=80=E9=BA=BC?= Date: Fri, 8 Jul 2022 19:45:35 +0800 Subject: [PATCH 09/19] Remove the un-need null check. --- osu.Game.Rulesets.Karaoke/Utils/LyricUtils.cs | 18 +++++++++--------- .../Utils/TimeTagUtils.cs | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Utils/LyricUtils.cs b/osu.Game.Rulesets.Karaoke/Utils/LyricUtils.cs index b53e7e2c0..13712e48a 100644 --- a/osu.Game.Rulesets.Karaoke/Utils/LyricUtils.cs +++ b/osu.Game.Rulesets.Karaoke/Utils/LyricUtils.cs @@ -85,7 +85,7 @@ public static void AddText(Lyric lyric, int position, string text) // make position is at the range. string lyricText = lyric.Text; - int lyricTextLength = lyricText?.Length ?? 0; + int lyricTextLength = lyricText.Length; position = Math.Clamp(position, 0, lyricTextLength); int offset = text.Length; @@ -98,7 +98,7 @@ public static void AddText(Lyric lyric, int position, string text) lyric.TimeTags = processTimeTags(lyric.TimeTags, position, offset); // deal with text - string newLyricText = lyricText?[..position] + text + lyricText?[position..]; + string newLyricText = lyricText[..position] + text + lyricText[position..]; lyric.Text = newLyricText; static T[] processTags(IEnumerable tags, int position, int offset) where T : ITextTag => @@ -220,7 +220,7 @@ public static string GetTimeTagDisplayRubyText(Lyric lyric, TimeTag timeTag) #region Ruby/romaji tag public static bool AbleToInsertTextTagAtIndex(Lyric lyric, int index) - => index >= 0 && index <= (lyric.Text?.Length ?? 0); + => index >= 0 && index <= lyric.Text.Length; #endregion @@ -245,8 +245,8 @@ public static string TimeTagTimeFormattedString(Lyric lyric) var minTimeTag = availableTimeTags.OrderBy(x => x.Time).FirstOrDefault(); var maxTimeTag = availableTimeTags.OrderByDescending(x => x.Time).FirstOrDefault(); - string startTime = TimeTagUtils.FormattedString(minTimeTag); - string endTime = TimeTagUtils.FormattedString(maxTimeTag); + string startTime = TimeTagUtils.FormattedString(minTimeTag ?? new TimeTag(new TextIndex())); + string endTime = TimeTagUtils.FormattedString(maxTimeTag ?? new TimeTag(new TextIndex())); return $"{startTime} - {endTime}"; } @@ -262,7 +262,7 @@ public static bool ContainsSinger(Lyric lyric, Singer singer) if (singer == null) throw new ArgumentNullException(nameof(singer)); - return lyric.Singers?.Contains(singer.ID) ?? false; + return lyric.Singers.Contains(singer.ID); } public static bool OnlyContainsSingers(Lyric lyric, List singers) @@ -271,7 +271,7 @@ public static bool OnlyContainsSingers(Lyric lyric, List singers) throw new ArgumentNullException(nameof(singers)); var singerIds = singers.Select(x => x.ID); - return lyric.Singers?.All(x => singerIds.Contains(x)) ?? true; + return lyric.Singers.All(x => singerIds.Contains(x)); } #endregion @@ -295,7 +295,7 @@ public static bool CheckIsTimeOverlapping(Lyric lyric) /// public static bool CheckIsStartTimeInvalid(Lyric lyric) { - if (lyric.TimeTags == null || !lyric.TimeTags.Any()) + if (!lyric.TimeTags.Any()) return false; return lyric.StartTime > TimeTagsUtils.GetStartTime(lyric.TimeTags); @@ -308,7 +308,7 @@ public static bool CheckIsStartTimeInvalid(Lyric lyric) /// public static bool CheckIsEndTimeInvalid(Lyric lyric) { - if (lyric.TimeTags == null || !lyric.TimeTags.Any()) + if (!lyric.TimeTags.Any()) return false; return lyric.EndTime < TimeTagsUtils.GetEndTime(lyric.TimeTags); diff --git a/osu.Game.Rulesets.Karaoke/Utils/TimeTagUtils.cs b/osu.Game.Rulesets.Karaoke/Utils/TimeTagUtils.cs index 9fd7aba35..057a594b0 100644 --- a/osu.Game.Rulesets.Karaoke/Utils/TimeTagUtils.cs +++ b/osu.Game.Rulesets.Karaoke/Utils/TimeTagUtils.cs @@ -32,7 +32,7 @@ public static TimeTag ShiftingTimeTag(TimeTag timeTag, int offset) /// public static string FormattedString(TimeTag timeTag) { - return timeTag?.Time?.ToEditorFormattedString() ?? "--:--:---"; + return timeTag.Time?.ToEditorFormattedString() ?? "--:--:---"; } } } From a965cb4386f7e4b02ab31e8e45ee4831879cbcb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=82=BA=E4=BB=80=E9=BA=BC?= Date: Fri, 8 Jul 2022 19:48:07 +0800 Subject: [PATCH 10/19] Remove some un-need null check. --- osu.Game.Rulesets.Karaoke/Beatmaps/Formats/LrcEncoder.cs | 3 --- .../Edit/Checks/CheckInvalidPropertyLyrics.cs | 2 +- .../Edit/Generator/TimeTags/Ja/JaTimeTagGenerator.cs | 3 --- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Beatmaps/Formats/LrcEncoder.cs b/osu.Game.Rulesets.Karaoke/Beatmaps/Formats/LrcEncoder.cs index bd388822a..e2ab637ee 100644 --- a/osu.Game.Rulesets.Karaoke/Beatmaps/Formats/LrcEncoder.cs +++ b/osu.Game.Rulesets.Karaoke/Beatmaps/Formats/LrcEncoder.cs @@ -69,9 +69,6 @@ static LrcParser.Model.TextIndex convertTextIndex(TextIndex textIndex) internal static IReadOnlyDictionary ToDictionary(IList timeTags, bool applyFix = true, GroupCheck other = GroupCheck.Asc, SelfCheck self = SelfCheck.BasedOnStart) { - if (timeTags == null) - return new Dictionary(); - // sorted value var sortedTimeTags = applyFix ? TimeTagsUtils.FixOverlapping(timeTags, other, self) : TimeTagsUtils.Sort(timeTags); diff --git a/osu.Game.Rulesets.Karaoke/Edit/Checks/CheckInvalidPropertyLyrics.cs b/osu.Game.Rulesets.Karaoke/Edit/Checks/CheckInvalidPropertyLyrics.cs index 796e6ba31..4618d625e 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Checks/CheckInvalidPropertyLyrics.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Checks/CheckInvalidPropertyLyrics.cs @@ -32,7 +32,7 @@ public IEnumerable Run(BeatmapVerifierContext context) if (string.IsNullOrWhiteSpace(lyric.Text)) yield return new IssueTemplateNoText(this).Create(lyric); - if (lyric.Singers == null || !lyric.Singers.Any()) + if (!lyric.Singers.Any()) yield return new IssueTemplateNoSinger(this).Create(lyric); // todo : check is singer in singer list. diff --git a/osu.Game.Rulesets.Karaoke/Edit/Generator/TimeTags/Ja/JaTimeTagGenerator.cs b/osu.Game.Rulesets.Karaoke/Edit/Generator/TimeTags/Ja/JaTimeTagGenerator.cs index 783e7bda8..2793cfcae 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Generator/TimeTags/Ja/JaTimeTagGenerator.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Generator/TimeTags/Ja/JaTimeTagGenerator.cs @@ -24,9 +24,6 @@ protected override void TimeTagLogic(Lyric lyric, List timeTags) { timeTags.AddRange(generateTimeTagByText(lyric.Text)); - if (lyric.RubyTags == null) - return; - foreach (var ruby in lyric.RubyTags) { // remove exist time tag From 761ac63d91244b065be299cff64c07d2a09076b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=82=BA=E4=BB=80=E9=BA=BC?= Date: Fri, 8 Jul 2022 19:52:17 +0800 Subject: [PATCH 11/19] Fix the null check because beatmap title will not be null. --- .../Beatmaps/TestSceneBeatmapInfoWedge.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke.Tests/Beatmaps/TestSceneBeatmapInfoWedge.cs b/osu.Game.Rulesets.Karaoke.Tests/Beatmaps/TestSceneBeatmapInfoWedge.cs index 61d443c01..d8f3b8ecf 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Beatmaps/TestSceneBeatmapInfoWedge.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Beatmaps/TestSceneBeatmapInfoWedge.cs @@ -55,10 +55,11 @@ private void selectBeatmap(IBeatmap b, string fileName) { BeatmapInfoWedge.WedgeInfoText infoBefore = null!; - AddStep($"select {b.Metadata.Title ?? fileName} beatmap", () => + string title = string.IsNullOrEmpty(b.Metadata.Title) ? fileName : b.Metadata.Title; + AddStep($"select {title} beatmap", () => { infoBefore = infoWedge.Info; - infoWedge.Beatmap = Beatmap.Value = b == null ? Beatmap.Default : CreateWorkingBeatmap(b); + infoWedge.Beatmap = Beatmap.Value = CreateWorkingBeatmap(b); }); AddUntilStep("wait for async load", () => infoWedge.Info != infoBefore); From ad7a06f8d967f3cd49bce7923f686728ccde9550 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=82=BA=E4=BB=80=E9=BA=BC?= Date: Fri, 8 Jul 2022 20:28:10 +0800 Subject: [PATCH 12/19] Remove un-need null check. --- .../GenerateRubyRomaji/GenerateRubyRomajiNavigation.cs | 4 ++-- .../ImportLyric/GenerateTimeTag/GenerateTimeTagNavigation.cs | 2 +- .../Rows/Extends/RecordingTimeTags/RecordingTimeTagPart.cs | 3 --- .../Blueprints/SingerLyricEditorHitObjectBlueprint.cs | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateRubyRomaji/GenerateRubyRomajiNavigation.cs b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateRubyRomaji/GenerateRubyRomajiNavigation.cs index b2d3103e4..8ae123ed0 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateRubyRomaji/GenerateRubyRomajiNavigation.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateRubyRomaji/GenerateRubyRomajiNavigation.cs @@ -36,10 +36,10 @@ protected override NavigationState GetState(Lyric[] lyrics) return NavigationState.Initial; static bool hasRuby(Lyric lyric) - => lyric.RubyTags != null && lyric.RubyTags.Any(); + => lyric.RubyTags.Any(); static bool hasRomaji(Lyric lyric) - => lyric.RubyTags != null && lyric.RubyTags.Any(); + => lyric.RubyTags.Any(); } protected override LocalisableString GetNavigationText(NavigationState value) => diff --git a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateTimeTag/GenerateTimeTagNavigation.cs b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateTimeTag/GenerateTimeTagNavigation.cs index 5ed8ded01..4b25f8d5f 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateTimeTag/GenerateTimeTagNavigation.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/ImportLyric/GenerateTimeTag/GenerateTimeTagNavigation.cs @@ -33,7 +33,7 @@ protected override NavigationState GetState(Lyric[] lyrics) return NavigationState.Initial; static bool hasTimeTag(Lyric lyric) - => lyric.TimeTags != null && lyric.TimeTags.Any(); + => lyric.TimeTags.Any(); } protected override LocalisableString GetNavigationText(NavigationState value) => diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Rows/Extends/RecordingTimeTags/RecordingTimeTagPart.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Rows/Extends/RecordingTimeTags/RecordingTimeTagPart.cs index 678282bd0..8cb14faa7 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Rows/Extends/RecordingTimeTags/RecordingTimeTagPart.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Rows/Extends/RecordingTimeTags/RecordingTimeTagPart.cs @@ -41,9 +41,6 @@ protected override void LoadBeatmap(EditorBeatmap beatmap) { base.LoadBeatmap(beatmap); - if (lyric.TimeTags == null) - return; - foreach (var timeTag in lyric.TimeTags) { Add(new RecordingTimeTagVisualization(lyric, timeTag)); diff --git a/osu.Game.Rulesets.Karaoke/Edit/Singers/Rows/Components/Blueprints/SingerLyricEditorHitObjectBlueprint.cs b/osu.Game.Rulesets.Karaoke/Edit/Singers/Rows/Components/Blueprints/SingerLyricEditorHitObjectBlueprint.cs index e66f6411d..4e1abb35a 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Singers/Rows/Components/Blueprints/SingerLyricEditorHitObjectBlueprint.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Singers/Rows/Components/Blueprints/SingerLyricEditorHitObjectBlueprint.cs @@ -92,7 +92,7 @@ private void load(SingerLyricEditor editor) static bool lyricInCurrentSinger(Lyric lyric, Singer singer) { if (singer == DefaultLyricPlacementColumn.DefaultSinger) - return lyric.Singers == null || !lyric.Singers.Any(); + return !lyric.Singers.Any(); return LyricUtils.ContainsSinger(lyric, singer); } From 8936443fdb2c44ebdafc8f469b6c664d2e0366ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=82=BA=E4=BB=80=E9=BA=BC?= Date: Fri, 8 Jul 2022 20:36:18 +0800 Subject: [PATCH 13/19] Fix the null issue and remove some un-need null check. --- .../Utils/LyricsUtils.cs | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Utils/LyricsUtils.cs b/osu.Game.Rulesets.Karaoke/Utils/LyricsUtils.cs index 64b4c957a..545feb0b2 100644 --- a/osu.Game.Rulesets.Karaoke/Utils/LyricsUtils.cs +++ b/osu.Game.Rulesets.Karaoke/Utils/LyricsUtils.cs @@ -40,20 +40,23 @@ public static Tuple SplitLyric(Lyric lyric, int splitIndex) var firstTag = firstTimeTag.LastOrDefault(); var secondTag = secondTimeTag.FirstOrDefault(); - // add end tag at end of first lyric if does not have tag in there. - if (!firstTimeTag.Any(x => x.Index.Index == splitIndex - 1 && x.Index.State == TextIndex.IndexState.End)) + if (firstTag != null && secondTag != null) { - var endTagIndex = new TextIndex(splitIndex - 1, TextIndex.IndexState.End); - var endTag = TimeTagsUtils.GenerateCenterTimeTag(firstTag, secondTag, endTagIndex); - firstTimeTag.Add(endTag); - } - - // add start tag at start of second lyric if does not have tag in there. - if (!secondTimeTag.Any(x => x.Index.Index == splitIndex && x.Index.State == TextIndex.IndexState.Start)) - { - var endTagIndex = new TextIndex(splitIndex); - var startTag = TimeTagsUtils.GenerateCenterTimeTag(firstTag, secondTag, endTagIndex); - secondTimeTag.Add(startTag); + // add end tag at end of first lyric if does not have tag in there. + if (!firstTimeTag.Any(x => x.Index.Index == splitIndex - 1 && x.Index.State == TextIndex.IndexState.End)) + { + var endTagIndex = new TextIndex(splitIndex - 1, TextIndex.IndexState.End); + var endTag = TimeTagsUtils.GenerateCenterTimeTag(firstTag, secondTag, endTagIndex); + firstTimeTag.Add(endTag); + } + + // add start tag at start of second lyric if does not have tag in there. + if (!secondTimeTag.Any(x => x.Index.Index == splitIndex && x.Index.State == TextIndex.IndexState.Start)) + { + var endTagIndex = new TextIndex(splitIndex); + var startTag = TimeTagsUtils.GenerateCenterTimeTag(firstTag, secondTag, endTagIndex); + secondTimeTag.Add(startTag); + } } } @@ -68,7 +71,7 @@ public static Tuple SplitLyric(Lyric lyric, int splitIndex) Language = lyric.Language, }; - string secondLyricText = lyric.Text?[splitIndex..] ?? string.Empty; + string secondLyricText = lyric.Text[splitIndex..]; var secondLyric = new Lyric { Text = secondLyricText, @@ -91,7 +94,7 @@ public static Lyric CombineLyric(Lyric firstLyric, Lyric secondLyric) if (secondLyric == null) throw new ArgumentNullException(nameof(secondLyric)); - int offsetIndexForSecondLyric = firstLyric.Text?.Length ?? 0; + int offsetIndexForSecondLyric = firstLyric.Text.Length; string lyricText = firstLyric.Text + secondLyric.Text; var timeTags = new List(); @@ -149,7 +152,7 @@ private static TimeTag[] shiftingTimeTag(IEnumerable timeTags, int offs #region Time tags public static bool HasTimedTimeTags(IEnumerable lyrics) - => lyrics?.Any(LyricUtils.HasTimedTimeTags) ?? false; + => lyrics.Any(LyricUtils.HasTimedTimeTags); #endregion From 6987a71e7c547b043d979ef0a13807e35137cd1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=82=BA=E4=BB=80=E9=BA=BC?= Date: Fri, 8 Jul 2022 20:40:56 +0800 Subject: [PATCH 14/19] Use empty array instead of assign null. --- .../Graphics/Sprites/DrawableKaraokeSpriteText.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Graphics/Sprites/DrawableKaraokeSpriteText.cs b/osu.Game.Rulesets.Karaoke/Graphics/Sprites/DrawableKaraokeSpriteText.cs index 5df38ff88..95ed0af85 100644 --- a/osu.Game.Rulesets.Karaoke/Graphics/Sprites/DrawableKaraokeSpriteText.cs +++ b/osu.Game.Rulesets.Karaoke/Graphics/Sprites/DrawableKaraokeSpriteText.cs @@ -75,7 +75,7 @@ private void updateRubies() { if (chunkIndex == whole_chunk_index) { - Rubies = DisplayRuby ? rubyTagsBindable?.Select(TextTagUtils.ToPositionText).ToArray() : null; + Rubies = DisplayRuby ? rubyTagsBindable.Select(TextTagUtils.ToPositionText).ToArray() : Array.Empty(); } else { @@ -87,7 +87,7 @@ private void updateRomajies() { if (chunkIndex == whole_chunk_index) { - Romajies = DisplayRomaji ? romajiTagsBindable?.Select(TextTagUtils.ToPositionText).ToArray() : null; + Romajies = DisplayRomaji ? romajiTagsBindable.Select(TextTagUtils.ToPositionText).ToArray() : Array.Empty(); } else { From 867e4472a8d6d44ccb52e0dc1ca0dd86fcb97ea0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=82=BA=E4=BB=80=E9=BA=BC?= Date: Fri, 8 Jul 2022 20:41:06 +0800 Subject: [PATCH 15/19] Should be nullable. --- .../Skinning/MappingRoles/DefaultMappingRole.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Skinning/MappingRoles/DefaultMappingRole.cs b/osu.Game.Rulesets.Karaoke/Skinning/MappingRoles/DefaultMappingRole.cs index a21cfd22e..600ebade6 100644 --- a/osu.Game.Rulesets.Karaoke/Skinning/MappingRoles/DefaultMappingRole.cs +++ b/osu.Game.Rulesets.Karaoke/Skinning/MappingRoles/DefaultMappingRole.cs @@ -18,11 +18,11 @@ public override bool CanApply(KaraokeBeatmapSkin beatmapSkin, KaraokeHitObject h return false; var group = getGroupById(beatmapSkin, GroupId); - bool inTheGroup = group.InTheGroup(hitObject, elementType); + bool inTheGroup = group?.InTheGroup(hitObject, elementType) ?? false; return inTheGroup; } - private static IGroup getGroupById(KaraokeBeatmapSkin beatmapSkin, int groupId) + private static IGroup? getGroupById(KaraokeBeatmapSkin beatmapSkin, int groupId) => beatmapSkin.Groups.FirstOrDefault(x => x.ID == groupId); } } From 68d256026e82d8e89c282f76b6fdef2ef6317ca7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=82=BA=E4=BB=80=E9=BA=BC?= Date: Fri, 8 Jul 2022 20:42:57 +0800 Subject: [PATCH 16/19] Make the code happy. --- .../Beatmaps/Formats/KaraokeJsonBeatmapDecoder.cs | 5 +---- .../Beatmaps/Formats/KaraokeLegacyBeatmapEncoder.cs | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Beatmaps/Formats/KaraokeJsonBeatmapDecoder.cs b/osu.Game.Rulesets.Karaoke/Beatmaps/Formats/KaraokeJsonBeatmapDecoder.cs index b5c6e789b..4a00678b3 100644 --- a/osu.Game.Rulesets.Karaoke/Beatmaps/Formats/KaraokeJsonBeatmapDecoder.cs +++ b/osu.Game.Rulesets.Karaoke/Beatmaps/Formats/KaraokeJsonBeatmapDecoder.cs @@ -57,10 +57,7 @@ protected override void ParseStreamInto(LineBufferedReader stream, Beatmap outpu { // because of json serializer contains object reference issue with serialize/deserialize the beatmap. // so should re-assign the lyric instance. - note.ParentLyric = lyrics.FirstOrDefault(x => x.ID == note.ParentLyric.ID); - - if (note.ParentLyric == null) - throw new InvalidOperationException(); + note.ParentLyric = lyrics.FirstOrDefault(x => x.ID == note.ParentLyric.ID) ?? throw new InvalidOperationException(); } hitObject.ApplyDefaults(output.ControlPointInfo, output.Difficulty); diff --git a/osu.Game.Rulesets.Karaoke/Beatmaps/Formats/KaraokeLegacyBeatmapEncoder.cs b/osu.Game.Rulesets.Karaoke/Beatmaps/Formats/KaraokeLegacyBeatmapEncoder.cs index 4e39c1afa..c2595a103 100644 --- a/osu.Game.Rulesets.Karaoke/Beatmaps/Formats/KaraokeLegacyBeatmapEncoder.cs +++ b/osu.Game.Rulesets.Karaoke/Beatmaps/Formats/KaraokeLegacyBeatmapEncoder.cs @@ -36,7 +36,7 @@ private IEnumerable encodeNote(Beatmap output) string noteGroupStr = string.Join(",", noteGroup.Select(x => { if (x.Count() == 1) - return convertNote(x.FirstOrDefault()); + return convertNote(x.First()); return "(" + string.Join("|", x.Select(convertNote)) + ")"; })); From 7dbf8694114c7e122f108d89e1edeec604411dc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=82=BA=E4=BB=80=E9=BA=BC?= Date: Fri, 8 Jul 2022 20:47:31 +0800 Subject: [PATCH 17/19] Remove un-need null check. --- .../Edit/Components/Cursor/InvalidLyricToolTip.cs | 8 ++++---- .../Edit/Components/Sprites/DrawableLayoutPreview.cs | 2 +- .../Rows/Components/Carets/DrawableLyricTextCaret.cs | 2 +- .../Edit/Lyrics/Rows/Components/SubInfo/SingerInfo.cs | 2 +- .../Overlays/Changelog/ChangelogSingleBuild.cs | 2 +- .../Overlays/Changelog/Sidebar/ChangelogSidebar.cs | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Edit/Components/Cursor/InvalidLyricToolTip.cs b/osu.Game.Rulesets.Karaoke/Edit/Components/Cursor/InvalidLyricToolTip.cs index 158dc4199..627db0de4 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Components/Cursor/InvalidLyricToolTip.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Components/Cursor/InvalidLyricToolTip.cs @@ -53,7 +53,7 @@ public override void SetContent(Issue[] issues) { // Print time invalid message case LyricTimeIssue lyricTimeIssue: - lyricTimeIssue.InvalidLyricTime?.ForEach(createTimeInvalidMessage); + lyricTimeIssue.InvalidLyricTime.ForEach(createTimeInvalidMessage); break; // Print time-tag invalid message @@ -64,17 +64,17 @@ public override void SetContent(Issue[] issues) if (timeTagIssue.MissingEndTimeTag) invalidMessage.AddAlertParagraph("Missing end time tag at the end of lyric."); - timeTagIssue.InvalidTimeTags?.ForEach(x => createTimeTagInvalidMessage(x.Key, x.Value)); + timeTagIssue.InvalidTimeTags.ForEach(x => createTimeTagInvalidMessage(x.Key, x.Value)); break; // Print ruby invalid message case RubyTagIssue rubyTagIssue: - rubyTagIssue.InvalidRubyTags?.ForEach(x => createRubyInvalidMessage(x.Key, x.Value)); + rubyTagIssue.InvalidRubyTags.ForEach(x => createRubyInvalidMessage(x.Key, x.Value)); break; // Print romaji invalid message case RomajiTagIssue romajiTagIssue: - romajiTagIssue.InvalidRomajiTags?.ForEach(x => createRomajiInvalidMessage(x.Key, x.Value)); + romajiTagIssue.InvalidRomajiTags.ForEach(x => createRomajiInvalidMessage(x.Key, x.Value)); break; // print normal message diff --git a/osu.Game.Rulesets.Karaoke/Edit/Components/Sprites/DrawableLayoutPreview.cs b/osu.Game.Rulesets.Karaoke/Edit/Components/Sprites/DrawableLayoutPreview.cs index 1ca87edb6..47810841c 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Components/Sprites/DrawableLayoutPreview.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Components/Sprites/DrawableLayoutPreview.cs @@ -100,7 +100,7 @@ private void updateLayout() // Set preview width const float text_size = 20; - previewLyric.Width = (Lyric?.Text?.Length ?? 10) * text_size * scale; + previewLyric.Width = (Lyric?.Text.Length ?? 10) * text_size * scale; previewLyric.Height = text_size * 1.5f * scale; // Set relative position diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Rows/Components/Carets/DrawableLyricTextCaret.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Rows/Components/Carets/DrawableLyricTextCaret.cs index 04ef2f3c6..a14dfe1af 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Rows/Components/Carets/DrawableLyricTextCaret.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Rows/Components/Carets/DrawableLyricTextCaret.cs @@ -23,7 +23,7 @@ protected DrawableLyricTextCaret(bool preview) protected Vector2 GetPosition(TextCaretPosition caret) { float textHeight = karaokeSpriteText.LineBaseHeight; - bool end = caret.Index == caret.Lyric?.Text?.Length; + bool end = caret.Index == caret.Lyric.Text.Length; var originPosition = karaokeSpriteText.GetTextIndexPosition(TextIndexUtils.FromStringIndex(caret.Index, end)); return new Vector2(originPosition.X, originPosition.Y - textHeight); } diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Rows/Components/SubInfo/SingerInfo.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Rows/Components/SubInfo/SingerInfo.cs index b97f83140..ed4002931 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Rows/Components/SubInfo/SingerInfo.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/Rows/Components/SubInfo/SingerInfo.cs @@ -45,7 +45,7 @@ private void load(EditorBeatmap beatmap) if (beatmap.PlayableBeatmap is not KaraokeBeatmap karaokeBeatmap) return; - var singers = karaokeBeatmap.Singers?.Where(singer => LyricUtils.ContainsSinger(lyric, singer)).ToList(); + var singers = karaokeBeatmap.Singers.Where(singer => LyricUtils.ContainsSinger(lyric, singer)).ToList(); singerDisplay.Current.Value = singers; }, true); } diff --git a/osu.Game.Rulesets.Karaoke/Overlays/Changelog/ChangelogSingleBuild.cs b/osu.Game.Rulesets.Karaoke/Overlays/Changelog/ChangelogSingleBuild.cs index 644bf6294..caa8bf23f 100644 --- a/osu.Game.Rulesets.Karaoke/Overlays/Changelog/ChangelogSingleBuild.cs +++ b/osu.Game.Rulesets.Karaoke/Overlays/Changelog/ChangelogSingleBuild.cs @@ -66,7 +66,7 @@ protected override FillFlowContainer CreateHeader() Icon = FontAwesome.Solid.ChevronLeft, SelectBuild = b => SelectBuild(b) }); - fill.Insert(1, new NavigationIconButton(Build.Versions?.Previous) + fill.Insert(1, new NavigationIconButton(Build.Versions.Previous) { Icon = FontAwesome.Solid.ChevronRight, SelectBuild = b => SelectBuild(b) diff --git a/osu.Game.Rulesets.Karaoke/Overlays/Changelog/Sidebar/ChangelogSidebar.cs b/osu.Game.Rulesets.Karaoke/Overlays/Changelog/Sidebar/ChangelogSidebar.cs index 8cab222ba..8bd2ec374 100644 --- a/osu.Game.Rulesets.Karaoke/Overlays/Changelog/Sidebar/ChangelogSidebar.cs +++ b/osu.Game.Rulesets.Karaoke/Overlays/Changelog/Sidebar/ChangelogSidebar.cs @@ -120,7 +120,7 @@ private void onMetadataChanged(APIChangelogSidebar metadata, int targetYear) var allPosts = metadata.Changelogs; - if (allPosts?.Any() != true) + if (allPosts.Any() != true) return; var lookup = metadata.Changelogs.ToLookup(post => post.PublishedAt.Year); From c807bd5abe75f7189361a31c0789f4a99cfeaf15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=82=BA=E4=BB=80=E9=BA=BC?= Date: Fri, 8 Jul 2022 20:49:50 +0800 Subject: [PATCH 18/19] This interface should be fucking null. --- .../Beatmaps/IKaraokeBeatmapResourcesProvider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Karaoke/Beatmaps/IKaraokeBeatmapResourcesProvider.cs b/osu.Game.Rulesets.Karaoke/Beatmaps/IKaraokeBeatmapResourcesProvider.cs index cc1c597d7..b2af611a9 100644 --- a/osu.Game.Rulesets.Karaoke/Beatmaps/IKaraokeBeatmapResourcesProvider.cs +++ b/osu.Game.Rulesets.Karaoke/Beatmaps/IKaraokeBeatmapResourcesProvider.cs @@ -8,6 +8,6 @@ namespace osu.Game.Rulesets.Karaoke.Beatmaps { public interface IKaraokeBeatmapResourcesProvider { - Texture GetSingerAvatar(ISinger singer); + Texture? GetSingerAvatar(ISinger singer); } } From 42c0d12b2cb4beae299c510d1fbf0295a3220f37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=82=BA=E4=BB=80=E9=BA=BC?= Date: Fri, 8 Jul 2022 21:06:08 +0800 Subject: [PATCH 19/19] Remove some un-need null check. --- .../Algorithms/TimeTagCaretPositionAlgorithmTest.cs | 2 +- .../Editor/TestSceneLayoutToolTip.cs | 2 +- .../Helper/TestCaseTagHelper.cs | 2 +- .../Beatmaps/KaraokeBeatmapExtension.cs | 2 +- .../Edit/Checks/CheckInvalidRubyRomajiLyrics.cs | 12 ++++++------ .../Edit/Checks/CheckInvalidTimeLyrics.cs | 4 ++-- .../Edit/Generator/Languages/LanguageDetector.cs | 3 +-- .../Skinning/Fonts/FontManager.cs | 2 +- .../Skinning/Legacy/LegacyNotePiece.cs | 2 +- osu.Game.Rulesets.Karaoke/Utils/TextTagUtils.cs | 2 +- 10 files changed, 16 insertions(+), 17 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke.Tests/Editor/Lyrics/CaretPosition/Algorithms/TimeTagCaretPositionAlgorithmTest.cs b/osu.Game.Rulesets.Karaoke.Tests/Editor/Lyrics/CaretPosition/Algorithms/TimeTagCaretPositionAlgorithmTest.cs index 23c4b1d41..3783cc3e3 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Editor/Lyrics/CaretPosition/Algorithms/TimeTagCaretPositionAlgorithmTest.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Editor/Lyrics/CaretPosition/Algorithms/TimeTagCaretPositionAlgorithmTest.cs @@ -178,7 +178,7 @@ private static TimeTagCaretPosition createCaretPosition(IEnumerable lyric var lyric = lyrics.ElementAtOrDefault(lyricIndex); var timeTag = timeTagIndex == not_exist_tag ? new TimeTag(new TextIndex(not_exist_tag)) - : lyric?.TimeTags?.ElementAtOrDefault(timeTagIndex); + : lyric?.TimeTags.ElementAtOrDefault(timeTagIndex); if (lyric == null || timeTag == null) throw new ArgumentNullException(); diff --git a/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneLayoutToolTip.cs b/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneLayoutToolTip.cs index b3e1c4e25..c683680ee 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneLayoutToolTip.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneLayoutToolTip.cs @@ -58,7 +58,7 @@ private void setTooltip(string testName, Action callBack) { Text = "karaoke!" }; - callBack?.Invoke(singer); + callBack.Invoke(singer); toolTip.SetContent(singer); }); } diff --git a/osu.Game.Rulesets.Karaoke.Tests/Helper/TestCaseTagHelper.cs b/osu.Game.Rulesets.Karaoke.Tests/Helper/TestCaseTagHelper.cs index 3f1cbcbbd..f823598ea 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Helper/TestCaseTagHelper.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Helper/TestCaseTagHelper.cs @@ -147,7 +147,7 @@ public static Lyric ParseLyric(string? str) TimeTags = new[] { new TimeTag(new TextIndex(0), startTime), - new TimeTag(new TextIndex((text?.Length ?? 0) - 1, TextIndex.IndexState.End), endTime) + new TimeTag(new TextIndex(text.Length - 1, TextIndex.IndexState.End), endTime) } }; } diff --git a/osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmapExtension.cs b/osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmapExtension.cs index c58dd86dd..e256e044f 100644 --- a/osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmapExtension.cs +++ b/osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmapExtension.cs @@ -25,7 +25,7 @@ public static bool IsScorable(this IBeatmap beatmap) public static IList AvailableTranslates(this IBeatmap beatmap) => (beatmap as KaraokeBeatmap)?.AvailableTranslates ?? new List(); - public static bool AnyTranslate(this IBeatmap beatmap) => beatmap?.AvailableTranslates().Any() ?? false; + public static bool AnyTranslate(this IBeatmap beatmap) => beatmap.AvailableTranslates().Any(); public static float PitchToScale(this IBeatmap beatmap, float pitch) { diff --git a/osu.Game.Rulesets.Karaoke/Edit/Checks/CheckInvalidRubyRomajiLyrics.cs b/osu.Game.Rulesets.Karaoke/Edit/Checks/CheckInvalidRubyRomajiLyrics.cs index ce4f2b5a3..03cff9ca7 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Checks/CheckInvalidRubyRomajiLyrics.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Checks/CheckInvalidRubyRomajiLyrics.cs @@ -49,18 +49,18 @@ private Dictionary checkInvalidRubyTags(Lyric lyric) // Checking out of range tags. var outOfRangeTags = TextTagsUtils.FindOutOfRange(lyric.RubyTags, lyric.Text); - if (outOfRangeTags?.Length > 0) + if (outOfRangeTags.Length > 0) result.Add(RubyTagInvalid.OutOfRange, outOfRangeTags); // Checking overlapping. var sorting = config.RomajiPositionSorting; var overlappingTags = TextTagsUtils.FindOverlapping(lyric.RubyTags, sorting); - if (overlappingTags?.Length > 0) + if (overlappingTags.Length > 0) result.Add(RubyTagInvalid.Overlapping, overlappingTags); // check empty string. var emptyTextTags = TextTagsUtils.FindEmptyText(lyric.RubyTags); - if (emptyTextTags?.Length > 0) + if (emptyTextTags.Length > 0) result.Add(RubyTagInvalid.EmptyText, emptyTextTags); return result; @@ -72,18 +72,18 @@ private Dictionary checkInvalidRomajiTags(Lyric l // Checking out of range tags. var outOfRangeTags = TextTagsUtils.FindOutOfRange(lyric.RomajiTags, lyric.Text); - if (outOfRangeTags?.Length > 0) + if (outOfRangeTags.Length > 0) result.Add(RomajiTagInvalid.OutOfRange, outOfRangeTags); // Checking overlapping. var sorting = config.RomajiPositionSorting; var overlappingTags = TextTagsUtils.FindOverlapping(lyric.RomajiTags, sorting); - if (overlappingTags?.Length > 0) + if (overlappingTags.Length > 0) result.Add(RomajiTagInvalid.Overlapping, overlappingTags); // check empty string. var emptyTextTags = TextTagsUtils.FindEmptyText(lyric.RomajiTags); - if (emptyTextTags?.Length > 0) + if (emptyTextTags.Length > 0) result.Add(RomajiTagInvalid.EmptyText, emptyTextTags); return result; diff --git a/osu.Game.Rulesets.Karaoke/Edit/Checks/CheckInvalidTimeLyrics.cs b/osu.Game.Rulesets.Karaoke/Edit/Checks/CheckInvalidTimeLyrics.cs index 847e74968..cebf0cf13 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Checks/CheckInvalidTimeLyrics.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Checks/CheckInvalidTimeLyrics.cs @@ -67,7 +67,7 @@ private Dictionary checkInvalidTimeTags(Lyric lyric) // todo : check out of range. var outOfRangeTags = TimeTagsUtils.FindOutOfRange(lyric.TimeTags, lyric.Text); - if (outOfRangeTags?.Length > 0) + if (outOfRangeTags.Length > 0) result.Add(TimeTagInvalid.OutOfRange, outOfRangeTags); // Check overlapping. @@ -79,7 +79,7 @@ private Dictionary checkInvalidTimeTags(Lyric lyric) // Check time-tag should have time. var noTimeTimeTags = TimeTagsUtils.FindNoneTime(lyric.TimeTags); - if (noTimeTimeTags?.Length > 0) + if (noTimeTimeTags.Length > 0) result.Add(TimeTagInvalid.EmptyTime, noTimeTimeTags); return result; diff --git a/osu.Game.Rulesets.Karaoke/Edit/Generator/Languages/LanguageDetector.cs b/osu.Game.Rulesets.Karaoke/Edit/Generator/Languages/LanguageDetector.cs index 4b1f17ac3..dea9f98fc 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Generator/Languages/LanguageDetector.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Generator/Languages/LanguageDetector.cs @@ -1,7 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -using System.Collections.Generic; using System.Globalization; using System.Linq; using osu.Framework.Localisation; @@ -16,7 +15,7 @@ public class LanguageDetector : ILyricPropertyDetector public LanguageDetector(LanguageDetectorConfig config) { - var targetLanguages = config?.AcceptLanguages?.Where(x => x != null).ToList() ?? new List(); + var targetLanguages = config.AcceptLanguages.Where(x => x != null).ToList(); if (targetLanguages.Any()) { diff --git a/osu.Game.Rulesets.Karaoke/Skinning/Fonts/FontManager.cs b/osu.Game.Rulesets.Karaoke/Skinning/Fonts/FontManager.cs index 988a4f517..1cb7c0002 100644 --- a/osu.Game.Rulesets.Karaoke/Skinning/Fonts/FontManager.cs +++ b/osu.Game.Rulesets.Karaoke/Skinning/Fonts/FontManager.cs @@ -244,7 +244,7 @@ protected override void Dispose(bool isDisposing) { base.Dispose(isDisposing); - watcher?.Dispose(); + watcher.Dispose(); } } } diff --git a/osu.Game.Rulesets.Karaoke/Skinning/Legacy/LegacyNotePiece.cs b/osu.Game.Rulesets.Karaoke/Skinning/Legacy/LegacyNotePiece.cs index f2fd29fb5..6b7b2ce63 100644 --- a/osu.Game.Rulesets.Karaoke/Skinning/Legacy/LegacyNotePiece.cs +++ b/osu.Game.Rulesets.Karaoke/Skinning/Legacy/LegacyNotePiece.cs @@ -101,7 +101,7 @@ private void onIsHittingChanged(ValueChangedEvent isHitting) private void applySingerStyle(ISkinSource skin, Note note) { - var noteSkin = skin?.GetConfig(note)?.Value; + var noteSkin = skin.GetConfig(note)?.Value; if (noteSkin == null) return; diff --git a/osu.Game.Rulesets.Karaoke/Utils/TextTagUtils.cs b/osu.Game.Rulesets.Karaoke/Utils/TextTagUtils.cs index f19bcfb24..f00ca1a9f 100644 --- a/osu.Game.Rulesets.Karaoke/Utils/TextTagUtils.cs +++ b/osu.Game.Rulesets.Karaoke/Utils/TextTagUtils.cs @@ -14,7 +14,7 @@ public static Tuple GetFixedIndex(T textTag, string lyric) where T public static Tuple GetShiftingIndex(T textTag, string lyric, int offset) where T : ITextTag { - int lyricLength = lyric?.Length ?? 0; + int lyricLength = lyric.Length; int newStartIndex = Math.Clamp(textTag.StartIndex + offset, 0, lyricLength); int newEndIndex = Math.Clamp(textTag.EndIndex + offset, 0, lyricLength); return new Tuple(Math.Min(newStartIndex, newEndIndex), Math.Max(newStartIndex, newEndIndex));