aaubry / YamlDotNet

YamlDotNet is a .NET library for YAML
MIT License
2.58k stars 484 forks source link

YamlIgnore is no longer respected during deserialization #959

Closed julian-burger-ttd closed 2 months ago

julian-burger-ttd commented 3 months ago

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?

EdwardCooke commented 2 months ago

This will go out in the next release