-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
Empty, unreferenced arrays are not being serialized #98
Comments
With some additional testing of tomlyn directly @hallipr found it's actually just dropping the last entry: var model = new TomlTable();
model.Add("something", "string value");
model.Add("array1", new TomlArray() { "hello" });
model.Add("array2", new TomlArray() { });
model.Add("array3", new TomlArray() { });
Console.WriteLine(Toml.FromModel(model)); something = "string value"
array1 = ["hello"]
array2 = [] There's no key named "string value" and both |
An even more detailed repro: var outer = new TomlTable
{
["inner1"] = new TomlTable {},
["inner2"] = new TomlTable {
{ "array1", new TomlArray {} },
{ "array2", new TomlArray {} }
},
["inner3"] = new TomlTable {
{ "array1", new TomlArray {} },
{ "array2", new TomlArray {} },
{ "array3", new TomlArray { "hello" } },
{ "array4", new TomlArray { } },
{ "array5", new TomlArray { } },
{ "array6", new TomlArray { } }
},
["inner4"] = new TomlTable {
{ "array1", new TomlArray {} },
{ "string", "value" },
{ "array2", new TomlArray {} },
{ "array3", new TomlArray {} },
},
};
Console.WriteLine("---");
Console.WriteLine(Toml.FromModel(outer));
Console.WriteLine("---");
|
To note, my repro was with versoin 0.17.0, which PSToml uses. @hallipr's repro was with 0.18.0, the latest version on nuget.org. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When serializing a dictionary, any keys that are empty arrays but unreferenced are not being serialized. Consider the following TOML:
A fairly common
Cargo.toml
manifest with default and non-default features. Deserializing this produces the expected ordered dictionary with array members for all three of default, foo, and bar. Serializing the resulting object only produces:Notice that bar is missing.
This is causing jborean93/PSToml#10, which we currently use in the Azure SDK for Rust pipelines. If there is a way to work around this for now, that would be great; however, looking through your documentation nothing pops out at me.
The text was updated successfully, but these errors were encountered: