dahomey-technologies/Dahomey.Cbor

[bug] StackOverflow Exception on using objectMapping.SetOrderBy()

Closed this issue · 5 comments

When adding objectMapping.SetOrderBy(m => m.MemberName); I get a StackOverflow Exception

My Callstack (obviously on debugging and not causing at this iteration, but just to get you the idea)
grafik

Please Check my implementation of IObjectMappingConvention here: https://github.com/helium-party/radixdlt-net/blob/enhancement%2FcborLibUpdate/HeliumParty.RadixDLT/src/HeliumParty.RadixDLT.Core/Serialization/Dson/DsonMappingConvention.cs

Edit: Note that I added
objectMapping.SetOrderBy(m => m.MemberName); // sort alphabetically
in line 83 compared to the link I gave you (and did some other changes in other files, let me know if you need to run my unit tests to reproduce this, then I'll push my error causing code)

I fixed a stackoverflow with SetOrderBy in 1.10.2. Could try this version and let me know if it fixes the issue?

Moreover, I noticed that your IObjectMappingConvention is mainly based on the default convention.

I suggest, if possible, that you embbed the default convention instead of writing it again like in this example:

public class ObjectMappingConvention : IObjectMappingConvention
        {
            private readonly DefaultObjectMappingConvention _defaultObjectMappingConvention = new DefaultObjectMappingConvention();

            public void Apply<T>(SerializationRegistry registry, ObjectMapping<T> objectMapping) where T : class
            {
                _defaultObjectMappingConvention.Apply<T>(registry, objectMapping);
                objectMapping.SetOrderBy(m => m.MemberName);
            }
        }

Unfortunately, I am already on version 1.10.2

Will do, I used the whole code in my own class because I thought this error is caused because stuff was not executed in the correct order.

I implemented a fix but I could not reproduce. Please reopen if the bug still exists

This fixed it, thanks so much!