From 77904196e35fac7228cf9d3bd36a6de263445270 Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Thu, 21 Jul 2022 00:50:01 -0500 Subject: [PATCH] Fix nullability warnings for new Newtonsoft version --- IPA.Loader/Config/Stores/Converters.cs | 2 +- IPA.Loader/Loader/PluginLoader.cs | 12 ++++++++++-- docs/build.ps1 | 4 ++-- docs/docfx.json | 2 +- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/IPA.Loader/Config/Stores/Converters.cs b/IPA.Loader/Config/Stores/Converters.cs index 12e222f1..433640ad 100644 --- a/IPA.Loader/Config/Stores/Converters.cs +++ b/IPA.Loader/Config/Stores/Converters.cs @@ -80,7 +80,7 @@ namespace IPA.Config.Stores.Converters if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Nullable<>)) { // this is a Nullable //Logger.log.Debug($"gives NullableConverter<{Nullable.GetUnderlyingType(t)}>"); - return (typeof(NullableConverter<>).MakeGenericType(Nullable.GetUnderlyingType(t))); + return typeof(NullableConverter<>).MakeGenericType(Nullable.GetUnderlyingType(t)); } //Logger.log.Debug($"gives converter for value type {t}"); diff --git a/IPA.Loader/Loader/PluginLoader.cs b/IPA.Loader/Loader/PluginLoader.cs index f5252eee..04930963 100644 --- a/IPA.Loader/Loader/PluginLoader.cs +++ b/IPA.Loader/Loader/PluginLoader.cs @@ -104,7 +104,8 @@ namespace IPA.Loader throw new InvalidOperationException())) manifest = manifestReader.ReadToEnd(); - selfMeta.Manifest = JsonConvert.DeserializeObject(manifest); + var manifestObj = JsonConvert.DeserializeObject(manifest); + selfMeta.Manifest = manifestObj ?? throw new InvalidOperationException("Deserialized manifest was null"); PluginsMetadata.Add(selfMeta); SelfMeta = selfMeta; @@ -276,7 +277,14 @@ namespace IPA.Loader IsBare = true, }; - metadata.Manifest = JsonConvert.DeserializeObject(File.ReadAllText(manifest)); + var manifestObj = JsonConvert.DeserializeObject(File.ReadAllText(manifest)); + if (manifestObj is null) + { + Logger.Loader.Error($"Bare manifest {Path.GetFileName(manifest)} deserialized to null"); + continue; + } + + metadata.Manifest = manifestObj; if (metadata.Manifest.Files.Length < 1) Logger.Loader.Warn($"Bare manifest {Path.GetFileName(manifest)} does not declare any files. " + diff --git a/docs/build.ps1 b/docs/build.ps1 index e8b95d6b..a2a0751d 100644 --- a/docs/build.ps1 +++ b/docs/build.ps1 @@ -7,8 +7,8 @@ if ($PSEdition -eq "Core") { # read SelfConfig, remove wierd bits, load it, load Newtonsoft, and turn it into a schema -$newtonsoftVer = "12.0.2" -$newtonsoftSchemaVer = "3.0.11" +$newtonsoftVer = "13.0.1" +$newtonsoftSchemaVer = "3.0.15-beta2" $codeDomProviderVer = "3.6.0" $roslynVer = "3.10.0" $nugetBase = "$(Get-Location)/nuget" diff --git a/docs/docfx.json b/docs/docfx.json index afe2c5b6..96426a9a 100644 --- a/docs/docfx.json +++ b/docs/docfx.json @@ -20,7 +20,7 @@ "disableGitFeatures": false, "disableDefaultFilter": false, "properties": { - "TargetFramework": "net461" + "TargetFramework": "net472" } }], "build": {