Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

struct serialization #358

Closed
aspektxxx opened this issue Jan 23, 2020 · 4 comments · Fixed by #359
Closed

struct serialization #358

aspektxxx opened this issue Jan 23, 2020 · 4 comments · Fixed by #359
Assignees
Labels
bug (cc: fix) Something isn't working

Comments

@aspektxxx
Copy link

When using version 2.0.24, given var serializer = new ConfigurationContainer() .EnableParameterizedContentWithPropertyAssignments() .EnableReferences() .Create(); when root object for graph to serialize is struct var v = new vector(new length(11), new length(13)); an exception is raised System.ArgumentNullException : Value cannot be null. Parameter name: key

required definitions:

    private class length
        {
            public length(int value)
            {
                Value = value;
            }

            public int Value { get;}
        }

    private struct vector
        {
            public vector(length l1, length l2)
            {
                L1 = l1;
                L2 = l2;
            }

            public length L1 { get; }
            public length L2 { get; }
        }
@Mike-E-angelo
Copy link
Member

Nice grab, @aspektxxx! That's a good point. If we're serializing structures as the root instance then capturing references doesn't make sense.

Although structures can technically have references, with ExtendedXmlSerializer references are intended to be captured and monitored in the context of a parent/root (class) reference that serves as the start of the object/reference graph.

I have disabled the reference capturing in the case of structure roots. If you would like to capture references the suggestion is to ensure the root object is a class/reference instead.

You can try out the preview of this here:
#359 (comment)

Please let me know if you encounter any issues using it and/or have any additional questions/suggestions.

@Mike-E-angelo
Copy link
Member

Doh... looks like there's also an issue altogether with using EnableReferences with EnableParameterizedContent* ... looking into this now.

@Mike-E-angelo
Copy link
Member

Boo @aspektxxx you sunk my battleship. 😆 While I can dodge the bullet with the structure root reference, combining EnableReferences with EnableParameterizedContent* leads to very bad things. I have captured this in #360.

@aspektxxx
Copy link
Author

Well @Mike-EEE the fix is working great. You can merge it.
PS: sorry for sinking your project. 🥇

Mike-E-angelo added a commit that referenced this issue Jul 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug (cc: fix) Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants