From ea536dea23c9b6cfe75693b679304ff416aa7688 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 11 Nov 2021 14:45:40 +0900 Subject: [PATCH] Gracefully handle missing type rather than triggering `ArgumentNullException` --- osu.Game/Rulesets/RulesetStore.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/osu.Game/Rulesets/RulesetStore.cs b/osu.Game/Rulesets/RulesetStore.cs index 391bf2c07d..914f33a7ae 100644 --- a/osu.Game/Rulesets/RulesetStore.cs +++ b/osu.Game/Rulesets/RulesetStore.cs @@ -129,13 +129,18 @@ namespace osu.Game.Rulesets { try { - var instanceInfo = ((Ruleset)Activator.CreateInstance(Type.GetType(r.InstantiationInfo).AsNonNull())).RulesetInfo; + var resolvedType = Type.GetType(r.InstantiationInfo); - r.Name = instanceInfo.Name; - r.ShortName = instanceInfo.ShortName; - r.InstantiationInfo = instanceInfo.InstantiationInfo; + if (resolvedType != null) + { + var instanceInfo = ((Ruleset)Activator.CreateInstance(resolvedType)).RulesetInfo; - r.Available = true; + r.Name = instanceInfo.Name; + r.ShortName = instanceInfo.ShortName; + r.InstantiationInfo = instanceInfo.InstantiationInfo; + + r.Available = true; + } } catch {