SamboyCoding / Tomlet

Zero-Dependency, model-based TOML De/Serializer for .NET

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Keys with symbols aren't quoted but they should be

ThatCoolCoder opened this issue · comments

I have a dictionary like so:

var obj = new Dictionary<string, string>()
{
    {"normal-key", "value for normal key"},
    {"key with spaces", "value for key with spaces"},
    {"key!with{}(*%&)random[other+symbols", "value for key with random other symbols"},
    {"key/with/slashes", "value for key with slashes"},
};

And I'm saving it with TomletMain.TomlStringFrom(obj);, but some of the keys in the output are not quoted even though they should be:

normal-key = "value for normal key" # correctly not quoted
"key with spaces" = "value for key with spaces" # correctly quoted
key!with{}(*%&)random[other+symbols = "value for key with random other symbols" # should be quoted but isn't
key/with/slashes = "value for key with slashes" # should be quoted but isn't

Now this isn't actually causing a problem for me currently since the only non-alphanumeric characters in my keys are forward slashes (which Tomlet can read back just fine), but technically this is against the toml spec and would cause issues with other characters.

Also, I get a Tomlet.Exceptions.TomlNoSuchValueException if I try having dictionary keys with full stops in them, but I don't know if that's a problem with this library or if that's against the toml spec.

The dictionary keys with full stops thing actually is a confusing-enough point that there's a paragraph or so on it https://github.com/SamboyCoding/Tomlet#a-word-on-dotted-keys