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

◆ ValidateOneArgument()

static Expression System.Dynamic.Utils.ExpressionUtils.ValidateOneArgument ( MethodBase method,
ExpressionType nodeKind,
Expression arguments,
ParameterInfo pi,
string methodParamName,
string argumentParamName,
int index = -1 )
inlinestatic

Definition at line 99 of file ExpressionUtils.cs.

100 {
102 Type type = pi.ParameterType;
103 if (type.IsByRef)
104 {
105 type = type.GetElementType();
106 }
107 TypeUtils.ValidateType(type, methodParamName, allowByRef: true, allowPointer: true);
108 if (!TypeUtils.AreReferenceAssignable(type, arguments.Type) && !TryQuote(type, ref arguments))
109 {
110 switch (nodeKind)
111 {
112 case ExpressionType.New:
114 case ExpressionType.Invoke:
116 case ExpressionType.Call:
117 case ExpressionType.Dynamic:
119 default:
120 throw ContractUtils.Unreachable;
121 }
122 }
123 return arguments;
124 }
static void RequiresCanRead(Expression expression, string paramName)
static bool TryQuote(Type parameterType, ref Expression argument)
static Exception ExpressionTypeDoesNotMatchParameter(object p0, object p1, string paramName)
Definition Error.cs:883
static Exception ExpressionTypeDoesNotMatchMethodParameter(object p0, object p1, object p2, string paramName)
Definition Error.cs:873
static Exception ExpressionTypeDoesNotMatchConstructorParameter(object p0, object p1, string paramName)
Definition Error.cs:903

References System.Dynamic.Utils.TypeUtils.AreReferenceAssignable(), System.Linq.Expressions.Error.ExpressionTypeDoesNotMatchConstructorParameter(), System.Linq.Expressions.Error.ExpressionTypeDoesNotMatchMethodParameter(), System.Linq.Expressions.Error.ExpressionTypeDoesNotMatchParameter(), System.index, System.Dynamic.Utils.ExpressionUtils.RequiresCanRead(), System.Dynamic.Utils.ExpressionUtils.TryQuote(), System.type, System.Dynamic.Utils.ContractUtils.Unreachable, and System.Dynamic.Utils.TypeUtils.ValidateType().

Referenced by System.Linq.Expressions.ExpressionExtension.MakeDynamic(), System.Linq.Expressions.ExpressionExtension.MakeDynamic(), System.Linq.Expressions.ExpressionExtension.MakeDynamic(), System.Linq.Expressions.ExpressionExtension.MakeDynamic(), System.Dynamic.Utils.ExpressionUtils.ValidateArgumentTypes(), and System.Linq.Expressions.Expression< TDelegate >.ValidateOneArgument().