Skip to content

Commit

Permalink
Fixes table arrays and inline (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
xoofx committed Nov 23, 2023
1 parent d0ef7e1 commit ffcc734
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Tomlyn.Tests/BasicTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@ namespace Tomlyn.Tests
{
public class BasicTests
{
[Test]
public void TestTableArraysContainingPrimitiveArraysSerialize()
{
var test = @"[[table_array]]
primitive_list = [4, 5, 6]
";

var model = Toml.ToModel(test);
var tomlOut = Toml.FromModel(model);

Assert.AreEqual(test, tomlOut);
}

[Test]
public void TestHelloWorld()
{
Expand Down
4 changes: 4 additions & 0 deletions src/Tomlyn/Model/ModelToTomlTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,10 @@ private bool IsRequiringInline(object? value)

private bool IsRequiringInline(ListDynamicAccessor accessor, object value, int parentConsecutiveList)
{
// Always disable inline for TomlTableArray
// This is only working for default TomlTableArray model
if (value is TomlTableArray) return false;

foreach (var element in accessor.GetElements(value))
{
if (element is null) continue; // TODO: should this log an error?
Expand Down

0 comments on commit ffcc734

Please sign in to comment.