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

Nullable structs processing #360

Open
incoboggart opened this issue Oct 24, 2018 · 3 comments
Open

Nullable structs processing #360

incoboggart opened this issue Oct 24, 2018 · 3 comments
Assignees
Labels

Comments

@incoboggart
Copy link

incoboggart commented Oct 24, 2018

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!

WojciechNagorski added a commit to WojciechNagorski/YamlDotNet that referenced this issue Oct 26, 2018
@aaubry aaubry added the bug label Jun 10, 2019
@aaubry aaubry self-assigned this Jun 10, 2019
@cgranade
Copy link

cgranade commented Jun 4, 2020

I'm running into the same issue on 8.1.2:

image

@benrebak
Copy link

benrebak commented Jul 10, 2020

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

EliahKagan added a commit to EliahKagan/VidDraw that referenced this issue May 30, 2021
The problem seems to be with nullable value type deserialization,
due to aaubry/YamlDotNet#360.

See yaml-nullable-scratch.linq.
pensono added a commit to pensono/YamlDotNet that referenced this issue Jun 28, 2021
@aaubry
Copy link
Owner

aaubry commented Jun 28, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants