diff --git a/osu.Game/IO/Serialization/Converters/TypedListConverter.cs b/osu.Game/IO/Serialization/Converters/TypedListConverter.cs index c3d5869035..32b7772092 100644 --- a/osu.Game/IO/Serialization/Converters/TypedListConverter.cs +++ b/osu.Game/IO/Serialization/Converters/TypedListConverter.cs @@ -16,6 +16,26 @@ namespace osu.Game.IO.Serialization.Converters /// The type of objects contained in the this attribute is attached to. public class TypedListConverter : JsonConverter { + private readonly bool requiresTypeVersion; + + /// + /// Constructs a new . + /// + // ReSharper disable once UnusedMember.Global + public TypedListConverter() + { + } + + /// + /// Constructs a new . + /// + /// Whether the version of the type should be serialized. + // ReSharper disable once UnusedMember.Global (Used in Beatmap) + public TypedListConverter(bool requiresTypeVersion) + { + this.requiresTypeVersion = requiresTypeVersion; + } + public override bool CanConvert(Type objectType) => objectType == typeof(List); public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) @@ -49,12 +69,17 @@ namespace osu.Game.IO.Serialization.Converters var objects = new List(); foreach (var item in list) { - var type = item.GetType().AssemblyQualifiedName; + var type = item.GetType(); + var assemblyName = type.Assembly.GetName(); - int typeId = lookupTable.IndexOf(type); + var typeString = $"{type.FullName}, {assemblyName.Name}"; + if (requiresTypeVersion) + typeString += $", {assemblyName.Version}"; + + int typeId = lookupTable.IndexOf(typeString); if (typeId == -1) { - lookupTable.Add(type); + lookupTable.Add(typeString); typeId = lookupTable.Count - 1; }