SamboyCoding / Tomlet

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

TomlDocument to CLR type #7

Closed avsteele closed 3 years ago

avsteele commented 3 years ago

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?

SamboyCoding commented 3 years ago

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

SamboyCoding commented 3 years ago

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