Git Product home page Git Product logo

Comments (15)

inethui avatar inethui commented on September 26, 2024

I'm currently stuck on this issue. Any help is highly appreciated.

from aqlaserializer.

AqlaSolutions avatar AqlaSolutions commented on September 26, 2024

It's possible that your scenario is not supported by the reference tracking system. I can't say what exactly causes this without a reproducable example. Try removing fields one by one until the issue disappears. Then send me an isolated repro.

from aqlaserializer.

AqlaSolutions avatar AqlaSolutions commented on September 26, 2024

To be more clear, TrapNextObject is used to set object id which is used by a following NoteObject call when an instance is created. If the next serializer in the chain can't create object instance right away, it should call ReserveNoteObject to store the id in a stack for later use. Either way, next TrapNextObject call should not happen before any of these. This exception is thrown when calling TrapNextObject while previous trap hasn't been utilized yet. Allowing such calls would lead to loosing previously stored object id.
So you need to find out which type of serializer called TrapNextObject previous time (without throwing) and why next serializer doesn't utilize the trap.

from aqlaserializer.

inethui avatar inethui commented on September 26, 2024

Finally, I was able to replicate this issue with a simple test case. The call "Serializer.DeepClone(inst);" will fail with error message like "AqlaSerializer.ProtoException : Trap count > 1, will be mismatched with next NoteObject".

Could you please take a look and see what's wrong? Thanks a lot for your help!

        private class Root
        {
            private UniqueIds2 _uniqueIds2;
            private Information _inputField;

            public UniqueIds2 InstrumentIds { get => _uniqueIds2; set => _uniqueIds2 = value; }
            public Information InputField { get => _inputField; set => _inputField = value; }
        }

        private sealed class Information
        {
            private object _data;

            public object Data { get => _data; set => _data = value; }
        }

        private class UniqueIds2
        {
            private long _uniqueId;
            private long _repeatableId;

            public UniqueIds2(long uniqueId, long repeatableId)
            {
                UniqueId = uniqueId;
                RepeatableId = repeatableId;
            }

            public long UniqueId { get => _uniqueId; private set => _uniqueId = value; }
            public long RepeatableId { get => _repeatableId; private set => _repeatableId = value; }
        }

        [Fact]
        public void Test()
        {
            var metaType1 = AqlaSerializer.Meta.RuntimeTypeModel.Default.Add(typeof(Root), false);
            metaType1.DefaultFormat = ValueFormat.Reference;
            metaType1.UseConstructor = false;
            metaType1.IgnoreListHandling = true;

            var metaType2 = AqlaSerializer.Meta.RuntimeTypeModel.Default.Add(typeof(Information), false);
            metaType2.DefaultFormat = ValueFormat.Reference;
            metaType2.UseConstructor = false;
            metaType2.IgnoreListHandling = true;

            AqlaSerializer.Meta.MetaType metaType3 = AqlaSerializer.Meta.RuntimeTypeModel.Default[typeof(Information)];
            var metaField1 = metaType3.AddField(1, "_data");
            metaField1.SetSettings(x => { x.V.Format = ValueFormat.Reference; });
            metaField1.SetSettings(x => x.V.WriteAsDynamicType = true, 0);

            AqlaSerializer.Meta.MetaType metaType4 = AqlaSerializer.Meta.RuntimeTypeModel.Default[typeof(Root)];
            var metaField2 = metaType4.AddField(1, "_inputField");
            metaField2.SetSettings(x => { x.V.Format = ValueFormat.Reference; });

            var metaType5 = AqlaSerializer.Meta.RuntimeTypeModel.Default.Add(typeof(UniqueIds2), false);
            metaType5.DefaultFormat = ValueFormat.Reference;
            metaType5.UseConstructor = false;
            metaType5.IgnoreListHandling = true;

            AqlaSerializer.Meta.MetaType metaType6 = AqlaSerializer.Meta.RuntimeTypeModel.Default[typeof(UniqueIds2)];
            var metaField3 = metaType6.AddField(1, "_repeatableId");
            metaField3.SetSettings(x => { x.V.Format = ValueFormat.Compact; });
            var metaField4 = metaType6.AddField(2, "_uniqueId");
            metaField4.SetSettings(x => { x.V.Format = ValueFormat.Compact; });

            AqlaSerializer.Meta.MetaType metaType8 = AqlaSerializer.Meta.RuntimeTypeModel.Default[typeof(Root)];
            var metaField5 = metaType8.AddField(2, "_uniqueIds2");
            metaField5.SetSettings(x => { x.V.Format = ValueFormat.Reference; });

            var inst = new Root();
            inst.InstrumentIds = new UniqueIds2(1001, 1001);

            var columnData = new Information();
            columnData.Data = "test";
            inst.InputField = columnData;

            Serializer.DeepClone(inst);
        }

from aqlaserializer.

AqlaSolutions avatar AqlaSolutions commented on September 26, 2024

Fixed in develop branch

from aqlaserializer.

inethui avatar inethui commented on September 26, 2024

Great! Thanks for the quick fix. Just be curious, what was the problem? It has take me hours to replicate it with a simple test case.

from aqlaserializer.

AqlaSolutions avatar AqlaSolutions commented on September 26, 2024

See 4f6a770

from aqlaserializer.

inethui avatar inethui commented on September 26, 2024

I see, thanks.

from aqlaserializer.

inethui avatar inethui commented on September 26, 2024

I just verified that the issue is fixed with the develop branch. Can you publish it in nuget? We can only use nuget packages for our official builds.

from aqlaserializer.

AqlaSolutions avatar AqlaSolutions commented on September 26, 2024

Unfortunately, I uninstalled VS 2019 and it's not possible to make the full build with all supported platforms using VS 2022. It may take some time before I will be able to publish the new release.

from aqlaserializer.

inethui avatar inethui commented on September 26, 2024

Any update on publishing the new release? Thanks

from aqlaserializer.

AqlaSolutions avatar AqlaSolutions commented on September 26, 2024

Not today unless you know how to build Portable Class Library project with VS 2022.

from aqlaserializer.

inethui avatar inethui commented on September 26, 2024

Any update on this? Thanks

from aqlaserializer.

AqlaSolutions avatar AqlaSolutions commented on September 26, 2024

Released

from aqlaserializer.

inethui avatar inethui commented on September 26, 2024

Cool, thank a lot!

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.