diff --git a/IPA.Loader/JsonConverters/SemverRangeConverter.cs b/IPA.Loader/JsonConverters/SemverRangeConverter.cs index edff82b8..71e84983 100644 --- a/IPA.Loader/JsonConverters/SemverRangeConverter.cs +++ b/IPA.Loader/JsonConverters/SemverRangeConverter.cs @@ -1,5 +1,6 @@ #nullable enable using System; +using System.Runtime.Remoting.Messaging; using Hive.Versioning; using Newtonsoft.Json; @@ -8,9 +9,12 @@ namespace IPA.JsonConverters internal class SemverRangeConverter : JsonConverter { public override VersionRange? ReadJson(JsonReader reader, Type objectType, VersionRange? existingValue, bool hasExistingValue, JsonSerializer serializer) - => reader.Value is string s && VersionRange.TryParse(s, out var range) ? range : existingValue; + => reader.Value is not string s ? existingValue : new VersionRange(s); public override void WriteJson(JsonWriter writer, VersionRange? value, JsonSerializer serializer) - => writer.WriteValue(value?.ToString()); + { + if (value is null) writer.WriteNull(); + else writer.WriteValue(value.ToString()); + } } } diff --git a/IPA.Loader/JsonConverters/SemverVersionConverter.cs b/IPA.Loader/JsonConverters/SemverVersionConverter.cs index c0c7c10a..40683f03 100644 --- a/IPA.Loader/JsonConverters/SemverVersionConverter.cs +++ b/IPA.Loader/JsonConverters/SemverVersionConverter.cs @@ -8,7 +8,7 @@ namespace IPA.JsonConverters internal class SemverVersionConverter : JsonConverter { public override Version? ReadJson(JsonReader reader, Type objectType, Version? existingValue, bool hasExistingValue, JsonSerializer serializer) - => reader.Value is string s && Version.TryParse(s, out var version) ? version : existingValue; + => reader.Value is not string s ? existingValue : new Version(s); public override void WriteJson(JsonWriter writer, Version? value, JsonSerializer serializer) {