Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ValidateIndexedProperty()

static void System.Linq.Expressions.Expression< TDelegate >.ValidateIndexedProperty ( Expression< TDelegate > instance,
PropertyInfo indexer,
string paramName,
ref ReadOnlyCollection< Expression< TDelegate > > argList )
inlinestaticprivateinherited

Definition at line 2948 of file Expression.cs.

2949 {
2951 if (indexer.PropertyType.IsByRef)
2952 {
2953 throw Error.PropertyCannotHaveRefType(paramName);
2954 }
2955 if (indexer.PropertyType == typeof(void))
2956 {
2957 throw Error.PropertyTypeCannotBeVoid(paramName);
2958 }
2959 ParameterInfo[] array = null;
2960 MethodInfo getMethod = indexer.GetGetMethod(nonPublic: true);
2961 if (getMethod != null)
2962 {
2963 if (getMethod.ReturnType != indexer.PropertyType)
2964 {
2965 throw Error.PropertyTypeMustMatchGetter(paramName);
2966 }
2967 array = getMethod.GetParametersCached();
2969 }
2970 MethodInfo setMethod = indexer.GetSetMethod(nonPublic: true);
2971 if (setMethod != null)
2972 {
2973 ParameterInfo[] parametersCached = setMethod.GetParametersCached();
2974 if (parametersCached.Length == 0)
2975 {
2976 throw Error.SetterHasNoParams(paramName);
2977 }
2978 Type parameterType = parametersCached[^1].ParameterType;
2979 if (parameterType.IsByRef)
2980 {
2981 throw Error.PropertyCannotHaveRefType(paramName);
2982 }
2983 if (setMethod.ReturnType != typeof(void))
2984 {
2985 throw Error.SetterMustBeVoid(paramName);
2986 }
2987 if (indexer.PropertyType != parameterType)
2988 {
2989 throw Error.PropertyTypeMustMatchSetter(paramName);
2990 }
2991 if (getMethod != null)
2992 {
2993 if (getMethod.IsStatic ^ setMethod.IsStatic)
2994 {
2995 throw Error.BothAccessorsMustBeStatic(paramName);
2996 }
2997 if (array.Length != parametersCached.Length - 1)
2998 {
2999 throw Error.IndexesOfSetGetMustMatch(paramName);
3000 }
3001 for (int i = 0; i < array.Length; i++)
3002 {
3003 if (array[i].ParameterType != parametersCached[i].ParameterType)
3004 {
3005 throw Error.IndexesOfSetGetMustMatch(paramName);
3006 }
3007 }
3008 }
3009 else
3010 {
3012 }
3013 }
3014 else if (getMethod == null)
3015 {
3016 throw Error.PropertyDoesNotHaveAccessor(indexer, paramName);
3017 }
3018 }
static void RequiresNotNull(object value, string paramName)
static void ValidateAccessor(Expression instance, MethodInfo method, ParameterInfo[] indexes, ref ReadOnlyCollection< Expression > arguments, string paramName)

References System.array, System.Linq.Expressions.Error.BothAccessorsMustBeStatic(), System.Linq.Expressions.Error.IndexesOfSetGetMustMatch(), System.Linq.Expressions.Error.PropertyCannotHaveRefType(), System.Linq.Expressions.Error.PropertyDoesNotHaveAccessor(), System.Linq.Expressions.Error.PropertyTypeCannotBeVoid(), System.Linq.Expressions.Error.PropertyTypeMustMatchGetter(), System.Linq.Expressions.Error.PropertyTypeMustMatchSetter(), System.Dynamic.Utils.ContractUtils.RequiresNotNull(), System.Linq.Expressions.Error.SetterHasNoParams(), System.Linq.Expressions.Error.SetterMustBeVoid(), and System.Linq.Expressions.Expression< TDelegate >.ValidateAccessor().

Referenced by System.Linq.Expressions.Expression< TDelegate >.MakeIndexProperty().