Switch OutPointJsonConverter from 'JsonConverter' to 'JsonConverter<T>'
MODIFY
WalletWasabi/JsonConverters/OutPointJsonConverter.cs
WalletWasabi/JsonConverters/OutPointJsonConverter.cs
@@ -3,27 +3,21 @@ using Newtonsoft.Json;
namespace WalletWasabi.JsonConverters;
-public class OutPointJsonConverter : JsonConverter
+public class OutPointJsonConverter : JsonConverter<OutPoint>
{
/// <inheritdoc />
- public override bool CanConvert(Type objectType)
+ public override OutPoint? ReadJson(JsonReader reader, Type objectType, OutPoint? existingValue, bool hasExistingValue, JsonSerializer serializer)
{
- return objectType == typeof(OutPoint);
- }
-
- /// <inheritdoc />
- public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
- {
- var value = (string)reader.Value;
+ var value = (string?)reader.Value;
var op = new OutPoint();
op.FromHex(value);
return op;
}
/// <inheritdoc />
- public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
+ public override void WriteJson(JsonWriter writer, OutPoint? value, JsonSerializer serializer)
{
- string opHex = ((OutPoint)value).ToHex();
+ string opHex = value?.ToHex() ?? throw new ArgumentNullException(nameof(value));
writer.WriteValue(opHex);
}
}

Switch OutPointJsonConverter from 'JsonConverter' to 'JsonConverter<T>'