Is there any way to retrieve the line ?
Hey there,
Thanks for your awesome Toml parser.
Is there a way to retrieve the line in which a toml element is located? For example, how can I find out the list line?
var toml = @"global = ""this is a string""
# This is a comment of a table
[my_table]
key = 1 # Comment a key
value = true
list = [4, 5, 6]
";
// Converts the TOML string to a `TomlTable`
var model = Toml.ToModel(toml);
// Prints "this is a string"
Console.WriteLine(model["global"]);
Is it possible to retrieve a line from a tomlArray...etc?
Line is accessible by parsing (but not converting to a model) and then through DocumentSyntax, you can access the Span property of the various elements. The model is a step that is compressing the information and would not be able to recover all the details that you get through the syntax model.
https://github.com/xoofx/Tomlyn/pull/69 might help, although you'll have to add public TomlPropertiesMetadata? PropertiesMetadata { get; set; } to your classes.
TomlTable.PropertiesMetadata.TryGetProperty provides TomlPropertyMetadata which has .Span, which is a SourceSpan. This will give you the line for list. This was added to main recently, so probably the next release?