diff options
author | Andrew Arnott <andrew.arnott@microsoft.com> | 2022-07-23 17:03:47 +0300 |
---|---|---|
committer | Andrew Arnott <andrew.arnott@microsoft.com> | 2022-07-23 17:03:47 +0300 |
commit | eb6b93bb63794566ebb4d36e37ea173782851c79 (patch) | |
tree | 92df36817d764defb669d0ef32b3698b30f709cf | |
parent | 287c4f7a7a2d6f93d98bd143cb7578cd9ea204da (diff) |
Revise the fix slightly
-rw-r--r-- | src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.NonGeneric.cs | 22 | ||||
-rw-r--r-- | src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.cs | 12 |
2 files changed, 19 insertions, 15 deletions
diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.NonGeneric.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.NonGeneric.cs index 019eb8e7..bd6f9b43 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.NonGeneric.cs +++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.NonGeneric.cs @@ -82,6 +82,22 @@ namespace MessagePack return GetOrAdd(type).Deserialize_ReadOnlySequence_Options_CancellationToken.Invoke(bytes, options, cancellationToken); } + /// <summary> + /// Helper method used by reflection. + /// </summary> + private static void SerializeSemiGeneric<T>(ref MessagePackWriter writer, object valueObject, MessagePackSerializerOptions options = null) + { + Serialize(ref writer, (T)valueObject, options); + } + + /// <summary> + /// Helper method used by reflection. + /// </summary> + private static object DeserializeSemiGeneric<T>(ref MessagePackReader reader, MessagePackSerializerOptions options = null) + { + return Deserialize<T>(ref reader, options); + } + private static async ValueTask<object> DeserializeObjectAsync<T>(Stream stream, MessagePackSerializerOptions options, CancellationToken cancellationToken) => await DeserializeAsync<T>(stream, options, cancellationToken).ConfigureAwait(false); private static CompiledMethods GetOrAdd(Type type) @@ -219,8 +235,8 @@ namespace MessagePack } { - // public static void Serialize<T>(ref MessagePackWriter writer, T obj, MessagePackSerializerOptions options) - MethodInfo serialize = GetMethod(nameof(SerializeSemiGeneric), type, new Type[] { typeof(MessagePackWriter).MakeByRefType(), typeof(Object), typeof(MessagePackSerializerOptions) }); + // private static void SerializeSemiGeneric<T>(ref MessagePackWriter writer, object obj, MessagePackSerializerOptions options) + MethodInfo serialize = GetMethod(nameof(SerializeSemiGeneric), type, new Type[] { typeof(MessagePackWriter).MakeByRefType(), typeof(object), typeof(MessagePackSerializerOptions) }); #if ENABLE_IL2CPP this.Serialize_MessagePackWriter_T_Options = (ref MessagePackWriter x, object y, MessagePackSerializerOptions z) => ThrowRefStructNotSupported(); #else @@ -229,7 +245,7 @@ namespace MessagePack } { - // public static T Deserialize<T>(ref MessagePackReader reader, MessagePackSerializerOptions options) + // private static object DeserializeSemiGeneric<T>(ref MessagePackReader reader, MessagePackSerializerOptions options) MethodInfo deserialize = GetMethod(nameof(DeserializeSemiGeneric), type, new Type[] { typeof(MessagePackReader).MakeByRefType(), typeof(MessagePackSerializerOptions) }); #if ENABLE_IL2CPP this.Deserialize_MessagePackReader_Options = (ref MessagePackReader reader, MessagePackSerializerOptions options) => { ThrowRefStructNotSupported(); return null; }; diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.cs index 9510ea89..8c4a454c 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.cs +++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.cs @@ -71,13 +71,6 @@ namespace MessagePack fastWriter.Flush(); } - internal static void SerializeSemiGeneric<T>(ref MessagePackWriter writer, Object valueObject, MessagePackSerializerOptions options = null) - { - T value = (T)valueObject; - - Serialize(ref writer, value, options); - } - /// <summary> /// Serializes a given value with the specified buffer writer. /// </summary> @@ -271,11 +264,6 @@ namespace MessagePack } } - internal static Object DeserializeSemiGeneric<T>(ref MessagePackReader reader, MessagePackSerializerOptions options = null) - { - return Deserialize<T>(ref reader, options); - } - /// <summary> /// Deserializes a value of a given type from a sequence of bytes. /// </summary> |