You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm unable to round-trip serialization of an Expression<Func<T, bool>>.
I can see the CanSerializeLambdaExpression test within the code base that is similar but my following test case fails, the Method property (of type MethodInfo) inside the MethodCallExpression is null upon de-serialization.
Hopefully someone can help me resolve this. It might take me a while to navigate the codebase and track down the solution myself. Happy to help with a pull request if someone has an idea though.
[Fact]
public void CanSerializeStronglyTypedLambdaExpression() {
Expression<Func<Something, bool>> expr = s => new[] { "Bar", "Car" }.Contains(s.Foo);
var serializer = new Serializer(new SerializerOptions(preserveObjectReferences: true));
using (var ms = new MemoryStream())
{
serializer.Serialize(expr, ms);
ms.Seek(0, SeekOrigin.Begin);
var deserialized = serializer.Deserialize<Expression<Func<Something, bool>>>(ms);
Assert.NotNull(((MethodCallExpression)deserialized.Body).Method);
Assert.True(expr.Parameters[0] == ((MemberExpression)(((MethodCallExpression)deserialized.Body).Arguments[1])).Expression);
Assert.True(deserialized.Compile()(new Something { Foo = "Bar" }));
}
}
public class Something {
public string Foo { get; set; }
}
The text was updated successfully, but these errors were encountered:
I'm unable to round-trip serialization of an Expression<Func<T, bool>>.
I can see the
CanSerializeLambdaExpression
test within the code base that is similar but my following test case fails, the Method property (of type MethodInfo) inside the MethodCallExpression is null upon de-serialization.Hopefully someone can help me resolve this. It might take me a while to navigate the codebase and track down the solution myself. Happy to help with a pull request if someone has an idea though.
The text was updated successfully, but these errors were encountered: