diff --git a/osu.Game/IO/Serialization/Converters/TypedListConverter.cs b/osu.Game/IO/Serialization/Converters/TypedListConverter.cs
index 64f1ebeb1a..f98fa05821 100644
--- a/osu.Game/IO/Serialization/Converters/TypedListConverter.cs
+++ b/osu.Game/IO/Serialization/Converters/TypedListConverter.cs
@@ -9,12 +9,12 @@ using Newtonsoft.Json.Linq;
namespace osu.Game.IO.Serialization.Converters
{
///
- /// A type of that serializes a alongside
+ /// A type of that serializes an alongside
/// a lookup table for the types contained. The lookup table is used in deserialization to
/// reconstruct the objects with their original types.
///
- /// The type of objects contained in the this attribute is attached to.
- public class TypedListConverter : JsonConverter
+ /// The type of objects contained in the this attribute is attached to.
+ public class TypedListConverter : JsonConverter>
{
private readonly bool requiresTypeVersion;
@@ -36,9 +36,7 @@ namespace osu.Game.IO.Serialization.Converters
this.requiresTypeVersion = requiresTypeVersion;
}
- public override bool CanConvert(Type objectType) => objectType == typeof(List);
-
- public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
+ public override IReadOnlyList ReadJson(JsonReader reader, Type objectType, IReadOnlyList existingValue, bool hasExistingValue, JsonSerializer serializer)
{
var list = new List();
@@ -59,14 +57,12 @@ namespace osu.Game.IO.Serialization.Converters
return list;
}
- public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
+ public override void WriteJson(JsonWriter writer, IReadOnlyList value, JsonSerializer serializer)
{
- var list = (IEnumerable)value;
-
var lookupTable = new List();
var objects = new List();
- foreach (var item in list)
+ foreach (var item in value)
{
var type = item.GetType();
var assemblyName = type.Assembly.GetName();
diff --git a/osu.Game/IO/Serialization/Converters/Vector2Converter.cs b/osu.Game/IO/Serialization/Converters/Vector2Converter.cs
index bf5edeef94..46447b607b 100644
--- a/osu.Game/IO/Serialization/Converters/Vector2Converter.cs
+++ b/osu.Game/IO/Serialization/Converters/Vector2Converter.cs
@@ -11,26 +11,22 @@ namespace osu.Game.IO.Serialization.Converters
///
/// A type of that serializes only the X and Y coordinates of a .
///
- public class Vector2Converter : JsonConverter
+ public class Vector2Converter : JsonConverter
{
- public override bool CanConvert(Type objectType) => objectType == typeof(Vector2);
-
- public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
+ public override Vector2 ReadJson(JsonReader reader, Type objectType, Vector2 existingValue, bool hasExistingValue, JsonSerializer serializer)
{
var obj = JObject.Load(reader);
return new Vector2((float)obj["x"], (float)obj["y"]);
}
- public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
+ public override void WriteJson(JsonWriter writer, Vector2 value, JsonSerializer serializer)
{
- var vector = (Vector2)value;
-
writer.WriteStartObject();
writer.WritePropertyName("x");
- writer.WriteValue(vector.X);
+ writer.WriteValue(value.X);
writer.WritePropertyName("y");
- writer.WriteValue(vector.Y);
+ writer.WriteValue(value.Y);
writer.WriteEndObject();
}