SamboyCoding/Tomlet

TomlDocument to CLR type

avsteele opened this issue · 2 comments

HI, Thanks for your work on Tomlet.

I am just trying the absolute basics but the conversion from TomlDocument to CLR type I can't get to work.

Number = 5

Then in a .NET 5 console project...

using System;
using Tomlet;

var f = TomlParser.ParseFile(@"testIn.toml");
f.GetInteger("Number");
Console.WriteLine(f.GetInteger("Number")); // => 5
var d = TomletMain.To<Data>(f);
Console.WriteLine(d.Number); // => 99

public class Data
{
    public int Number { get; set; } = 99;
}

Where am I going wrong?

Hi, I'm afraid that at present you have to use fields instead of properties for de/serialization

I've added a note to the relevant sections in the README about this.