Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/aspnet/MessagePack-CSharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Mikhisor <40904997+MaximMikhisor@users.noreply.github.com>2022-07-25 01:51:37 +0300
committerGitHub <noreply@github.com>2022-07-25 01:51:37 +0300
commitd75c56acc197c4dac8767192f8f40ace632918ed (patch)
tree92df36817d764defb669d0ef32b3698b30f709cf
parent287c4f7a7a2d6f93d98bd143cb7578cd9ea204da (diff)
parenteb6b93bb63794566ebb4d36e37ea173782851c79 (diff)
Merge pull request #3 from AArnott/pr1461
Revise the fix slightly
-rw-r--r--src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.NonGeneric.cs22
-rw-r--r--src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.cs12
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>