Git Product home page Git Product logo

Comments (22)

AqlaSolutions avatar AqlaSolutions commented on September 26, 2024

Stacktrace?

from aqlaserializer.

inethui avatar inethui commented on September 26, 2024

Stack Trace: 

DeflateStream.get_Position()
ProtoWriter.ctor(Stream dest, TypeModel model, SerializationContext context) line 886
TypeModel.Serialize(Stream dest, Object value, SerializationContext context) line 240
TypeModel.Serialize(Stream dest, Object value) line 227
Serializer.Serialize[T](Stream destination, T instance) line 135
UnitTest.TestCompress() line 170

from aqlaserializer.

AqlaSolutions avatar AqlaSolutions commented on September 26, 2024

Yeah, it's expected that it's possible to get stream position, if it's not supported in DeflateStream than you can't use it directly. Though you can make a wrapper around DeflateStream which implements Position. It should just count written bytes.

from aqlaserializer.

inethui avatar inethui commented on September 26, 2024

But this code works for Protobuf-net. Is Aqla supposed to support whatever Protobuf-net provides?
The following code works:

            using (DeflateStream dest = new DeflateStream(new MemoryStream(), CompressionMode.Compress))
            {
                ProtoBuf.Serializer.Serialize(dest, "Test");
            }

from aqlaserializer.

AqlaSolutions avatar AqlaSolutions commented on September 26, 2024

Mostly it supports things from Protobuf-net, but not using Position property is a very implementation specific thing. Ok, I'll see if Position can be avoided. For now you can workaround it using a wrapper.

from aqlaserializer.

inethui avatar inethui commented on September 26, 2024

We've already had a serialization solution which is a mix of BinaryFormatter and ProtoBuf, each has its own issues. I'm trying to consolidate them into Aqla, but found these two issues. It would be very much appreciated if you can get them addressed.

from aqlaserializer.

AqlaSolutions avatar AqlaSolutions commented on September 26, 2024

Can you provide an example with full cycle: serialization + deserialization using DeflateStream?

from aqlaserializer.

inethui avatar inethui commented on September 26, 2024

This is an example of how to serialize/deserialize into/from a DeflateStream:

        public void TestCompress()
        {
            byte[] bytes;
            using (MemoryStream stream = new MemoryStream())
            {
                using (DeflateStream dest = new DeflateStream(stream, CompressionMode.Compress))
                {
                    ProtoBuf.Serializer.Serialize(dest, "Test");
                }

                bytes = stream.ToArray();
            }

            using (var stream = new MemoryStream(bytes))
                using (DeflateStream dest = new DeflateStream(stream, CompressionMode.Decompress))
                {
                    var str = ProtoBuf.Serializer.Deserialize<string>(dest);
                    Assert.Equal("Test", str);
                }
        }

from aqlaserializer.

AqlaSolutions avatar AqlaSolutions commented on September 26, 2024

Ok, I fixed it so that Position is not used unless it is really necessary. You can test it with the develop branch. But mind that some features require seeking during reading like If you try to reference an object from inside itself.

from aqlaserializer.

inethui avatar inethui commented on September 26, 2024

Thanks for the quick turn around. I want to make Aqla our standard serializer, but these two issues have caused many unit tests to fail. Now you have quickly fixed issue #36, it would be really helpful if you can also fix #35.

from aqlaserializer.

inethui avatar inethui commented on September 26, 2024

I got the following error while trying to run our tests with the Aqla develop branch:
AqlaSerializer.ProtoAggregateException : One or multiple exceptions occurred: InvalidOperationException (Non-public member cannot be used with full dll compilation:
Any idea what could be the cause?

from aqlaserializer.

AqlaSolutions avatar AqlaSolutions commented on September 26, 2024

It means you are serializing a private field. If it's not the case can you give me a repro?

from aqlaserializer.

inethui avatar inethui commented on September 26, 2024

Yes, we are serializing private fields. We use reflection to find out all fields (public and private) and use RuntimeTypeModel APIs to register our classes and fields. This has never been a problem before.

from aqlaserializer.

inethui avatar inethui commented on September 26, 2024

I have encountered similar issues before. One thing I noticed is that if I download and use the binaries you built, then this problem goes away.

from aqlaserializer.

inethui avatar inethui commented on September 26, 2024

Can you please publish the binaries? I would like to give it a try.

from aqlaserializer.

inethui avatar inethui commented on September 26, 2024

What does "full dll compilation" mean?

from aqlaserializer.

AqlaSolutions avatar AqlaSolutions commented on September 26, 2024

When you call RuntimeTypeModel.Compile(dllName) it generates dll that can serialize your classes without reflection. If works as any other compiled C# code so it can't access private members.

from aqlaserializer.

AqlaSolutions avatar AqlaSolutions commented on September 26, 2024

It looks like you use DEBUG configuration of aqlaserializer project, that's why it attempts to test dll compilation. Just switch to release.

from aqlaserializer.

inethui avatar inethui commented on September 26, 2024

You are right, I was running in DEBUG configuration. However, I didn't call RuntimeTypeModel.Compile(dllName), instead what I called is RuntimeTypeModel.Default.CompileInPlace(). Does this have the same effect as "RuntimeTypeModel.Compile(dllName)"?

from aqlaserializer.

inethui avatar inethui commented on September 26, 2024

I'm having some trouble to build the release build of Aqla. Can you post the release build of it? Thanks

from aqlaserializer.

inethui avatar inethui commented on September 26, 2024

Never mind, I figured out how to create the release build. I've verified that this issue is fixed in develop branch. Now can you please create a nuget package? I will ask our IT to download it and put it in our internal nuget repo so that our system can start to use it.

from aqlaserializer.

AqlaSolutions avatar AqlaSolutions commented on September 26, 2024

I've published the new release.

from aqlaserializer.

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.