SamboyCoding / Tomlet

Zero-Dependency, model-based TOML De/Serializer for .NET
MIT License
155 stars 29 forks source link

Fixed support for multiple subtables #12

Closed ITR13 closed 2 years ago

ITR13 commented 2 years ago

When the parent table was part of a TableArray, then having multiple subtables was not possible:

[[SomeArray]]
[SomeArray.SubTable1]
property="SomeValue"
[SomeArray.SubTable2]
property="SomeOtherValue"

This happened due to "_lastTableArrayName" being set to null when a sub-table is created.

The proposed change fixes this by storing the full path to both arrays and tables, since both can be nested multiple times.

The library also errored when a subtable was defined before a parent table:

[[SomeArray]]
[SomeArray.SubTable.SubSubTable]
property="SomeValue"
[SomeArray.SubTable]
property="SomeOtherValue"

This is valid Toml, which the proposed change also fixes.

The following is invalid Toml and correctly errors, but does not have a test:

[SomeArray.SubTable]
property="SomeValue"

[[SomeArray]]
property="SomeOtherValue"