YamlDotNet icon indicating copy to clipboard operation
YamlDotNet copied to clipboard

Nullable structs processing

Open incoboggart opened this issue 7 years ago • 3 comments

Hi!

I have an issue with YamlDotNet and dont understand how to resolve it. The code is:

public class SomeClass
{
    public SomeStruct? Struct { get; set; }
}

public struct SomeStruct
{
    public int Value { get; set; }
}

public static void Test()
    {
        var s = new YamlDotNet.Serialization.SerializerBuilder().Build();

        var yaml = s.Serialize(new SomeClass
        {
            Struct = new SomeStruct { Value = 42 }
        });

        var d = new YamlDotNet.Serialization.DeserializerBuilder().Build();
        var i = d.Deserialize<SomeClass>(yaml);
    }

This code is throwing exception: SerializationException: Property 'Value' not found on type 'System.Nullable`1[[SomeStruct]]

Is there any workaround for parsing such structure?

Thanks!

incoboggart avatar Oct 24 '18 17:10 incoboggart

I'm running into the same issue on 8.1.2:

image

cgranade avatar Jun 04 '20 19:06 cgranade

I'm also running into this issue. Any advice @aaubry ?

benrebak avatar Jul 10 '20 12:07 benrebak

A fix for this issue has been released in version 11.2.1.

aaubry avatar Jun 28 '21 21:06 aaubry