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

Nested TomlTable may generate incorrect result #34

Closed
lexchou-aspose opened this issue Apr 18, 2022 · 1 comment
Closed

Nested TomlTable may generate incorrect result #34

lexchou-aspose opened this issue Apr 18, 2022 · 1 comment
Labels
bug Something isn't working PR welcome User contribution/PR is welcome

Comments

@lexchou-aspose
Copy link

Code to reproduce:

            var root = new Tomlyn.Model.TomlTable()
            {
                {
                    "root",
                    new Tomlyn.Model.TomlTable()
                    {
                        {"a", "a" },
                        {"b",
                            new Tomlyn.Model.TomlTable()
                            {
                                { "d", "d"}
                            }
                        },
                        {"c", "c" },

                    }
                }
            };
            var toml = Tomlyn.Toml.FromModel(root);
            var root2 = Tomlyn.Toml.ToModel(toml);

This will generates:

[level1]
a = "a"
[level1.b]
d = "d"
[level1]
c = "c"

And reload it will fail with exception: Tomlyn.TomlException: '(5,1) : error : The key level1 is already defined at (1,1) with [level1]␍␤a = "a" and cannot be redefined

The _order in TomlTable will record the order of TomlTable's elements, primitive elements should be serialized prior to the table/array elements.

@xoofx xoofx added bug Something isn't working PR welcome User contribution/PR is welcome labels Apr 20, 2022
@xoofx
Copy link
Owner

xoofx commented Apr 21, 2022

Fixed by commit 9d6ebf3

@xoofx xoofx closed this as completed Apr 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working PR welcome User contribution/PR is welcome
Projects
None yet
Development

No branches or pull requests

2 participants