Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enum value not serialized #55

Closed
redrabbit007 opened this issue Feb 24, 2023 · 0 comments · Fixed by #67
Closed

Enum value not serialized #55

redrabbit007 opened this issue Feb 24, 2023 · 0 comments · Fixed by #67

Comments

@redrabbit007
Copy link

I have an enum, and a class that contains an enum property:

namespace TomlynTests
{
  public enum SizeType : byte
  {
    Average,
    Big,
    Small
  }
}

namespace TomlynTests
{
  public class TestModel
  {
    public string Name { get; set; }

    public SizeType Size { get; set; }

    public TestModel(string name, SizeType size)
    {
      Name = name;
      Size = size;
    }
  }
}

When I create toml text from this the enum property value isn't serialized:

using Tomlyn.Model;
using Tomlyn;
using TomlynTests;

TestModel model = new("Pliers", SizeType.Small);

TomlTable table = new()
{
  { "model", model }
};

string text = Toml.FromModel(table);
Console.WriteLine(text);
[model]
name = "Pliers"
[model.size]

Is there something special I need to do to serialize enums?

taks added a commit to taks/Tomlyn that referenced this issue Jun 30, 2023
@xoofx xoofx closed this as completed in #67 Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant