hadashiA / VYaml

The extra fast, low memory footprint YAML library for C#, focued on .NET and Unity.
MIT License
305 stars 18 forks source link

Fails to Properly Deserialize `null` Strings #46

Closed Freeesia closed 1 year ago

Freeesia commented 1 year ago

An exception is thrown when using VYaml to serialize and then deserialize a record object containing a null string. The following code reproduces this issue:

var obj = new StringTest(null);
var yaml = YamlSerializer.Serialize(obj);
var obj2 = YamlSerializer.Deserialize<StringTest>(yaml);

if (obj.Name != obj2.Name)
{
    throw new Exception("Failed");
}

[YamlObject]
partial record StringTest(string? Name);

The expected outcome of this code is that obj.Name and obj2.Name should be equal. However, they are not, hence the exception. Could you please look into this issue and provide guidance or a potential fix? Thank you.

hadashiA commented 1 year ago

Oh. Sorry. I thought I fixed this issue in #44, but there was an omission. I only had the Unity side of the source committed by mistake.

Fixed in #47

Freeesia commented 1 year ago

Thank you for the fix. I am looking forward to the release.