diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-04-07 02:33:23 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-04-07 02:33:23 -0400 |
commit | d706a25053cdc5d9f1ccc2c09dc3913f835c3f78 (patch) | |
tree | bb628c31b328e46d8aa7ae4c521f5f76bdfcbd38 /src/SMAPI.Toolkit/Serialization/Converters/ManifestDependencyArrayConverter.cs | |
parent | 6b05296e71c32abd158f354eeeaf1e135e72e6e2 (diff) | |
download | SMAPI-d706a25053cdc5d9f1ccc2c09dc3913f835c3f78.tar.gz SMAPI-d706a25053cdc5d9f1ccc2c09dc3913f835c3f78.tar.bz2 SMAPI-d706a25053cdc5d9f1ccc2c09dc3913f835c3f78.zip |
enable nullable annotations for most of the SMAPI toolkit (#837)
Diffstat (limited to 'src/SMAPI.Toolkit/Serialization/Converters/ManifestDependencyArrayConverter.cs')
-rw-r--r-- | src/SMAPI.Toolkit/Serialization/Converters/ManifestDependencyArrayConverter.cs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/SMAPI.Toolkit/Serialization/Converters/ManifestDependencyArrayConverter.cs b/src/SMAPI.Toolkit/Serialization/Converters/ManifestDependencyArrayConverter.cs index 2c3c2ee7..c499a2c6 100644 --- a/src/SMAPI.Toolkit/Serialization/Converters/ManifestDependencyArrayConverter.cs +++ b/src/SMAPI.Toolkit/Serialization/Converters/ManifestDependencyArrayConverter.cs @@ -1,5 +1,3 @@ -#nullable disable - using System; using System.Collections.Generic; using Newtonsoft.Json; @@ -37,13 +35,13 @@ namespace StardewModdingAPI.Toolkit.Serialization.Converters /// <param name="objectType">The object type.</param> /// <param name="existingValue">The object being read.</param> /// <param name="serializer">The calling serializer.</param> - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + public override object ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) { List<ManifestDependency> result = new List<ManifestDependency>(); foreach (JObject obj in JArray.Load(reader).Children<JObject>()) { - string uniqueID = obj.ValueIgnoreCase<string>(nameof(ManifestDependency.UniqueID)); - string minVersion = obj.ValueIgnoreCase<string>(nameof(ManifestDependency.MinimumVersion)); + string uniqueID = obj.ValueIgnoreCase<string>(nameof(ManifestDependency.UniqueID))!; // will be validated separately if null + string? minVersion = obj.ValueIgnoreCase<string>(nameof(ManifestDependency.MinimumVersion)); bool required = obj.ValueIgnoreCase<bool?>(nameof(ManifestDependency.IsRequired)) ?? true; result.Add(new ManifestDependency(uniqueID, minVersion, required)); } @@ -54,7 +52,7 @@ namespace StardewModdingAPI.Toolkit.Serialization.Converters /// <param name="writer">The JSON writer.</param> /// <param name="value">The value.</param> /// <param name="serializer">The calling serializer.</param> - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) { throw new InvalidOperationException("This converter does not write JSON."); } |