System.Linq.Expressions.Error.OnlyStaticPropertiesHaveNullInstance C# (CSharp) Method

OnlyStaticPropertiesHaveNullInstance() static private method

ArgumentException with message like "Static property requires null instance, non-static property requires non-null instance."
static private OnlyStaticPropertiesHaveNullInstance ( string paramName ) : Exception
paramName string
return Exception
        internal static Exception OnlyStaticPropertiesHaveNullInstance(string paramName)
        {
            return new ArgumentException(Strings.OnlyStaticPropertiesHaveNullInstance, paramName);
        }
        /// <summary>

Usage Example

        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);
        }
All Usage Examples Of System.Linq.Expressions.Error::OnlyStaticPropertiesHaveNullInstance
Error