public static void SaveParametersToNewObjectArray(this ILProcessor processor, VariableDefinition array, IList <ParameterDefinition> parameters) { const byte MaxArraySize = sbyte.MaxValue - 1; if (parameters.Count > MaxArraySize) { throw new InvalidOperationException( string.Format( CultureInfo.InvariantCulture, "There are {0} method parameters, but the supported maximum is {1}", parameters.Count, MaxArraySize)); } processor.CreateArrayAndStoreToVariable(array, WeavingInformation.ObjectTypeReference, (sbyte)parameters.Count); for (sbyte i = 0; i < parameters.Count; i++) { processor.SaveParameterValueToObjectArray(array, parameters[i], i); } }