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

IncludeNonPublicProperties() broken in 16.0.0 #952

Closed
dsdante opened this issue Aug 12, 2024 · 3 comments
Closed

IncludeNonPublicProperties() broken in 16.0.0 #952

dsdante opened this issue Aug 12, 2024 · 3 comments

Comments

@dsdante
Copy link

dsdante commented Aug 12, 2024

After updating from 15.3.0 to 16.0.0 the deserializer no longer sees private/internal/etc properties even when built with DeserializerBuilder.IncludeNonPublicProperties().

// Program.cs
using YamlDotNet.Serialization;

using StreamReader file = new("test.yaml");
var result = new DeserializerBuilder()
    .IncludeNonPublicProperties()
    .Build()
    .Deserialize<Test>(file);
Console.WriteLine(result.PublicValue);

class Test
{
    [YamlMember(Alias = "key")]
    private string YamlValue { get; set; } = null!;

    public string PublicValue => YamlValue;
}
# test.yaml
key: value
@EdwardCooke
Copy link
Collaborator

Thanks for the report. I’ll take a look at this as soon as I can.

@EdwardCooke
Copy link
Collaborator

Ok, just looked at it, I'll have a fix for it. What it really is is that YamlMember isn't read on non public properties/fields. For example, using the following yaml works:

YamlValue: value

@EdwardCooke
Copy link
Collaborator

It's actually already fixed by a different commit going out in the next release. I have added a regression test so it doesn't happen again.

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

No branches or pull requests

2 participants