/// <summary>
        /// Creates object initialization delegate.
        /// </summary>
        private protected override Delegate CreateInitializer()
        {
            ConstructorInfo ctor = (ConstructorInfo)MemberInfo;

#if !NETSTANDARD2_0
            // for constructors with ref/out parameters: Dynamic method
            if (ParameterTypes.Any(p => p.IsByRef))
            {
                DynamicMethod dm = CreateMethodInvokerAsDynamicMethod(ctor, DynamicMethodOptions.HandleByRefParameters);
                return(dm.CreateDelegate(typeof(Ctor)));
            }
#endif

            // for constructors that have no ref parameters: Lambda expression
            ParameterExpression argumentsParameter = Expression.Parameter(typeof(object[]), "arguments");
            var ctorParameters = new Expression[ParameterTypes.Length];
            for (int i = 0; i < ParameterTypes.Length; i++)
            {
                Type parameterType = ParameterTypes[i];
#if NETSTANDARD2_0
                // This just avoids error when ref parameters are used but does not assign results back
                if (parameterType.IsByRef)
                {
                    parameterType = parameterType.GetElementType();
                }

                // ReSharper disable once AssignNullToNotNullAttribute
#endif
                ctorParameters[i] = Expression.Convert(Expression.ArrayIndex(argumentsParameter, Expression.Constant(i)), parameterType);
            }

            NewExpression construct = Expression.New(
                ctor,            // constructor info
                ctorParameters); // arguments cast to target types

            LambdaExpression lambda = Expression.Lambda <Ctor>(
                Expression.Convert(construct, Reflector.ObjectType), // return type converted to object
                argumentsParameter);
            return(lambda.Compile());
        }