diff --git a/osu.Game.Rulesets.Karaoke.Tests/Resources/TestResources.cs b/osu.Game.Rulesets.Karaoke.Tests/Resources/TestResources.cs index 3c99baf34..fa77e3166 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Resources/TestResources.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Resources/TestResources.cs @@ -44,8 +44,6 @@ public static string GetTestLrcForImport(string name) public static IStorageResourceProvider CreateSkinStorageResourceProvider(string skinName = "special-skin") => new TestStorageResourceProvider(skinName); -#nullable disable - private class TestStorageResourceProvider : IStorageResourceProvider { public TestStorageResourceProvider(string skinName) @@ -55,13 +53,11 @@ public TestStorageResourceProvider(string skinName) public IRenderer Renderer => new DummyRenderer(); - public AudioManager AudioManager => null; + public AudioManager AudioManager => null!; public IResourceStore Files { get; } public IResourceStore Resources { get; } - public RealmAccess RealmAccess => null; + public RealmAccess RealmAccess => null!; - public IResourceStore CreateTextureLoaderStore(IResourceStore underlyingStore) => null; + public IResourceStore CreateTextureLoaderStore(IResourceStore underlyingStore) => null!; } - -#nullable enable } diff --git a/osu.Game.Rulesets.Karaoke.Tests/Skinning/Fonts/BitmapFontCompressorTest.cs b/osu.Game.Rulesets.Karaoke.Tests/Skinning/Fonts/BitmapFontCompressorTest.cs index bb4bf9224..82bdabfc1 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Skinning/Fonts/BitmapFontCompressorTest.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Skinning/Fonts/BitmapFontCompressorTest.cs @@ -31,7 +31,7 @@ public void OneTimeSetUp() if (normalGlyph == null) throw new ArgumentNullException(nameof(normalGlyph)); - font = glyphStore.BitmapFont; + font = glyphStore.BitmapFont ?? throw new InvalidOperationException("Font should not be null in the test case."); } [TestCase("A", 1)] diff --git a/osu.Game.Rulesets.Karaoke.Tests/Skinning/Fonts/BitmapFontImageGeneratorTest.cs b/osu.Game.Rulesets.Karaoke.Tests/Skinning/Fonts/BitmapFontImageGeneratorTest.cs index 0262c9565..54370f112 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Skinning/Fonts/BitmapFontImageGeneratorTest.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Skinning/Fonts/BitmapFontImageGeneratorTest.cs @@ -18,7 +18,7 @@ public class BitmapFontImageGeneratorTest { private TestFntGlyphStore glyphStore = null!; - private BitmapFont font => glyphStore.BitmapFont; + private BitmapFont font = null!; [OneTimeSetUp] public void OneTimeSetUp() @@ -31,6 +31,8 @@ public void OneTimeSetUp() var normalGlyph = glyphStore.Get('a'); if (normalGlyph == null) throw new ArgumentNullException(nameof(normalGlyph)); + + font = glyphStore.BitmapFont ?? throw new InvalidOperationException("Font should not be null in the test case."); } [Test] diff --git a/osu.Game.Rulesets.Karaoke/IO/Archives/CachedFontArchiveReader.cs b/osu.Game.Rulesets.Karaoke/IO/Archives/CachedFontArchiveReader.cs index 9b157aff4..e67dd7b4e 100644 --- a/osu.Game.Rulesets.Karaoke/IO/Archives/CachedFontArchiveReader.cs +++ b/osu.Game.Rulesets.Karaoke/IO/Archives/CachedFontArchiveReader.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.IO; using System.Linq; @@ -22,7 +20,7 @@ public class CachedFontArchiveReader : ArchiveReader private readonly Stream archiveStream; private readonly ZipArchive archive; - public CachedFontArchiveReader(Stream archiveStream, string name = null) + public CachedFontArchiveReader(Stream archiveStream, string name) : base(name) { this.archiveStream = archiveStream; diff --git a/osu.Game.Rulesets.Karaoke/IO/Stores/FntGlyphStore.cs b/osu.Game.Rulesets.Karaoke/IO/Stores/FntGlyphStore.cs index 5b231434a..1eecb2422 100644 --- a/osu.Game.Rulesets.Karaoke/IO/Stores/FntGlyphStore.cs +++ b/osu.Game.Rulesets.Karaoke/IO/Stores/FntGlyphStore.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.Graphics.Textures; using osu.Framework.IO.Stores; using SharpFNT; @@ -11,9 +9,9 @@ namespace osu.Game.Rulesets.Karaoke.IO.Stores; public class FntGlyphStore : GlyphStore { - public BitmapFont BitmapFont => Font; + public BitmapFont? BitmapFont => Font; - public FntGlyphStore(ResourceStore store, string assetName = null, IResourceStore textureLoader = null) + public FntGlyphStore(ResourceStore store, string? assetName = null, IResourceStore? textureLoader = null) : base(store, assetName, textureLoader) { } diff --git a/osu.Game.Rulesets.Karaoke/IO/Stores/KaraokeLocalFontStore.cs b/osu.Game.Rulesets.Karaoke/IO/Stores/KaraokeLocalFontStore.cs index 73c681d22..9ece0a89e 100644 --- a/osu.Game.Rulesets.Karaoke/IO/Stores/KaraokeLocalFontStore.cs +++ b/osu.Game.Rulesets.Karaoke/IO/Stores/KaraokeLocalFontStore.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 osu.Framework.Graphics.Rendering; using osu.Framework.Graphics.Sprites; @@ -25,7 +23,7 @@ public class KaraokeLocalFontStore : FontStore /// The renderer to create textures with. /// The texture source. /// The raw pixel height of the font. Can be used to apply a global scale or metric to font usages. - public KaraokeLocalFontStore(FontManager fontManager, IRenderer renderer, IResourceStore store = null, float scaleAdjust = 100) + public KaraokeLocalFontStore(FontManager fontManager, IRenderer renderer, IResourceStore? store = null, float scaleAdjust = 100) : base(renderer, store, scaleAdjust) { this.fontManager = fontManager; diff --git a/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableBarLine.cs b/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableBarLine.cs index f0981d087..0145a3128 100644 --- a/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableBarLine.cs +++ b/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableBarLine.cs @@ -1,9 +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 JetBrains.Annotations; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; @@ -33,12 +30,12 @@ public partial class DrawableBarLine : DrawableKaraokeScrollingHitObject /// The visual line tracker. /// - private Box line; + private Box line = null!; /// /// Container with triangles. Only visible for major lines. /// - private Container triangleContainer; + private Container triangleContainer = null!; private readonly Bindable major = new(); @@ -47,7 +44,7 @@ public DrawableBarLine() { } - public DrawableBarLine([CanBeNull] BarLine barLine) + public DrawableBarLine(BarLine? barLine) : base(barLine) { } diff --git a/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableKaraokeHitObject.cs b/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableKaraokeHitObject.cs index b2c5c54fa..569719f25 100644 --- a/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableKaraokeHitObject.cs +++ b/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableKaraokeHitObject.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.Game.Rulesets.Judgements; using osu.Game.Rulesets.Karaoke.Judgements; using osu.Game.Rulesets.Karaoke.Objects.Types; @@ -12,8 +10,8 @@ namespace osu.Game.Rulesets.Karaoke.Objects.Drawables; public partial class DrawableKaraokeHitObject : DrawableHitObject { - protected DrawableKaraokeHitObject(KaraokeHitObject hitObject) - : base(hitObject) + protected DrawableKaraokeHitObject(KaraokeHitObject? hitObject) + : base(hitObject!) { } diff --git a/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableKaraokeScrollingHitObject.cs b/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableKaraokeScrollingHitObject.cs index 14654ebe0..415e3af86 100644 --- a/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableKaraokeScrollingHitObject.cs +++ b/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableKaraokeScrollingHitObject.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.Bindables; using osu.Framework.Graphics; @@ -17,8 +15,8 @@ public abstract partial class DrawableKaraokeScrollingHitObject : DrawableHitObj protected readonly IBindable TimeRange = new Bindable(); - protected DrawableKaraokeScrollingHitObject(KaraokeHitObject hitObject) - : base(hitObject) + protected DrawableKaraokeScrollingHitObject(KaraokeHitObject? hitObject) + : base(hitObject!) { } @@ -102,9 +100,9 @@ protected virtual void OnTimeRangeChanged(ValueChangedEvent e) public abstract partial class DrawableKaraokeScrollingHitObject : DrawableKaraokeScrollingHitObject where TObject : KaraokeHitObject { - public new TObject HitObject => base.HitObject as TObject; + public new TObject HitObject => (TObject)base.HitObject; - protected DrawableKaraokeScrollingHitObject(TObject hitObject) + protected DrawableKaraokeScrollingHitObject(TObject? hitObject) : base(hitObject) { } diff --git a/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableLyric.cs b/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableLyric.cs index c6333235c..0405e1837 100644 --- a/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableLyric.cs +++ b/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableLyric.cs @@ -1,11 +1,8 @@ // 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.Globalization; -using JetBrains.Annotations; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Extensions.IEnumerableExtensions; @@ -24,11 +21,10 @@ namespace osu.Game.Rulesets.Karaoke.Objects.Drawables; public partial class DrawableLyric : DrawableKaraokeHitObject { - private Container lyricPieces; - private OsuSpriteText translateText; + private Container lyricPieces = null!; + private OsuSpriteText translateText = null!; - [Resolved(canBeNull: true)] - private KaraokeRulesetConfigManager config { get; set; } + private KaraokeRulesetConfigManager? config { get; set; } private readonly BindableBool useTranslateBindable = new(); private readonly Bindable preferLanguageBindable = new(); @@ -43,8 +39,8 @@ public partial class DrawableLyric : DrawableKaraokeHitObject private readonly IBindableDictionary singersBindable = new BindableDictionary(); private readonly BindableDictionary translateTextBindable = new(); - public event Action OnLyricStart; - public event Action OnLyricEnd; + public event Action? OnLyricStart; + public event Action? OnLyricEnd; public new Lyric HitObject => (Lyric)base.HitObject; @@ -53,13 +49,13 @@ public DrawableLyric() { } - public DrawableLyric([CanBeNull] Lyric hitObject) + public DrawableLyric(Lyric? hitObject) : base(hitObject) { } [BackgroundDependencyLoader(true)] - private void load([CanBeNull] KaraokeSessionStatics session) + private void load(KaraokeSessionStatics? session) { AutoSizeAxes = Axes.Both; @@ -180,11 +176,11 @@ private void applyTranslate() if (!needTranslate || language == null) { - translateText.Text = (string)null; + translateText.Text = string.Empty; } else { - if (translateTextBindable.TryGetValue(language, out string translate)) + if (translateTextBindable.TryGetValue(language, out string? translate)) translateText.Text = translate; } } diff --git a/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableNote.cs b/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableNote.cs index 0fd587855..4b3293827 100644 --- a/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableNote.cs +++ b/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableNote.cs @@ -1,11 +1,8 @@ // 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.Diagnostics; -using JetBrains.Annotations; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; @@ -44,7 +41,7 @@ public partial class DrawableNote : DrawableKaraokeScrollingHitObject, IKe private readonly IBindable positionBindable = new Bindable(); public readonly IBindable TextBindable = new Bindable(); - public readonly IBindable RubyTextBindable = new Bindable(); + public readonly IBindable RubyTextBindable = new Bindable(); public readonly IBindableDictionary SingersBindable = new BindableDictionary(); public readonly IBindable DisplayBindable = new Bindable(); public readonly IBindable ToneBindable = new Bindable(); @@ -54,7 +51,7 @@ public DrawableNote() { } - public DrawableNote([CanBeNull] Note hitObject) + public DrawableNote(Note? hitObject) : base(hitObject) { AddRangeInternal(new Drawable[] @@ -81,7 +78,7 @@ private void load(INotePositionInfo notePositionInfo) TextBindable.BindValueChanged(_ => { changeText(HitObject); }); RubyTextBindable.BindValueChanged(_ => { changeText(HitObject); }); SingersBindable.BindCollectionChanged((_, _) => { ApplySkin(CurrentSkin, false); }); - DisplayBindable.BindValueChanged(e => { (Result.Judgement as KaraokeNoteJudgement).Scorable = e.NewValue; }); + DisplayBindable.BindValueChanged(e => { (Result.Judgement as KaraokeNoteJudgement)!.Scorable = e.NewValue; }); ToneBindable.BindValueChanged(_ => updateNotePositionAndHeight()); void updateNotePositionAndHeight() diff --git a/osu.Game.Rulesets.Karaoke/Skinning/InternalSkinStorageResourceProvider.cs b/osu.Game.Rulesets.Karaoke/Skinning/InternalSkinStorageResourceProvider.cs index ae58248ff..002fb2d54 100644 --- a/osu.Game.Rulesets.Karaoke/Skinning/InternalSkinStorageResourceProvider.cs +++ b/osu.Game.Rulesets.Karaoke/Skinning/InternalSkinStorageResourceProvider.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.Audio; using osu.Framework.Graphics.Rendering; using osu.Framework.Graphics.Rendering.Dummy; @@ -23,9 +21,9 @@ public InternalSkinStorageResourceProvider(string skinName) public IRenderer Renderer => new DummyRenderer(); - public AudioManager AudioManager => null; + public AudioManager AudioManager => null!; public IResourceStore Files { get; } public IResourceStore Resources { get; } - public RealmAccess RealmAccess => null; - public IResourceStore CreateTextureLoaderStore(IResourceStore underlyingStore) => null; + public RealmAccess RealmAccess => null!; + public IResourceStore CreateTextureLoaderStore(IResourceStore underlyingStore) => null!; }