Comments (9)
Trying to triangulate the problem. Apparently, Guid.NewGuid
and Guid.Empty
are treated differently.
This expression is deserialized without errors:
Expression<Func<Guid, bool>> exp = g => Guid.NewGuid() != g;
And this one is throwing NRE:
Expression<Func<Guid, bool>> exp = g => Guid.Empty != g;
from serialize.linq.
Another case of deserialization failure:
var guid = Guid.NewGuid();
Expression<Func<Company, bool>> exp = c => c.ID == guid;
It looks like whenever a Guid value is provided deserialization fails...
from serialize.linq.
thanks. i will look into it.
from serialize.linq.
Narrowed it down to ConstantExpressionNode. When on deserialization the Value
is set then it's a string, no a Guid. For other primitive types (int, bool) the implicit conversion is performed and Value holds the value of correct type...
from serialize.linq.
Guid.NewGuid()
is a function call where as Guid.Empty
is a static variable.
the question is now, what are you expecting?
g => g == Guid.Empty
is equivalent to
g => g == new Guid("00000000-0000-0000-0000-000000000000")
from serialize.linq.
I'm still getting NullReferenceException. While trying to simplify reproduction of the problem I've came to Guid.Empty as an example. But with a Guid value the deserializer is still failing. See this failing test:
[TestMethod]
public void SerializeDeserializeGuidValue()
{
var guidValue = Guid.NewGuid();
Expression<Func<Guid>> exp = () => guidValue;
var serializer = new ExpressionSerializer(new JsonSerializer());
var serialized = serializer.SerializeText(exp);
serializer.DeserializeText(serialized);
}
from serialize.linq.
Yet another test:
[TestMethod]
public void SerializeDeserializeGuidValue()
{
var guidValue = Guid.NewGuid();
Expression<Func<Guid>> exp = () => guidValue;
SerializeAndDeserialize(exp, new XmlSerializer()); // PASSES!
SerializeAndDeserialize(exp, new JsonSerializer()); // FAILS
SerializeAndDeserialize(exp, new BinarySerializer()); // FAILS
}
public void SerializeAndDeserialize(Expression exp, ISerializer serializer)
{
var eSerializer = new ExpressionSerializer(serializer);
eSerializer.DeserializeText(eSerializer.SerializeText(exp));
}
So, only with XmlSerializer expression is deserialized properly.
from serialize.linq.
seems to be a bug in JsonSerializer
and BinarySerializer
from serialize.linq.
never mind. i'll fix it.
from serialize.linq.
Related Issues (20)
- bug when using expressions that contain dynamic HOT 1
- Question on LambdaExpression serialization HOT 1
- .net 5.0 problem HOT 2
- Serialize expression when it is a property of a class? HOT 2
- Cannot Serialize Expression Converted From Func HOT 3
- How to Revice Post arguments in core 3.1
- Change of License HOT 6
- Expression.Default not supported in serialization HOT 2
- Question about deserialization security: HOT 1
- Need your help with other issue HOT 2
- "System.InvalidOperationException: Sequence contains no matching element" during SerializeText HOT 1
- Known type cannot be an interface
- Error converting type: Bug or implementation issue - please help HOT 3
- Undefined variable error when using ToString in lambda expression HOT 2
- Deploy the latest build to NuGet HOT 3
- Serialize Linq Expression not working - Workaround / Suggestion HOT 2
- Target framework net standard 2.0 & 2.1 HOT 3
- Changes from 2.x to 3.x HOT 2
- Error when serializing an expression with nested method calls
- Method serialization issue
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from serialize.linq.