Git Product home page Git Product logo

Comments (9)

vcaraulean avatar vcaraulean commented on July 21, 2024

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.

vcaraulean avatar vcaraulean commented on July 21, 2024

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.

esskar avatar esskar commented on July 21, 2024

thanks. i will look into it.

from serialize.linq.

vcaraulean avatar vcaraulean commented on July 21, 2024

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.

esskar avatar esskar commented on July 21, 2024

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.

vcaraulean avatar vcaraulean commented on July 21, 2024

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.

vcaraulean avatar vcaraulean commented on July 21, 2024

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.

esskar avatar esskar commented on July 21, 2024

seems to be a bug in JsonSerializer and BinarySerializer

from serialize.linq.

esskar avatar esskar commented on July 21, 2024

never mind. i'll fix it.

from serialize.linq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.