diff --git a/osu.Game/IO/Legacy/SerializationReader.cs b/osu.Game/IO/Legacy/SerializationReader.cs
index f7b3f33e87..5423485c95 100644
--- a/osu.Game/IO/Legacy/SerializationReader.cs
+++ b/osu.Game/IO/Legacy/SerializationReader.cs
@@ -3,11 +3,7 @@
using System;
using System.Collections.Generic;
-using System.Diagnostics;
using System.IO;
-using System.Reflection;
-using System.Runtime.Serialization;
-using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
namespace osu.Game.IO.Legacy
@@ -26,15 +22,6 @@ namespace osu.Game.IO.Legacy
public int RemainingBytes => (int)(stream.Length - stream.Position);
- /// Static method to take a SerializationInfo object (an input to an ISerializable constructor)
- /// and produce a SerializationReader from which serialized objects can be read .
- public static SerializationReader GetReader(SerializationInfo info)
- {
- byte[] byteArray = (byte[])info.GetValue("X", typeof(byte[]));
- MemoryStream ms = new MemoryStream(byteArray);
- return new SerializationReader(ms);
- }
-
/// Reads a string from the buffer. Overrides the base implementation so it can cope with nulls.
public override string ReadString()
{
@@ -186,98 +173,12 @@ namespace osu.Game.IO.Legacy
return ReadCharArray();
case ObjType.otherType:
- return DynamicDeserializer.Deserialize(BaseStream);
+ throw new IOException("Deserialization of arbitrary type is not supported.");
default:
return null;
}
}
-
- public static class DynamicDeserializer
- {
- private static VersionConfigToNamespaceAssemblyObjectBinder versionBinder;
- private static BinaryFormatter formatter;
-
- private static void initialize()
- {
- versionBinder = new VersionConfigToNamespaceAssemblyObjectBinder();
- formatter = new BinaryFormatter
- {
- // AssemblyFormat = FormatterAssemblyStyle.Simple,
- Binder = versionBinder
- };
- }
-
- public static object Deserialize(Stream stream)
- {
- if (formatter == null)
- initialize();
-
- Debug.Assert(formatter != null, "formatter != null");
-
- // ReSharper disable once PossibleNullReferenceException
- return formatter.Deserialize(stream);
- }
-
- #region Nested type: VersionConfigToNamespaceAssemblyObjectBinder
-
- public sealed class VersionConfigToNamespaceAssemblyObjectBinder : SerializationBinder
- {
- private readonly Dictionary cache = new Dictionary();
-
- public override Type BindToType(string assemblyName, string typeName)
- {
- if (cache.TryGetValue(assemblyName + typeName, out var typeToDeserialize))
- return typeToDeserialize;
-
- List tmpTypes = new List();
- Type genType = null;
-
- if (typeName.Contains("System.Collections.Generic") && typeName.Contains("[["))
- {
- string[] splitTypes = typeName.Split('[');
-
- foreach (string typ in splitTypes)
- {
- if (typ.Contains("Version"))
- {
- string asmTmp = typ.Substring(typ.IndexOf(',') + 1);
- string asmName = asmTmp.Remove(asmTmp.IndexOf(']')).Trim();
- string typName = typ.Remove(typ.IndexOf(','));
- tmpTypes.Add(BindToType(asmName, typName));
- }
- else if (typ.Contains("Generic"))
- {
- genType = BindToType(assemblyName, typ);
- }
- }
-
- if (genType != null && tmpTypes.Count > 0)
- {
- return genType.MakeGenericType(tmpTypes.ToArray());
- }
- }
-
- string toAssemblyName = assemblyName.Split(',')[0];
- Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
-
- foreach (Assembly a in assemblies)
- {
- if (a.FullName.Split(',')[0] == toAssemblyName)
- {
- typeToDeserialize = a.GetType(typeName);
- break;
- }
- }
-
- cache.Add(assemblyName + typeName, typeToDeserialize);
-
- return typeToDeserialize;
- }
- }
-
- #endregion
- }
}
public enum ObjType : byte
diff --git a/osu.Game/IO/Legacy/SerializationWriter.cs b/osu.Game/IO/Legacy/SerializationWriter.cs
index 9ebeaf616e..c9fff05bcc 100644
--- a/osu.Game/IO/Legacy/SerializationWriter.cs
+++ b/osu.Game/IO/Legacy/SerializationWriter.cs
@@ -4,9 +4,6 @@
using System;
using System.Collections.Generic;
using System.IO;
-using System.Runtime.Serialization;
-using System.Runtime.Serialization.Formatters;
-using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
// ReSharper disable ConditionIsAlwaysTrueOrFalse (we're allowing nulls to be passed to the writer where the underlying class doesn't).
@@ -218,25 +215,11 @@ namespace osu.Game.IO.Legacy
break;
default:
- Write((byte)ObjType.otherType);
- BinaryFormatter b = new BinaryFormatter
- {
- // AssemblyFormat = FormatterAssemblyStyle.Simple,
- TypeFormat = FormatterTypeStyle.TypesWhenNeeded
- };
- b.Serialize(BaseStream, obj);
- break;
+ throw new IOException("Serialization of arbitrary type is not supported.");
} // switch
} // if obj==null
} // WriteObject
- /// Adds the SerializationWriter buffer to the SerializationInfo at the end of GetObjectData().
- public void AddToInfo(SerializationInfo info)
- {
- byte[] b = ((MemoryStream)BaseStream).ToArray();
- info.AddValue("X", b, typeof(byte[]));
- }
-
public void WriteRawBytes(byte[] b)
{
base.Write(b);