Skip to content

Commit eb6b93b

Browse files
committed
Revise the fix slightly
1 parent 287c4f7 commit eb6b93b

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.NonGeneric.cs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,22 @@ public static object Deserialize(Type type, ReadOnlySequence<byte> bytes, Messag
8282
return GetOrAdd(type).Deserialize_ReadOnlySequence_Options_CancellationToken.Invoke(bytes, options, cancellationToken);
8383
}
8484

85+
/// <summary>
86+
/// Helper method used by reflection.
87+
/// </summary>
88+
private static void SerializeSemiGeneric<T>(ref MessagePackWriter writer, object valueObject, MessagePackSerializerOptions options = null)
89+
{
90+
Serialize(ref writer, (T)valueObject, options);
91+
}
92+
93+
/// <summary>
94+
/// Helper method used by reflection.
95+
/// </summary>
96+
private static object DeserializeSemiGeneric<T>(ref MessagePackReader reader, MessagePackSerializerOptions options = null)
97+
{
98+
return Deserialize<T>(ref reader, options);
99+
}
100+
85101
private static async ValueTask<object> DeserializeObjectAsync<T>(Stream stream, MessagePackSerializerOptions options, CancellationToken cancellationToken) => await DeserializeAsync<T>(stream, options, cancellationToken).ConfigureAwait(false);
86102

87103
private static CompiledMethods GetOrAdd(Type type)
@@ -219,8 +235,8 @@ internal CompiledMethods(Type type)
219235
}
220236

221237
{
222-
// public static void Serialize<T>(ref MessagePackWriter writer, T obj, MessagePackSerializerOptions options)
223-
MethodInfo serialize = GetMethod(nameof(SerializeSemiGeneric), type, new Type[] { typeof(MessagePackWriter).MakeByRefType(), typeof(Object), typeof(MessagePackSerializerOptions) });
238+
// private static void SerializeSemiGeneric<T>(ref MessagePackWriter writer, object obj, MessagePackSerializerOptions options)
239+
MethodInfo serialize = GetMethod(nameof(SerializeSemiGeneric), type, new Type[] { typeof(MessagePackWriter).MakeByRefType(), typeof(object), typeof(MessagePackSerializerOptions) });
224240
#if ENABLE_IL2CPP
225241
this.Serialize_MessagePackWriter_T_Options = (ref MessagePackWriter x, object y, MessagePackSerializerOptions z) => ThrowRefStructNotSupported();
226242
#else
@@ -229,7 +245,7 @@ internal CompiledMethods(Type type)
229245
}
230246

231247
{
232-
// public static T Deserialize<T>(ref MessagePackReader reader, MessagePackSerializerOptions options)
248+
// private static object DeserializeSemiGeneric<T>(ref MessagePackReader reader, MessagePackSerializerOptions options)
233249
MethodInfo deserialize = GetMethod(nameof(DeserializeSemiGeneric), type, new Type[] { typeof(MessagePackReader).MakeByRefType(), typeof(MessagePackSerializerOptions) });
234250
#if ENABLE_IL2CPP
235251
this.Deserialize_MessagePackReader_Options = (ref MessagePackReader reader, MessagePackSerializerOptions options) => { ThrowRefStructNotSupported(); return null; };

src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,6 @@ public static void Serialize<T>(IBufferWriter<byte> writer, T value, MessagePack
7171
fastWriter.Flush();
7272
}
7373

74-
internal static void SerializeSemiGeneric<T>(ref MessagePackWriter writer, Object valueObject, MessagePackSerializerOptions options = null)
75-
{
76-
T value = (T)valueObject;
77-
78-
Serialize(ref writer, value, options);
79-
}
80-
8174
/// <summary>
8275
/// Serializes a given value with the specified buffer writer.
8376
/// </summary>
@@ -271,11 +264,6 @@ public static T Deserialize<T>(ref MessagePackReader reader, MessagePackSerializ
271264
}
272265
}
273266

274-
internal static Object DeserializeSemiGeneric<T>(ref MessagePackReader reader, MessagePackSerializerOptions options = null)
275-
{
276-
return Deserialize<T>(ref reader, options);
277-
}
278-
279267
/// <summary>
280268
/// Deserializes a value of a given type from a sequence of bytes.
281269
/// </summary>

0 commit comments

Comments
 (0)