SamboyCoding / Tomlet

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

Tomlet.TomletMain.TomlStringFrom<T> throwing exceptions in version 5.2+ #37

Closed jrx00e closed 5 months ago

jrx00e commented 8 months ago

Using object serialization to toml via Tomlet.TomletMain.TomlStringFrom an exception is being thrown in 5.2+ that didn't occur before.

The object hierarchy has a few layers of nesting. The change in behavior likely from this PR

Exception:

The string |'"items.item_details".item_schedule'.hours| (between the two bars) contains at least one of both a double quote and a single quote, so it cannot be used for a TOML key.

here is code samples

  1. dotnetfiddle with serialization working in 5.1.2: https://dotnetfiddle.net/8qkxkT
  2. dotnetfiddle with exception for same in 5.3 https://dotnetfiddle.net/4xqirr

Expected serialized to toml output :

`model_name = "M1"

[[items]] item_name = "item1" [items.item_details] detail_group_name = "item1details"

[[items.item_details.item_schedule]] schedule_day = "Mon"

[[items.item_details.item_schedule.hours]] [[items.item_details.item_schedule.hours.shifts]] shift_name = "morningA"

[[items.item_details.item_schedule.hours.shifts]] shift_name = "afternoonA"

[[items.item_details.item_schedule.hours.holidays]] holiday_name = "none"`

SamboyCoding commented 8 months ago

Ooh that is certainly a nasty bug, I'll try to take a look, might be this weekend

SamboyCoding commented 5 months ago

Sorry for the delay, this should be fixed in 5.3.1