Skip to content

YamlIgnore is no longer respected during deserialization #959

@julian-burger-ttd

Description

@julian-burger-ttd

Describe the bug
We are upgrading from 11.2.1 to 16.0.0. Aside from a handful of function signature breaking changes which were easy to deal with, we have found a functionality break. We have a base class with a [Yamlgnore] property. The derived class declares a new property of the same name. Previously this worked as expected. With 16.0.0 it fails with an AmbiguousMatchException. I didn't spend any time isolating exactly when it changed but it seems related to the refactoring to use Type.GetRuntimeProperty .

To Reproduce

    public class IgnoreTest
    {
        public class Base
        {
            [YamlIgnore]
            public object Prop { get; set; }
        }

        public class Derived<T> : Base
        {
            public new T Prop { get; set; }
        }

        [Fact]
        public void Test()
        {
            var yaml = @"
prop: Jack
";
            var sut = new DeserializerBuilder()
                .WithNamingConvention(CamelCaseNamingConvention.Instance)
                .Build();

            sut.Deserialize<Derived<string>>(yaml);
        }
    }

Perhaps there is some configuration bit we don't know about to make this work?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions