Exemplo n.º 1
0
        internal static Type MakeNewDelegate(Type[] types)
        {
            Debug.Assert(types?.Length > 0);

            // Can only used predefined delegates if we have no byref types and
            // the arity is small enough to fit in Func<...> or Action<...>

            var needCustom = types.Length > _maximumArity || types.Any(type => type.IsByRef || /*type.IsByRefLike ||*/ type.IsPointer);

            if (needCustom)
            {
                return(MakeNewCustomDelegate(types));
            }

            var result = types[types.Length - 1] == typeof(void) ? DelegateBuilder.GetActionType(types.RemoveLast()) : DelegateBuilder.GetFuncType(types);

            Debug.Assert(result != null);
            return(result);
        }