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

◆ ValidateLambdaArgs()

static void System.Linq.Expressions.Expression< TDelegate >.ValidateLambdaArgs ( Type delegateType,
ref Expression< TDelegate > body,
ReadOnlyCollection< ParameterExpression< TDelegate > > parameters,
string paramName )
inlinestaticprivateinherited

Definition at line 3381 of file Expression.cs.

3382 {
3384 ExpressionUtils.RequiresCanRead(body, "body");
3385 if (!typeof(MulticastDelegate).IsAssignableFrom(delegateType) || delegateType == typeof(MulticastDelegate))
3386 {
3387 throw Error.LambdaTypeMustBeDerivedFromSystemDelegate(paramName);
3388 }
3392 {
3393 value = delegateType.GetInvokeMethod();
3394 if (!delegateType.IsCollectible)
3395 {
3397 }
3398 }
3399 ParameterInfo[] parametersCached = value.GetParametersCached();
3400 if (parametersCached.Length != 0)
3401 {
3402 if (parametersCached.Length != parameters.Count)
3403 {
3404 throw Error.IncorrectNumberOfLambdaDeclarationParameters();
3405 }
3407 int i = 0;
3408 for (int num = parametersCached.Length; i < num; i++)
3409 {
3410 ParameterExpression parameterExpression = parameters[i];
3413 Type type = parameterInfo.ParameterType;
3414 if (parameterExpression.IsByRef)
3415 {
3416 if (!type.IsByRef)
3417 {
3418 throw Error.ParameterExpressionNotValidAsDelegate(parameterExpression.Type.MakeByRefType(), type);
3419 }
3420 type = type.GetElementType();
3421 }
3423 {
3424 throw Error.ParameterExpressionNotValidAsDelegate(parameterExpression.Type, type);
3425 }
3427 {
3428 throw Error.DuplicateVariable(parameterExpression, "parameters", i);
3429 }
3430 }
3431 }
3432 else if (parameters.Count > 0)
3433 {
3434 throw Error.IncorrectNumberOfLambdaDeclarationParameters();
3435 }
3436 if (value.ReturnType != typeof(void) && !TypeUtils.AreReferenceAssignable(value.ReturnType, body.Type) && !TryQuote(value.ReturnType, ref body))
3437 {
3438 throw Error.ExpressionTypeDoesNotMatchReturn(body.Type, value.ReturnType);
3439 }
3440 }
bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value)
void Add(TKey key, TValue value)
static void RequiresNotNull(object value, string paramName)
static void RequiresCanRead(Expression expression, string paramName)
static void ValidateType(Type type, string paramName)
Definition TypeUtils.cs:695
static bool AreReferenceAssignable(Type dest, Type src)
Definition TypeUtils.cs:673
static readonly CacheDict< Type, MethodInfo > s_lambdaDelegateCache
static bool TryQuote(Type parameterType, ref Expression argument)

References System.Collections.Generic.Dictionary< TKey, TValue >.Add(), System.Dynamic.Utils.TypeUtils.AreReferenceAssignable(), System.Collections.Generic.Dictionary< TKey, TValue >.Count, System.Linq.Expressions.Error.DuplicateVariable(), System.Linq.Expressions.Error.ExpressionTypeDoesNotMatchReturn(), System.Linq.Expressions.Error.IncorrectNumberOfLambdaDeclarationParameters(), System.Linq.Expressions.Error.LambdaTypeMustBeDerivedFromSystemDelegate(), System.Linq.Expressions.Error.ParameterExpressionNotValidAsDelegate(), System.Dynamic.Utils.ExpressionUtils.RequiresCanRead(), System.Dynamic.Utils.ContractUtils.RequiresNotNull(), System.Linq.Expressions.Expression< TDelegate >.s_lambdaDelegateCache, System.Collections.Generic.Dictionary< TKey, TValue >.TryGetValue(), System.Linq.Expressions.Expression< TDelegate >.TryQuote(), System.type, System.Dynamic.Utils.TypeUtils.ValidateType(), and System.value.

Referenced by System.Linq.Expressions.Expression< TDelegate >.Lambda(), System.Linq.Expressions.Expression< TDelegate >.Lambda(), and System.Linq.Expressions.Expression< TDelegate >.Lambda< TDelegate >().