1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 16:02:55 +08:00

Resolve NREs

This commit is contained in:
smoogipoo 2020-06-03 16:59:37 +09:00
parent f3b5149648
commit 8aa8d2c880
5 changed files with 23 additions and 11 deletions

View File

@ -59,7 +59,7 @@ namespace osu.Desktop
try
{
using (RegistryKey key = Registry.ClassesRoot.OpenSubKey("osu"))
stableInstallPath = key?.OpenSubKey(@"shell\open\command")?.GetValue(string.Empty).ToString().Split('"')[1].Replace("osu!.exe", "");
stableInstallPath = key?.OpenSubKey(@"shell\open\command")?.GetValue(string.Empty).ToString()?.Split('"')[1].Replace("osu!.exe", "");
if (checkExists(stableInstallPath))
return stableInstallPath;

View File

@ -428,23 +428,23 @@ namespace osu.Game.Tests.Chat
Assert.AreEqual(5, result.Links.Count);
Link f = result.Links.Find(l => l.Url == "https://osu.ppy.sh/wiki/wiki links");
Assert.AreEqual(44, f.Index);
Assert.AreEqual(44, f!.Index);
Assert.AreEqual(10, f.Length);
f = result.Links.Find(l => l.Url == "http://www.simple-test.com");
Assert.AreEqual(10, f.Index);
Assert.AreEqual(10, f!.Index);
Assert.AreEqual(11, f.Length);
f = result.Links.Find(l => l.Url == "http://google.com");
Assert.AreEqual(97, f.Index);
Assert.AreEqual(97, f!.Index);
Assert.AreEqual(4, f.Length);
f = result.Links.Find(l => l.Url == "https://osu.ppy.sh");
Assert.AreEqual(78, f.Index);
Assert.AreEqual(78, f!.Index);
Assert.AreEqual(18, f.Length);
f = result.Links.Find(l => l.Url == "\uD83D\uDE12");
Assert.AreEqual(101, f.Index);
Assert.AreEqual(101, f!.Index);
Assert.AreEqual(3, f.Length);
}

View File

@ -45,7 +45,7 @@ namespace osu.Game.Tests.Visual.UserInterface
});
foreach (var p in typeof(OsuIcon).GetProperties(BindingFlags.Public | BindingFlags.Static))
flow.Add(new Icon($"{nameof(OsuIcon)}.{p.Name}", (IconUsage)p.GetValue(null)));
flow.Add(new Icon($"{nameof(OsuIcon)}.{p.Name}", (IconUsage)p.GetValue(null)!));
AddStep("toggle shadows", () => flow.Children.ForEach(i => i.SpriteIcon.Shadow = !i.SpriteIcon.Shadow));
AddStep("change icons", () => flow.Children.ForEach(i => i.SpriteIcon.Icon = new IconUsage((char)(i.SpriteIcon.Icon.Icon + 1))));

View File

@ -41,13 +41,25 @@ namespace osu.Game.IO.Serialization.Converters
var list = new List<T>();
var obj = JObject.Load(reader);
var lookupTable = serializer.Deserialize<List<string>>(obj["$lookup_table"].CreateReader());
foreach (var tok in obj["$items"])
if (!obj.TryGetValue("$lookup_table", out var lookupTableToken) || lookupTableToken == null)
return list;
var lookupTable = serializer.Deserialize<List<string>>(lookupTableToken.CreateReader());
if (lookupTable == null)
return list;
if (!obj.TryGetValue("$items", out var itemsToken) || itemsToken == null)
return list;
foreach (var tok in itemsToken)
{
var itemReader = tok.CreateReader();
var typeName = lookupTable[(int)tok["$type"]];
if (!obj.TryGetValue("$type", out var typeToken) || typeToken == null)
throw new JsonException("Expected $type token.");
var typeName = lookupTable[(int)typeToken];
var instance = (T)Activator.CreateInstance(Type.GetType(typeName));
serializer.Populate(itemReader, instance);

View File

@ -250,7 +250,7 @@ namespace osu.Game.Online.API
{
try
{
return JObject.Parse(req.GetResponseString()).SelectToken("form_error", true).ToObject<RegistrationRequest.RegistrationRequestErrors>();
return JObject.Parse(req.GetResponseString()).SelectToken("form_error", true)!.ToObject<RegistrationRequest.RegistrationRequestErrors>();
}
catch
{