Open nicloay opened 10 months ago
I tried the following test, which passed: the number of elements in the list is 3.
BTW, - !type2
this is included in the list as null. Using - !type2 {}
will produce an intance.
[Test]
public void Deserialize_UnionFromEmptyElement()
{
var result = Deserialize<Dictionary<string, IEmpty[]>>(
"list:\n" +
" - !impl1\n" +
" a: 9999\n" +
" - !impl2\n" +
" - !impl1\n" +
" a: 3333");
Assert.That(result.Count, Is.EqualTo(1));
Assert.That(result["list"].Length, Is.EqualTo(3));
}
[YamlObject]
[YamlObjectUnion("!impl1", typeof(EmptyInterfaceImpl1))]
[YamlObjectUnion("!impl2", typeof(EmptyInterfaceImpl2))]
public partial interface IEmpty
{
}
[YamlObject]
public partial class EmptyInterfaceImpl1 : IEmpty
{
}
[YamlObject]
public partial class EmptyInterfaceImpl2 : IEmpty
{
}
If I have 2 types like Type1 and Type2 which implement a common interface it's not possible to deserialize document if one of them has no extra parameters
as type2 doesn't have parameter the result list will have only 2 elements of type1