Stashbox by Peter Csajtai

<PackageReference Include="Stashbox" Version="5.10.0-preview-808" />

 EnumerableWrapper

using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Runtime.CompilerServices; namespace Stashbox.Resolution.Wrappers { internal class EnumerableWrapper : IEnumerableWrapper, IResolver { [System.Runtime.CompilerServices.NullableContext(1)] public Expression WrapExpression(TypeInformation originalTypeInformation, TypeInformation wrappedTypeInformation, IEnumerable<ServiceContext> serviceContexts) { return wrappedTypeInformation.Type.InitNewArray(from e in serviceContexts select e.ServiceExpression); } [System.Runtime.CompilerServices.NullableContext(1)] public bool TryUnWrap(TypeInformation typeInformation, out TypeInformation unWrappedType) { Type enumerableType = typeInformation.Type.GetEnumerableType(); if (enumerableType == (Type)null) { unWrappedType = TypeInformation.Empty; return false; } unWrappedType = typeInformation.Clone(enumerableType, null, null); return true; } } }