From 23c4f9910e5bba1c0b556bb3838d9eea87cdd6dd Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Fri, 25 Mar 2022 15:53:55 +0900 Subject: [PATCH] Apply notnull constraint --- osu.Game/Skinning/ISkin.cs | 4 +++- osu.Game/Skinning/LegacySkin.cs | 6 +++--- osu.Game/Skinning/ResourceStoreBackedSkin.cs | 5 ++++- osu.Game/Skinning/Skin.cs | 4 +++- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/osu.Game/Skinning/ISkin.cs b/osu.Game/Skinning/ISkin.cs index 4b14dcfd62..414a316dec 100644 --- a/osu.Game/Skinning/ISkin.cs +++ b/osu.Game/Skinning/ISkin.cs @@ -52,6 +52,8 @@ public interface ISkin /// /// The requested configuration value. /// A matching value boxed in an , or null if unavailable. - IBindable? GetConfig(TLookup lookup); + IBindable? GetConfig(TLookup lookup) + where TLookup : notnull + where TValue : notnull; } } diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index a3c08f4ba2..92713023f4 100644 --- a/osu.Game/Skinning/LegacySkin.cs +++ b/osu.Game/Skinning/LegacySkin.cs @@ -282,6 +282,7 @@ protected override void ParseConfigurationStream(Stream stream) => source.ImageLookups.TryGetValue(lookup, out string image) ? new Bindable(image) : null; private IBindable? legacySettingLookup(SkinConfiguration.LegacySetting legacySetting) + where TValue : notnull { switch (legacySetting) { @@ -294,10 +295,9 @@ protected override void ParseConfigurationStream(Stream stream) } private IBindable? genericLookup(TLookup lookup) + where TLookup : notnull + where TValue : notnull { - if (lookup == null) - return null; - try { if (Configuration.ConfigDictionary.TryGetValue(lookup.ToString(), out string val)) diff --git a/osu.Game/Skinning/ResourceStoreBackedSkin.cs b/osu.Game/Skinning/ResourceStoreBackedSkin.cs index 4787b5a4e9..48286bff59 100644 --- a/osu.Game/Skinning/ResourceStoreBackedSkin.cs +++ b/osu.Game/Skinning/ResourceStoreBackedSkin.cs @@ -46,7 +46,10 @@ public ResourceStoreBackedSkin(IResourceStore resources, GameHost host, return null; } - public IBindable? GetConfig(TLookup lookup) => null; + public IBindable? GetConfig(TLookup lookup) + where TLookup : notnull + where TValue : notnull + => null; public void Dispose() { diff --git a/osu.Game/Skinning/Skin.cs b/osu.Game/Skinning/Skin.cs index 2766e58c96..324ed90a67 100644 --- a/osu.Game/Skinning/Skin.cs +++ b/osu.Game/Skinning/Skin.cs @@ -50,7 +50,9 @@ public abstract class Skin : IDisposable, ISkin public abstract Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT); - public abstract IBindable? GetConfig(TLookup lookup); + public abstract IBindable? GetConfig(TLookup lookup) + where TLookup : notnull + where TValue : notnull; /// /// Construct a new skin.