Is your feature request related to a problem? Please describe.
It seems to me that there is currently no way to extend defaultGenericInterfaceImplementations of DefaultObjectFactory.
|
private readonly Dictionary<Type, Type> defaultGenericInterfaceImplementations = new() |
|
{ |
|
{ typeof(IEnumerable<>), typeof(List<>) }, |
|
{ typeof(ICollection<>), typeof(List<>) }, |
|
{ typeof(IList<>), typeof(List<>) }, |
|
{ typeof(IDictionary<,>), typeof(Dictionary<,>) } |
|
}; |
Mappings are only added to defaultNonGenericInterfaceImplementations.
|
foreach (var pair in mappings) |
|
{ |
|
if (!pair.Key.IsAssignableFrom(pair.Value)) |
|
{ |
|
throw new InvalidOperationException($"Type '{pair.Value}' does not implement type '{pair.Key}'."); |
|
} |
|
|
|
defaultNonGenericInterfaceImplementations.Add(pair.Key, pair.Value); |
|
} |
Describe the solution you'd like
Provide a "simple" way to extend defaultGenericInterfaceImplementations.
Describe alternatives you've considered
Modify copy of DefaultObjectFactory.
Additional context
N/A
Is your feature request related to a problem? Please describe.
It seems to me that there is currently no way to extend
defaultGenericInterfaceImplementationsofDefaultObjectFactory.YamlDotNet/YamlDotNet/Serialization/ObjectFactories/DefaultObjectFactory.cs
Lines 45 to 51 in 485daaa
Mappings are only added to
defaultNonGenericInterfaceImplementations.YamlDotNet/YamlDotNet/Serialization/ObjectFactories/DefaultObjectFactory.cs
Lines 75 to 83 in 485daaa
Describe the solution you'd like
Provide a "simple" way to extend
defaultGenericInterfaceImplementations.Describe alternatives you've considered
Modify copy of
DefaultObjectFactory.Additional context
N/A