Git Product home page Git Product logo

Comments (4)

MiloszKrajewski avatar MiloszKrajewski commented on August 15, 2024 1

Fixed in 1.1.7

from k4os.compression.lz4.

MiloszKrajewski avatar MiloszKrajewski commented on August 15, 2024

Caused by #18. Seems like it wasn't a good idea.

from k4os.compression.lz4.

mejje avatar mejje commented on August 15, 2024

Thank you, it works with the default datacontractserializer (text), but when using a binary reader/writer it causes a SerializationException:

System.Runtime.Serialization.SerializationException: There was an error deserializing the object of type LZ4Tests+TestClass. The input source is not correctly formatted. ---> System.Xml.XmlException: The input source is not correctly formatted.

Verified test with GZipStream.

        [TestMethod]
        public void LibEncodeDecode_Binary()
        {
            var obj = new TestClass { Test1 = "1" };
            var serializer = new DataContractSerializer(typeof(TestClass));

            byte[] bytes;
            using (var ms = new MemoryStream())
            {
                using (var compressionStream = LZ4Stream.Encode(ms))
                //using (var compressionStream = new System.IO.Compression.GZipStream(ms, System.IO.Compression.CompressionMode.Compress))
                {
                    using (var writer = System.Xml.XmlDictionaryWriter.CreateBinaryWriter(compressionStream))
                    {
                        serializer.WriteObject(writer, obj);
                    }
                }
                bytes = ms.ToArray();
            }

            using (var ms = new MemoryStream(bytes))
            {
                using (var decompressionStream = LZ4Stream.Decode(ms))
                //using (var decompressionStream = new System.IO.Compression.GZipStream(ms, System.IO.Compression.CompressionMode.Decompress))
                {
                    using (var reader = System.Xml.XmlDictionaryReader.CreateBinaryReader(decompressionStream, System.Xml.XmlDictionaryReaderQuotas.Max))
                    {
                        var o = serializer.ReadObject(reader) as TestClass;

                        Assert.AreEqual(obj.Test1, o.Test1);
                    }
                }
            }
        }

from k4os.compression.lz4.

MiloszKrajewski avatar MiloszKrajewski commented on August 15, 2024

...and fixed again, in 1.1.9 this time

from k4os.compression.lz4.

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.