Stashbox by Peter Csajtai

<PackageReference Include="Stashbox" Version="3.2.9-preview-599" />

 DefaultValueResolver

using System.Linq.Expressions; using System.Reflection; namespace Stashbox.Resolution.Resolvers { internal class DefaultValueResolver : IResolver { public Expression GetExpression(IResolutionStrategy resolutionStrategy, TypeInformation typeInfo, ResolutionContext resolutionContext) { return typeInfo.Type.AsDefault(); } public bool CanUseForResolution(TypeInformation typeInfo, ResolutionContext resolutionContext) { if (resolutionContext.CurrentContainerContext.ContainerConfiguration.DefaultValueInjectionEnabled) { if (!typeInfo.Type.GetTypeInfo().IsValueType) return typeInfo.Type == typeof(string); return true; } return false; } } }