Closed
Description
YamlDotNet tries to get generic reflection on an interface that is not guaranteed to be generic:
public sealed class DefaultObjectFactory : IObjectFactory
//...
public object Create(Type type)
{
if (type.IsInterface())
{
if (defaultInterfaceImplementations.TryGetValue(type.GetGenericTypeDefinition(), out var implementationType))
{
type = implementationType.MakeGenericType(type.GetGenericArguments());
}
}
Trace:
System.InvalidOperationException: This operation is only valid on generic types.
at System.RuntimeType.GetGenericTypeDefinition()
at YamlDotNet.Serialization.ObjectFactories.DefaultObjectFactory.Create(Type type)
at YamlDotNet.Serialization.NodeDeserializers.ObjectNodeDeserializer.YamlDotNet.Serialization.INodeDeserializer.Deserialize(IParser parser, Type expectedType, Func`3 nestedObjectDeserializer, Object& value)
at YamlDotNet.Serialization.ValueDeserializers.NodeValueDeserializer.DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer)
Activity
aaubry commentedon Oct 12, 2019
You're right. I should fix that. Thanks for reporting!
Fix exception when deserializing an interface