AccessorsCannotHaveVarArgs() статический приватный Метод

ArgumentException with message like "Accessor method should not have VarArgs."
static private AccessorsCannotHaveVarArgs ( string paramName ) : Exception
paramName string
Результат System.Exception
Пример #1
0
        private static void ValidateAccessor(Expression instance, MethodInfo method, ParameterInfo[] indexes, ref ReadOnlyCollection <Expression> arguments)
        {
            ContractUtils.RequiresNotNull(arguments, "arguments");

            ValidateMethodInfo(method);
            if ((method.CallingConvention & CallingConventions.VarArgs) != 0)
            {
                throw Error.AccessorsCannotHaveVarArgs();
            }

            if (method.IsStatic)
            {
                if (instance != null)
                {
                    throw Error.OnlyStaticMethodsHaveNullInstance();
                }
            }
            else
            {
                if (instance == null)
                {
                    throw Error.OnlyStaticMethodsHaveNullInstance();
                }

                RequiresCanRead(instance, "instance");
                ValidateCallInstanceType(instance.Type, method);
            }

            ValidateAccessorArgumentTypes(method, indexes, ref arguments);
        }
Пример #2
0
        private static void ValidateAccessor(Expression?instance, MethodInfo method, ParameterInfo[] indexes, ref ReadOnlyCollection <Expression> arguments, string?paramName)
        {
            ContractUtils.RequiresNotNull(arguments, nameof(arguments));

            ValidateMethodInfo(method, nameof(method));
            if ((method.CallingConvention & CallingConventions.VarArgs) != 0)
            {
                throw Error.AccessorsCannotHaveVarArgs(paramName);
            }

            if (method.IsStatic)
            {
                if (instance != null)
                {
                    throw Error.OnlyStaticPropertiesHaveNullInstance(nameof(instance));
                }
            }
            else
            {
                if (instance == null)
                {
                    throw Error.OnlyStaticPropertiesHaveNullInstance(nameof(instance));
                }

                ExpressionUtils.RequiresCanRead(instance, nameof(instance));
                ValidateCallInstanceType(instance.Type, method);
            }

            ValidateAccessorArgumentTypes(method, indexes, ref arguments, paramName);
        }