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 <maxim@DESKTOP-1UT7L1T>2022-04-01 09:01:45 +0300
committermaxim <maxim@DESKTOP-1UT7L1T>2022-04-01 09:01:45 +0300
commitc9fad94175b6b1d5686325cb96baaacc6f424257 (patch)
tree455221ea235c53973bb4f53f817d6a38da0c2708
parentdb187ed67ed2732c9886e6ebde895e0e5255f8fa (diff)
Fix for "System.NotImplementedException: byref delegate" in System.Linq.Expressions for AOT compilation.
-rw-r--r--src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.NonGeneric.cs4
-rw-r--r--src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.cs12
-rw-r--r--src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializerOptions.cs5
-rw-r--r--src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/DynamicObjectResolver.cs4
4 files changed, 25 insertions, 0 deletions
diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.NonGeneric.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.NonGeneric.cs
index 281e20f3..18c52d4e 100644
--- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.NonGeneric.cs
+++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.NonGeneric.cs
@@ -221,6 +221,7 @@ namespace MessagePack
{
// public static void Serialize<T>(ref MessagePackWriter writer, T obj, MessagePackSerializerOptions options)
MethodInfo serialize = GetMethod(nameof(Serialize), type, new Type[] { typeof(MessagePackWriter).MakeByRefType(), null, typeof(MessagePackSerializerOptions) });
+ 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
@@ -237,12 +238,14 @@ namespace MessagePack
MessagePackWriterSerialize lambda = Expression.Lambda<MessagePackWriterSerialize>(body, param1, param2, param3).Compile(PreferInterpretation);
this.Serialize_MessagePackWriter_T_Options = lambda;
+ this.Serialize_MessagePackWriter_T_Options = (MessagePackWriterSerialize)serialize.CreateDelegate(typeof(MessagePackWriterSerialize));
#endif
}
{
// public static T Deserialize<T>(ref MessagePackReader reader, MessagePackSerializerOptions options)
MethodInfo deserialize = GetMethod(nameof(Deserialize), type, new Type[] { typeof(MessagePackReader).MakeByRefType(), typeof(MessagePackSerializerOptions) });
+ 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; };
#else
@@ -252,6 +255,7 @@ namespace MessagePack
MessagePackReaderDeserialize lambda = Expression.Lambda<MessagePackReaderDeserialize>(body, param1, param2).Compile();
this.Deserialize_MessagePackReader_Options = lambda;
+ this.Deserialize_MessagePackReader_Options = (MessagePackReaderDeserialize)deserialize.CreateDelegate(typeof(MessagePackReaderDeserialize));
#endif
}
diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.cs
index 0e0188cf..a4f902f5 100644
--- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.cs
+++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.cs
@@ -66,6 +66,13 @@ namespace MessagePack
/// <param name="value">The value to serialize.</param>
/// <param name="options">The options. Use <c>null</c> to use default options.</param>
/// <exception cref="MessagePackSerializationException">Thrown when any error occurs during serialization.</exception>
+ internal static void SerializeSemiGeneric<T>(ref MessagePackWriter writer, Object valueObject, MessagePackSerializerOptions options = null)
+ {
+ T value = (T)valueObject;
+
+ Serialize(ref writer, value, options);
+ }
+
public static void Serialize<T>(ref MessagePackWriter writer, T value, MessagePackSerializerOptions options = null)
{
options = options ?? DefaultOptions;
@@ -221,6 +228,11 @@ namespace MessagePack
/// <exception cref="MessagePackSerializationException">Thrown when any error occurs during deserialization.</exception>
public static T Deserialize<T>(ref MessagePackReader reader, MessagePackSerializerOptions options = null)
{
+ return (T)DeserializeSemiGeneric<T>(ref reader, options);
+ }
+
+ internal static Object DeserializeSemiGeneric<T>(ref MessagePackReader reader, MessagePackSerializerOptions options = null)
+ {
options = options ?? DefaultOptions;
try
diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializerOptions.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializerOptions.cs
index ebf1ca43..f3117455 100644
--- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializerOptions.cs
+++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializerOptions.cs
@@ -29,6 +29,11 @@ namespace MessagePack
};
#if !DYNAMICCODEDUMPER
+#if DYNAMICCODEDUMPER
+ static readonly MessagePackSerializerOptions _standard = new MessagePackSerializerOptions(Resolvers.BuiltinResolver.Instance);
+
+ public static MessagePackSerializerOptions Standard => _standard;
+#else
/// <summary>
/// Gets a good default set of options that uses the <see cref="Resolvers.StandardResolver"/> and no compression.
/// </summary>
diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/DynamicObjectResolver.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/DynamicObjectResolver.cs
index 52b92b0e..643a6643 100644
--- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/DynamicObjectResolver.cs
+++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/DynamicObjectResolver.cs
@@ -1264,6 +1264,9 @@ namespace MessagePack.Internal
il.Emit(OpCodes.Br, readNext);
}
+#if NET_STANDARD_2_0
+ throw new NotImplementedException("NET_STANDARD_2_0 directive was used");
+#else
if (canOverwrite)
{
automata.EmitMatch(il, buffer, longKey, OnFoundAssignDirect, OnNotFound);
@@ -1272,6 +1275,7 @@ namespace MessagePack.Internal
{
automata.EmitMatch(il, buffer, longKey, OnFoundAssignLocalVariable, OnNotFound);
}
+#endif
il.MarkLabel(readNext);
reader.EmitLdarg();