25 types derived from Expression
System.Linq.Expressions (25)
System\Linq\Expressions\BinaryExpression.cs (1)
18public class BinaryExpression : Expression
System\Linq\Expressions\BlockExpression.cs (1)
17public class BlockExpression : Expression
System\Linq\Expressions\ConditionalExpression.cs (1)
14public class ConditionalExpression : Expression
System\Linq\Expressions\ConstantExpression.cs (1)
13public class ConstantExpression : Expression
System\Linq\Expressions\DebugInfoExpression.cs (1)
17public class DebugInfoExpression : Expression
System\Linq\Expressions\DefaultExpression.cs (1)
13public sealed class DefaultExpression : Expression
System\Linq\Expressions\DynamicExpression.cs (1)
20public class DynamicExpression : Expression, IDynamicExpression
System\Linq\Expressions\GotoExpression.cs (1)
36public sealed class GotoExpression : Expression
System\Linq\Expressions\IndexExpression.cs (1)
19public sealed class IndexExpression : Expression, IArgumentProvider
System\Linq\Expressions\InvocationExpression.cs (1)
17public class InvocationExpression : Expression, IArgumentProvider
System\Linq\Expressions\LabelExpression.cs (1)
15public sealed class LabelExpression : Expression
System\Linq\Expressions\LambdaExpression.cs (1)
22public abstract class LambdaExpression : Expression, IParameterProvider
System\Linq\Expressions\ListInitExpression.cs (1)
22public sealed class ListInitExpression : Expression
System\Linq\Expressions\LoopExpression.cs (1)
13public sealed class LoopExpression : Expression
System\Linq\Expressions\MemberExpression.cs (1)
15public class MemberExpression : Expression
System\Linq\Expressions\MemberInitExpression.cs (1)
15public sealed class MemberInitExpression : Expression
System\Linq\Expressions\MethodCallExpression.cs (1)
17public class MethodCallExpression : Expression, IArgumentProvider
System\Linq\Expressions\NewArrayExpression.cs (1)
18public class NewArrayExpression : Expression
System\Linq\Expressions\NewExpression.cs (1)
18public class NewExpression : Expression, IArgumentProvider
System\Linq\Expressions\ParameterExpression.cs (1)
13public class ParameterExpression : Expression
System\Linq\Expressions\RuntimeVariablesExpression.cs (1)
18public sealed class RuntimeVariablesExpression : Expression
System\Linq\Expressions\SwitchExpression.cs (1)
16public sealed class SwitchExpression : Expression
System\Linq\Expressions\TryExpression.cs (1)
22public sealed class TryExpression : Expression
System\Linq\Expressions\TypeBinaryExpression.cs (1)
15public sealed class TypeBinaryExpression : Expression
System\Linq\Expressions\UnaryExpression.cs (1)
16public sealed class UnaryExpression : Expression
5308 references to Expression
illink (8)
ILLink.RoslynAnalyzer (8)
src\tools\illink\src\ILLink.Shared\TrimAnalysis\IntrinsicId.cs (8)
187 /// <see cref="System.Linq.Expressions.Expression.Call(System.Type, string, System.Type[]?, System.Linq.Expressions.Expression[]?))"/> 191 /// <see cref="System.Linq.Expressions.Expression.Field(System.Linq.Expressions.Expression?, System.Type, string)"/> 196 /// <item><see cref="System.Linq.Expressions.Expression.Property(System.Linq.Expressions.Expression?, System.Reflection.MethodInfo)"/></item> 197 /// <item><see cref="System.Linq.Expressions.Expression.Property(System.Linq.Expressions.Expression?, System.Type, string)"/></item> 202 /// <see cref="System.Linq.Expressions.Expression.New(System.Type)"/>
Microsoft.AspNetCore.Components.Endpoints (134)
FormMapping\Factories\ComplexType\ComplexTypeExpressionConverterFactoryOfT.cs (134)
36var propertyFoundValue = Expression.Variable(typeof(bool), "foundValueForProperty"); 37var succeeded = Expression.Variable(typeof(bool), "succeeded"); 38var localFoundValueVar = Expression.Variable(typeof(bool), "localFoundValue"); 39var exceptionVar = Expression.Variable(typeof(Exception), "mappingException"); 45var body = new List<Expression>() 47Expression.Assign(succeeded, Expression.Constant(true)), 50var end = Expression.Label("done"); 81body.Add(Expression.IfThen( 83Expression.Block(CreateInstanceAndAssignProperties( 95body.Add(Expression.Assign(foundValueParam, localFoundValueVar)); 96body.Add(Expression.Label(end)); 108private static IEnumerable<Expression> CreateInstanceAndAssignProperties( 145var exception = Expression.Variable(typeof(Exception), "constructorException"); 147yield return Expression.TryCatch( 148Expression.Assign( 150Expression.New( 153Expression.Catch( 155Expression.Block( 156Expression.Call( 161Expression.Constant(null, typeof(string))), 162Expression.Assign(succeeded, Expression.Constant(false, typeof(bool))), 171var failedAndHasHandler = Expression.And(Expression.Not(succeeded), HasHandler(context)); 174Expression.And( 176Expression.NotEqual( 178Expression.Constant(null, resultParam.Type))); 180yield return Expression.IfThen( 182Expression.Call( 186Expression.Convert(resultParam, typeof(object)))); 190var assignments = new List<Expression>(); 193assignments.Add(Expression.Assign(Expression.Property(resultParam, props[i].Property), GetValueLocalVariableValueExpression(propsLocals[i]))); 202yield return Expression.IfThen( 203Expression.NotEqual(resultParam, Expression.Constant(null, resultParam.Type)), 204Expression.Block(assignments)); 210yield return Expression.Assign(Expression.Property(resultParam, props[i].Property), GetValueLocalVariableValueExpression(propsLocals[i])); 216return Expression.NotEqual( 217Expression.Property(context, nameof(FormDataReader.AttachInstanceToErrorsHandler)), 218Expression.Constant(null, typeof(Action<string, object>))); 224private static IEnumerable<Expression> ReportMissingValues( 225Expression readerParam, 247yield return Expression.IfThen( 248Expression.Not(GetValueLocalVariableFoundExpression(parameter)), 249Expression.Block( 253Expression.Assign(succeeded, Expression.Constant(false, typeof(bool))))); 272yield return Expression.IfThen( 273Expression.Not(GetValueLocalVariableFoundExpression(property)), 274Expression.Block( 278Expression.Assign(succeeded, Expression.Constant(false, typeof(bool))))); 282static MethodCallExpression PushPrefix(Expression readerParam, string prefix) 284return Expression.Call( 288Expression.Constant(prefix)); 291static MethodCallExpression AddMappingError(Expression readerParam, string message, string parameter) 294var formattableString = Expression.Call( 298Expression.Constant(message), 299Expression.NewArrayInit(typeof(object), Expression.Constant(parameter))); 301return Expression.Call( 306Expression.Constant(null, typeof(string))); 309static MethodCallExpression PopPrefix(Expression readerParam, string prefix) 311return Expression.Call( 315Expression.Constant(prefix)); 331List<Expression> body) 344var propertyConverterVar = Expression.Variable(propertyConverterType, $"{property.Name}Converter"); 355var propertyConverter = Expression.Assign( 357Expression.Call( 361Array.Empty<Expression>())); 364body.Add(Expression.TryCatchFinally( 374body: Expression.Block( 376Expression.Call( 380Expression.Constant(property.Name)), 383Expression.AndAssign( 385Expression.Call( 390Expression.Constant(property.Type), 395@finally: Expression.Call( 399Expression.Constant(property.Name)), 400handlers: Expression.Catch( 402Expression.Block( 403Expression.Call( 408Expression.Constant(null, typeof(string))), 409Expression.Assign(succeeded, Expression.Constant(false, typeof(bool))) 413body.Add(Expression.Assign(GetValueLocalVariableFoundExpression(propertyVar), propertyFoundValue)); 414body.Add(Expression.OrAssign(localFoundValueVar, propertyFoundValue)); 430List<Expression> body) 444var constructorParameterConverterVar = Expression.Variable(constructorParameterConverterType, $"{constructorParameter.Name}Converter"); 455var constructorParameterConverter = Expression.Assign( 457Expression.Call( 461Array.Empty<Expression>())); 477body.Add(Expression.TryCatchFinally( 478body: Expression.Block( 480Expression.Call( 484Expression.Constant(constructorParameter.Name)), 486Expression.AndAssign( 488Expression.Call( 493Expression.Constant(constructorParameter.Type), 498@finally: Expression.Call( 502Expression.Constant(constructorParameter.Name)), 503handlers: Expression.Catch( 505Expression.Block( 506Expression.Call( 511Expression.Constant(null, typeof(string))), 512Expression.Assign(succeeded, Expression.Constant(false, typeof(bool))) 516body.Add(Expression.Assign(GetValueLocalVariableFoundExpression(constructorParameterVar), propertyFoundValue)); 517body.Add(Expression.OrAssign(localFoundValueVar, propertyFoundValue)); 523private static Expression GetValueLocalVariableFoundExpression(ParameterExpression constructorParameterVar) 525return Expression.PropertyOrField(constructorParameterVar, nameof(ValueTuple<bool, object>.Item1)); 530private static Expression GetValueLocalVariableValueExpression(ParameterExpression constructorParameterVar) => 531Expression.PropertyOrField(constructorParameterVar, nameof(ValueTuple<bool, object>.Item2)); 537return Expression.Variable(typeof(ValueTuple<,>).MakeGenericType(typeof(bool), constructorParameter.Type), constructorParameter.Name); 551return Expression.IfThen( 552Expression.Not(Expression.Call(readerParam, nameof(FormDataReader.CurrentPrefixExists), Array.Empty<Type>())), 553Expression.Block( 554Expression.Assign(foundValueParam, Expression.Constant(false)), 555Expression.Assign(succeeded, Expression.Constant(true)), 556Expression.Goto(end))); 562List<Expression> body) 564var lambda = Expression.Lambda<CompiledComplexTypeConverter<T>.ConverterDelegate>( 565Expression.Block(variables, body), 574Expression.Parameter(typeof(FormDataReader).MakeByRefType(), "reader"), 575Expression.Parameter(typeof(Type), "type"), 576Expression.Parameter(typeof(FormDataMapperOptions), "options"), 577Expression.Parameter(typeof(T).MakeByRefType(), "result"), 578Expression.Parameter(typeof(bool).MakeByRefType(), "foundValue"));
Microsoft.AspNetCore.Components.Forms (17)
FieldIdentifier.cs (10)
97var accessorBody = accessor.Body; 129var modelLambda = Expression.Lambda(typeof(Func<object?>), memberExpression.Expression); 189var parameter = Expression.Parameter(typeof(object), "value"); 190Expression expression = Expression.Convert(parameter, arg.model); 192expression = Expression.MakeMemberAccess(expression, arg.member); 193expression = Expression.Convert(expression, typeof(object)); 194var lambda = Expression.Lambda<Func<object, object>>(expression, parameter); 201private static object GetModelFromIndexer(Expression methodCallExpression) 204var methodCallObjectLambda = Expression.Lambda(typeof(Func<object?>), methodCallExpression!);
src\Components\Shared\src\ExpressionFormatting\ExpressionFormatter.cs (7)
41var node = expression.Body; 143internal static bool IsSingleArgumentIndexer(Expression expression) 202Expression indexExpression, 219Expression indexExpression) 277var parameterExpression = Expression.Parameter(typeof(object)); 278var convertExpression = Expression.Convert(parameterExpression, memberExpression.Member.DeclaringType!); 280var replacedExpression = Expression.Lambda<Func<object, TResult>>(replacedMemberExpression, parameterExpression);
Microsoft.AspNetCore.Components.Web (7)
src\Components\Shared\src\ExpressionFormatting\ExpressionFormatter.cs (7)
41var node = expression.Body; 143internal static bool IsSingleArgumentIndexer(Expression expression) 202Expression indexExpression, 219Expression indexExpression) 277var parameterExpression = Expression.Parameter(typeof(object)); 278var convertExpression = Expression.Convert(parameterExpression, memberExpression.Member.DeclaringType!); 280var replacedExpression = Expression.Lambda<Func<object, TResult>>(replacedMemberExpression, parameterExpression);
Microsoft.AspNetCore.Http.Abstractions (14)
Extensions\UseMiddlewareExtensions.cs (14)
248var parameterTypeExpression = new List<Expression>() { providerArg }; 253parameterTypeExpression.Add(Expression.Constant(key, typeof(object))); 256parameterTypeExpression.Add(Expression.Constant(parameterType, typeof(Type))); 257parameterTypeExpression.Add(Expression.Constant(declaringType, typeof(Type))); 259var getServiceCall = Expression.Call(hasServiceKey ? GetKeyedServiceInfo : GetServiceInfo, parameterTypeExpression); 260var methodArgument = Expression.Convert(getServiceCall, parameterType); 297var httpContextArg = Expression.Parameter(typeof(HttpContext), "httpContext"); 298var providerArg = Expression.Parameter(typeof(IServiceProvider), "serviceProvider"); 299var instanceArg = Expression.Parameter(middleware, "middleware"); 301var methodArguments = new Expression[parameters.Length]; 315Expression middlewareInstanceArg = instanceArg; 318middlewareInstanceArg = Expression.Convert(middlewareInstanceArg, methodInfo.DeclaringType); 321var body = Expression.Call(middlewareInstanceArg, methodInfo, methodArguments); 323var lambda = Expression.Lambda<Func<T, HttpContext, IServiceProvider, Task>>(body, instanceArg, httpContextArg, providerArg);
Microsoft.AspNetCore.Http.Extensions (613)
RequestDelegateFactory.cs (354)
85private static readonly ParameterExpression TargetExpr = Expression.Parameter(typeof(object), "target"); 86private static readonly ParameterExpression BodyValueExpr = Expression.Parameter(typeof(object), "bodyValue"); 87private static readonly ParameterExpression WasParamCheckFailureExpr = Expression.Variable(typeof(bool), "wasParamCheckFailure"); 88private static readonly ParameterExpression BoundValuesArrayExpr = Expression.Parameter(typeof(object[]), "boundValues"); 91private static readonly MemberExpression RequestServicesExpr = Expression.Property(HttpContextExpr, typeof(HttpContext).GetProperty(nameof(HttpContext.RequestServices))!); 92private static readonly MemberExpression HttpRequestExpr = Expression.Property(HttpContextExpr, typeof(HttpContext).GetProperty(nameof(HttpContext.Request))!); 93private static readonly MemberExpression HttpResponseExpr = Expression.Property(HttpContextExpr, typeof(HttpContext).GetProperty(nameof(HttpContext.Response))!); 94private static readonly MemberExpression RequestAbortedExpr = Expression.Property(HttpContextExpr, typeof(HttpContext).GetProperty(nameof(HttpContext.RequestAborted))!); 95private static readonly MemberExpression UserExpr = Expression.Property(HttpContextExpr, typeof(HttpContext).GetProperty(nameof(HttpContext.User))!); 96private static readonly MemberExpression RouteValuesExpr = Expression.Property(HttpRequestExpr, typeof(HttpRequest).GetProperty(nameof(HttpRequest.RouteValues))!); 97private static readonly MemberExpression QueryExpr = Expression.Property(HttpRequestExpr, typeof(HttpRequest).GetProperty(nameof(HttpRequest.Query))!); 98private static readonly MemberExpression HeadersExpr = Expression.Property(HttpRequestExpr, typeof(HttpRequest).GetProperty(nameof(HttpRequest.Headers))!); 99private static readonly MemberExpression FormExpr = Expression.Property(HttpRequestExpr, typeof(HttpRequest).GetProperty(nameof(HttpRequest.Form))!); 100private static readonly MemberExpression RequestStreamExpr = Expression.Property(HttpRequestExpr, typeof(HttpRequest).GetProperty(nameof(HttpRequest.Body))!); 101private static readonly MemberExpression RequestPipeReaderExpr = Expression.Property(HttpRequestExpr, typeof(HttpRequest).GetProperty(nameof(HttpRequest.BodyReader))!); 102private static readonly MemberExpression FormFilesExpr = Expression.Property(FormExpr, typeof(IFormCollection).GetProperty(nameof(IFormCollection.Files))!); 103private static readonly MemberExpression StatusCodeExpr = Expression.Property(HttpResponseExpr, typeof(HttpResponse).GetProperty(nameof(HttpResponse.StatusCode))!); 104private static readonly MemberExpression CompletedTaskExpr = Expression.Property(null, (PropertyInfo)GetMemberInfo<Func<Task>>(() => Task.CompletedTask)); 105private static readonly NewExpression EmptyHttpResultValueTaskExpr = Expression.New(typeof(ValueTask<object>).GetConstructor(new[] { typeof(EmptyHttpResult) })!, Expression.Property(null, typeof(EmptyHttpResult), nameof(EmptyHttpResult.Instance))); 107private static readonly BinaryExpression TempSourceStringNotNullExpr = Expression.NotEqual(TempSourceStringExpr, Expression.Constant(null)); 108private static readonly BinaryExpression TempSourceStringNullExpr = Expression.Equal(TempSourceStringExpr, Expression.Constant(null)); 109private static readonly UnaryExpression TempSourceStringIsNotNullOrEmptyExpr = Expression.Not(Expression.Call(StringIsNullOrEmptyMethod, TempSourceStringExpr)); 114private static readonly ParameterExpression FilterContextExpr = Expression.Parameter(typeof(EndpointFilterInvocationContext), "context"); 115private static readonly MemberExpression FilterContextHttpContextExpr = Expression.Property(FilterContextExpr, typeof(EndpointFilterInvocationContext).GetProperty(nameof(EndpointFilterInvocationContext.HttpContext))!); 116private static readonly MemberExpression FilterContextArgumentsExpr = Expression.Property(FilterContextExpr, typeof(EndpointFilterInvocationContext).GetProperty(nameof(EndpointFilterInvocationContext.Arguments))!); 117private static readonly MemberExpression FilterContextHttpContextResponseExpr = Expression.Property(FilterContextHttpContextExpr, typeof(HttpContext).GetProperty(nameof(HttpContext.Response))!); 118private static readonly MemberExpression FilterContextHttpContextStatusCodeExpr = Expression.Property(FilterContextHttpContextResponseExpr, typeof(HttpResponse).GetProperty(nameof(HttpResponse.StatusCode))!); 119private static readonly ParameterExpression InvokedFilterContextExpr = Expression.Parameter(typeof(EndpointFilterInvocationContext), "filterContext"); 181object => Expression.Convert(TargetExpr, handler.Target.GetType()), 252var targetExpression = Expression.Convert(TargetExpr, methodInfo.DeclaringType); 314Expression? targetExpression, 360factoryContext.MethodCall = Expression.Block( 362Expression.Assign( 365Expression.Invoke(invokePipeline, InvokedFilterContextExpr) 382responseWritingMethodCall = Expression.Block(new[] { TempSourceStringExpr }, responseWritingMethodCall); 388private static Expression[] CreateArgumentsAndInferMetadata(MethodInfo methodInfo, RequestDelegateFactoryContext factoryContext) 412private static EndpointFilterDelegate? CreateFilterPipeline(MethodInfo methodInfo, Expression? targetExpression, RequestDelegateFactoryContext factoryContext, Expression<Func<HttpContext, object?>>? targetFactory) 437var contextArgAccess = new Expression[argTypes.Length]; 449contextArgAccess[i] = Expression.Call(FilterContextExpr, EndpointFilterInvocationContextGetArgument.MakeGenericMethod(argTypes[i]), Expression.Constant(i)); 454contextArgAccess[i] = Expression.Convert( 455Expression.Property(FilterContextArgumentsExpr, ListIndexer, Expression.Constant(i)), 460var handlerReturnMapping = MapHandlerReturnTypeToValueTask( 462? Expression.Call(methodInfo, contextArgAccess) 463: Expression.Call(targetExpression, methodInfo, contextArgAccess), 465var handlerInvocation = Expression.Block( 468? Expression.Empty() 469: Expression.Assign(TargetExpr, Expression.Invoke(targetFactory, FilterContextHttpContextExpr)), 472var filteredInvocation = Expression.Lambda<EndpointFilterDelegate>( 473Expression.Condition( 474Expression.GreaterThanOrEqual(FilterContextHttpContextStatusCodeExpr, Expression.Constant(400)), 502private static Expression MapHandlerReturnTypeToValueTask(Expression methodCall, Type returnType) 506return Expression.Block(methodCall, EmptyHttpResultValueTaskExpr); 517methodCall = Expression.Invoke(coercerExpression, methodCall); 522return Expression.Call(ExecuteTaskWithEmptyResultMethod, methodCall); 526return Expression.Call(ExecuteValueTaskWithEmptyResultMethod, methodCall); 536return Expression.Call(ValueTaskOfTToValueTaskOfObjectMethod.MakeGenericMethod(typeArg), methodCall); 542return Expression.Call(TaskOfTToValueTaskOfObjectMethod.MakeGenericMethod(typeArg), methodCall); 548return Expression.Call(WrapObjectAsValueTaskMethod, Expression.Convert(methodCall, typeof(object))); 551return Expression.Call(WrapObjectAsValueTaskMethod, methodCall); 584private static Expression CreateEndpointFilterInvocationContextBase(RequestDelegateFactoryContext factoryContext, Expression[] arguments) 589Expression paramArray = factoryContext.BoxedArgs.Length > 0 590? Expression.NewArrayInit(typeof(object), factoryContext.BoxedArgs) 591: Expression.Call(ArrayEmptyOfObjectMethod); 592var fallbackConstruction = Expression.New( 594new Expression[] { HttpContextExpr, paramArray }); 603var expandedArguments = new Expression[arguments.Length + 1]; 632return Expression.New(constructor, expandedArguments); 639private static Expression[] CreateArguments(ParameterInfo[]? parameters, RequestDelegateFactoryContext factoryContext) 643return Array.Empty<Expression>(); 646var args = new Expression[parameters.Length]; 649factoryContext.BoxedArgs = new Expression[parameters.Length]; 667factoryContext.BoxedArgs[i] = Expression.Convert(args[i], typeof(object)); 691private static Expression CreateArgument(ParameterInfo parameter, RequestDelegateFactoryContext factoryContext, out bool hasTryParse, out bool hasBindAsync, out bool isAsParameters) 915return Expression.Call(GetRequiredServiceMethod.MakeGenericMethod(parameter.ParameterType), RequestServicesExpr); 925private static Expression CreateMethodCall(MethodInfo methodInfo, Expression? target, Expression[] arguments) => 927Expression.Call(methodInfo, arguments) : 928Expression.Call(target, methodInfo, arguments); 937private static Expression CreateParamCheckingResponseWritingMethodCall(Type returnType, RequestDelegateFactoryContext factoryContext) 973var checkParamAndCallMethod = new Expression[factoryContext.ParamCheckExpressions.Count + 1]; 996var checkWasParamCheckFailureWithFilters = Expression.Block( 997Expression.IfThen( 999Expression.Assign(StatusCodeExpr, Expression.Constant(400))), 1013var checkWasParamCheckFailure = Expression.Condition( 1015Expression.Block( 1016Expression.Assign(StatusCodeExpr, Expression.Constant(400)), 1022return Expression.Block(localVariables, checkParamAndCallMethod); 1059private static Expression AddResponseWritingToMethodCall(Expression methodCall, Type returnType, RequestDelegateFactoryContext factoryContext) 1064return Expression.Block(methodCall, CompletedTaskExpr); 1068return Expression.Call( 1072Expression.Constant(factoryContext.JsonSerializerOptions.GetReadOnlyTypeInfo(typeof(object)), typeof(JsonTypeInfo<object>))); 1076return Expression.Call(ExecuteValueTaskOfObjectMethod, 1079Expression.Constant(factoryContext.JsonSerializerOptions.GetReadOnlyTypeInfo(typeof(object)), typeof(JsonTypeInfo<object>))); 1083return Expression.Call(ExecuteTaskOfObjectMethod, 1086Expression.Constant(factoryContext.JsonSerializerOptions.GetReadOnlyTypeInfo(typeof(object)), typeof(JsonTypeInfo<object>))); 1097methodCall = Expression.Invoke(coercerExpression, methodCall); 1106return Expression.Call( 1117return Expression.Call( 1125return Expression.Call( 1132return Expression.Call( 1136Expression.Constant(factoryContext.JsonSerializerOptions.GetReadOnlyTypeInfo(typeof(object)), typeof(JsonTypeInfo<object>))); 1144return Expression.Call( 1148Expression.Constant(jsonTypeInfo, typeof(JsonTypeInfo<>).MakeGenericType(typeArg))); 1151return Expression.Call( 1155Expression.Constant(jsonTypeInfo, typeof(JsonTypeInfo<>).MakeGenericType(typeArg))); 1165return Expression.Call( 1173return Expression.Call( 1180return Expression.Call( 1184Expression.Constant(factoryContext.JsonSerializerOptions.GetReadOnlyTypeInfo(typeof(object)), typeof(JsonTypeInfo<object>))); 1192return Expression.Call( 1196Expression.Constant(jsonTypeInfo, typeof(JsonTypeInfo<>).MakeGenericType(typeArg))); 1199return Expression.Call( 1203Expression.Constant(jsonTypeInfo, typeof(JsonTypeInfo<>).MakeGenericType(typeArg))); 1216var box = Expression.TypeAs(methodCall, typeof(IResult)); 1217return Expression.Call(ResultWriteResponseAsyncMethod, box, HttpContextExpr); 1219return Expression.Call(ResultWriteResponseAsyncMethod, methodCall, HttpContextExpr); 1223return Expression.Call(StringResultWriteResponseAsyncMethod, HttpContextExpr, methodCall); 1235return Expression.Call( 1239Expression.Constant(jsonTypeInfo, typeof(JsonTypeInfo<>).MakeGenericType(returnType))); 1243return Expression.Call( 1247Expression.Constant(jsonTypeInfo, typeof(JsonTypeInfo<>).MakeGenericType(returnType))); 1251private static Func<object?, HttpContext, Task> HandleRequestBodyAndCompileRequestDelegate(Expression responseWritingMethodCall, RequestDelegateFactoryContext factoryContext) 1258var continuation = Expression.Lambda<Func<object?, HttpContext, object?[], Task>>( 1278return Expression.Lambda<Func<object?, HttpContext, Task>>( 1292private static Func<object?, HttpContext, Task> HandleRequestBodyAndCompileRequestDelegateForJson(Expression responseWritingMethodCall, RequestDelegateFactoryContext factoryContext) 1306var continuation = Expression.Lambda<Func<object?, HttpContext, object?, object?[], Task>>( 1343var continuation = Expression.Lambda<Func<object?, HttpContext, object?, Task>>( 1426Expression responseWritingMethodCall, 1441var continuation = Expression.Lambda<Func<object?, HttpContext, object?, object?[], Task>>( 1475var continuation = Expression.Lambda<Func<object?, HttpContext, object?, Task>>( 1552private static Expression GetValueFromProperty(MemberExpression sourceExpression, PropertyInfo itemProperty, string key, Type? returnType = null) 1554var indexArguments = new[] { Expression.Constant(key) }; 1555var indexExpression = Expression.MakeIndex(sourceExpression, itemProperty, indexArguments); 1556return Expression.Convert(indexExpression, returnType ?? typeof(string)); 1559private static Expression BindParameterFromProperties(ParameterInfo parameter, RequestDelegateFactoryContext factoryContext) 1570var argumentExpression = Expression.Variable(parameter.ParameterType, $"{parameter.Name}_local"); 1573Expression initExpression; 1579var constructorArguments = new Expression[parameters.Length]; 1591initExpression = Expression.New(constructor, constructorArguments); 1611bindings.Add(Expression.Bind(properties[i], CreateArgument(parameterInfo, factoryContext, out var hasTryParse, out var hasBindAsync, out var _))); 1618Expression.New(parameterType) : 1619Expression.New(constructor); 1621initExpression = Expression.MemberInit(newExpression, bindings); 1625Expression.Assign(argumentExpression, initExpression)); 1633private static Expression BindParameterFromService(ParameterInfo parameter, RequestDelegateFactoryContext factoryContext) 1639return Expression.Call(GetServiceMethod.MakeGenericMethod(parameter.ParameterType), RequestServicesExpr); 1641return Expression.Call(GetRequiredServiceMethod.MakeGenericMethod(parameter.ParameterType), RequestServicesExpr); 1644private static Expression BindParameterFromKeyedService(ParameterInfo parameter, object key, RequestDelegateFactoryContext factoryContext) 1650return Expression.Call(GetKeyedServiceMethod.MakeGenericMethod(parameter.ParameterType), RequestServicesExpr, Expression.Convert( 1651Expression.Constant(key), 1654return Expression.Call(GetRequiredKeyedServiceMethod.MakeGenericMethod(parameter.ParameterType), RequestServicesExpr, Expression.Convert( 1655Expression.Constant(key), 1659private static Expression BindParameterFromValue(ParameterInfo parameter, Expression valueExpression, RequestDelegateFactoryContext factoryContext, string source) 1668var argument = Expression.Variable(parameter.ParameterType, $"{parameter.Name}_local"); 1670var parameterTypeNameConstant = Expression.Constant(TypeNameHelper.GetTypeDisplayName(parameter.ParameterType, fullName: false)); 1671var parameterNameConstant = Expression.Constant(parameter.Name); 1672var sourceConstant = Expression.Constant(source); 1752var parsedValue = Expression.Variable(nonNullableParameterType, "parsedValue"); 1754var failBlock = Expression.Block( 1755Expression.Assign(WasParamCheckFailureExpr, Expression.Constant(true)), 1756Expression.Call(LogParameterBindingFailedMethod, 1758TempSourceStringExpr, Expression.Constant(factoryContext.ThrowOnBadRequest))); 1760var tryParseCall = tryParseMethodCall(parsedValue, Expression.Constant(CultureInfo.InvariantCulture)); 1770var checkRequiredParaseableParameterBlock = Expression.Block( 1771Expression.IfThen(TempSourceStringNullExpr, 1772Expression.Block( 1773Expression.Assign(WasParamCheckFailureExpr, Expression.Constant(true)), 1774Expression.Call(LogRequiredParameterNotProvidedMethod, 1776Expression.Constant(factoryContext.ThrowOnBadRequest)) 1781var index = Expression.Variable(typeof(int), "index"); 1784var tryParseExpression = Expression.Block(new[] { parsedValue }, 1785Expression.IfThenElse(tryParseCall, 1786Expression.Assign(parameter.ParameterType.IsArray ? Expression.ArrayAccess(argument, index) : argument, Expression.Convert(parsedValue, targetParseType)), 1790? Expression.IfThen(TempSourceStringNotNullExpr, tryParseExpression) 1791: Expression.IfThenElse(TempSourceStringNotNullExpr, tryParseExpression, 1792Expression.Assign(argument, 1793Expression.Constant(parameter.DefaultValue, parameter.ParameterType))); 1795var loopExit = Expression.Label(); 1798var stringArrayExpr = parameter.ParameterType.IsArray ? Expression.Variable(typeof(string[]), "tempStringArray") : null; 1805var arrayLoop = parameter.ParameterType.IsArray ? Expression.Block( 1807Expression.Assign(argument, Expression.NewArrayBounds(parameter.ParameterType.GetElementType()!, Expression.ArrayLength(stringArrayExpr!))), 1809Expression.Assign(index, Expression.Constant(0)), 1811Expression.Loop( 1812Expression.Block( 1813Expression.IfThenElse( 1814Expression.LessThan(index, Expression.ArrayLength(stringArrayExpr!)), 1816Expression.Block( 1817Expression.Assign(TempSourceStringExpr, Expression.ArrayIndex(stringArrayExpr!, index)), 1818elementTypeOptional ? Expression.IfThen(TempSourceStringIsNotNullOrEmptyExpr, tryParseExpression) 1822Expression.Break(loopExit) 1825Expression.PostIncrementAssign(index) 1835Expression.Block( 1838Expression.Assign(stringArrayExpr!, valueExpression), 1839Expression.IfThen( 1840Expression.NotEqual(stringArrayExpr!, Expression.Constant(null)), 1848Expression.Block( 1851Expression.Assign(stringArrayExpr!, valueExpression), 1852Expression.IfThenElse( 1853Expression.NotEqual(stringArrayExpr!, Expression.Constant(null)), 1862Expression.Block( 1864Expression.Assign(TempSourceStringExpr, valueExpression), 1873Expression.Block( 1875Expression.Assign(TempSourceStringExpr, valueExpression), 1886private static Expression BindParameterFromExpression( 1888Expression valueExpression, 1895var argument = Expression.Variable(parameter.ParameterType, $"{parameter.Name}_local"); 1897var parameterTypeNameConstant = Expression.Constant(TypeNameHelper.GetTypeDisplayName(parameter.ParameterType, fullName: false)); 1898var parameterNameConstant = Expression.Constant(parameter.Name); 1899var sourceConstant = Expression.Constant(source); 1911var checkRequiredStringParameterBlock = Expression.Block( 1912Expression.Assign(argument, valueExpression), 1913Expression.IfThen(Expression.Equal(argument, Expression.Constant(null)), 1914Expression.Block( 1915Expression.Assign(WasParamCheckFailureExpr, Expression.Constant(true)), 1916Expression.Call(LogRequiredParameterNotProvidedMethod, 1918Expression.Constant(factoryContext.ThrowOnBadRequest)) 1936return Expression.Block( 1937Expression.Condition(Expression.Equal(valueExpression, Expression.Convert(Expression.Constant(StringValues.Empty), parameter.ParameterType)), 1938Expression.Convert(Expression.Constant(null), parameter.ParameterType), 1952return Expression.Block( 1953Expression.Condition(Expression.NotEqual(valueExpression, Expression.Constant(null)), 1955Expression.Convert(Expression.Constant(parameter.DefaultValue), parameter.ParameterType))); 1958private static Expression BindParameterFromProperty(ParameterInfo parameter, MemberExpression property, PropertyInfo itemProperty, string key, RequestDelegateFactoryContext factoryContext, string source) => 1967private static Expression BindParameterFromRouteValueOrQueryString(ParameterInfo parameter, string key, RequestDelegateFactoryContext factoryContext) 1969var routeValue = GetValueFromProperty(RouteValuesExpr, RouteValuesIndexerProperty, key); 1970var queryValue = GetValueFromProperty(QueryExpr, QueryIndexerProperty, key); 1971return BindParameterFromValue(parameter, Expression.Coalesce(routeValue, queryValue), factoryContext, "route or query string"); 1974private static Expression BindParameterFromBindAsync(ParameterInfo parameter, RequestDelegateFactoryContext factoryContext) 1985var bindAsyncDelegate = Expression.Lambda<Func<HttpContext, ValueTask<object?>>>(bindAsyncMethod.Expression, HttpContextExpr).Compile(); 1989var boundValueExpr = Expression.ArrayIndex(BoundValuesArrayExpr, Expression.Constant(factoryContext.ParameterBinders.Count - 1)); 1995var checkRequiredBodyBlock = Expression.Block( 1996Expression.IfThen( 1997Expression.Equal(boundValueExpr, Expression.Constant(null)), 1998Expression.Block( 1999Expression.Assign(WasParamCheckFailureExpr, Expression.Constant(true)), 2000Expression.Call(LogRequiredParameterNotProvidedMethod, 2002Expression.Constant(typeName), 2003Expression.Constant(parameter.Name), 2004Expression.Constant(message), 2005Expression.Constant(factoryContext.ThrowOnBadRequest)) 2014return Expression.Convert(boundValueExpr, parameter.ParameterType); 2049private static Expression BindParameterFromFormCollection( 2064private static Expression BindParameterFromFormItem( 2069var valueExpression = GetValueFromProperty(FormExpr, FormIndexerProperty, key, GetExpressionType(parameter.ParameterType)); 2101private static Expression BindComplexParameterFromFormItem( 2112var formArgument = Expression.Variable(parameter.ParameterType, $"{parameter.Name}_local"); 2133var formReader = Expression.Variable(typeof(FormDataReader), $"{parameter.Name}_reader"); 2134var formDict = Expression.Variable(typeof(IReadOnlyDictionary<FormKey, StringValues>), "form_dict"); 2135var formBuffer = Expression.Variable(typeof(char[]), "form_buffer"); 2136var formDataMappingException = Expression.Variable(typeof(FormDataMappingException), "form_exception"); 2139var processFormExpr = Expression.Call(ProcessFormMethod, FormExpr, Expression.Constant(formDataMapperOptions.MaxKeyBufferSize), formDict, formBuffer); 2141var initializeReaderExpr = Expression.Assign( 2143Expression.New(FormDataReaderConstructor, 2145Expression.Constant(CultureInfo.InvariantCulture), 2146Expression.Call(AsMemoryMethod, formBuffer, Expression.Constant(0), Expression.Constant(formDataMapperOptions.MaxKeyBufferSize)), 2149var setMaxRecursionDepthExpr = Expression.Assign( 2150Expression.Property(formReader, nameof(FormDataReader.MaxRecursionDepth)), 2151Expression.Constant(formDataMapperOptions.MaxRecursionDepth)); 2153var invokeMapMethodExpr = Expression.Call( 2156Expression.Constant(formDataMapperOptions)); 2161var returnBufferExpr = Expression.Call( 2162Expression.Property(null, typeof(ArrayPool<char>).GetProperty(nameof(ArrayPool<char>.Shared))!), 2165Expression.Constant(false)); 2166var conditionalReturnBufferExpr = Expression.IfThen( 2167Expression.NotEqual(formBuffer, Expression.Constant(null)), 2170var parameterTypeNameConstant = Expression.Constant(TypeNameHelper.GetTypeDisplayName(parameter.ParameterType, fullName: false)); 2171var parameterNameConstant = Expression.Constant(parameter.Name); 2192var bindAndCheckForm = Expression.Block( 2194Expression.TryCatchFinally( 2195Expression.Block( 2200Expression.Assign(formArgument, invokeMapMethodExpr)), 2202Expression.Catch(formDataMappingException, Expression.Block( 2204Expression.Assign(WasParamCheckFailureExpr, Expression.Constant(true)), 2205Expression.Call( 2211Expression.Constant(factoryContext.ThrowOnBadRequest)) 2232private static Expression BindParameterFromFormFiles( 2248private static Expression BindParameterFromFormFile( 2254var valueExpression = GetValueFromProperty(FormFilesExpr, FormFilesIndexerProperty, key, typeof(IFormFile)); 2268private static Expression BindParameterFromBody(ParameterInfo parameter, bool allowEmpty, RequestDelegateFactoryContext factoryContext) 2299factoryContext.ParamCheckExpressions.Add(Expression.Block( 2300Expression.IfThen( 2301Expression.Equal(BodyValueExpr, Expression.Constant(null)), 2302Expression.Block( 2303Expression.Assign(WasParamCheckFailureExpr, Expression.Constant(true)), 2304Expression.Call(LogImplicitBodyNotProvidedMethod, 2306Expression.Constant(parameter.Name), 2307Expression.Constant(factoryContext.ThrowOnBadRequest) 2323var checkRequiredBodyBlock = Expression.Block( 2324Expression.IfThen( 2325Expression.Equal(BodyValueExpr, Expression.Constant(null)), 2326Expression.Block( 2327Expression.Assign(WasParamCheckFailureExpr, Expression.Constant(true)), 2328Expression.Call(LogRequiredParameterNotProvidedMethod, 2330Expression.Constant(TypeNameHelper.GetTypeDisplayName(parameter.ParameterType, fullName: false)), 2331Expression.Constant(parameter.Name), 2332Expression.Constant("body"), 2333Expression.Constant(factoryContext.ThrowOnBadRequest)) 2343return Expression.Convert( 2344Expression.Coalesce(BodyValueExpr, Expression.Constant(parameter.DefaultValue)), 2349return Expression.Convert(BodyValueExpr, parameter.ParameterType);
RequestDelegateFactoryContext.cs (5)
40public List<Expression> ParamCheckExpressions { get; } = new(); 56public Expression? MethodCall { get; set; } 58public Expression[]? ArgumentExpressions { get; set; } 59public Expression[] BoxedArgs { get; set; } = Array.Empty<Expression>();
src\Components\Endpoints\src\FormMapping\Factories\ComplexType\ComplexTypeExpressionConverterFactoryOfT.cs (134)
36var propertyFoundValue = Expression.Variable(typeof(bool), "foundValueForProperty"); 37var succeeded = Expression.Variable(typeof(bool), "succeeded"); 38var localFoundValueVar = Expression.Variable(typeof(bool), "localFoundValue"); 39var exceptionVar = Expression.Variable(typeof(Exception), "mappingException"); 45var body = new List<Expression>() 47Expression.Assign(succeeded, Expression.Constant(true)), 50var end = Expression.Label("done"); 81body.Add(Expression.IfThen( 83Expression.Block(CreateInstanceAndAssignProperties( 95body.Add(Expression.Assign(foundValueParam, localFoundValueVar)); 96body.Add(Expression.Label(end)); 108private static IEnumerable<Expression> CreateInstanceAndAssignProperties( 145var exception = Expression.Variable(typeof(Exception), "constructorException"); 147yield return Expression.TryCatch( 148Expression.Assign( 150Expression.New( 153Expression.Catch( 155Expression.Block( 156Expression.Call( 161Expression.Constant(null, typeof(string))), 162Expression.Assign(succeeded, Expression.Constant(false, typeof(bool))), 171var failedAndHasHandler = Expression.And(Expression.Not(succeeded), HasHandler(context)); 174Expression.And( 176Expression.NotEqual( 178Expression.Constant(null, resultParam.Type))); 180yield return Expression.IfThen( 182Expression.Call( 186Expression.Convert(resultParam, typeof(object)))); 190var assignments = new List<Expression>(); 193assignments.Add(Expression.Assign(Expression.Property(resultParam, props[i].Property), GetValueLocalVariableValueExpression(propsLocals[i]))); 202yield return Expression.IfThen( 203Expression.NotEqual(resultParam, Expression.Constant(null, resultParam.Type)), 204Expression.Block(assignments)); 210yield return Expression.Assign(Expression.Property(resultParam, props[i].Property), GetValueLocalVariableValueExpression(propsLocals[i])); 216return Expression.NotEqual( 217Expression.Property(context, nameof(FormDataReader.AttachInstanceToErrorsHandler)), 218Expression.Constant(null, typeof(Action<string, object>))); 224private static IEnumerable<Expression> ReportMissingValues( 225Expression readerParam, 247yield return Expression.IfThen( 248Expression.Not(GetValueLocalVariableFoundExpression(parameter)), 249Expression.Block( 253Expression.Assign(succeeded, Expression.Constant(false, typeof(bool))))); 272yield return Expression.IfThen( 273Expression.Not(GetValueLocalVariableFoundExpression(property)), 274Expression.Block( 278Expression.Assign(succeeded, Expression.Constant(false, typeof(bool))))); 282static MethodCallExpression PushPrefix(Expression readerParam, string prefix) 284return Expression.Call( 288Expression.Constant(prefix)); 291static MethodCallExpression AddMappingError(Expression readerParam, string message, string parameter) 294var formattableString = Expression.Call( 298Expression.Constant(message), 299Expression.NewArrayInit(typeof(object), Expression.Constant(parameter))); 301return Expression.Call( 306Expression.Constant(null, typeof(string))); 309static MethodCallExpression PopPrefix(Expression readerParam, string prefix) 311return Expression.Call( 315Expression.Constant(prefix)); 331List<Expression> body) 344var propertyConverterVar = Expression.Variable(propertyConverterType, $"{property.Name}Converter"); 355var propertyConverter = Expression.Assign( 357Expression.Call( 361Array.Empty<Expression>())); 364body.Add(Expression.TryCatchFinally( 374body: Expression.Block( 376Expression.Call( 380Expression.Constant(property.Name)), 383Expression.AndAssign( 385Expression.Call( 390Expression.Constant(property.Type), 395@finally: Expression.Call( 399Expression.Constant(property.Name)), 400handlers: Expression.Catch( 402Expression.Block( 403Expression.Call( 408Expression.Constant(null, typeof(string))), 409Expression.Assign(succeeded, Expression.Constant(false, typeof(bool))) 413body.Add(Expression.Assign(GetValueLocalVariableFoundExpression(propertyVar), propertyFoundValue)); 414body.Add(Expression.OrAssign(localFoundValueVar, propertyFoundValue)); 430List<Expression> body) 444var constructorParameterConverterVar = Expression.Variable(constructorParameterConverterType, $"{constructorParameter.Name}Converter"); 455var constructorParameterConverter = Expression.Assign( 457Expression.Call( 461Array.Empty<Expression>())); 477body.Add(Expression.TryCatchFinally( 478body: Expression.Block( 480Expression.Call( 484Expression.Constant(constructorParameter.Name)), 486Expression.AndAssign( 488Expression.Call( 493Expression.Constant(constructorParameter.Type), 498@finally: Expression.Call( 502Expression.Constant(constructorParameter.Name)), 503handlers: Expression.Catch( 505Expression.Block( 506Expression.Call( 511Expression.Constant(null, typeof(string))), 512Expression.Assign(succeeded, Expression.Constant(false, typeof(bool))) 516body.Add(Expression.Assign(GetValueLocalVariableFoundExpression(constructorParameterVar), propertyFoundValue)); 517body.Add(Expression.OrAssign(localFoundValueVar, propertyFoundValue)); 523private static Expression GetValueLocalVariableFoundExpression(ParameterExpression constructorParameterVar) 525return Expression.PropertyOrField(constructorParameterVar, nameof(ValueTuple<bool, object>.Item1)); 530private static Expression GetValueLocalVariableValueExpression(ParameterExpression constructorParameterVar) => 531Expression.PropertyOrField(constructorParameterVar, nameof(ValueTuple<bool, object>.Item2)); 537return Expression.Variable(typeof(ValueTuple<,>).MakeGenericType(typeof(bool), constructorParameter.Type), constructorParameter.Name); 551return Expression.IfThen( 552Expression.Not(Expression.Call(readerParam, nameof(FormDataReader.CurrentPrefixExists), Array.Empty<Type>())), 553Expression.Block( 554Expression.Assign(foundValueParam, Expression.Constant(false)), 555Expression.Assign(succeeded, Expression.Constant(true)), 556Expression.Goto(end))); 562List<Expression> body) 564var lambda = Expression.Lambda<CompiledComplexTypeConverter<T>.ConverterDelegate>( 565Expression.Block(variables, body), 574Expression.Parameter(typeof(FormDataReader).MakeByRefType(), "reader"), 575Expression.Parameter(typeof(Type), "type"), 576Expression.Parameter(typeof(FormDataMapperOptions), "options"), 577Expression.Parameter(typeof(T).MakeByRefType(), "result"), 578Expression.Parameter(typeof(bool).MakeByRefType(), "foundValue"));
src\Shared\ObjectMethodExecutor\CoercedAwaitableInfo.cs (4)
14public Expression CoercerExpression { get; } 25public CoercedAwaitableInfo(Expression coercerExpression, Type coercerResultType, AwaitableInfo coercedAwaitableInfo) 42out var coercerExpression, 60out var coercerExpression,
src\Shared\ObjectMethodExecutor\ObjectMethodExecutor.cs (59)
200var targetParameter = Expression.Parameter(typeof(object), "target"); 201var parametersParameter = Expression.Parameter(typeof(object?[]), "parameters"); 205var parameters = new List<Expression>(paramInfos.Length); 209var valueObj = Expression.ArrayIndex(parametersParameter, Expression.Constant(i)); 210var valueCast = Expression.Convert(valueObj, paramInfo.ParameterType); 217var instanceCast = Expression.Convert(targetParameter, targetTypeInfo.AsType()); 218var methodCall = Expression.Call(instanceCast, methodInfo, parameters); 224var lambda = Expression.Lambda<VoidMethodExecutor>(methodCall, targetParameter, parametersParameter); 231var castMethodCall = Expression.Convert(methodCall, typeof(object)); 232var lambda = Expression.Lambda<MethodExecutor>(castMethodCall, targetParameter, parametersParameter); 252var targetParameter = Expression.Parameter(typeof(object), "target"); 253var parametersParameter = Expression.Parameter(typeof(object[]), "parameters"); 257var parameters = new List<Expression>(paramInfos.Length); 261var valueObj = Expression.ArrayIndex(parametersParameter, Expression.Constant(i)); 262var valueCast = Expression.Convert(valueObj, paramInfo.ParameterType); 269var instanceCast = Expression.Convert(targetParameter, targetTypeInfo.AsType()); 270var methodCall = Expression.Call(instanceCast, methodInfo, parameters); 279var customAwaitableParam = Expression.Parameter(typeof(object), "awaitable"); 282var getAwaiterFunc = Expression.Lambda<Func<object, object>>( 283Expression.Convert( 284Expression.Call( 285Expression.Convert(customAwaitableParam, postCoercionMethodReturnType), 292var isCompletedParam = Expression.Parameter(typeof(object), "awaiter"); 293var isCompletedFunc = Expression.Lambda<Func<object, bool>>( 294Expression.MakeMemberAccess( 295Expression.Convert(isCompletedParam, awaitableInfo.AwaiterType), 299var getResultParam = Expression.Parameter(typeof(object), "awaiter"); 308getResultFunc = Expression.Lambda<Func<object, object>>( 309Expression.Block( 310Expression.Call( 311Expression.Convert(getResultParam, awaitableInfo.AwaiterType), 313Expression.Constant(null) 321getResultFunc = Expression.Lambda<Func<object, object>>( 322Expression.Convert( 323Expression.Call( 324Expression.Convert(getResultParam, awaitableInfo.AwaiterType), 333var onCompletedParam1 = Expression.Parameter(typeof(object), "awaiter"); 334var onCompletedParam2 = Expression.Parameter(typeof(Action), "continuation"); 335var onCompletedFunc = Expression.Lambda<Action<object, Action>>( 336Expression.Call( 337Expression.Convert(onCompletedParam1, awaitableInfo.AwaiterType), 349var unsafeOnCompletedParam1 = Expression.Parameter(typeof(object), "awaiter"); 350var unsafeOnCompletedParam2 = Expression.Parameter(typeof(Action), "continuation"); 351unsafeOnCompletedFunc = Expression.Lambda<Action<object, Action>>( 352Expression.Call( 353Expression.Convert(unsafeOnCompletedParam1, awaitableInfo.AwaiterType), 362var coercedMethodCall = coercedAwaitableInfo.RequiresCoercion 363? Expression.Invoke(coercedAwaitableInfo.CoercerExpression, methodCall) 364: (Expression)methodCall; 373var returnValueExpression = Expression.New( 375Expression.Convert(coercedMethodCall, typeof(object)), 376Expression.Constant(getAwaiterFunc), 377Expression.Constant(isCompletedFunc), 378Expression.Constant(getResultFunc), 379Expression.Constant(onCompletedFunc), 380Expression.Constant(unsafeOnCompletedFunc, typeof(Action<object, Action>))); 382var lambda = Expression.Lambda<MethodExecutorAsync>(returnValueExpression, targetParameter, parametersParameter);
src\Shared\ObjectMethodExecutor\ObjectMethodExecutorFSharpSupport.cs (18)
60out Expression coerceToAwaitableExpression, 88var coerceToAwaitableParam = Expression.Parameter(possibleFSharpAsyncType); 91Expression.Call( 94arg1: Expression.MakeMemberAccess(null, _fsharpOptionOfTaskCreationOptionsNoneProperty), 95arg2: Expression.MakeMemberAccess(null, _fsharpOptionOfCancellationTokenNoneProperty)); 97Expression body = 98TryBuildCoercerFromUnitAwaitableToVoidAwaitable(awaitableType, out var coercerExpression, out var nonGenericAwaitableType) 99? Expression.Invoke(coercerExpression, startAsTaskCall) 102coerceToAwaitableExpression = Expression.Lambda(body, coerceToAwaitableParam); 133out Expression coercerExpression, 152static Expression MakeTaskOfUnitToTaskExpression(Type type) 154var closedGenericTaskParam = Expression.Parameter(type); 155return Expression.Lambda(Expression.Convert(closedGenericTaskParam, typeof(Task)), closedGenericTaskParam); 158static Expression MakeValueTaskOfUnitToValueTaskExpression(Type type) 160var closedGenericTaskParam = Expression.Parameter(type); 167return Expression.Lambda(Expression.Call(conversionMethod, closedGenericTaskParam), closedGenericTaskParam);
src\Shared\ParameterBindingMethodCache.cs (39)
38internal static readonly ParameterExpression TempSourceStringExpr = Expression.Variable(typeof(string), "tempSourceString"); 39internal static readonly ParameterExpression HttpContextExpr = Expression.Parameter(typeof(HttpContext), "httpContext"); 46private readonly ConcurrentDictionary<Type, Func<ParameterExpression, Expression, Expression>?> _stringMethodCallCache = new(); 47private readonly ConcurrentDictionary<Type, (Func<ParameterInfo, Expression>?, int)> _bindAsyncMethodCallCache = new(); 80public Func<ParameterExpression, Expression, Expression>? FindTryParseMethod(Type type) 85Func<ParameterExpression, Expression, Expression>? Finder(Type type) 91return (expression, formatProvider) => Expression.Call(explicitIParsableTryParseMethod, TempSourceStringExpr, formatProvider, expression); 100return (expression, formatProvider) => Expression.Call(methodInfo!, TempSourceStringExpr, expression); 105var enumAsObject = Expression.Variable(typeof(object), "enumAsObject"); 106var success = Expression.Variable(typeof(bool), "success"); 114return Expression.Block(new[] { success, enumAsObject }, 115Expression.Assign(success, Expression.Call(_enumTryParseMethod, Expression.Constant(type), TempSourceStringExpr, enumAsObject)), 116Expression.Assign(expression, 117Expression.Condition(success, Expression.Convert(enumAsObject, type), Expression.Default(type))), 125return (expression, formatProvider) => Expression.Call( 128Expression.Constant(UriKind.RelativeOrAbsolute), 154return (expression, formatProvider) => Expression.Call( 158Expression.Constant(dateTimeStyles), 164return (expression, formatProvider) => Expression.Call( 167Expression.Constant(numberStyle), 176return (expression, formatProvider) => Expression.Call( 187return (expression, formatProvider) => Expression.Call(methodInfo, TempSourceStringExpr, expression); 216public (Expression? Expression, int ParamCount) FindBindAsyncMethod(ParameterInfo parameter) 218(Func<ParameterInfo, Expression>?, int) Finder(Type nonNullableParameterType) 252typedCall = Expression.Call(methodInfo, HttpContextExpr, Expression.Constant(parameter)); 256typedCall = Expression.Call(methodInfo, HttpContextExpr); 258return Expression.Call(ConvertValueTaskMethod.MakeGenericMethod(nonNullableParameterType), typedCall); 273typedCall = Expression.Call(methodInfo, HttpContextExpr, Expression.Constant(parameter)); 277typedCall = Expression.Call(methodInfo, HttpContextExpr); 279return Expression.Call(ConvertValueTaskOfNullableResultMethod.MakeGenericMethod(nonNullableParameterType), typedCall);
Microsoft.AspNetCore.Http.Extensions.Tests (30)
ParameterBindingMethodCacheTests.cs (27)
33var call = methodFound!(Expression.Variable(type, "parsedValue"), Expression.Constant(CultureInfo.InvariantCulture)) as MethodCallExpression; 51var call = methodFound!(Expression.Variable(typeof(Uri), "parsedValue"), Expression.Constant(UriKind.RelativeOrAbsolute)) as MethodCallExpression; 73var call = methodFound!(Expression.Variable(type, "parsedValue"), Expression.Constant(CultureInfo.InvariantCulture)) as MethodCallExpression; 105var call = methodFound!(Expression.Variable(type, "parsedValue"), Expression.Constant(CultureInfo.InvariantCulture)) as MethodCallExpression; 129var call = methodFound!(Expression.Variable(type, "parsedValue"), Expression.Constant(CultureInfo.InvariantCulture)) as MethodCallExpression; 183var call = methodFound!(Expression.Variable(type, "parsedValue"), Expression.Constant(CultureInfo.InvariantCulture)) as MethodCallExpression; 204var parsedValue = Expression.Variable(type, "parsedValue"); 205var block = methodFound!(parsedValue, Expression.Constant(CultureInfo.InvariantCulture)) as BlockExpression; 209var parseEnum = Expression.Lambda<Func<string, Choice>>(Expression.Block(new[] { parsedValue }, 229var parsedValue = Expression.Variable(type, "parsedValue"); 231var parseHttpContext = Expression.Lambda<Func<HttpContext, ValueTask<object>>>( 232Expression.Block(new[] { parsedValue }, methodFound.Expression!), 260var parsedValue = Expression.Variable(type, "parsedValue"); 262var parseHttpContext = Expression.Lambda<Func<HttpContext, ValueTask<object>>>( 263Expression.Block(new[] { parsedValue }, methodFound.Expression!), 388var parseHttpContext = Expression.Lambda<Func<HttpContext, ValueTask<object?>>>(methodFound.Expression!, 406var parseHttpContext = Expression.Lambda<Func<HttpContext, ValueTask<object?>>>(methodFound.Expression!, 424var parseHttpContext = Expression.Lambda<Func<HttpContext, ValueTask<object>>>(methodFound.Expression!, 440var parseHttpContext = Expression.Lambda<Func<HttpContext, ValueTask<object>>>(methodFound.Expression!, 456var parseHttpContext = Expression.Lambda<Func<HttpContext, ValueTask<object>>>(methodFound.Expression!,
RequestDelegateFactoryTests.cs (3)
736var unnamedParameter = Expression.Parameter(typeof(int)); 737var lambda = Expression.Lambda(Expression.Block(), unnamedParameter);
Microsoft.AspNetCore.Http.Results.Tests (1)
ResultsTests.cs (1)
1718private static string GetMemberName(Expression expression)
Microsoft.AspNetCore.JsonPatch (5)
JsonPatchDocumentOfT.cs (5)
676private List<string> GetPathSegments(Expression expr) 729private static string EvaluateExpression(Expression expression) 731var converted = Expression.Convert(expression, typeof(object)); 732var fakeParameter = Expression.Parameter(typeof(object), null); 733var lambda = Expression.Lambda<Func<object, object>>(converted, fakeParameter);
Microsoft.AspNetCore.Mvc.Abstractions (41)
ModelBinding\ModelMetadata.cs (2)
643internal static Func<ParameterExpression, Expression, Expression>? FindTryParseMethod(Type modelType)
src\Shared\ParameterBindingMethodCache.cs (39)
38internal static readonly ParameterExpression TempSourceStringExpr = Expression.Variable(typeof(string), "tempSourceString"); 39internal static readonly ParameterExpression HttpContextExpr = Expression.Parameter(typeof(HttpContext), "httpContext"); 46private readonly ConcurrentDictionary<Type, Func<ParameterExpression, Expression, Expression>?> _stringMethodCallCache = new(); 47private readonly ConcurrentDictionary<Type, (Func<ParameterInfo, Expression>?, int)> _bindAsyncMethodCallCache = new(); 80public Func<ParameterExpression, Expression, Expression>? FindTryParseMethod(Type type) 85Func<ParameterExpression, Expression, Expression>? Finder(Type type) 91return (expression, formatProvider) => Expression.Call(explicitIParsableTryParseMethod, TempSourceStringExpr, formatProvider, expression); 100return (expression, formatProvider) => Expression.Call(methodInfo!, TempSourceStringExpr, expression); 105var enumAsObject = Expression.Variable(typeof(object), "enumAsObject"); 106var success = Expression.Variable(typeof(bool), "success"); 114return Expression.Block(new[] { success, enumAsObject }, 115Expression.Assign(success, Expression.Call(_enumTryParseMethod, Expression.Constant(type), TempSourceStringExpr, enumAsObject)), 116Expression.Assign(expression, 117Expression.Condition(success, Expression.Convert(enumAsObject, type), Expression.Default(type))), 125return (expression, formatProvider) => Expression.Call( 128Expression.Constant(UriKind.RelativeOrAbsolute), 154return (expression, formatProvider) => Expression.Call( 158Expression.Constant(dateTimeStyles), 164return (expression, formatProvider) => Expression.Call( 167Expression.Constant(numberStyle), 176return (expression, formatProvider) => Expression.Call( 187return (expression, formatProvider) => Expression.Call(methodInfo, TempSourceStringExpr, expression); 216public (Expression? Expression, int ParamCount) FindBindAsyncMethod(ParameterInfo parameter) 218(Func<ParameterInfo, Expression>?, int) Finder(Type nonNullableParameterType) 252typedCall = Expression.Call(methodInfo, HttpContextExpr, Expression.Constant(parameter)); 256typedCall = Expression.Call(methodInfo, HttpContextExpr); 258return Expression.Call(ConvertValueTaskMethod.MakeGenericMethod(nonNullableParameterType), typedCall); 273typedCall = Expression.Call(methodInfo, HttpContextExpr, Expression.Constant(parameter)); 277typedCall = Expression.Call(methodInfo, HttpContextExpr); 279return Expression.Call(ConvertValueTaskOfNullableResultMethod.MakeGenericMethod(nonNullableParameterType), typedCall);
Microsoft.AspNetCore.Mvc.Core (127)
ControllerBase.cs (2)
2600/// <param name="includeExpressions"> <see cref="Expression"/>(s) which represent top-level properties 2676/// <param name="includeExpressions"> <see cref="Expression"/>(s) which represent top-level properties
ModelBinding\Binders\CollectionModelBinder.cs (2)
252_modelCreator = Expression 253.Lambda<Func<object>>(Expression.New(targetType))
ModelBinding\Binders\ComplexObjectModelBinder.cs (2)
214_modelCreator = Expression 215.Lambda<Func<object>>(Expression.New(bindingContext.ModelType))
ModelBinding\Binders\ComplexTypeModelBinder.cs (2)
503_modelCreator = Expression 504.Lambda<Func<object>>(Expression.New(bindingContext.ModelType))
ModelBinding\Binders\TryParseModelBinder.cs (18)
19private static readonly ParameterExpression BindingContextExpression = Expression.Parameter(typeof(ModelBindingContext), "bindingContext"); 20private static readonly ParameterExpression ValueProviderResultExpression = Expression.Parameter(typeof(ValueProviderResult), "valueProviderResult"); 21private static readonly MemberExpression BindingResultExpression = Expression.Property(BindingContextExpression, nameof(ModelBindingContext.Result)); 22private static readonly MemberExpression ValueExpression = Expression.Property(ValueProviderResultExpression, nameof(ValueProviderResult.FirstValue)); 23private static readonly MemberExpression CultureExpression = Expression.Property(ValueProviderResultExpression, nameof(ValueProviderResult.Culture)); 126var parsedValue = Expression.Variable(modelType, "parsedValue"); 127var modelValue = Expression.Variable(typeof(object), "model"); 129var expression = Expression.Block( 131Expression.Assign(ParameterBindingMethodCache.SharedExpressions.TempSourceStringExpr, ValueExpression), 132Expression.IfThenElse(tryParseMethodExpession(parsedValue, CultureExpression), 133Expression.Block( 134Expression.Assign(modelValue, Expression.Convert(parsedValue, modelValue.Type)), 135Expression.Assign(BindingResultExpression, Expression.Call(SuccessBindingResultMethod, modelValue))), 136Expression.Call(AddModelErrorMethod, BindingContextExpression, Expression.Constant(new FormatException()))), 139return Expression.Lambda<Func<ValueProviderResult, ModelBindingContext, object?>>(expression, new[] { ValueProviderResultExpression, BindingContextExpression }).Compile();
ModelBinding\Metadata\DefaultModelMetadataProvider.cs (12)
255var args = Expression.Parameter(typeof(object?[]), "args"); 256var factoryExpressionBody = BuildFactoryExpression(constructor, args); 258var factoryLamda = Expression.Lambda<Func<object?[], object>>(factoryExpressionBody, args); 264private static Expression BuildFactoryExpression( 266Expression factoryArgumentArray) 269var constructorArguments = new Expression[constructorParameters.Length]; 276constructorArguments[i] = Expression.ArrayAccess(factoryArgumentArray, Expression.Constant(i)); 288var defaultValueExpression = Expression.Constant(defaultValue); 289constructorArguments[i] = Expression.Coalesce(constructorArguments[i], defaultValueExpression); 292constructorArguments[i] = Expression.Convert(constructorArguments[i], parameterType); 295return Expression.New(constructor, constructorArguments);
ModelBinding\ModelBindingHelper.cs (5)
286internal static string GetPropertyName(Expression expression) 337var orWrapperExpression = firstExpression.Body; 341orWrapperExpression = Expression.OrElse( 343Expression.Invoke(predicate, firstExpression.Parameters)); 346return Expression.Lambda<Func<ModelMetadata, bool>>(orWrapperExpression, firstExpression.Parameters);
ModelBinding\Validation\DefaultCollectionValidationStrategy.cs (3)
72var parameter = Expression.Parameter(typeof(object), "model"); 74Expression.Lambda<Func<object, IEnumerator>>( 75Expression.Call(null, getEnumeratorMethod, parameter),
src\Shared\ObjectMethodExecutor\CoercedAwaitableInfo.cs (4)
14public Expression CoercerExpression { get; } 25public CoercedAwaitableInfo(Expression coercerExpression, Type coercerResultType, AwaitableInfo coercedAwaitableInfo) 42out var coercerExpression, 60out var coercerExpression,
src\Shared\ObjectMethodExecutor\ObjectMethodExecutor.cs (59)
200var targetParameter = Expression.Parameter(typeof(object), "target"); 201var parametersParameter = Expression.Parameter(typeof(object?[]), "parameters"); 205var parameters = new List<Expression>(paramInfos.Length); 209var valueObj = Expression.ArrayIndex(parametersParameter, Expression.Constant(i)); 210var valueCast = Expression.Convert(valueObj, paramInfo.ParameterType); 217var instanceCast = Expression.Convert(targetParameter, targetTypeInfo.AsType()); 218var methodCall = Expression.Call(instanceCast, methodInfo, parameters); 224var lambda = Expression.Lambda<VoidMethodExecutor>(methodCall, targetParameter, parametersParameter); 231var castMethodCall = Expression.Convert(methodCall, typeof(object)); 232var lambda = Expression.Lambda<MethodExecutor>(castMethodCall, targetParameter, parametersParameter); 252var targetParameter = Expression.Parameter(typeof(object), "target"); 253var parametersParameter = Expression.Parameter(typeof(object[]), "parameters"); 257var parameters = new List<Expression>(paramInfos.Length); 261var valueObj = Expression.ArrayIndex(parametersParameter, Expression.Constant(i)); 262var valueCast = Expression.Convert(valueObj, paramInfo.ParameterType); 269var instanceCast = Expression.Convert(targetParameter, targetTypeInfo.AsType()); 270var methodCall = Expression.Call(instanceCast, methodInfo, parameters); 279var customAwaitableParam = Expression.Parameter(typeof(object), "awaitable"); 282var getAwaiterFunc = Expression.Lambda<Func<object, object>>( 283Expression.Convert( 284Expression.Call( 285Expression.Convert(customAwaitableParam, postCoercionMethodReturnType), 292var isCompletedParam = Expression.Parameter(typeof(object), "awaiter"); 293var isCompletedFunc = Expression.Lambda<Func<object, bool>>( 294Expression.MakeMemberAccess( 295Expression.Convert(isCompletedParam, awaitableInfo.AwaiterType), 299var getResultParam = Expression.Parameter(typeof(object), "awaiter"); 308getResultFunc = Expression.Lambda<Func<object, object>>( 309Expression.Block( 310Expression.Call( 311Expression.Convert(getResultParam, awaitableInfo.AwaiterType), 313Expression.Constant(null) 321getResultFunc = Expression.Lambda<Func<object, object>>( 322Expression.Convert( 323Expression.Call( 324Expression.Convert(getResultParam, awaitableInfo.AwaiterType), 333var onCompletedParam1 = Expression.Parameter(typeof(object), "awaiter"); 334var onCompletedParam2 = Expression.Parameter(typeof(Action), "continuation"); 335var onCompletedFunc = Expression.Lambda<Action<object, Action>>( 336Expression.Call( 337Expression.Convert(onCompletedParam1, awaitableInfo.AwaiterType), 349var unsafeOnCompletedParam1 = Expression.Parameter(typeof(object), "awaiter"); 350var unsafeOnCompletedParam2 = Expression.Parameter(typeof(Action), "continuation"); 351unsafeOnCompletedFunc = Expression.Lambda<Action<object, Action>>( 352Expression.Call( 353Expression.Convert(unsafeOnCompletedParam1, awaitableInfo.AwaiterType), 362var coercedMethodCall = coercedAwaitableInfo.RequiresCoercion 363? Expression.Invoke(coercedAwaitableInfo.CoercerExpression, methodCall) 364: (Expression)methodCall; 373var returnValueExpression = Expression.New( 375Expression.Convert(coercedMethodCall, typeof(object)), 376Expression.Constant(getAwaiterFunc), 377Expression.Constant(isCompletedFunc), 378Expression.Constant(getResultFunc), 379Expression.Constant(onCompletedFunc), 380Expression.Constant(unsafeOnCompletedFunc, typeof(Action<object, Action>))); 382var lambda = Expression.Lambda<MethodExecutorAsync>(returnValueExpression, targetParameter, parametersParameter);
src\Shared\ObjectMethodExecutor\ObjectMethodExecutorFSharpSupport.cs (18)
60out Expression coerceToAwaitableExpression, 88var coerceToAwaitableParam = Expression.Parameter(possibleFSharpAsyncType); 91Expression.Call( 94arg1: Expression.MakeMemberAccess(null, _fsharpOptionOfTaskCreationOptionsNoneProperty), 95arg2: Expression.MakeMemberAccess(null, _fsharpOptionOfCancellationTokenNoneProperty)); 97Expression body = 98TryBuildCoercerFromUnitAwaitableToVoidAwaitable(awaitableType, out var coercerExpression, out var nonGenericAwaitableType) 99? Expression.Invoke(coercerExpression, startAsTaskCall) 102coerceToAwaitableExpression = Expression.Lambda(body, coerceToAwaitableParam); 133out Expression coercerExpression, 152static Expression MakeTaskOfUnitToTaskExpression(Type type) 154var closedGenericTaskParam = Expression.Parameter(type); 155return Expression.Lambda(Expression.Convert(closedGenericTaskParam, typeof(Task)), closedGenericTaskParam); 158static Expression MakeValueTaskOfUnitToValueTaskExpression(Type type) 160var closedGenericTaskParam = Expression.Parameter(type); 167return Expression.Lambda(Expression.Call(conversionMethod, closedGenericTaskParam), closedGenericTaskParam);
Microsoft.AspNetCore.Mvc.Razor (5)
Compilation\DefaultRazorPageFactoryProvider.cs (5)
44var newExpression = Expression.New(viewType); 49var propertyBindExpression = Expression.Bind(pathProperty, Expression.Constant(viewDescriptor.RelativePath)); 50var objectInitializeExpression = Expression.MemberInit(newExpression, propertyBindExpression); 51var pageFactory = Expression
Microsoft.AspNetCore.Mvc.RazorPages (37)
Infrastructure\DefaultPageActivatorProvider.cs (4)
67var parameter1 = Expression.Parameter(typeof(PageContext), "pageContext"); 68var parameter2 = Expression.Parameter(typeof(ViewContext), "viewContext"); 71var newExpression = Expression.New(pageTypeInfo); 74var pageFactory = Expression
Infrastructure\ExecutorFactory.cs (29)
54protected static Expression[] Unpack(Expression arguments, HandlerParameterDescriptor[] parameters) 56var unpackExpressions = new Expression[parameters.Length]; 59unpackExpressions[i] = Expression.Convert( 60Expression.ArrayIndex(arguments, Expression.Constant(i)), 84var receiver = Expression.Parameter(typeof(object), "receiver"); 85var arguments = Expression.Parameter(typeof(object[]), "arguments"); 87_thunk = Expression.Lambda<Func<object, object?[]?, Task>>( 88Expression.Call( 89Expression.Convert(receiver, method.DeclaringType!), 114var receiver = Expression.Parameter(typeof(object), "receiver"); 115var arguments = Expression.Parameter(typeof(object[]), "arguments"); 117_thunk = Expression.Lambda<Func<object, object?[]?, Task<object>>>( 118Expression.Call( 120Expression.Convert( 121Expression.Call( 122Expression.Convert(receiver, method.DeclaringType!), 150var receiver = Expression.Parameter(typeof(object), "receiver"); 151var arguments = Expression.Parameter(typeof(object[]), "arguments"); 153_thunk = Expression.Lambda<Action<object, object?[]?>>( 154Expression.Call( 155Expression.Convert(receiver, method.DeclaringType!), 176var receiver = Expression.Parameter(typeof(object), "receiver"); 177var arguments = Expression.Parameter(typeof(object[]), "arguments"); 179_thunk = Expression.Lambda<Func<object, object?[]?, IActionResult?>>( 180Expression.Convert( 181Expression.Call( 182Expression.Convert(receiver, method.DeclaringType!),
PageBase.cs (2)
1349/// <param name="includeExpressions"> <see cref="Expression"/>(s) which represent top-level properties 1423/// <param name="includeExpressions"> <see cref="Expression"/>(s) which represent top-level properties
PageModel.cs (2)
254/// <param name="includeExpressions"> <see cref="Expression"/>(s) which represent top-level properties 328/// <param name="includeExpressions"> <see cref="Expression"/>(s) which represent top-level properties
Microsoft.AspNetCore.Mvc.ViewFeatures (44)
CachedExpressionCompiler.cs (16)
13private static readonly Expression NullExpression = Expression.Constant(value: null); 175var parameterExpression = Expression.Parameter(typeof(object), "capturedLocal"); 177Expression.Convert(parameterExpression, memberExpression.Member.DeclaringType); 179var replacementExpression = Expression.Lambda<Func<object, TResult>>( 195Expression combinedNullTest = null; 212var body = expression.Body; 218body = Expression.Convert(body, typeof(object)); 224body = Expression.Condition( 226Expression.Constant(value: null, body.Type), 230var rewrittenExpression = Expression.Lambda<Func<TModel, object>>(body, expression.Parameters); 234private static void AddNullCheck(Expression invokingExpression, ref Expression combinedNullTest) 247Expression.Equal(invokingExpression, NullExpression) : 248Expression.ReferenceEqual(invokingExpression, NullExpression); 257combinedNullTest = Expression.OrElse(nullTest, combinedNullTest);
ExpressionHelper.cs (6)
46var part = expression.Body; 199Expression indexExpression, 213var converted = Expression.Convert(indexExpression, typeof(object)); 214var fakeParameter = Expression.Parameter(typeof(object), null); 215var lambda = Expression.Lambda<Func<object, object>>(converted, fakeParameter); 235public static bool IsSingleArgumentIndexer(Expression expression)
LambdaExpressionComparer.cs (3)
22var expression1 = lambdaExpression1.Body; 23var expression2 = lambdaExpression2.Body; 83var expression = lambdaExpression.Body;
ModelExpression.cs (9)
9/// Describes an <see cref="System.Linq.Expressions.Expression"/> passed to a tag helper. 17/// String representation of the <see cref="System.Linq.Expressions.Expression"/> of interest. 20/// Includes the model and metadata about the <see cref="System.Linq.Expressions.Expression"/> of interest. 32/// String representation of the <see cref="System.Linq.Expressions.Expression"/> of interest. 37/// Metadata about the <see cref="System.Linq.Expressions.Expression"/> of interest. 42/// Gets the model object for the <see cref="System.Linq.Expressions.Expression"/> of interest. 46/// <see cref="System.Linq.Expressions.Expression"/>. 51/// Gets the model explorer for the <see cref="System.Linq.Expressions.Expression"/> of interest. 55/// <see cref="System.Linq.Expressions.Expression"/>.
ModelStateDictionaryExtensions.cs (1)
156return ExpressionHelper.GetUncachedExpressionText(Expression.Lambda(
ViewDataDictionaryFactory.cs (9)
20var parameter1 = Expression.Parameter(typeof(IModelMetadataProvider), "metadataProvider"); 21var parameter2 = Expression.Parameter(typeof(ModelStateDictionary), "modelState"); 24Expression.Lambda<Func<IModelMetadataProvider, ModelStateDictionary, ViewDataDictionary>>( 25Expression.Convert( 26Expression.New(constructor, parameter1, parameter2), 41var parameter = Expression.Parameter(typeof(ViewDataDictionary), "viewDataDictionary"); 44Expression.Lambda<Func<ViewDataDictionary, ViewDataDictionary>>( 45Expression.Convert( 46Expression.New(constructor, parameter),
Microsoft.AspNetCore.OpenApi (120)
src\Shared\ObjectMethodExecutor\CoercedAwaitableInfo.cs (4)
14public Expression CoercerExpression { get; } 25public CoercedAwaitableInfo(Expression coercerExpression, Type coercerResultType, AwaitableInfo coercedAwaitableInfo) 42out var coercerExpression, 60out var coercerExpression,
src\Shared\ObjectMethodExecutor\ObjectMethodExecutor.cs (59)
200var targetParameter = Expression.Parameter(typeof(object), "target"); 201var parametersParameter = Expression.Parameter(typeof(object?[]), "parameters"); 205var parameters = new List<Expression>(paramInfos.Length); 209var valueObj = Expression.ArrayIndex(parametersParameter, Expression.Constant(i)); 210var valueCast = Expression.Convert(valueObj, paramInfo.ParameterType); 217var instanceCast = Expression.Convert(targetParameter, targetTypeInfo.AsType()); 218var methodCall = Expression.Call(instanceCast, methodInfo, parameters); 224var lambda = Expression.Lambda<VoidMethodExecutor>(methodCall, targetParameter, parametersParameter); 231var castMethodCall = Expression.Convert(methodCall, typeof(object)); 232var lambda = Expression.Lambda<MethodExecutor>(castMethodCall, targetParameter, parametersParameter); 252var targetParameter = Expression.Parameter(typeof(object), "target"); 253var parametersParameter = Expression.Parameter(typeof(object[]), "parameters"); 257var parameters = new List<Expression>(paramInfos.Length); 261var valueObj = Expression.ArrayIndex(parametersParameter, Expression.Constant(i)); 262var valueCast = Expression.Convert(valueObj, paramInfo.ParameterType); 269var instanceCast = Expression.Convert(targetParameter, targetTypeInfo.AsType()); 270var methodCall = Expression.Call(instanceCast, methodInfo, parameters); 279var customAwaitableParam = Expression.Parameter(typeof(object), "awaitable"); 282var getAwaiterFunc = Expression.Lambda<Func<object, object>>( 283Expression.Convert( 284Expression.Call( 285Expression.Convert(customAwaitableParam, postCoercionMethodReturnType), 292var isCompletedParam = Expression.Parameter(typeof(object), "awaiter"); 293var isCompletedFunc = Expression.Lambda<Func<object, bool>>( 294Expression.MakeMemberAccess( 295Expression.Convert(isCompletedParam, awaitableInfo.AwaiterType), 299var getResultParam = Expression.Parameter(typeof(object), "awaiter"); 308getResultFunc = Expression.Lambda<Func<object, object>>( 309Expression.Block( 310Expression.Call( 311Expression.Convert(getResultParam, awaitableInfo.AwaiterType), 313Expression.Constant(null) 321getResultFunc = Expression.Lambda<Func<object, object>>( 322Expression.Convert( 323Expression.Call( 324Expression.Convert(getResultParam, awaitableInfo.AwaiterType), 333var onCompletedParam1 = Expression.Parameter(typeof(object), "awaiter"); 334var onCompletedParam2 = Expression.Parameter(typeof(Action), "continuation"); 335var onCompletedFunc = Expression.Lambda<Action<object, Action>>( 336Expression.Call( 337Expression.Convert(onCompletedParam1, awaitableInfo.AwaiterType), 349var unsafeOnCompletedParam1 = Expression.Parameter(typeof(object), "awaiter"); 350var unsafeOnCompletedParam2 = Expression.Parameter(typeof(Action), "continuation"); 351unsafeOnCompletedFunc = Expression.Lambda<Action<object, Action>>( 352Expression.Call( 353Expression.Convert(unsafeOnCompletedParam1, awaitableInfo.AwaiterType), 362var coercedMethodCall = coercedAwaitableInfo.RequiresCoercion 363? Expression.Invoke(coercedAwaitableInfo.CoercerExpression, methodCall) 364: (Expression)methodCall; 373var returnValueExpression = Expression.New( 375Expression.Convert(coercedMethodCall, typeof(object)), 376Expression.Constant(getAwaiterFunc), 377Expression.Constant(isCompletedFunc), 378Expression.Constant(getResultFunc), 379Expression.Constant(onCompletedFunc), 380Expression.Constant(unsafeOnCompletedFunc, typeof(Action<object, Action>))); 382var lambda = Expression.Lambda<MethodExecutorAsync>(returnValueExpression, targetParameter, parametersParameter);
src\Shared\ObjectMethodExecutor\ObjectMethodExecutorFSharpSupport.cs (18)
60out Expression coerceToAwaitableExpression, 88var coerceToAwaitableParam = Expression.Parameter(possibleFSharpAsyncType); 91Expression.Call( 94arg1: Expression.MakeMemberAccess(null, _fsharpOptionOfTaskCreationOptionsNoneProperty), 95arg2: Expression.MakeMemberAccess(null, _fsharpOptionOfCancellationTokenNoneProperty)); 97Expression body = 98TryBuildCoercerFromUnitAwaitableToVoidAwaitable(awaitableType, out var coercerExpression, out var nonGenericAwaitableType) 99? Expression.Invoke(coercerExpression, startAsTaskCall) 102coerceToAwaitableExpression = Expression.Lambda(body, coerceToAwaitableParam); 133out Expression coercerExpression, 152static Expression MakeTaskOfUnitToTaskExpression(Type type) 154var closedGenericTaskParam = Expression.Parameter(type); 155return Expression.Lambda(Expression.Convert(closedGenericTaskParam, typeof(Task)), closedGenericTaskParam); 158static Expression MakeValueTaskOfUnitToValueTaskExpression(Type type) 160var closedGenericTaskParam = Expression.Parameter(type); 167return Expression.Lambda(Expression.Call(conversionMethod, closedGenericTaskParam), closedGenericTaskParam);
src\Shared\ParameterBindingMethodCache.cs (39)
38internal static readonly ParameterExpression TempSourceStringExpr = Expression.Variable(typeof(string), "tempSourceString"); 39internal static readonly ParameterExpression HttpContextExpr = Expression.Parameter(typeof(HttpContext), "httpContext"); 46private readonly ConcurrentDictionary<Type, Func<ParameterExpression, Expression, Expression>?> _stringMethodCallCache = new(); 47private readonly ConcurrentDictionary<Type, (Func<ParameterInfo, Expression>?, int)> _bindAsyncMethodCallCache = new(); 80public Func<ParameterExpression, Expression, Expression>? FindTryParseMethod(Type type) 85Func<ParameterExpression, Expression, Expression>? Finder(Type type) 91return (expression, formatProvider) => Expression.Call(explicitIParsableTryParseMethod, TempSourceStringExpr, formatProvider, expression); 100return (expression, formatProvider) => Expression.Call(methodInfo!, TempSourceStringExpr, expression); 105var enumAsObject = Expression.Variable(typeof(object), "enumAsObject"); 106var success = Expression.Variable(typeof(bool), "success"); 114return Expression.Block(new[] { success, enumAsObject }, 115Expression.Assign(success, Expression.Call(_enumTryParseMethod, Expression.Constant(type), TempSourceStringExpr, enumAsObject)), 116Expression.Assign(expression, 117Expression.Condition(success, Expression.Convert(enumAsObject, type), Expression.Default(type))), 125return (expression, formatProvider) => Expression.Call( 128Expression.Constant(UriKind.RelativeOrAbsolute), 154return (expression, formatProvider) => Expression.Call( 158Expression.Constant(dateTimeStyles), 164return (expression, formatProvider) => Expression.Call( 167Expression.Constant(numberStyle), 176return (expression, formatProvider) => Expression.Call( 187return (expression, formatProvider) => Expression.Call(methodInfo, TempSourceStringExpr, expression); 216public (Expression? Expression, int ParamCount) FindBindAsyncMethod(ParameterInfo parameter) 218(Func<ParameterInfo, Expression>?, int) Finder(Type nonNullableParameterType) 252typedCall = Expression.Call(methodInfo, HttpContextExpr, Expression.Constant(parameter)); 256typedCall = Expression.Call(methodInfo, HttpContextExpr); 258return Expression.Call(ConvertValueTaskMethod.MakeGenericMethod(nonNullableParameterType), typedCall); 273typedCall = Expression.Call(methodInfo, HttpContextExpr, Expression.Constant(parameter)); 277typedCall = Expression.Call(methodInfo, HttpContextExpr); 279return Expression.Call(ConvertValueTaskOfNullableResultMethod.MakeGenericMethod(nonNullableParameterType), typedCall);
Microsoft.AspNetCore.OpenApi.Tests (3)
Services\OpenApiGeneratorTests.cs (3)
75var unnamedParameter = Expression.Parameter(typeof(int)); 76var lambda = Expression.Lambda(Expression.Block(), unnamedParameter);
Microsoft.AspNetCore.Shared.Tests (84)
src\Shared\ObjectMethodExecutor\CoercedAwaitableInfo.cs (4)
14public Expression CoercerExpression { get; } 25public CoercedAwaitableInfo(Expression coercerExpression, Type coercerResultType, AwaitableInfo coercedAwaitableInfo) 42out var coercerExpression, 60out var coercerExpression,
src\Shared\ObjectMethodExecutor\ObjectMethodExecutor.cs (59)
200var targetParameter = Expression.Parameter(typeof(object), "target"); 201var parametersParameter = Expression.Parameter(typeof(object?[]), "parameters"); 205var parameters = new List<Expression>(paramInfos.Length); 209var valueObj = Expression.ArrayIndex(parametersParameter, Expression.Constant(i)); 210var valueCast = Expression.Convert(valueObj, paramInfo.ParameterType); 217var instanceCast = Expression.Convert(targetParameter, targetTypeInfo.AsType()); 218var methodCall = Expression.Call(instanceCast, methodInfo, parameters); 224var lambda = Expression.Lambda<VoidMethodExecutor>(methodCall, targetParameter, parametersParameter); 231var castMethodCall = Expression.Convert(methodCall, typeof(object)); 232var lambda = Expression.Lambda<MethodExecutor>(castMethodCall, targetParameter, parametersParameter); 252var targetParameter = Expression.Parameter(typeof(object), "target"); 253var parametersParameter = Expression.Parameter(typeof(object[]), "parameters"); 257var parameters = new List<Expression>(paramInfos.Length); 261var valueObj = Expression.ArrayIndex(parametersParameter, Expression.Constant(i)); 262var valueCast = Expression.Convert(valueObj, paramInfo.ParameterType); 269var instanceCast = Expression.Convert(targetParameter, targetTypeInfo.AsType()); 270var methodCall = Expression.Call(instanceCast, methodInfo, parameters); 279var customAwaitableParam = Expression.Parameter(typeof(object), "awaitable"); 282var getAwaiterFunc = Expression.Lambda<Func<object, object>>( 283Expression.Convert( 284Expression.Call( 285Expression.Convert(customAwaitableParam, postCoercionMethodReturnType), 292var isCompletedParam = Expression.Parameter(typeof(object), "awaiter"); 293var isCompletedFunc = Expression.Lambda<Func<object, bool>>( 294Expression.MakeMemberAccess( 295Expression.Convert(isCompletedParam, awaitableInfo.AwaiterType), 299var getResultParam = Expression.Parameter(typeof(object), "awaiter"); 308getResultFunc = Expression.Lambda<Func<object, object>>( 309Expression.Block( 310Expression.Call( 311Expression.Convert(getResultParam, awaitableInfo.AwaiterType), 313Expression.Constant(null) 321getResultFunc = Expression.Lambda<Func<object, object>>( 322Expression.Convert( 323Expression.Call( 324Expression.Convert(getResultParam, awaitableInfo.AwaiterType), 333var onCompletedParam1 = Expression.Parameter(typeof(object), "awaiter"); 334var onCompletedParam2 = Expression.Parameter(typeof(Action), "continuation"); 335var onCompletedFunc = Expression.Lambda<Action<object, Action>>( 336Expression.Call( 337Expression.Convert(onCompletedParam1, awaitableInfo.AwaiterType), 349var unsafeOnCompletedParam1 = Expression.Parameter(typeof(object), "awaiter"); 350var unsafeOnCompletedParam2 = Expression.Parameter(typeof(Action), "continuation"); 351unsafeOnCompletedFunc = Expression.Lambda<Action<object, Action>>( 352Expression.Call( 353Expression.Convert(unsafeOnCompletedParam1, awaitableInfo.AwaiterType), 362var coercedMethodCall = coercedAwaitableInfo.RequiresCoercion 363? Expression.Invoke(coercedAwaitableInfo.CoercerExpression, methodCall) 364: (Expression)methodCall; 373var returnValueExpression = Expression.New( 375Expression.Convert(coercedMethodCall, typeof(object)), 376Expression.Constant(getAwaiterFunc), 377Expression.Constant(isCompletedFunc), 378Expression.Constant(getResultFunc), 379Expression.Constant(onCompletedFunc), 380Expression.Constant(unsafeOnCompletedFunc, typeof(Action<object, Action>))); 382var lambda = Expression.Lambda<MethodExecutorAsync>(returnValueExpression, targetParameter, parametersParameter);
src\Shared\ObjectMethodExecutor\ObjectMethodExecutorFSharpSupport.cs (18)
60out Expression coerceToAwaitableExpression, 88var coerceToAwaitableParam = Expression.Parameter(possibleFSharpAsyncType); 91Expression.Call( 94arg1: Expression.MakeMemberAccess(null, _fsharpOptionOfTaskCreationOptionsNoneProperty), 95arg2: Expression.MakeMemberAccess(null, _fsharpOptionOfCancellationTokenNoneProperty)); 97Expression body = 98TryBuildCoercerFromUnitAwaitableToVoidAwaitable(awaitableType, out var coercerExpression, out var nonGenericAwaitableType) 99? Expression.Invoke(coercerExpression, startAsTaskCall) 102coerceToAwaitableExpression = Expression.Lambda(body, coerceToAwaitableParam); 133out Expression coercerExpression, 152static Expression MakeTaskOfUnitToTaskExpression(Type type) 154var closedGenericTaskParam = Expression.Parameter(type); 155return Expression.Lambda(Expression.Convert(closedGenericTaskParam, typeof(Task)), closedGenericTaskParam); 158static Expression MakeValueTaskOfUnitToValueTaskExpression(Type type) 160var closedGenericTaskParam = Expression.Parameter(type); 167return Expression.Lambda(Expression.Call(conversionMethod, closedGenericTaskParam), closedGenericTaskParam);
StackTraceHelperTest.cs (3)
234var action = (Action)Expression.Lambda( 235Expression.Throw( 236Expression.New(typeof(Exception)))).Compile();
Microsoft.AspNetCore.SignalR.Core (87)
Internal\HubMethodDescriptor.cs (6)
233Expression.Parameter(typeof(object)), 234Expression.Parameter(typeof(CancellationToken)), 239var methodArguments = new Expression[] 241Expression.Convert(parameters[0], methodParameters[0].ParameterType), 245var methodCall = Expression.Call(null, genericMethodInfo, methodArguments); 246var lambda = Expression.Lambda<Func<object, CancellationToken, IAsyncEnumerator<object?>>>(methodCall, parameters);
src\Shared\ObjectMethodExecutor\CoercedAwaitableInfo.cs (4)
14public Expression CoercerExpression { get; } 25public CoercedAwaitableInfo(Expression coercerExpression, Type coercerResultType, AwaitableInfo coercedAwaitableInfo) 42out var coercerExpression, 60out var coercerExpression,
src\Shared\ObjectMethodExecutor\ObjectMethodExecutor.cs (59)
200var targetParameter = Expression.Parameter(typeof(object), "target"); 201var parametersParameter = Expression.Parameter(typeof(object?[]), "parameters"); 205var parameters = new List<Expression>(paramInfos.Length); 209var valueObj = Expression.ArrayIndex(parametersParameter, Expression.Constant(i)); 210var valueCast = Expression.Convert(valueObj, paramInfo.ParameterType); 217var instanceCast = Expression.Convert(targetParameter, targetTypeInfo.AsType()); 218var methodCall = Expression.Call(instanceCast, methodInfo, parameters); 224var lambda = Expression.Lambda<VoidMethodExecutor>(methodCall, targetParameter, parametersParameter); 231var castMethodCall = Expression.Convert(methodCall, typeof(object)); 232var lambda = Expression.Lambda<MethodExecutor>(castMethodCall, targetParameter, parametersParameter); 252var targetParameter = Expression.Parameter(typeof(object), "target"); 253var parametersParameter = Expression.Parameter(typeof(object[]), "parameters"); 257var parameters = new List<Expression>(paramInfos.Length); 261var valueObj = Expression.ArrayIndex(parametersParameter, Expression.Constant(i)); 262var valueCast = Expression.Convert(valueObj, paramInfo.ParameterType); 269var instanceCast = Expression.Convert(targetParameter, targetTypeInfo.AsType()); 270var methodCall = Expression.Call(instanceCast, methodInfo, parameters); 279var customAwaitableParam = Expression.Parameter(typeof(object), "awaitable"); 282var getAwaiterFunc = Expression.Lambda<Func<object, object>>( 283Expression.Convert( 284Expression.Call( 285Expression.Convert(customAwaitableParam, postCoercionMethodReturnType), 292var isCompletedParam = Expression.Parameter(typeof(object), "awaiter"); 293var isCompletedFunc = Expression.Lambda<Func<object, bool>>( 294Expression.MakeMemberAccess( 295Expression.Convert(isCompletedParam, awaitableInfo.AwaiterType), 299var getResultParam = Expression.Parameter(typeof(object), "awaiter"); 308getResultFunc = Expression.Lambda<Func<object, object>>( 309Expression.Block( 310Expression.Call( 311Expression.Convert(getResultParam, awaitableInfo.AwaiterType), 313Expression.Constant(null) 321getResultFunc = Expression.Lambda<Func<object, object>>( 322Expression.Convert( 323Expression.Call( 324Expression.Convert(getResultParam, awaitableInfo.AwaiterType), 333var onCompletedParam1 = Expression.Parameter(typeof(object), "awaiter"); 334var onCompletedParam2 = Expression.Parameter(typeof(Action), "continuation"); 335var onCompletedFunc = Expression.Lambda<Action<object, Action>>( 336Expression.Call( 337Expression.Convert(onCompletedParam1, awaitableInfo.AwaiterType), 349var unsafeOnCompletedParam1 = Expression.Parameter(typeof(object), "awaiter"); 350var unsafeOnCompletedParam2 = Expression.Parameter(typeof(Action), "continuation"); 351unsafeOnCompletedFunc = Expression.Lambda<Action<object, Action>>( 352Expression.Call( 353Expression.Convert(unsafeOnCompletedParam1, awaitableInfo.AwaiterType), 362var coercedMethodCall = coercedAwaitableInfo.RequiresCoercion 363? Expression.Invoke(coercedAwaitableInfo.CoercerExpression, methodCall) 364: (Expression)methodCall; 373var returnValueExpression = Expression.New( 375Expression.Convert(coercedMethodCall, typeof(object)), 376Expression.Constant(getAwaiterFunc), 377Expression.Constant(isCompletedFunc), 378Expression.Constant(getResultFunc), 379Expression.Constant(onCompletedFunc), 380Expression.Constant(unsafeOnCompletedFunc, typeof(Action<object, Action>))); 382var lambda = Expression.Lambda<MethodExecutorAsync>(returnValueExpression, targetParameter, parametersParameter);
src\Shared\ObjectMethodExecutor\ObjectMethodExecutorFSharpSupport.cs (18)
60out Expression coerceToAwaitableExpression, 88var coerceToAwaitableParam = Expression.Parameter(possibleFSharpAsyncType); 91Expression.Call( 94arg1: Expression.MakeMemberAccess(null, _fsharpOptionOfTaskCreationOptionsNoneProperty), 95arg2: Expression.MakeMemberAccess(null, _fsharpOptionOfCancellationTokenNoneProperty)); 97Expression body = 98TryBuildCoercerFromUnitAwaitableToVoidAwaitable(awaitableType, out var coercerExpression, out var nonGenericAwaitableType) 99? Expression.Invoke(coercerExpression, startAsTaskCall) 102coerceToAwaitableExpression = Expression.Lambda(body, coerceToAwaitableParam); 133out Expression coercerExpression, 152static Expression MakeTaskOfUnitToTaskExpression(Type type) 154var closedGenericTaskParam = Expression.Parameter(type); 155return Expression.Lambda(Expression.Convert(closedGenericTaskParam, typeof(Task)), closedGenericTaskParam); 158static Expression MakeValueTaskOfUnitToValueTaskExpression(Type type) 160var closedGenericTaskParam = Expression.Parameter(type); 167return Expression.Lambda(Expression.Call(conversionMethod, closedGenericTaskParam), closedGenericTaskParam);
Microsoft.CodeAnalysis.CSharp.Scripting.Desktop.UnitTests (1)
InteractiveSessionReferencesTests.cs (1)
184typeof(System.Linq.Expressions.Expression).Assembly);
Microsoft.CodeAnalysis.EditorFeatures.Wpf (60)
Lightup\LightupHelpers.cs (60)
86var parameter = Expression.Parameter(typeof(T), GenerateParameterName(typeof(T))); 87var instance = 89? (Expression)parameter 90: Expression.Convert(parameter, type); 93Expression.Lambda<Func<T, TResult>>( 94Expression.Convert(Expression.Call(instance, property.GetMethod), typeof(TResult)), 138var parameter = Expression.Parameter(typeof(T), GenerateParameterName(typeof(T))); 139var instance = 141? (Expression)parameter 142: Expression.Convert(parameter, type); 145Expression.Lambda<Action<T>>( 146Expression.Call(instance, method), 205var parameter = Expression.Parameter(typeof(T), GenerateParameterName(typeof(T))); 206var argument = Expression.Parameter(typeof(TArg), parameters[0].Name); 207var instance = 209? (Expression)parameter 210: Expression.Convert(parameter, type); 211var convertedArgument = 213? (Expression)argument 214: Expression.Convert(argument, argType); 217Expression.Lambda<Action<T, TArg>>( 218Expression.Call(instance, method, convertedArgument), 270var parameter = Expression.Parameter(typeof(T), GenerateParameterName(typeof(T))); 273Expression.Lambda<Func<T, TResult>>( 274Expression.Convert(Expression.Call(null, method), typeof(TResult)), 322var parameter = Expression.Parameter(typeof(T), GenerateParameterName(typeof(T))); 323var instance = 325? (Expression)parameter 326: Expression.Convert(parameter, type); 329Expression.Lambda<Func<T, TResult>>( 330Expression.Convert(Expression.Call(instance, method), typeof(TResult)), 387var parameter = Expression.Parameter(typeof(T), GenerateParameterName(typeof(T))); 388var argument = Expression.Parameter(typeof(TArg), parameters[0].Name); 389var instance = 391? (Expression)parameter 392: Expression.Convert(parameter, type); 393var convertedArgument = 395? (Expression)argument 396: Expression.Convert(argument, argType); 399Expression.Lambda<Func<T, TArg, TResult>>( 400Expression.Convert( 401Expression.Call( 472var parameter = Expression.Parameter(typeof(T), GenerateParameterName(typeof(T))); 473var argument0 = Expression.Parameter(typeof(TArg0), parameters[0].Name); 474var argument1 = Expression.Parameter(typeof(TArg1), parameters[1].Name); 475var instance = 477? (Expression)parameter 478: Expression.Convert(parameter, type); 479var convertedArgument0 = 481? (Expression)argument0 482: Expression.Convert(argument0, arg0Type); 483var convertedArgument1 = 485? (Expression)argument1 486: Expression.Convert(argument1, arg1Type); 489Expression.Lambda<Func<T, TArg0, TArg1, TResult>>( 490Expression.Convert( 491Expression.Call(
Microsoft.CodeAnalysis.LanguageServer.Protocol (9)
Protocol\Converters\StringEnumConverter.cs (3)
33var param = Expression.Parameter(typeof(string), "value"); 34var body = Expression.New(constructor, param); 35CreateEnum = Expression.Lambda<Func<string, TStringEnumType>>(body, param).Compile();
Protocol\Converters\SumConverter.cs (6)
128private static readonly Type[] expressionLambdaMethodTypes = [typeof(Type), typeof(Expression), typeof(ParameterExpression[])]; 129private static readonly MethodInfo expressionLambdaMethod = typeof(Expression) 156var param1 = Expression.Parameter(typeof(Utf8JsonReader).MakeByRefType(), "reader"); 157var param2 = Expression.Parameter(typeof(JsonSerializerOptions), "options"); 158var body = Expression.New( 160Expression.Call(
Microsoft.CodeAnalysis.VisualBasic.Emit.UnitTests (25)
ExpressionTrees\Sources\ExprLambdaUtils.vb (19)
79Public Shared Function Print(e As Expression) As String 85Public Overrides Function Visit(node As Expression) As Expression 147Protected Overrides Function VisitMemberInit(node As MemberInitExpression) As Expression 161Protected Overrides Function VisitBinary(node As BinaryExpression) As Expression 191Protected Overrides Function VisitConditional(node As ConditionalExpression) As Expression 201Protected Overrides Function VisitConstant(node As ConstantExpression) As Expression 206Protected Overrides Function VisitDefault(node As DefaultExpression) As Expression 210Protected Overrides Function VisitIndex(node As IndexExpression) As Expression 231Protected Overrides Function VisitInvocation(node As InvocationExpression) As Expression 245Protected Overrides Function VisitLambda(Of T)(node As Expression(Of T)) As Expression 273Protected Overrides Function VisitParameter(node As ParameterExpression) As Expression 282Protected Overrides Function VisitListInit(node As ListInitExpression) As Expression 315Protected Overrides Function VisitUnary(node As UnaryExpression) As Expression 334Protected Overrides Function VisitMember(node As MemberExpression) As Expression 341Protected Overrides Function VisitMethodCall(node As MethodCallExpression) As Expression 357Protected Overrides Function VisitNew(node As NewExpression) As Expression 384Protected Overrides Function VisitNewArray(node As NewArrayExpression) As Expression 394Protected Overrides Function VisitTypeBinary(node As TypeBinaryExpression) As Expression
ExpressionTrees\Sources\QueryHelper.vb (6)
28Public ReadOnly Property Expression As Expression Implements System.Linq.IQueryable.Expression 30Return System.Linq.Expressions.Expression.Constant(DirectCast(Nothing, QueryHelper(Of T)), GetType(QueryHelper(Of T))) 39Public Function CreateQuery(expression As System.Linq.Expressions.Expression) As System.Linq.IQueryable Implements System.Linq.IQueryProvider.CreateQuery 43Public Function CreateQuery1(Of TElement)(expression As System.Linq.Expressions.Expression) As System.Linq.IQueryable(Of TElement) Implements System.Linq.IQueryProvider.CreateQuery 47Public Function Execute(expression As System.Linq.Expressions.Expression) As Object Implements System.Linq.IQueryProvider.Execute 51Public Function Execute1(Of TResult)(expression As System.Linq.Expressions.Expression) As TResult Implements System.Linq.IQueryProvider.Execute
Microsoft.CodeAnalysis.VisualBasic.Features (1)
EditAndContinue\DeclarationBody\FieldOrPropertyDeclarationBody.vb (1)
41''' <see cref="Expression"/> or <see cref="ArgumentListSyntax"/>.
Microsoft.CSharp (149)
Microsoft\CSharp\RuntimeBinder\BinderHelper.cs (24)
31Expression[] parameters = new Expression[args.Length]; 55tempForIncrement = Expression.Variable(value != null ? value.GetType() : typeof(object), "t0"); 74Expression e = Expression.Call(null, isNaN, o.Expression); 80Expression e = Expression.Call(null, isNaN, o.Expression); 85Expression e = Expression.Equal(o.Expression, Expression.Constant(o.Value, o.Expression.Type)); 95Expression expression = binder.Bind(action, parameters, args, out DynamicMetaObject deferredBinding); 116expression = Expression.Block( 118Expression.Assign(tempForIncrement, Expression.Convert(arg0.Expression, arg0.Value.GetType())), 120Expression.Assign(arg0.Expression, Expression.Convert(tempForIncrement, arg0.Expression.Type))); 135Expression.Throw( 136Expression.New( 138Expression.Constant(e.Message) 244private static Expression ConvertResult(Expression binding, ICSharpBinder action) 265return Expression.Block(binding, Expression.Default(action.ReturnType)); 274return Expression.Convert(binding, action.ReturnType);
Microsoft\CSharp\RuntimeBinder\DynamicDebuggerProxy.cs (4)
45var error = new DynamicMetaObject(System.Linq.Expressions.Expression.Throw( 46System.Linq.Expressions.Expression.Constant(new DynamicBindingFailedException(), typeof(Exception)), typeof(object)), System.Dynamic.BindingRestrictions.Combine(v)); 110private static readonly ParameterExpression parameter = Expression.Parameter(typeof(object), "debug"); 210Type delegateType = Expression.GetDelegateType(delegateSignatureTypes);
Microsoft\CSharp\RuntimeBinder\ExpressionTreeCallRewriter.cs (103)
21public readonly Expression Expression; 22public ExpressionExpr(Expression e) 29private readonly Dictionary<ExprCall, Expression> _DictionaryOfParameters; 30private readonly Expression[] _ListOfParameters; 37private ExpressionTreeCallRewriter(Expression[] listOfParameters) 39_DictionaryOfParameters = new Dictionary<ExprCall, Expression>(); 46public static Expression Rewrite(ExprBinOp binOp, Expression[] listOfParameters) 80Expression parameter = _ListOfParameters[_currentParameterIndex++]; 96Expression exp; 244private Expression GenerateCall(ExprCall pExpr) 265Expression obj = null; 267Expression[] arguments = GetArgumentsFromArrayInit(arrinit); 282return Expression.Call(obj, m, arguments); 288private Expression GenerateArrayIndex(ExprCall pExpr) 297Expression obj = GetExpression(list.OptionalElement); 298Expression[] indices; 309return Expression.ArrayAccess(obj, indices); 315private Expression GenerateConvert(ExprCall pExpr) 318Expression e; 345return Expression.Convert(e, t, m); 347return Expression.ConvertChecked(e, t, m); 371return Expression.Unbox(e, t); 376return Expression.Convert(e, t); 378return Expression.ConvertChecked(e, t); 385private Expression GenerateProperty(ExprCall pExpr) 414return Expression.Property(GetExpression(instance), p); 417return Expression.Property(GetExpression(instance), p, GetArgumentsFromArrayInit(arguments)); 423private Expression GenerateField(ExprCall pExpr) 445return Expression.Field(GetExpression(list.OptionalElement), f); 451private Expression GenerateInvoke(ExprCall pExpr) 455return Expression.Invoke( 463private Expression GenerateNew(ExprCall pExpr) 468Expression[] arguments = GetArgumentsFromArrayInit(list.OptionalNextListNode as ExprArrayInit); 469return Expression.New(constructor, arguments); 475private static Expression GenerateConstantType(ExprCall pExpr) 479return Expression.Constant( 486private Expression GenerateAssignment(ExprCall pExpr) 490return Expression.Assign( 498private Expression GenerateBinaryOperator(ExprCall pExpr) 502Expression arg1 = GetExpression(list.OptionalElement); 503Expression arg2 = GetExpression(list.OptionalNextListNode); 508return Expression.Add(arg1, arg2); 510return Expression.And(arg1, arg2); 512return Expression.Divide(arg1, arg2); 514return Expression.Equal(arg1, arg2); 516return Expression.ExclusiveOr(arg1, arg2); 518return Expression.GreaterThan(arg1, arg2); 520return Expression.GreaterThanOrEqual(arg1, arg2); 522return Expression.LeftShift(arg1, arg2); 524return Expression.LessThan(arg1, arg2); 526return Expression.LessThanOrEqual(arg1, arg2); 528return Expression.Modulo(arg1, arg2); 530return Expression.Multiply(arg1, arg2); 532return Expression.NotEqual(arg1, arg2); 534return Expression.Or(arg1, arg2); 536return Expression.RightShift(arg1, arg2); 538return Expression.Subtract(arg1, arg2); 540return Expression.OrElse(arg1, arg2); 542return Expression.AndAlso(arg1, arg2); 546return Expression.AddChecked(arg1, arg2); 548return Expression.MultiplyChecked(arg1, arg2); 550return Expression.SubtractChecked(arg1, arg2); 561private Expression GenerateUserDefinedBinaryOperator(ExprCall pExpr) 564Expression arg1 = GetExpression(list.OptionalElement); 565Expression arg2 = GetExpression(((ExprList)list.OptionalNextListNode).OptionalElement); 585return Expression.Add(arg1, arg2, methodInfo); 587return Expression.And(arg1, arg2, methodInfo); 589return Expression.Divide(arg1, arg2, methodInfo); 591return Expression.Equal(arg1, arg2, bIsLifted, methodInfo); 593return Expression.ExclusiveOr(arg1, arg2, methodInfo); 595return Expression.GreaterThan(arg1, arg2, bIsLifted, methodInfo); 597return Expression.GreaterThanOrEqual(arg1, arg2, bIsLifted, methodInfo); 599return Expression.LeftShift(arg1, arg2, methodInfo); 601return Expression.LessThan(arg1, arg2, bIsLifted, methodInfo); 603return Expression.LessThanOrEqual(arg1, arg2, bIsLifted, methodInfo); 605return Expression.Modulo(arg1, arg2, methodInfo); 607return Expression.Multiply(arg1, arg2, methodInfo); 609return Expression.NotEqual(arg1, arg2, bIsLifted, methodInfo); 611return Expression.Or(arg1, arg2, methodInfo); 613return Expression.RightShift(arg1, arg2, methodInfo); 615return Expression.Subtract(arg1, arg2, methodInfo); 617return Expression.OrElse(arg1, arg2, methodInfo); 619return Expression.AndAlso(arg1, arg2, methodInfo); 623return Expression.AddChecked(arg1, arg2, methodInfo); 625return Expression.MultiplyChecked(arg1, arg2, methodInfo); 627return Expression.SubtractChecked(arg1, arg2, methodInfo); 638private Expression GenerateUnaryOperator(ExprCall pExpr) 641Expression arg = GetExpression(pExpr.OptionalArguments); 646return Expression.Not(arg); 649return Expression.Negate(arg); 652return Expression.NegateChecked(arg); 663private Expression GenerateUserDefinedUnaryOperator(ExprCall pExpr) 667Expression arg = GetExpression(list.OptionalElement); 673return Expression.Not(arg, methodInfo); 676return Expression.Negate(arg, methodInfo); 679return Expression.UnaryPlus(arg, methodInfo); 682return Expression.NegateChecked(arg, methodInfo); 695private Expression GetExpression(Expr pExpr) 798Expression.NewArrayInit( 888private Expression[] GetArgumentsFromArrayInit(ExprArrayInit arrinit) 890List<Expression> expressions = new List<Expression>();
Microsoft\CSharp\RuntimeBinder\RuntimeBinder.cs (11)
44public Expression Bind(ICSharpBinder payload, Expression[] parameters, DynamicMetaObject[] args, out DynamicMetaObject deferredBinding) 70private Expression BindCore( 72Expression[] parameters, 189private static Expression CreateExpressionTreeFromResult(Expression[] parameters, Scope pScope, Expr pResult) 198Expression e = ExpressionTreeCallRewriter.Rewrite(exprTree, parameters); 203private Type GetArgumentType(ICSharpBinder p, CSharpArgumentInfo argInfo, Expression param, DynamicMetaObject arg, int index) 245Expression[] parameters, 331Expression[] parameterExpressions) 339Expression parameter = parameterExpressions[i];
Microsoft\CSharp\RuntimeBinder\RuntimeBinderExtensions.cs (6)
285var parameter1 = Expression.Parameter(memberInfo); 286var parameter2 = Expression.Parameter(memberInfo); 287var memberEquivalence = Expression.Lambda<Func<MemberInfo, MemberInfo, bool>>( 288Expression.Equal( 289Expression.Property(parameter1, property), 290Expression.Property(parameter2, property)),
Microsoft\CSharp\RuntimeBinder\Semantics\Types\PredefinedTypes.cs (1)
159new PredefinedTypeInfo(PredefinedType.PT_EXPRESSION, typeof(System.Linq.Expressions.Expression), "System.Linq.Expressions.Expression"),
Microsoft.DotNet.SwaggerGenerator.CodeGenerator (54)
HelperFactory.cs (54)
128var outputParameter = Expression.Parameter(typeof(TextWriter), "output"); 129var optionsParameter = Expression.Parameter(typeof(HelperOptions), "options"); 130var contextParameter = Expression.Parameter(typeof(object), "context"); 131var argumentsParameter = Expression.Parameter(typeof(object[]), "arguments"); 137new ProvidedParameter("template", typeof(Action<TextWriter, object>), Expression.MakeMemberAccess(optionsParameter, typeof(HelperOptions).GetProperty("Template"))), 138new ProvidedParameter("inverse", typeof(Action<TextWriter, object>), Expression.MakeMemberAccess(optionsParameter, typeof(HelperOptions).GetProperty("Inverse"))), 141Expression invokeExpression; 144invokeExpression = Expression.Call(Expression.Constant(instance), method, parameterExpressions); 148invokeExpression = Expression.Call(method, parameterExpressions); 151Expression body; 158var writerOutput = ConvertResultExpression(method.ReturnType, invokeExpression); 159body = Expression.Call(HandlebarsExtensionsWriteSafeString, outputParameter, writerOutput); 162var result = Expression.Lambda<HandlebarsBlockHelper>( 175var outputParameter = Expression.Parameter(typeof(TextWriter), "output"); 176var contextParameter = Expression.Parameter(typeof(object), "context"); 177var argumentsParameter = Expression.Parameter(typeof(object[]), "arguments"); 185Expression invokeExpression; 188invokeExpression = Expression.Call(Expression.Constant(instance), method, parameterExpressions); 192invokeExpression = Expression.Call(method, parameterExpressions); 194var writerOutput = ConvertResultExpression(method.ReturnType, invokeExpression); 195var body = Expression.Call(HandlebarsExtensionsWriteSafeString, outputParameter, writerOutput); 197var result = Expression.Lambda<HandlebarsHelper>( 235public ProvidedParameter(string name, Type type, Expression value) 244public Expression Value { get; } 247private static IEnumerable<Expression> GetParameterExpressions(MethodInfo method, ParameterExpression argumentsParameter, List<ProvidedParameter> providedParameters) 271private static Expression CoerceObjectExpression(Type output, Expression input) 275return Expression.Call(HandlebarsUtilsIsTruthyOrNonEmpty, input); 280return Expression.Convert(Expression.Call(ConvertChangeType, input, Expression.Constant(output)), output); 286input = Expression.Condition( 287Expression.TypeIs(input, UndefinedBindingResultType), 288Expression.Constant(null, typeof(object)), 292return Expression.Convert(input, output); 295private static Expression ConvertResultExpression(Type type, Expression input) 299return Expression.Condition(input, Expression.Constant("true"), Expression.Constant("")); 302return Expression.Call(input, ObjectToString); 305private static Expression GetExpressionForParameter( 316var element = Expression.ArrayIndex(argumentsParameter, Expression.Constant(index)); 320private static Expression GetExpressionForParamArrayParameter(Type parameterType, int index, ParameterExpression argumentsParameter) 322Expression result = argumentsParameter; 325result = Expression.Call(EnumerableSkip(typeof(object)), result, Expression.Constant(index)); 329var selectParam = Expression.Parameter(typeof(object), "o"); 331result = Expression.Call( 333Expression.Call( 336Expression.Lambda(CoerceObjectExpression(elementType, selectParam), selectParam)));
Microsoft.Extensions.DependencyInjection (69)
DependencyInjectionEventSource.cs (3)
305public static void ExpressionTreeGenerated(this DependencyInjectionEventSource source, ServiceProvider provider, Type serviceType, Expression expression) 320public override Expression? Visit(Expression? e)
ServiceLookup\Expressions\ExpressionResolverBuilder.cs (66)
15internal sealed class ExpressionResolverBuilder : CallSiteVisitor<object?, Expression> 17private static readonly ParameterExpression ScopeParameter = Expression.Parameter(typeof(ServiceProviderEngineScope)); 19private static readonly ParameterExpression ResolvedServices = Expression.Variable(typeof(IDictionary<ServiceCacheKey, object>), ScopeParameter.Name + "resolvedServices"); 20private static readonly ParameterExpression Sync = Expression.Variable(typeof(object), ScopeParameter.Name + "sync"); 22Expression.Assign(ResolvedServices, 23Expression.Property( 28Expression.Assign(Sync, 29Expression.Property( 33private static readonly ParameterExpression CaptureDisposableParameter = Expression.Parameter(typeof(object)); 34private static readonly LambdaExpression CaptureDisposable = Expression.Lambda( 36Expression.Call(ScopeParameter, ServiceLookupHelpers.CaptureDisposableMethodInfo, CaptureDisposableParameter), 39private static readonly ConstantExpression CallSiteRuntimeResolverInstanceExpression = Expression.Constant( 82return Expression.Lambda<Func<ServiceProviderEngineScope, object>>( 83Expression.Block( 91return Expression.Lambda<Func<ServiceProviderEngineScope, object>>( 96protected override Expression VisitRootCache(ServiceCallSite singletonCallSite, object? context) 98return Expression.Constant(CallSiteRuntimeResolver.Instance.Resolve(singletonCallSite, _rootScope)); 101protected override Expression VisitConstant(ConstantCallSite constantCallSite, object? context) 103return Expression.Constant(constantCallSite.DefaultValue); 106protected override Expression VisitServiceProvider(ServiceProviderCallSite serviceProviderCallSite, object? context) 111protected override Expression VisitFactory(FactoryCallSite factoryCallSite, object? context) 113return Expression.Invoke(Expression.Constant(factoryCallSite.Factory), ScopeParameter); 116protected override Expression VisitIEnumerable(IEnumerableCallSite callSite, object? context) 129static NewArrayExpression NewArrayInit(Type elementType, IEnumerable<Expression> expr) 133return Expression.NewArrayInit(elementType, expr); 138return Expression.Constant( 151protected override Expression VisitDisposeCache(ServiceCallSite callSite, object? context) 160private static Expression TryCaptureDisposable(ServiceCallSite callSite, ParameterExpression scope, Expression service) 167return Expression.Invoke(GetCaptureDisposable(scope), service); 170protected override Expression VisitConstructor(ConstructorCallSite callSite, object? context) 173Expression[] parameterExpressions; 176parameterExpressions = Array.Empty<Expression>(); 180parameterExpressions = new Expression[callSite.ParameterCallSites.Length]; 187Expression expression = Expression.New(callSite.ConstructorInfo, parameterExpressions); 190expression = Expression.Convert(expression, typeof(object)); 195private static Expression Convert(Expression expression, Type type, bool forceValueTypeConversion = false) 204return Expression.Convert(expression, type); 207protected override Expression VisitScopeCache(ServiceCallSite callSite, object? context) 210return Expression.Invoke(Expression.Constant(lambda), ScopeParameter); 216ConstantExpression callSiteExpression = Expression.Constant( 223MethodCallExpression resolveRootScopeExpression = Expression.Call( 229ConstantExpression keyExpression = Expression.Constant( 233ParameterExpression resolvedVariable = Expression.Variable(typeof(object), "resolved"); 237MethodCallExpression tryGetValueExpression = Expression.Call( 243Expression captureDisposible = TryCaptureDisposable(callSite, ScopeParameter, VisitCallSiteMain(callSite, null)); 245BinaryExpression assignExpression = Expression.Assign( 249MethodCallExpression addValueExpression = Expression.Call( 255BlockExpression blockExpression = Expression.Block( 261Expression.IfThen( 262Expression.Not(tryGetValueExpression), 263Expression.Block( 271ParameterExpression lockWasTaken = Expression.Variable(typeof(bool), "lockWasTaken"); 274MethodCallExpression monitorEnter = Expression.Call(ServiceLookupHelpers.MonitorEnterMethodInfo, sync, lockWasTaken); 275MethodCallExpression monitorExit = Expression.Call(ServiceLookupHelpers.MonitorExitMethodInfo, sync); 277BlockExpression tryBody = Expression.Block(monitorEnter, blockExpression); 278ConditionalExpression finallyBody = Expression.IfThen(lockWasTaken, monitorExit); 280return Expression.Condition( 281Expression.Property( 286Expression.Block( 289Expression.TryFinally(tryBody, finallyBody)) 293public static Expression GetCaptureDisposable(ParameterExpression scope)
Microsoft.Extensions.DependencyInjection.Abstractions (28)
ActivatorUtilities.cs (28)
292CreateFactoryInternal(instanceType, argumentTypes, out ParameterExpression provider, out ParameterExpression argumentArray, out Expression factoryExpressionBody); 294var factoryLambda = Expression.Lambda<ObjectFactory>( 325CreateFactoryInternal(typeof(T), argumentTypes, out ParameterExpression provider, out ParameterExpression argumentArray, out Expression factoryExpressionBody); 327var factoryLambda = Expression.Lambda<ObjectFactory<T>>( 334private static void CreateFactoryInternal([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type instanceType, Type[] argumentTypes, out ParameterExpression provider, out ParameterExpression argumentArray, out Expression factoryExpressionBody) 338provider = Expression.Parameter(typeof(IServiceProvider), "provider"); 339argumentArray = Expression.Parameter(typeof(object[]), "argumentArray"); 398Expression serviceProvider, 399Expression factoryArgumentArray) 402var constructorArguments = new Expression[constructorParameters.Length]; 412constructorArguments[i] = Expression.ArrayAccess(factoryArgumentArray, Expression.Constant(parameterMap[i])); 417var parameterTypeExpression = new Expression[] { serviceProvider, 418Expression.Constant(parameterType, typeof(Type)), 419Expression.Constant(constructor.DeclaringType, typeof(Type)), 420Expression.Constant(hasDefaultValue), 421Expression.Constant(keyAttribute?.Key, typeof(object)) }; 422constructorArguments[i] = Expression.Call(GetServiceInfo, parameterTypeExpression); 429ConstantExpression? defaultValueExpression = Expression.Constant(defaultValue); 430constructorArguments[i] = Expression.Coalesce(constructorArguments[i], defaultValueExpression); 433constructorArguments[i] = Expression.Convert(constructorArguments[i], parameterType); 436return Expression.Block(Expression.IfThen(Expression.Equal(serviceProvider, Expression.Constant(null)), Expression.Throw(Expression.Constant(new ArgumentNullException(nameof(serviceProvider))))), 437Expression.New(constructor, constructorArguments));
Microsoft.VisualBasic.Core (127)
Microsoft\VisualBasic\CompilerServices\IDOBinder.vb (121)
313Dim arguments As Expression() = Nothing 322Dim result As ParameterExpression = Expression.Variable(GetType(Object), "result") 323Dim array As ParameterExpression = Expression.Variable(GetType(Object()), "array") 325Dim fallback As Expression = 326Expression.Call( 329Expression.Constant(Name, GetType(String)), 330Expression.Assign( 332Expression.NewArrayInit(GetType(Object), arguments) 334Expression.Constant(argNames, GetType(String())), 335Expression.Constant(_ignoreReturn, GetType(Boolean)) 339Expression.Block( 341Expression.Assign(result, fallback), 392Dim arguments As Expression() = Nothing 401Dim result As ParameterExpression = Expression.Variable(GetType(Object), "result") 402Dim array As ParameterExpression = Expression.Variable(GetType(Object()), "array") 404Dim fallback As Expression = 405Expression.Call( 408Expression.Constant(Name), 409Expression.Assign( 411Expression.NewArrayInit(GetType(Object), arguments) 413Expression.Constant(argNames, GetType(String())) 417Expression.Block( 419Expression.Assign(result, fallback), 480Dim arguments As Expression() = Nothing 489Dim result As ParameterExpression = Expression.Variable(GetType(Object), "result") 490Dim array As ParameterExpression = Expression.Variable(GetType(Object()), "array") 492Dim fallback As Expression = Expression.Call( 495Expression.Assign( 497Expression.NewArrayInit(GetType(Object), arguments) 499Expression.Constant(argNames, GetType(String())), 500Expression.Constant(_lateCall) 504Expression.Block( 506Expression.Assign(result, fallback), 549Dim arguments As Expression() = Nothing 558Dim result As ParameterExpression = Expression.Variable(GetType(Object), "result") 559Dim array As ParameterExpression = Expression.Variable(GetType(Object()), "array") 561Dim fallback As Expression = Expression.Call( 564Expression.Assign( 566Expression.NewArrayInit(GetType(Object), arguments) 568Expression.Constant(argNames, GetType(String())), 569Expression.Constant(_reportErrors) 573Expression.Block( 575Expression.Assign(result, fallback), 618Dim arguments As Expression() = Nothing 627Dim result As ParameterExpression = Expression.Variable(GetType(Object), "result") 628Dim array As ParameterExpression = Expression.Variable(GetType(Object()), "array") 630Dim fallback As Expression = Expression.Call( 633Expression.Assign( 635Expression.NewArrayInit(GetType(Object), arguments) 637Expression.Constant(argNames, GetType(String())), 638Expression.Constant(_reportErrors) 642Expression.Block( 644Expression.Assign(result, fallback), 688Dim valueExpression As Expression = IDOUtils.ConvertToObject(value.Expression()) 689Dim arguments() As Expression = {valueExpression} 691Dim fallback As Expression = Expression.Call( 694Expression.Constant(Name), 695Expression.NewArrayInit(GetType(Object), arguments) 699Expression.Block(fallback, valueExpression), 745Dim valueExpression As Expression = IDOUtils.ConvertToObject(value.Expression()) 746Dim arguments() As Expression = {valueExpression} 748Dim fallback As Expression = Expression.Call( 751Expression.Constant(Name), 752Expression.NewArrayInit(GetType(Object), arguments), 753Expression.Constant(_optimisticSet), 754Expression.Constant(_rValueBase) 758Expression.Block(fallback, valueExpression), 793Return New DynamicMetaObject(Expression.Constant(IDOBinder.missingMemberSentinel), IDOUtils.CreateRestrictions(target)) 842Dim fallback As Expression = Expression.Call( 845Expression.Constant(Me.Type(), GetType(System.Type)) 848Return New DynamicMetaObject(Expression.Convert(fallback, ReturnType), IDOUtils.CreateRestrictions(target)) 891Dim fallback As Expression = Expression.Call( 893Expression.Constant(_Op, GetType(Object)), 894Expression.NewArrayInit(GetType(Object), New Expression() {IDOUtils.ConvertToObject(target.Expression)}) 940Dim fallback As Expression = Expression.Call( 942Expression.Constant(_Op, GetType(Object)), 943Expression.NewArrayInit(GetType(Object), New Expression() { 987Dim indexes As Expression() = Nothing 1001Dim valueExpression As Expression = IDOUtils.ConvertToObject(value.Expression) 1002Dim indexesPlusValue(indexes.Length) As Expression 1006Dim fallback As Expression = Expression.Call( 1009Expression.NewArrayInit(GetType(Object), indexesPlusValue), 1010Expression.Constant(indexNames, GetType(String())) 1014Expression.Block(fallback, valueExpression), 1060Dim indexes As Expression() = Nothing 1074Dim valueExpression As Expression = IDOUtils.ConvertToObject(value.Expression) 1075Dim indexesPlusValue(indexes.Length) As Expression 1079Dim fallback As Expression = Expression.Call( 1082Expression.NewArrayInit(GetType(Object), indexesPlusValue), 1083Expression.Constant(indexNames, GetType(String())), 1084Expression.Constant(_optimisticSet), 1085Expression.Constant(_rValueBase) 1089Expression.Block(fallback, valueExpression), 1270ByRef args As Expression(), 1283args = New Expression(argCount - 1) {} 1306Public Shared Function GetWriteBack(ByVal arguments() As Expression, ByVal array As ParameterExpression) As Expression 1307Dim writeback As New List(Of Expression) 1311writeback.Add(Expression.Assign(arg, Expression.ArrayIndex(array, Expression.Constant(i)))) 1316Return Expression.Empty() 1320Return Expression.Block(writeback) 1325Public Shared Function ConvertToObject(ByVal valueExpression As Expression) As Expression 1326Return If(valueExpression.Type.Equals(GetType(Object)), valueExpression, Expression.Convert(valueExpression, GetType(Object))) 1379Dim CallSiteDelegate As Type = Expression.GetDelegateType(CallSiteSignature) 1455Dim c As CallSite = CallSite.Create(Expression.GetDelegateType(delegateArgTypes), action) 1481Dim c As CallSite = CallSite.Create(Expression.GetFuncType(delegateArgTypes), GetCachedBinder(action))
Microsoft\VisualBasic\CompilerServices\Utils.vb (6)
355Dim parameter1 As ParameterExpression = Expression.Parameter(MemberInfo) 356Dim parameter2 As ParameterExpression = Expression.Parameter(MemberInfo) 357Dim memberEquivalence As Func(Of MethodBase, MethodBase, Boolean) = Expression.Lambda(Of Func(Of MethodBase, MethodBase, Boolean))( 358Expression.Equal( 359Expression.Property(parameter1, [property]), 360Expression.Property(parameter2, [property])),
netstandard (1)
netstandard.cs (1)
996[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Linq.Expressions.Expression))]
PresentationFramework (45)
MS\Internal\WindowsRuntime\Generated\WinRT\Marshalers.cs (42)
370var parms = new[] { Expression.Parameter(typeof(T), "arg") }; 371return Expression.Lambda<Func<T, object>>( 372Expression.Convert(Expression.Call(HelperType.GetMethod("CreateMarshaler", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static), parms), 379var parms = new[] { Expression.Parameter(typeof(object), "arg") }; 380return Expression.Lambda<Func<object, object>>( 381Expression.Convert(Expression.Call(HelperType.GetMethod("GetAbi", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static), 382new[] { Expression.Convert(parms[0], MarshalerType) }), 391var parms = new[] { Expression.Parameter(typeof(object), "arg"), Expression.Parameter(typeof(IntPtr), "dest") }; 392return Expression.Lambda<Action<object, IntPtr>>( 393Expression.Call(copyAbi, 394new Expression[] { Expression.Convert(parms[0], MarshalerType), parms[1] }), parms).Compile(); 400var parms = new[] { Expression.Parameter(typeof(object), "arg") }; 401return Expression.Lambda<Func<object, T>>( 402Expression.Call(HelperType.GetMethod("FromAbi", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static), 403new[] { Expression.Convert(parms[0], AbiType) }), parms).Compile(); 409var parms = new[] { Expression.Parameter(typeof(T), "arg") }; 410return Expression.Lambda<Func<T, object>>( 411Expression.Convert(Expression.Call(HelperType.GetMethod("FromManaged", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static), parms), 420var parms = new[] { Expression.Parameter(typeof(T), "arg"), Expression.Parameter(typeof(IntPtr), "dest") }; 421return Expression.Lambda<Action<T, IntPtr>>( 422Expression.Call(copyManaged, parms), parms).Compile(); 428var parms = new[] { Expression.Parameter(typeof(object), "arg") }; 429return Expression.Lambda<Action<object>>( 430Expression.Call(HelperType.GetMethod("DisposeMarshaler", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static), 431new[] { Expression.Convert(parms[0], MarshalerType) }), parms).Compile(); 885var parms = new[] { Expression.Parameter(typeof(IntPtr), "arg") }; 886return Expression.Lambda<Func<IntPtr, T>>( 887Expression.New(objReferenceConstructor, 888Expression.Call(fromAbiMethod, parms[0])), parms).Compile(); 893var parms = new[] { Expression.Parameter(typeof(T), "arg") }; 894return Expression.Lambda<Func<T, IObjectReference>>( 895Expression.MakeMemberAccess( 896Expression.Convert(parms[0], HelperType), 903var parms = new[] { Expression.Parameter(typeof(IObjectReference), "arg") }; 904return Expression.Lambda<Func<IObjectReference, IObjectReference>>( 905Expression.Call(
MS\Internal\WindowsRuntime\Generated\WinRT\Projections\IEnumerable.cs (1)
429private static readonly Type get_Current_0_Type = Expression.GetDelegateType(new Type[] { typeof(void*), Marshaler<T>.AbiType.MakeByRefType(), typeof(int) });
MS\Internal\WindowsRuntime\Generated\WinRT\Projections\IReadOnlyList.cs (2)
219private static readonly Type GetAt_0_Type = Expression.GetDelegateType(new Type[] { typeof(void*), typeof(uint), Marshaler<T>.AbiType.MakeByRefType(), typeof(int) }); 220private static readonly Type IndexOf_2_Type = Expression.GetDelegateType(new Type[] { typeof(void*), Marshaler<T>.AbiType, typeof(uint).MakeByRefType(), typeof(byte).MakeByRefType(), typeof(int) });
PresentationFramework-SystemCore (5)
DynamicAccessorImpl.cs (5)
76delegateType = Expression.GetDelegateType(typeArgs); 96delegateType = Expression.GetDelegateType(typeArgs); 235Expression.Throw( 236Expression.New( 238Expression.Constant(message)
System.ComponentModel.Composition (49)
System\ComponentModel\Composition\ConstraintServices.cs (48)
25ParameterExpression parameter = Expression.Parameter(typeof(ExportDefinition), "exportDefinition"); 27Expression constraintBody = ConstraintServices.CreateContractConstraintBody(contractName, parameter); 31Expression typeIdentityConstraintBody = ConstraintServices.CreateTypeIdentityConstraint(requiredTypeIdentity, parameter); 33constraintBody = Expression.AndAlso(constraintBody, typeIdentityConstraintBody); 38Expression? metadataConstraintBody = ConstraintServices.CreateMetadataConstraintBody(requiredMetadata, parameter); 41constraintBody = Expression.AndAlso(constraintBody, metadataConstraintBody); 47Expression policyConstraintBody = ConstraintServices.CreateCreationPolicyConstraint(requiredCreationPolicy, parameter); 49constraintBody = Expression.AndAlso(constraintBody, policyConstraintBody); 52Expression<Func<ExportDefinition, bool>> constraint = Expression.Lambda<Func<ExportDefinition, bool>>(constraintBody, parameter); 61return Expression.Equal( 62Expression.Property(parameter, ConstraintServices._exportDefinitionContractNameProperty), 63Expression.Constant(contractName ?? string.Empty, typeof(string))); 66private static Expression? CreateMetadataConstraintBody(IEnumerable<KeyValuePair<string, Type>> requiredMetadata, ParameterExpression parameter) 71Expression? body = null; 75Expression metadataItemExpression = CreateMetadataContainsKeyExpression(parameter, requiredMetadataItem.Key); 77body = (body != null) ? Expression.AndAlso(body, metadataItemExpression) : metadataItemExpression; 78body = Expression.AndAlso(body, CreateMetadataOfTypeExpression(parameter, requiredMetadataItem.Key, requiredMetadataItem.Value)); 97return Expression.MakeBinary(ExpressionType.OrElse, 98Expression.MakeBinary(ExpressionType.OrElse, 99Expression.Not(CreateMetadataContainsKeyExpression(parameter, CompositionConstants.PartCreationPolicyMetadataName)), 112return Expression.MakeBinary(ExpressionType.AndAlso, 130return Expression.Call( 131Expression.Property(parameter, ConstraintServices._exportDefinitionMetadataProperty), 133Expression.Constant(constantKey)); 154return Expression.Call( 155Expression.Constant(constantType, typeof(Type)), 157Expression.Call( 158Expression.Property(parameter, ConstraintServices._exportDefinitionMetadataProperty), 160Expression.Constant(constantKey)) 177return Expression.Call( 178Expression.Constant(constantValue), 180Expression.Call( 181Expression.Property(parameter, ConstraintServices._exportDefinitionMetadataProperty), 183Expression.Constant(metadataName))); 191Expression metadataExpression = Expression.Property(exportDefinitionParameter, ConstraintServices._exportDefinitionMetadataProperty); 194Expression containsProductExpression = Expression.Call( 197Expression.Constant(CompositionConstants.ProductDefinitionMetadataName)); 200Expression productExportDefinitionExpression = Expression.Call( 203Expression.Constant(CompositionConstants.ProductDefinitionMetadataName)); 206Expression productMatchExpression = 207Expression.Invoke(productImportDefinition.Constraint, 208Expression.Convert(productExportDefinitionExpression, typeof(ExportDefinition))); 214Expression.Lambda<Func<ExportDefinition, bool>>( 215Expression.AndAlso( 217Expression.AndAlso(
System\ComponentModel\Composition\Primitives\ExportedDelegate.cs (1)
57return Expression.GetDelegateType(parameterTypes);
System.ComponentModel.Composition.Registration (4)
System\ComponentModel\Composition\Registration\PartBuilderOfT.cs (4)
49Expression expr = Reduce(propertyFilter).Body; 104Expression expr = Reduce(constructorFilter).Body; 116foreach (Expression argument in newExpression.Arguments) 123Expression parameter = methodCallExpression.Arguments[0];
System.Composition.Convention (5)
System\Composition\Convention\PartConventionBuilderOfT.cs (5)
37Expression expr = Reduce(methodSelector).Body; 108Expression expr = Reduce(propertySelector).Body; 167Expression expr = Reduce(constructorSelector).Body; 178foreach (Expression argument in newExpression.Arguments) 185Expression parameter = methodCallExpression.Arguments[0];
System.Composition.Hosting (15)
System\Composition\Hosting\Providers\Metadata\MetadataViewProvider.cs (15)
36var providerArg = Expression.Parameter(typeof(IDictionary<string, object>), "metadata"); 37return Expression.Lambda<Func<IDictionary<string, object>, TMetadata>>( 38Expression.New(dictionaryConstructor, providerArg), 46var providerArg = Expression.Parameter(typeof(IDictionary<string, object>), "metadata"); 47var resultVar = Expression.Variable(typeof(TMetadata), "result"); 49var blockExprs = new List<Expression>(); 50blockExprs.Add(Expression.Assign(resultVar, Expression.New(parameterlessConstructor))); 57var dva = Expression.Constant(prop.GetCustomAttribute<DefaultValueAttribute>(false), typeof(DefaultValueAttribute)); 58var name = Expression.Constant(prop.Name, typeof(string)); 60var assign = Expression.Assign( 61Expression.Property(resultVar, prop), 62Expression.Call(null, m, providerArg, name, dva)); 68return Expression.Lambda<Func<IDictionary<string, object>, TMetadata>>( 69Expression.Block(new[] { resultVar }, blockExprs), providerArg)
System.Composition.TypedParts (37)
System\Composition\TypedParts\ActivationFeatures\OnImportsSatisfiedFeature.cs (4)
53var ois = Expression.Parameter(typeof(object), "ois"); 54var call = Expression.Lambda<Action<object>>( 55Expression.Call(Expression.Convert(ois, partType.AsType()), m), ois).Compile();
System\Composition\TypedParts\ActivationFeatures\PropertyInjectionFeature.cs (14)
74var lc = Expression.Parameter(typeof(LifetimeContext)); 75var op = Expression.Parameter(typeof(CompositionOperation)); 76var inst = Expression.Parameter(typeof(object)); 77var typed = Expression.Variable(partType.AsType()); 79var statements = new List<Expression>(); 80var assignTyped = Expression.Assign(typed, Expression.Convert(inst, partType.AsType())); 87var assignment = Expression.Assign( 88Expression.MakeMemberAccess(typed, property), 89Expression.Convert( 90Expression.Call( 91Expression.Constant(d.Value.Target.GetDescriptor().Activator), 102var setAll = Expression.Block(new[] { typed }, statements); 103var setAction = Expression.Lambda<Func<object, LifetimeContext, CompositionOperation, object>>(
System\Composition\TypedParts\Discovery\DiscoveredPart.cs (12)
168var contextParam = Expression.Parameter(typeof(LifetimeContext), "cc"); 169var operationParm = Expression.Parameter(typeof(CompositionOperation), "op"); 172Expression[] paramActivatorCalls = new Expression[cps.Length]; 187Expression.Convert(Expression.Call(Expression.Constant(a), s_activatorInvoke, contextParam, operationParm), pi.ParameterType); 191paramActivatorCalls[i] = Expression.Default(pi.ParameterType); 195Expression body = Expression.Convert(Expression.New(_constructor, paramActivatorCalls), typeof(object)); 197var activator = Expression
System\Composition\TypedParts\Discovery\DiscoveredPropertyExport.cs (7)
25var args = new[] { Expression.Parameter(typeof(LifetimeContext)), Expression.Parameter(typeof(CompositionOperation)) }; 27var activator = Expression.Lambda<CompositeActivator>( 28Expression.Property( 29Expression.Convert(Expression.Call(Expression.Constant(partActivator), s_activatorInvoke, args), _property.DeclaringType),
System.Core (1)
System.Core.cs (1)
134[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Linq.Expressions.Expression))]
System.Linq.Expressions (2815)
System\Dynamic\BinaryOperationBinder.cs (1)
13[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)]
System\Dynamic\BindingRestrictions.cs (35)
34internal abstract Expression GetExpression(); 63public static BindingRestrictions GetTypeRestriction(Expression expression, Type type) 94public static BindingRestrictions GetInstanceRestriction(Expression expression, object? instance) 110public static BindingRestrictions GetExpressionRestriction(Expression expression) 151internal Expression Node; 162internal Expression ToExpression() 164Expression result = _tests.Pop().Node; 167result = Expression.AndAlso(_tests.Pop().Node, result); 172private void Push(Expression node, int depth) 176node = Expression.AndAlso(_tests.Pop().Node, node); 184/// Creates the <see cref="Expression"/> representing the binding restrictions. 187public Expression ToExpression() => GetExpression(); 200internal override Expression GetExpression() 237private readonly Expression _expression; 239internal CustomRestriction(Expression expression) 252internal override Expression GetExpression() => _expression; 257private readonly Expression _expression; 260internal TypeRestriction(Expression parameter, Type type) 275internal override Expression GetExpression() => Expression.TypeEqual(_expression, _type); 280private readonly Expression _expression; 283internal InstanceRestriction(Expression parameter, object? instance) 298internal override Expression GetExpression() 302return Expression.Equal( 303Expression.Convert(_expression, typeof(object)), 308ParameterExpression temp = Expression.Parameter(typeof(object), null); 309return Expression.Block( 311new TrueReadOnlyCollection<Expression>( 321Expression.Assign( 323Expression.Constant(_instance, typeof(object)) 326Expression.AndAlso( 328Expression.NotEqual(temp, AstUtils.Null), 329Expression.Equal( 330Expression.Convert(_expression, typeof(object)), 353public Expression Test => _node.ToExpression();
System\Dynamic\ConvertBinder.cs (1)
13[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)]
System\Dynamic\CreateInstanceBinder.cs (1)
13[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)]
System\Dynamic\DeleteIndexBinder.cs (1)
13[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)]
System\Dynamic\DeleteMemberBinder.cs (1)
13[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)]
System\Dynamic\DynamicMetaObject.cs (8)
26public DynamicMetaObject(Expression expression, BindingRestrictions restrictions) 41public DynamicMetaObject(Expression expression, BindingRestrictions restrictions, object value) 54public Expression Expression { get; } 254internal static Expression[] GetExpressions(DynamicMetaObject[] objects) 258Expression[] res = new Expression[objects.Length]; 263Expression expr = mo.Expression; 281public static DynamicMetaObject Create(object value, Expression expression)
System\Dynamic\DynamicMetaObjectBinder.cs (10)
23[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)] 48/// to produce a new <see cref="Expression"/> for the new argument types. 50public sealed override Expression Bind(object[] args, ReadOnlyCollection<ParameterExpression> parameters, LabelTarget returnLabel) 90Expression body = binding.Expression; 125body = Expression.Return(returnLabel, body); 131body = Expression.IfThen(restrictions.ToExpression(), body); 169/// <param name="type">The <see cref="Expression.Type">Type</see> property of the resulting expression; any type is allowed.</param> 171public Expression GetUpdateExpression(Type type) 173return Expression.Goto(CallSiteBinder.UpdateLabel, type); 218DynamicExpression.Make(ReturnType, delegateType, this, new TrueReadOnlyCollection<Expression>(exprs)),
System\Dynamic\DynamicObject.cs (90)
26[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)] 209[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)] 212internal MetaDynamic(Expression expression, DynamicObject value) 438private static readonly Expression[] s_noArgs = new Expression[0]; 441private static ReadOnlyCollection<Expression> GetConvertedArgs(params Expression[] args) 443var paramArgs = new Expression[args.Length]; 447paramArgs[i] = Expression.Convert(args[i], typeof(object)); 450return new TrueReadOnlyCollection<Expression>(paramArgs); 457private static Expression ReferenceArgAssign(Expression callArgs, Expression[] args) 459ReadOnlyCollectionBuilder<Expression>? block = null; 468block ??= new ReadOnlyCollectionBuilder<Expression>(); 471Expression.Assign( 473Expression.Convert( 474Expression.ArrayIndex( 486return Expression.Block(block); 497private static Expression[] BuildCallArgs<TBinder>(TBinder binder, Expression[] parameters, Expression arg0, Expression? arg1) 501return arg1 != null ? new Expression[] { Constant(binder), arg0, arg1 } : new Expression[] { Constant(binder), arg0 }; 503return arg1 != null ? new Expression[] { Constant(binder), arg1 } : new Expression[] { Constant(binder) }; 508return Expression.Constant(binder, typeof(TBinder)); 515private DynamicMetaObject CallMethodWithResult<TBinder>(MethodInfo method, TBinder binder, Expression[] args, Fallback<TBinder> fallback) 525private DynamicMetaObject CallMethodWithResult<TBinder>(MethodInfo method, TBinder binder, Expression[] args, Fallback<TBinder> fallback, Fallback<TBinder>? fallbackInvoke) 555private DynamicMetaObject BuildCallMethodWithResult<TBinder>(MethodInfo method, TBinder binder, Expression[] args, DynamicMetaObject fallbackResult, Fallback<TBinder>? fallbackInvoke) 570ParameterExpression result = Expression.Parameter(typeof(object), null); 571ParameterExpression callArgs = method != DynamicObject_TryBinaryOperation ? Expression.Parameter(typeof(object[]), null) : Expression.Parameter(typeof(object), null); 572ReadOnlyCollection<Expression> callArgsValue = GetConvertedArgs(args); 581UnaryExpression convert = Expression.Convert(resultMO.Expression, binder.ReturnType); 593Expression condition; 597condition = Expression.TypeIs(resultMO.Expression, binder.ReturnType); 601condition = Expression.OrElse( 602Expression.Equal(resultMO.Expression, AstUtils.Null), 603Expression.TypeIs(resultMO.Expression, binder.ReturnType)); 606Expression checkedConvert = Expression.Condition( 609Expression.Throw( 610Expression.New( 612new TrueReadOnlyCollection<Expression>( 613Expression.Call( 615Expression.Constant(convertFailed), 616Expression.NewObjectArrayInit( 617new TrueReadOnlyCollection<Expression>( 618Expression.Condition( 619Expression.Equal(resultMO.Expression, AstUtils.Null), 620Expression.Constant("null"), 621Expression.Call( 646Expression.Block( 648new TrueReadOnlyCollection<Expression>( 649method != DynamicObject_TryBinaryOperation ? Expression.Assign(callArgs, Expression.NewObjectArrayInit(callArgsValue)) : Expression.Assign(callArgs, callArgsValue[0]), 650Expression.Condition( 651Expression.Call( 661Expression.Block( 684private DynamicMetaObject CallMethodReturnLast<TBinder>(MethodInfo method, TBinder binder, Expression[] args, Expression value, Fallback<TBinder> fallback) 701ParameterExpression result = Expression.Parameter(typeof(object), null); 702ParameterExpression callArgs = Expression.Parameter(typeof(object[]), null); 703ReadOnlyCollection<Expression> callArgsValue = GetConvertedArgs(args); 706Expression.Block( 708new TrueReadOnlyCollection<Expression>( 709Expression.Assign(callArgs, Expression.NewObjectArrayInit(callArgsValue)), 710Expression.Condition( 711Expression.Call( 718Expression.Assign(result, Expression.Convert(value, typeof(object))) 721Expression.Block( 753private DynamicMetaObject CallMethodNoResult<TBinder>(MethodInfo method, TBinder binder, Expression[] args, Fallback<TBinder> fallback) 761ParameterExpression callArgs = Expression.Parameter(typeof(object[]), null); 762ReadOnlyCollection<Expression> callArgsValue = GetConvertedArgs(args); 769Expression.Block( 771new TrueReadOnlyCollection<Expression>( 772Expression.Assign(callArgs, Expression.NewObjectArrayInit(callArgsValue)), 773Expression.Condition( 774Expression.Call( 784Expression.Block( 843private Expression GetLimitedSelf() 851return Expression.Convert(Expression, typeof(DynamicObject)); 860[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)] 888public virtual DynamicMetaObject GetMetaObject(Expression parameter) => new MetaDynamic(parameter, this);
System\Dynamic\ExpandoObject.cs (30)
293DynamicMetaObject IDynamicMetaObjectProvider.GetMetaObject(Expression parameter) 778public MetaExpando(Expression expression, ExpandoObject value) 790ParameterExpression value = Expression.Parameter(typeof(object), "value"); 792Expression tryGetValue = Expression.Call( 795Expression.Constant(klass, typeof(object)), 797Expression.Constant(name), 809Expression.Block( 811new TrueReadOnlyCollection<Expression>( 812Expression.Condition( 865Expression.Call( 868Expression.Constant(klass, typeof(object)), 870Expression.Convert(value.Expression, typeof(object)), 871Expression.Constant(binder.Name), 885Expression tryDelete = Expression.Call( 888Expression.Constant(Value.Class, typeof(object)), 890Expression.Constant(binder.Name), 896Expression.IfThen(Expression.Not(tryDelete), fallback.Expression), 923Expression ifTestSucceeds = succeeds.Expression; 932ifTestSucceeds = Expression.Block( 933Expression.Call( 937Expression.Constant(originalClass, typeof(object)), 938Expression.Constant(klass, typeof(object)) 945Expression.Condition( 946Expression.Call( 950Expression.Constant(originalClass ?? klass, typeof(object)) 995private Expression GetLimitedSelf() 1001return Expression.Convert(Expression, LimitType);
System\Dynamic\GetIndexBinder.cs (1)
13[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)]
System\Dynamic\GetMemberBinder.cs (1)
13[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)]
System\Dynamic\IDynamicMetaObjectProvider.cs (1)
22DynamicMetaObject GetMetaObject(Expression parameter);
System\Dynamic\InvokeBinder.cs (1)
13[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)]
System\Dynamic\InvokeMemberBinder.cs (1)
13[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)]
System\Dynamic\SetIndexBinder.cs (1)
13[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)]
System\Dynamic\SetMemberBinder.cs (1)
13[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)]
System\Dynamic\UnaryOperationBinder.cs (1)
13[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)]
System\Dynamic\UpdateDelegates.Generated.cs (20)
13[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)] 159[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)] 305[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)] 451[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)] 597[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)] 743[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)] 889[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)] 1035[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)] 1181[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)] 1327[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)] 1473[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)] 1618[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)] 1763[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)] 1908[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)] 2053[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)] 2198[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)] 2343[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)] 2488[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)] 2633[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)] 2778[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)]
System\Dynamic\Utils\DelegateHelpers.cs (1)
127[RequiresDynamicCode(Expression.GenericMethodRequiresDynamicCode)]
System\Dynamic\Utils\ExpressionUtils.cs (15)
66public static ReadOnlyCollection<Expression> ReturnReadOnly(IArgumentProvider provider, ref object collection) 68if (collection is Expression tObj) 73new ReadOnlyCollection<Expression>(new ListArgumentProvider(provider, tObj)), 79return (ReadOnlyCollection<Expression>)collection; 100public static void ValidateArgumentTypes(MethodBase method, ExpressionType nodeKind, ref ReadOnlyCollection<Expression> arguments, string? methodParamName) 108Expression[]? newArgs = null; 111Expression arg = arguments[i]; 117newArgs = new Expression[arguments.Count]; 130arguments = new TrueReadOnlyCollection<Expression>(newArgs); 154public static Expression ValidateOneArgument(MethodBase method, ExpressionType nodeKind, Expression arguments, ParameterInfo pi, string? methodParamName, string argumentParamName, int index = -1) 186public static void RequiresCanRead(Expression expression, string paramName) 191public static void RequiresCanRead(Expression expression, string paramName, int idx) 219public static bool TryQuote(Type parameterType, ref Expression argument) 228argument = Expression.Quote(argument);
System\Dynamic\Utils\ExpressionVisitorUtils.cs (10)
10public static Expression[]? VisitBlockExpressions(ExpressionVisitor visitor, BlockExpression block) 12Expression[]? newNodes = null; 15Expression curNode = block.GetExpression(i); 16Expression node = visitor.Visit(curNode); 24newNodes = new Expression[n]; 60public static Expression[]? VisitArguments(ExpressionVisitor visitor, IArgumentProvider nodes) 62Expression[]? newNodes = null; 65Expression curNode = nodes.GetArgument(i); 66Expression node = visitor.Visit(curNode); 74newNodes = new Expression[n];
System\Dynamic\Utils\ListArgumentProvider.cs (5)
154internal sealed class ListArgumentProvider : ListProvider<Expression> 157private readonly Expression _arg0; 159internal ListArgumentProvider(IArgumentProvider provider, Expression arg0) 165protected override Expression First => _arg0; 167protected override Expression GetElement(int index) => _provider.GetArgument(index);
System\Linq\Expressions\BinaryExpression.cs (459)
20internal BinaryExpression(Expression left, Expression right) 64public Expression Right { get; } 69public Expression Left { get; } 92public BinaryExpression Update(Expression left, LambdaExpression? conversion, Expression right) 102return Expression.ReferenceEqual(left, right); 106return Expression.ReferenceNotEqual(left, right); 109return Expression.MakeBinary(NodeType, left, right, IsLiftedToNull, Method, conversion); 119public override Expression Reduce() 158private Expression ReduceVariable() 164Expression r = Expression.MakeBinary(op, Left, Right, false, Method); 168r = Expression.Invoke(conversion, r); 170return Expression.Assign(Left, r); 173private Expression ReduceMember() 193Expression e1 = Expression.Assign(temp1, member.Expression); 197Expression e2 = Expression.MakeBinary(op, Expression.MakeMemberAccess(temp1, member.Member), Right, false, Method); 201e2 = Expression.Invoke(conversion, e2); 204e2 = Expression.Assign(temp2, e2); 207Expression e3 = Expression.Assign(Expression.MakeMemberAccess(temp1, member.Member), temp2); 210Expression e4 = temp2; 212return Expression.Block( 214new TrueReadOnlyCollection<Expression>(e1, e2, e3, e4) 219private Expression ReduceIndex() 235var exprs = new ArrayBuilder<Expression>(index.ArgumentCount + 3); 237ParameterExpression tempObj = Expression.Variable(index.Object!.Type, "tempObj"); 239exprs.UncheckedAdd(Expression.Assign(tempObj, index.Object)); 242var tempArgs = new ArrayBuilder<Expression>(n); 245Expression arg = index.GetArgument(i); 246ParameterExpression tempArg = Expression.Variable(arg.Type, "tempArg" + i); 249exprs.UncheckedAdd(Expression.Assign(tempArg, arg)); 252IndexExpression tempIndex = Expression.MakeIndex(tempObj, index.Indexer, tempArgs.ToReadOnly()); 256Expression op = Expression.MakeBinary(binaryOp, tempIndex, Right, false, Method); 260op = Expression.Invoke(conversion, op); 262ParameterExpression tempValue = Expression.Variable(op.Type, "tempValue"); 264exprs.UncheckedAdd(Expression.Assign(tempValue, op)); 267exprs.UncheckedAdd(Expression.Assign(tempIndex, tempValue)); 269return Expression.Block(vars.ToReadOnly(), exprs.ToReadOnly()); 308protected internal override Expression Accept(ExpressionVisitor visitor) 313internal static BinaryExpression Create(ExpressionType nodeType, Expression left, Expression right, Type type, MethodInfo? method, LambdaExpression? conversion) 393internal Expression ReduceUserdefinedLifted() 405new TrueReadOnlyCollection<Expression>( 414new TrueReadOnlyCollection<Expression>( 460internal LogicalBinaryExpression(ExpressionType nodeType, Expression left, Expression right) 474internal AssignBinaryExpression(Expression left, Expression right) 479public static AssignBinaryExpression Make(Expression left, Expression right, bool byRef) 500internal ByRefAssignBinaryExpression(Expression left, Expression right) 515internal CoalesceConversionBinaryExpression(Expression left, Expression right, LambdaExpression conversion) 535internal OpAssignMethodConversionBinaryExpression(ExpressionType nodeType, Expression left, Expression right, Type type, MethodInfo method, LambdaExpression conversion) 548internal SimpleBinaryExpression(ExpressionType nodeType, Expression left, Expression right, Type type) 566internal MethodBinaryExpression(ExpressionType nodeType, Expression left, Expression right, Type type, MethodInfo method) 582/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 583/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 587public static BinaryExpression Assign(Expression left, Expression right) 602private static BinaryExpression? GetUserDefinedBinaryOperator(ExpressionType binaryType, string name, Expression left, Expression right, bool liftToNull) 631private static BinaryExpression GetMethodBasedBinaryOperator(ExpressionType binaryType, Expression left, Expression right, MethodInfo method, bool liftToNull) 662private static BinaryExpression GetMethodBasedAssignOperator(ExpressionType binaryType, Expression left, Expression right, MethodInfo method, LambdaExpression? conversion, bool liftToNull) 682private static BinaryExpression GetUserDefinedBinaryOperatorOrThrow(ExpressionType binaryType, string name, Expression left, Expression right, bool liftToNull) 695private static BinaryExpression GetUserDefinedAssignOperatorOrThrow(ExpressionType binaryType, string name, Expression left, Expression right, LambdaExpression? conversion, bool liftToNull) 777private static bool IsNullComparison(Expression left, Expression right) 793private static bool IsNullConstant(Expression e) 870public static BinaryExpression MakeBinary(ExpressionType binaryType, Expression left, Expression right) 884public static BinaryExpression MakeBinary(ExpressionType binaryType, Expression left, Expression right, bool liftToNull, MethodInfo? method) 900public static BinaryExpression MakeBinary(ExpressionType binaryType, Expression left, Expression right, bool liftToNull, MethodInfo? method, LambdaExpression? conversion) => 950/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 951/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 954public static BinaryExpression Equal(Expression left, Expression right) 962/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 963/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 969public static BinaryExpression Equal(Expression left, Expression right, bool liftToNull, MethodInfo? method) 983/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 984/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 988public static BinaryExpression ReferenceEqual(Expression left, Expression right) 1002/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1003/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1006public static BinaryExpression NotEqual(Expression left, Expression right) 1014/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1015/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1021public static BinaryExpression NotEqual(Expression left, Expression right, bool liftToNull, MethodInfo? method) 1035/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1036/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1040public static BinaryExpression ReferenceNotEqual(Expression left, Expression right) 1051private static BinaryExpression GetEqualityComparisonOperator(ExpressionType binaryType, string opName, Expression left, Expression right, bool liftToNull) 1095/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1096/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1099public static BinaryExpression GreaterThan(Expression left, Expression right) 1107/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1108/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1114public static BinaryExpression GreaterThan(Expression left, Expression right, bool liftToNull, MethodInfo? method) 1128/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1129/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1133public static BinaryExpression LessThan(Expression left, Expression right) 1141/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1142/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1148public static BinaryExpression LessThan(Expression left, Expression right, bool liftToNull, MethodInfo? method) 1162/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1163/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1166public static BinaryExpression GreaterThanOrEqual(Expression left, Expression right) 1174/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1175/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1181public static BinaryExpression GreaterThanOrEqual(Expression left, Expression right, bool liftToNull, MethodInfo? method) 1195/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1196/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1199public static BinaryExpression LessThanOrEqual(Expression left, Expression right) 1207/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1208/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1214public static BinaryExpression LessThanOrEqual(Expression left, Expression right, bool liftToNull, MethodInfo? method) 1225private static BinaryExpression GetComparisonOperator(ExpressionType binaryType, string opName, Expression left, Expression right, bool liftToNull) 1248/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1249/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1252public static BinaryExpression AndAlso(Expression left, Expression right) 1260/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1261/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1266public static BinaryExpression AndAlso(Expression left, Expression right, MethodInfo? method) 1301/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1302/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1305public static BinaryExpression OrElse(Expression left, Expression right) 1313/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1314/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1319public static BinaryExpression OrElse(Expression left, Expression right, MethodInfo? method) 1358/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1359/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1362public static BinaryExpression Coalesce(Expression left, Expression right) 1370/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1371/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1376public static BinaryExpression Coalesce(Expression left, Expression right, LambdaExpression? conversion) 1455/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1456/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1459public static BinaryExpression Add(Expression left, Expression right) 1467/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1468/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1473public static BinaryExpression Add(Expression left, Expression right, MethodInfo? method) 1491/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1492/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1495public static BinaryExpression AddAssign(Expression left, Expression right) 1503/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1504/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1509public static BinaryExpression AddAssign(Expression left, Expression right, MethodInfo? method) 1517/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1518/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1525public static BinaryExpression AddAssign(Expression left, Expression right, MethodInfo? method, LambdaExpression? conversion) 1546private static void ValidateOpAssignConversionLambda(LambdaExpression conversion, Expression left, MethodInfo method, ExpressionType nodeType) 1572/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1573/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1578public static BinaryExpression AddAssignChecked(Expression left, Expression right) 1586/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1587/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1592public static BinaryExpression AddAssignChecked(Expression left, Expression right, MethodInfo? method) 1600/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1601/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1608public static BinaryExpression AddAssignChecked(Expression left, Expression right, MethodInfo? method, LambdaExpression? conversion) 1633/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1634/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1637public static BinaryExpression AddChecked(Expression left, Expression right) 1645/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1646/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1651public static BinaryExpression AddChecked(Expression left, Expression right, MethodInfo? method) 1669/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1670/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1673public static BinaryExpression Subtract(Expression left, Expression right) 1681/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1682/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1687public static BinaryExpression Subtract(Expression left, Expression right, MethodInfo? method) 1705/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1706/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1709public static BinaryExpression SubtractAssign(Expression left, Expression right) 1717/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1718/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1723public static BinaryExpression SubtractAssign(Expression left, Expression right, MethodInfo? method) 1731/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1732/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1739public static BinaryExpression SubtractAssign(Expression left, Expression right, MethodInfo? method, LambdaExpression? conversion) 1763/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1764/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1767public static BinaryExpression SubtractAssignChecked(Expression left, Expression right) 1775/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1776/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1781public static BinaryExpression SubtractAssignChecked(Expression left, Expression right, MethodInfo? method) 1789/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1790/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1797public static BinaryExpression SubtractAssignChecked(Expression left, Expression right, MethodInfo? method, LambdaExpression? conversion) 1821/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1822/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1825public static BinaryExpression SubtractChecked(Expression left, Expression right) 1833/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1834/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1839public static BinaryExpression SubtractChecked(Expression left, Expression right, MethodInfo? method) 1857/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1858/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1861public static BinaryExpression Divide(Expression left, Expression right) 1869/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1870/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1875public static BinaryExpression Divide(Expression left, Expression right, MethodInfo? method) 1893/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1894/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1897public static BinaryExpression DivideAssign(Expression left, Expression right) 1905/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1906/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1911public static BinaryExpression DivideAssign(Expression left, Expression right, MethodInfo? method) 1919/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1920/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1927public static BinaryExpression DivideAssign(Expression left, Expression right, MethodInfo? method, LambdaExpression? conversion) 1951/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1952/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1955public static BinaryExpression Modulo(Expression left, Expression right) 1963/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1964/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1969public static BinaryExpression Modulo(Expression left, Expression right, MethodInfo? method) 1987/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 1988/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 1991public static BinaryExpression ModuloAssign(Expression left, Expression right) 1999/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2000/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2005public static BinaryExpression ModuloAssign(Expression left, Expression right, MethodInfo? method) 2013/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2014/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2021public static BinaryExpression ModuloAssign(Expression left, Expression right, MethodInfo? method, LambdaExpression? conversion) 2045/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2046/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2049public static BinaryExpression Multiply(Expression left, Expression right) 2057/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2058/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2063public static BinaryExpression Multiply(Expression left, Expression right, MethodInfo? method) 2081/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2082/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2085public static BinaryExpression MultiplyAssign(Expression left, Expression right) 2093/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2094/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2099public static BinaryExpression MultiplyAssign(Expression left, Expression right, MethodInfo? method) 2107/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2108/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2115public static BinaryExpression MultiplyAssign(Expression left, Expression right, MethodInfo? method, LambdaExpression? conversion) 2139/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2140/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2143public static BinaryExpression MultiplyAssignChecked(Expression left, Expression right) 2151/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2152/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2157public static BinaryExpression MultiplyAssignChecked(Expression left, Expression right, MethodInfo? method) 2165/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2166/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2173public static BinaryExpression MultiplyAssignChecked(Expression left, Expression right, MethodInfo? method, LambdaExpression? conversion) 2197/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2198/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2201public static BinaryExpression MultiplyChecked(Expression left, Expression right) 2209/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2210/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2215public static BinaryExpression MultiplyChecked(Expression left, Expression right, MethodInfo? method) 2249/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2250/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2253public static BinaryExpression LeftShift(Expression left, Expression right) 2261/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2262/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2267public static BinaryExpression LeftShift(Expression left, Expression right, MethodInfo? method) 2286/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2287/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2290public static BinaryExpression LeftShiftAssign(Expression left, Expression right) 2298/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2299/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2304public static BinaryExpression LeftShiftAssign(Expression left, Expression right, MethodInfo? method) 2312/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2313/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2320public static BinaryExpression LeftShiftAssign(Expression left, Expression right, MethodInfo? method, LambdaExpression? conversion) 2345/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2346/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2349public static BinaryExpression RightShift(Expression left, Expression right) 2357/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2358/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2363public static BinaryExpression RightShift(Expression left, Expression right, MethodInfo? method) 2382/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2383/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2386public static BinaryExpression RightShiftAssign(Expression left, Expression right) 2394/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2395/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2400public static BinaryExpression RightShiftAssign(Expression left, Expression right, MethodInfo? method) 2408/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2409/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2416public static BinaryExpression RightShiftAssign(Expression left, Expression right, MethodInfo? method, LambdaExpression? conversion) 2441/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2442/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2445public static BinaryExpression And(Expression left, Expression right) 2453/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2454/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2459public static BinaryExpression And(Expression left, Expression right, MethodInfo? method) 2477/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2478/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2481public static BinaryExpression AndAssign(Expression left, Expression right) 2489/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2490/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2495public static BinaryExpression AndAssign(Expression left, Expression right, MethodInfo? method) 2503/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2504/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2511public static BinaryExpression AndAssign(Expression left, Expression right, MethodInfo? method, LambdaExpression? conversion) 2535/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2536/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2539public static BinaryExpression Or(Expression left, Expression right) 2547/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2548/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2553public static BinaryExpression Or(Expression left, Expression right, MethodInfo? method) 2571/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2572/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2575public static BinaryExpression OrAssign(Expression left, Expression right) 2583/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2584/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2589public static BinaryExpression OrAssign(Expression left, Expression right, MethodInfo? method) 2597/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2598/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2605public static BinaryExpression OrAssign(Expression left, Expression right, MethodInfo? method, LambdaExpression? conversion) 2629/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2630/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2633public static BinaryExpression ExclusiveOr(Expression left, Expression right) 2641/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2642/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2647public static BinaryExpression ExclusiveOr(Expression left, Expression right, MethodInfo? method) 2665/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2666/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2669public static BinaryExpression ExclusiveOrAssign(Expression left, Expression right) 2677/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2678/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2683public static BinaryExpression ExclusiveOrAssign(Expression left, Expression right, MethodInfo? method) 2691/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2692/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2699public static BinaryExpression ExclusiveOrAssign(Expression left, Expression right, MethodInfo? method, LambdaExpression? conversion) 2723/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2724/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2727public static BinaryExpression Power(Expression left, Expression right) 2735/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2736/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2741public static BinaryExpression Power(Expression left, Expression right, MethodInfo? method) 2781/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2782/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2785public static BinaryExpression PowerAssign(Expression left, Expression right) 2793/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2794/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2799public static BinaryExpression PowerAssign(Expression left, Expression right, MethodInfo? method) 2807/// <param name="left">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2808/// <param name="right">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2815public static BinaryExpression PowerAssign(Expression left, Expression right, MethodInfo? method, LambdaExpression? conversion) 2838/// <param name="array">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Left"/> property equal to.</param> 2839/// <param name="index">An <see cref="Expression"/> to set the <see cref="BinaryExpression.Right"/> property equal to.</param> 2842public static BinaryExpression ArrayIndex(Expression array, Expression index)
System\Linq\Expressions\BlockExpression.cs (132)
22public ReadOnlyCollection<Expression> Expressions => GetOrMakeExpressions(); 32public Expression Result => GetExpression(ExpressionCount - 1); 41protected internal override Expression Accept(ExpressionVisitor visitor) 54/// Gets the static type of the expression that this <see cref="Expression"/> represents. 67public BlockExpression Update(IEnumerable<ParameterExpression>? variables, IEnumerable<Expression> expressions) 91ICollection<Expression>? exps = expressions as ICollection<Expression>; 110internal virtual bool SameExpressions(ICollection<Expression> expressions) 116internal virtual Expression GetExpression(int index) 131internal virtual ReadOnlyCollection<Expression> GetOrMakeExpressions() 152internal virtual BlockExpression Rewrite(ReadOnlyCollection<ParameterExpression>? variables, Expression[] args) 170internal static ReadOnlyCollection<Expression> ReturnReadOnlyExpressions(BlockExpression provider, ref object collection) 172if (collection is Expression tObj) 177new ReadOnlyCollection<Expression>(new BlockExpressionList(provider, tObj)), 183return (ReadOnlyCollection<Expression>)collection; 192private readonly Expression _arg1; // storage for the 2nd argument. 194internal Block2(Expression arg0, Expression arg1) 200internal override Expression GetExpression(int index) => 2030 => ExpressionUtils.ReturnObject<Expression>(_arg0), 208internal override bool SameExpressions(ICollection<Expression> expressions) 213if (_arg0 is ReadOnlyCollection<Expression> alreadyCollection) 218using (IEnumerator<Expression> en = expressions.GetEnumerator()) 234internal override ReadOnlyCollection<Expression> GetOrMakeExpressions() 239internal override BlockExpression Rewrite(ReadOnlyCollection<ParameterExpression>? variables, Expression[] args) 252private readonly Expression _arg1, _arg2; // storage for the 2nd and 3rd arguments. 254internal Block3(Expression arg0, Expression arg1, Expression arg2) 261internal override bool SameExpressions(ICollection<Expression> expressions) 266if (_arg0 is ReadOnlyCollection<Expression> alreadyCollection) 271using (IEnumerator<Expression> en = expressions.GetEnumerator()) 289internal override Expression GetExpression(int index) => 2920 => ExpressionUtils.ReturnObject<Expression>(_arg0), 300internal override ReadOnlyCollection<Expression> GetOrMakeExpressions() 305internal override BlockExpression Rewrite(ReadOnlyCollection<ParameterExpression>? variables, Expression[] args) 318private readonly Expression _arg1, _arg2, _arg3; // storage for the 2nd, 3rd, and 4th arguments. 320internal Block4(Expression arg0, Expression arg1, Expression arg2, Expression arg3) 328internal override bool SameExpressions(ICollection<Expression> expressions) 333if (_arg0 is ReadOnlyCollection<Expression> alreadyCollection) 338using (IEnumerator<Expression> en = expressions.GetEnumerator()) 360internal override Expression GetExpression(int index) => 3630 => ExpressionUtils.ReturnObject<Expression>(_arg0), 372internal override ReadOnlyCollection<Expression> GetOrMakeExpressions() 377internal override BlockExpression Rewrite(ReadOnlyCollection<ParameterExpression>? variables, Expression[] args) 390private readonly Expression _arg1, _arg2, _arg3, _arg4; // storage for the 2nd - 5th args. 392internal Block5(Expression arg0, Expression arg1, Expression arg2, Expression arg3, Expression arg4) 401internal override Expression GetExpression(int index) => 4040 => ExpressionUtils.ReturnObject<Expression>(_arg0), 412internal override bool SameExpressions(ICollection<Expression> expressions) 417if (_arg0 is ReadOnlyCollection<Expression> alreadyCollection) 422using (IEnumerator<Expression> en = expressions.GetEnumerator()) 450internal override ReadOnlyCollection<Expression> GetOrMakeExpressions() 455internal override BlockExpression Rewrite(ReadOnlyCollection<ParameterExpression>? variables, Expression[] args) 467private IReadOnlyList<Expression> _expressions; // either the original IList<Expression> or a ReadOnlyCollection if the user has accessed it. 469internal BlockN(IReadOnlyList<Expression> expressions) 476internal override bool SameExpressions(ICollection<Expression> expressions) => 479internal override Expression GetExpression(int index) 488internal override ReadOnlyCollection<Expression> GetOrMakeExpressions() 493internal override BlockExpression Rewrite(ReadOnlyCollection<ParameterExpression>? variables, Expression[] args) 541internal Scope1(IReadOnlyList<ParameterExpression> variables, Expression body) 552internal override bool SameExpressions(ICollection<Expression> expressions) 557if (_body is ReadOnlyCollection<Expression> alreadyCollection) 562using (IEnumerator<Expression> en = expressions.GetEnumerator()) 565return ExpressionUtils.ReturnObject<Expression>(_body) == en.Current; 572internal override Expression GetExpression(int index) => 5750 => ExpressionUtils.ReturnObject<Expression>(_body), 581internal override ReadOnlyCollection<Expression> GetOrMakeExpressions() 586internal override BlockExpression Rewrite(ReadOnlyCollection<ParameterExpression>? variables, Expression[]? args) 603private IReadOnlyList<Expression> _body; 605internal ScopeN(IReadOnlyList<ParameterExpression> variables, IReadOnlyList<Expression> body) 611internal override bool SameExpressions(ICollection<Expression> expressions) => 614protected IReadOnlyList<Expression> Body => _body; 616internal override Expression GetExpression(int index) => _body[index]; 620internal override ReadOnlyCollection<Expression> GetOrMakeExpressions() 625internal override BlockExpression Rewrite(ReadOnlyCollection<ParameterExpression>? variables, Expression[]? args) 642internal ScopeWithType(IReadOnlyList<ParameterExpression> variables, IReadOnlyList<Expression> expressions, Type type) 650internal override BlockExpression Rewrite(ReadOnlyCollection<ParameterExpression>? variables, Expression[]? args) 679internal sealed class BlockExpressionList : IList<Expression> 682private readonly Expression _arg0; 684internal BlockExpressionList(BlockExpression provider, Expression arg0) 692public int IndexOf(Expression item) 711public void Insert(int index, Expression item) 722public Expression this[int index] 745public void Add(Expression item) 756public bool Contains(Expression item) 761public void CopyTo(Expression[] array, int index) 795public bool Remove(Expression item) 804public IEnumerator<Expression> GetEnumerator() 836public static BlockExpression Block(Expression arg0, Expression arg1) 851public static BlockExpression Block(Expression arg0, Expression arg1, Expression arg2) 867public static BlockExpression Block(Expression arg0, Expression arg1, Expression arg2, Expression arg3) 885public static BlockExpression Block(Expression arg0, Expression arg1, Expression arg2, Expression arg3, Expression arg4) 901public static BlockExpression Block(params Expression[] expressions) 914public static BlockExpression Block(IEnumerable<Expression> expressions) 925public static BlockExpression Block(Type type, params Expression[] expressions) 928return Block(type, (IEnumerable<Expression>)expressions); 937public static BlockExpression Block(Type type, IEnumerable<Expression> expressions) 948public static BlockExpression Block(IEnumerable<ParameterExpression>? variables, params Expression[] expressions) 950return Block(variables, (IEnumerable<Expression>)expressions); 960public static BlockExpression Block(Type type, IEnumerable<ParameterExpression>? variables, params Expression[] expressions) 962return Block(type, variables, (IEnumerable<Expression>)expressions); 971public static BlockExpression Block(IEnumerable<ParameterExpression>? variables, IEnumerable<Expression> expressions) 978IReadOnlyList<Expression> expressionList = expressions as IReadOnlyList<Expression> ?? expressions.ToReadOnly(); 985ReadOnlyCollection<Expression> expressionList = expressions.ToReadOnly(); 999public static BlockExpression Block(Type type, IEnumerable<ParameterExpression>? variables, IEnumerable<Expression> expressions) 1004ReadOnlyCollection<Expression> expressionList = expressions.ToReadOnly(); 1015Expression lastExpression = expressionList[expressionCount - 1]; 1027private static BlockExpression BlockCore(Type? type, ReadOnlyCollection<ParameterExpression> variables, ReadOnlyCollection<Expression> expressions) 1042Expression last = expressions[^1]; 1088private static BlockExpression GetOptimizedBlockExpression(IReadOnlyList<Expression> expressions) 10920 => BlockCore(typeof(void), ReadOnlyCollection<ParameterExpression>.Empty, ReadOnlyCollection<Expression>.Empty), 1097_ => new BlockN(expressions as ReadOnlyCollection<Expression> ?? (IReadOnlyList<Expression>)expressions.ToArray()),
System\Linq\Expressions\CatchBlock.cs (16)
13[DebuggerTypeProxy(typeof(Expression.CatchBlockProxy))] 16internal CatchBlock(Type test, ParameterExpression? variable, Expression body, Expression? filter) 37public Expression Body { get; } 42public Expression? Filter { get; } 62public CatchBlock Update(ParameterExpression? variable, Expression? filter, Expression body) 68return Expression.MakeCatchBlock(Test, variable, body, filter); 82public static CatchBlock Catch(Type type, Expression body) 93public static CatchBlock Catch(ParameterExpression variable, Expression body) 107public static CatchBlock Catch(Type type, Expression body, Expression? filter) 120public static CatchBlock Catch(ParameterExpression variable, Expression body, Expression? filter) 135public static CatchBlock MakeCatchBlock(Type type, ParameterExpression? variable, Expression body, Expression? filter)
System\Linq\Expressions\Common\ConstantCheck.cs (2)
18internal static bool IsNull(Expression e) 50private static AnalyzeTypeIsResult AnalyzeTypeIs(Expression operand, Type testType)
System\Linq\Expressions\Compiler\CompilerScope.cs (2)
32[RequiresDynamicCode(Expression.StrongBoxRequiresDynamicCode)] 399[RequiresDynamicCode(Expression.StrongBoxRequiresDynamicCode)]
System\Linq\Expressions\Compiler\CompilerScope.Storage.cs (2)
102[RequiresDynamicCode(Expression.StrongBoxRequiresDynamicCode)] 158[RequiresDynamicCode(Expression.StrongBoxRequiresDynamicCode)]
System\Linq\Expressions\Compiler\DelegateHelpers.cs (3)
22[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 23internal static Type MakeCallSiteDelegate(ReadOnlyCollection<Expression> types, Type returnType) 57[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)]
System\Linq\Expressions\Compiler\DelegateHelpers.Generated.cs (5)
18[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 95[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 133[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 187[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 232[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)]
System\Linq\Expressions\Compiler\HoistedLocals.cs (6)
51internal readonly ReadOnlyDictionary<Expression, int> Indexes; 69Dictionary<Expression, int> indexes = new Dictionary<Expression, int>(vars.Count); 75Indexes = new ReadOnlyDictionary<Expression, int>(indexes); 79Indexes = ReadOnlyDictionary<Expression, int>.Empty; 84SelfVariable = Expression.Variable(typeof(object[]), name: null);
System\Linq\Expressions\Compiler\LambdaCompiler.Address.cs (5)
13private void EmitAddress(Expression node, Type type) 22private void EmitAddress(Expression node, Type type, CompilationFlags flags) 217private void EmitExpressionAddress(Expression node, Type type) 232private WriteBack? EmitAddressWriteBack(Expression node, Type type) 339Expression arg = node.GetArgument(i);
System\Linq\Expressions\Compiler\LambdaCompiler.Binary.cs (7)
15private void EmitBinaryExpression(Expression expr) 20private void EmitBinaryExpression(Expression expr, CompilationFlags flags) 69private void EmitNullEquality(ExpressionType op, Expression e, bool isLiftedToNull) 97ParameterExpression p1 = Expression.Variable(b.Left.Type.GetNonNullableType(), name: null); 98ParameterExpression p2 = Expression.Variable(b.Right.Type.GetNonNullableType(), name: null); 99MethodCallExpression mc = Expression.Call(null, b.Method!, p1, p2); 124EmitMethodCallExpression(Expression.Call(null, b.Method!, b.Left, b.Right), flags);
System\Linq\Expressions\Compiler\LambdaCompiler.ControlFlow.cs (7)
51private void EmitLabelExpression(Expression expr, CompilationFlags flags) 93private void EmitGotoExpression(Expression expr, CompilationFlags flags) 131private void EmitUnreachable(Expression node, CompilationFlags flags) 139private bool TryPushLabelBlock(Expression node) 221private void DefineBlockLabels(Expression? node) 230Expression e = block.GetExpression(i); 245Expression expression = lambda.Body;
System\Linq\Expressions\Compiler\LambdaCompiler.cs (2)
27[RequiresDynamicCode(Expression.LambdaCompilerRequiresDynamicCode)] 291return Utils.GetStrongBoxValueField(Expression.Constant(new StrongBox<T>()));
System\Linq\Expressions\Compiler\LambdaCompiler.Expressions.cs (33)
69internal void EmitExpression(Expression node) 78private void EmitExpressionAsVoid(Expression node) 83private void EmitExpressionAsVoid(Expression node, CompilationFlags flags) 123private void EmitExpressionAsType(Expression node, Type type, CompilationFlags flags) 149private CompilationFlags EmitExpressionStart(Expression node) 170private void EmitInvocationExpression(Expression expr, CompilationFlags flags) 189expr = Expression.Call(expr, LambdaExpression.GetCompileMethod(expr.Type)); 227private void EmitIndexExpression(Expression expr) 242Expression arg = node.GetArgument(i); 268Expression arg = index.GetArgument(i); 353private void EmitMethodCallExpression(Expression expr, CompilationFlags flags) 360private void EmitMethodCallExpression(Expression expr) 365private void EmitMethodCall(Expression obj, MethodInfo method, IArgumentProvider methodCallExpr) 370private void EmitMethodCall(Expression? obj, MethodInfo method, IArgumentProvider methodCallExpr, CompilationFlags flags) 522Expression argument = args.GetArgument(i - skipParameters); 558private void EmitConstantExpression(Expression expr) 580private void EmitDynamicExpression(Expression expr) 620private void EmitNewExpression(Expression expr) 645private void EmitTypeBinaryExpression(Expression expr) 740private void EmitAssignBinaryExpression(Expression expr) 763private void EmitParameterExpression(Expression expr) 773private void EmitLambdaExpression(Expression expr) 779private void EmitRuntimeVariablesExpression(Expression expr) 831private void EmitMemberExpression(Expression expr) 869private void EmitInstance(Expression instance, out Type type) 896private void EmitNewArrayExpression(Expression expr) 900ReadOnlyCollection<Expression> expressions = node.Expressions; 921Expression x = expressions[i]; 931private void EmitListInitExpression(Expression expr) 936private void EmitMemberInitExpression(Expression expr) 1112private void EmitLift(ExpressionType nodeType, Type resultType, MethodCallExpression mc, ParameterExpression[] paramList, Expression[] argList) 1132Expression arg = argList[i]; 1218Expression arg = argList[i];
System\Linq\Expressions\Compiler\LambdaCompiler.Generated.cs (2)
13private void EmitExpression(Expression node, CompilationFlags flags) 20_guard.RunOnEmptyStack((LambdaCompiler @this, Expression n, CompilationFlags f) => @this.EmitExpression(n, f), this, node, flags);
System\Linq\Expressions\Compiler\LambdaCompiler.Logical.cs (9)
15private void EmitConditionalExpression(Expression expr, CompilationFlags flags) 49private static bool NotEmpty(Expression node) 64private static bool Significant(Expression node) 86private void EmitCoalesceBinaryExpression(Expression expr) 310private void EmitAndAlsoBinaryExpression(Expression expr, CompilationFlags flags) 404private void EmitOrElseBinaryExpression(Expression expr, CompilationFlags flags) 456private void EmitExpressionAndBranch(bool branchValue, Expression node, Label label) 568private static Expression GetEqualityOperand(Expression expression)
System\Linq\Expressions\Compiler\LambdaCompiler.Statements.cs (38)
18private void EmitBlockExpression(Expression expr, CompilationFlags flags) 40Expression e = node.GetExpression(index); 41Expression next = node.GetExpression(index + 1); 129private void EmitDefaultExpression(Expression expr) 139private void EmitLoopExpression(Expression expr) 160private void EmitSwitchExpression(Expression expr, CompilationFlags flags) 202ParameterExpression switchValue = Expression.Parameter(node.SwitchValue.Type, "switchValue"); 203ParameterExpression testValue = Expression.Parameter(GetTestValueType(node), "testValue"); 216foreach (Expression test in node.Cases[i].TestValues) 223EmitExpressionAndBranch(true, Expression.Equal(switchValue, testValue, false, node.Comparison), labels[i]); 647foreach (Expression t in c.TestValues) 677initializers.Add(Expression.ElementInit(add, new TrueReadOnlyCollection<Expression>(t, Utils.Constant(i)))); 684cases.UncheckedAdd(Expression.SwitchCase(node.Cases[i].Body, new TrueReadOnlyCollection<Expression>(Utils.Constant(i)))); 693Expression dictInit = Expression.Condition( 694Expression.Equal(dictField, Expression.Constant(null, dictField.Type)), 695Expression.Assign( 697Expression.ListInit( 698Expression.New( 700new TrueReadOnlyCollection<Expression>( 729ParameterExpression switchValue = Expression.Variable(typeof(string), "switchValue"); 730ParameterExpression switchIndex = Expression.Variable(typeof(int), "switchIndex"); 731BlockExpression reduced = Expression.Block( 733new TrueReadOnlyCollection<Expression>( 734Expression.Assign(switchValue, node.SwitchValue), 735Expression.IfThenElse( 736Expression.Equal(switchValue, Expression.Constant(null, typeof(string))), 737Expression.Assign(switchIndex, Utils.Constant(nullCase)), 738Expression.IfThenElse( 741Expression.Assign(switchIndex, Utils.Constant(-1)) 744Expression.Switch(node.Type, switchIndex, node.DefaultBody, null, cases.ToReadOnly()) 755private static MethodCallExpression CallTryGetValue(Expression dictInit, ParameterExpression switchValue, ParameterExpression switchIndex) 757return Expression.Call(dictInit, "TryGetValue", null, switchValue, switchIndex); 809private void EmitTryExpression(Expression expr)
System\Linq\Expressions\Compiler\LambdaCompiler.Unary.cs (12)
14private void EmitQuoteUnaryExpression(Expression expr) 39private void EmitThrowUnaryExpression(Expression expr) 61private void EmitUnaryExpression(Expression expr, CompilationFlags flags) 271private void EmitUnboxUnaryExpression(Expression expr) 281private void EmitConvertUnaryExpression(Expression expr, CompilationFlags flags) 316UnaryExpression operand = Expression.Convert(node.Operand, paramType); 319node = Expression.Convert(Expression.Call(node.Method, operand), node.Type); 354ParameterExpression v = Expression.Variable(node.Operand.Type.GetNonNullableType(), name: null); 355MethodCallExpression mc = Expression.Call(node.Method!, v); 358EmitLift(node.NodeType, resultType, mc, new ParameterExpression[] { v }, new Expression[] { node.Operand }); 363EmitMethodCallExpression(Expression.Call(node.Method!, node.Operand), flags);
System\Linq\Expressions\Compiler\StackSpiller.Bindings.cs (22)
28internal abstract Expression AsExpression(Expression target); 95internal override Expression AsExpression(Expression target) 99Expression member = MemberExpression.Make(target, _binding.Member); 100Expression memberTemp = _spiller.MakeTemp(member.Type); 103Expression[] block = new Expression[count + 2]; 115block[count + 1] = Expression.Block( 172newInits[i] = new ElementInit(_inits[i].AddMethod, new TrueReadOnlyCollection<Expression>(cr[0, -1]!)); 180internal override Expression AsExpression(Expression target) 184Expression member = MemberExpression.Make(target, _binding.Member); 185Expression memberTemp = _spiller.MakeTemp(member.Type); 188Expression[] block = new Expression[count + 2]; 201block[count + 1] = Expression.Block( 217private readonly Expression _rhs; 235internal override Expression AsExpression(Expression target) 237Expression member = MemberExpression.Make(target, _binding.Member); 238Expression memberTemp = _spiller.MakeTemp(member.Type);
System\Linq\Expressions\Compiler\StackSpiller.ChildRewriter.cs (22)
35private readonly Expression?[] _expressions; 68private List<Expression>? _comma; 73/// in calls to <see cref="Add(Expression)"/>. 79/// child expression through <see cref="Add(Expression)"/>, the state changes from 88/// calls to <see cref="Add(Expression)"/> are no longer allowed. 111_expressions = new Expression[count]; 120internal void Add(Expression? expression) 149internal void Add(ReadOnlyCollection<Expression> expressions) 175/// Called after all child expressions have been added using <see cref="Add(Expression)"/> 203Expression?[] clone = _expressions; 205List<Expression> comma = new List<Expression>(count + 1); 208Expression? current = clone[i]; 211Expression temp; 233private static bool ShouldSaveToTemp(Expression? expression) 301/// calls to <see cref="Add(Expression)"/>. 311internal void MarkRefInstance(Expression? expr) 373internal Result Finish(Expression expression) 400internal Expression? this[int index] 434internal Expression?[] this[int first, int last] 456Expression[] clone = new Expression[count];
System\Linq\Expressions\Compiler\StackSpiller.cs (51)
63internal readonly Expression Node; 65internal Result(RewriteAction action, Expression node) 115Expression newBody = body.Node; 118newBody = Expression.Block(_tm.Temps, new TrueReadOnlyCollection<Expression>(newBody)); 131private static void VerifyRewrite(Result result, Expression node) 156private Result RewriteExpressionFreeTemps(Expression? expression, Stack stack) 164private Result RewriteDynamicExpression(Expression expr) 212private Result RewriteLogicalBinaryExpression(Expression expr, Stack stack) 244private Result RewriteReducibleExpression(Expression expr, Stack stack) 252private Result RewriteBinaryExpression(Expression expr, Stack stack) 293private Result RewriteAssignBinaryExpression(Expression expr, Stack stack) 317private static Result RewriteLambdaExpression(Expression expr) 331private Result RewriteConditionalExpression(Expression expr, Stack stack) 382private Result RewriteMemberExpression(Expression expr, Stack stack) 404private Result RewriteIndexExpression(Expression expr, Stack stack) 432private Result RewriteMethodCallExpression(Expression expr, Stack stack) 467private Result RewriteNewArrayExpression(Expression expr, Stack stack) 489expr = NewArrayExpression.Make(node.NodeType, node.Type, new TrueReadOnlyCollection<Expression>(cr[0, -1]!)); 495private Result RewriteInvocationExpression(Expression expr, Stack stack) 511cr.MarkRefArgs(Expression.GetInvokeMethod(node.Expression), startIndex: 0); 537cr.MarkRefArgs(Expression.GetInvokeMethod(node.Expression), startIndex: 1); 543private Result RewriteNewExpression(Expression expr, Stack stack) 560private Result RewriteTypeBinaryExpression(Expression expr, Stack stack) 575private Result RewriteThrowUnaryExpression(Expression expr, Stack stack) 601private Result RewriteUnaryExpression(Expression expr, Stack stack) 624private Result RewriteListInitExpression(Expression expr, Stack stack) 630Expression rewrittenNew = newResult.Node; 665newInits[i] = new ElementInit(inits[i].AddMethod, new TrueReadOnlyCollection<Expression>(cr[0, -1]!)); 673var comma = new ArrayBuilder<Expression>(count + 2 + (isRefNew ? 1 : 0)); 702private Result RewriteMemberInitExpression(Expression expr, Stack stack) 708Expression rewrittenNew = result.Node; 742var comma = new ArrayBuilder<Expression>(count + 2 + (isRefNew ? 1 : 0)); 757Expression initExpr = cr.AsExpression(refTempNew); 775private Result RewriteBlockExpression(Expression expr, Stack stack) 781Expression[]? clone = null; 784Expression expression = node.GetExpression(i); 811private Result RewriteLabelExpression(Expression expr, Stack stack) 824private Result RewriteLoopExpression(Expression expr, Stack stack) 853private Result RewriteGotoExpression(Expression expr, Stack stack) 871expr = Expression.MakeGoto(node.Kind, node.Target, value.Node, node.Type); 877private Result RewriteSwitchExpression(Expression expr, Stack stack) 891Expression[]? cloneTests = null; 892ReadOnlyCollection<Expression> testValues = @case.TestValues; 919testValues = new ReadOnlyCollection<Expression>(cloneTests); 951private Result RewriteTryExpression(Expression expr, Stack stack) 970Expression? filter = handler.Filter; 987handler = Expression.MakeCatchBlock(handler.Test, handler.Variable, rbody.Node, filter); 1025private Result RewriteExtensionExpression(Expression expr, Stack stack) 1088private static void RequireNotRefInstance(Expression? instance) 1096private static bool IsRefInstance([NotNullWhen(true)] Expression? instance)
System\Linq\Expressions\Compiler\StackSpiller.Generated.cs (2)
16private Result RewriteExpression(Expression node, Stack stack) 28return _guard.RunOnEmptyStack((StackSpiller @this, Expression n, Stack s) => @this.RewriteExpression(n, s), this, node, stack);
System\Linq\Expressions\Compiler\StackSpiller.SpilledExpressionBlock.cs (8)
18private static Expression MakeBlock(ArrayBuilder<Expression> expressions) 28private static Expression MakeBlock(params Expression[] expressions) 38private static Expression MakeBlock(IReadOnlyList<Expression> expressions) 50internal SpilledExpressionBlock(IReadOnlyList<Expression> expressions) 56internal override BlockExpression Rewrite(ReadOnlyCollection<ParameterExpression>? variables, Expression[] args)
System\Linq\Expressions\Compiler\StackSpiller.Temps.cs (2)
66private ParameterExpression ToTemp(Expression expression, out Expression save, bool byRef)
System\Linq\Expressions\Compiler\TypeInfoExtensions.cs (5)
12[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 13public static Type MakeDelegateType(this DelegateHelpers.TypeInfo info, Type retType, params Expression[] args) 15return info.MakeDelegateType(retType, (IList<Expression>)args); 18[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 19public static Type MakeDelegateType(this DelegateHelpers.TypeInfo info, Type retType, IList<Expression> args)
System\Linq\Expressions\Compiler\VariableBinder.cs (15)
16[RequiresDynamicCode(Expression.StrongBoxRequiresDynamicCode)] 37public override Expression? Visit(Expression? node) 44return _guard.RunOnEmptyStack((VariableBinder @this, Expression? e) => @this.Visit(e), this, node); 50protected internal override Expression VisitConstant(ConstantExpression node) 69protected internal override Expression VisitUnary(UnaryExpression node) 85protected internal override Expression VisitLambda<T>(Expression<T> node) 95protected internal override Expression VisitInvocation(InvocationExpression node) 117protected internal override Expression VisitBlock(BlockExpression node) 148private ReadOnlyCollection<Expression> MergeScopes(Expression node) 150ReadOnlyCollection<Expression> body; 154body = new ReadOnlyCollection<Expression>(new[] { lambda.Body }); 195protected internal override Expression VisitParameter(ParameterExpression node) 228protected internal override Expression VisitRuntimeVariables(RuntimeVariablesExpression node)
System\Linq\Expressions\ConditionalExpression.cs (46)
16internal ConditionalExpression(Expression test, Expression ifTrue) 22internal static ConditionalExpression Make(Expression test, Expression ifTrue, Expression ifFalse, Type type) 46/// Gets the static type of the expression that this <see cref="Expression"/> represents. 54public Expression Test { get; } 59public Expression IfTrue { get; } 64public Expression IfFalse => GetFalse(); 66internal virtual Expression GetFalse() 75protected internal override Expression Accept(ExpressionVisitor visitor) 89public ConditionalExpression Update(Expression test, Expression ifTrue, Expression ifFalse) 95return Expression.Condition(test, ifTrue, ifFalse, Type); 101private readonly Expression _false; 103internal FullConditionalExpression(Expression test, Expression ifTrue, Expression ifFalse) 109internal override Expression GetFalse() => _false; 114internal FullConditionalExpressionWithType(Expression test, Expression ifTrue, Expression ifFalse, Type type) 128/// <param name="test">An <see cref="Expression"/> to set the <see cref="ConditionalExpression.Test"/> property equal to.</param> 129/// <param name="ifTrue">An <see cref="Expression"/> to set the <see cref="ConditionalExpression.IfTrue"/> property equal to.</param> 130/// <param name="ifFalse">An <see cref="Expression"/> to set the <see cref="ConditionalExpression.IfFalse"/> property equal to.</param> 134public static ConditionalExpression Condition(Expression test, Expression ifTrue, Expression ifFalse) 155/// <param name="test">An <see cref="Expression"/> to set the <see cref="ConditionalExpression.Test"/> property equal to.</param> 156/// <param name="ifTrue">An <see cref="Expression"/> to set the <see cref="ConditionalExpression.IfTrue"/> property equal to.</param> 157/// <param name="ifFalse">An <see cref="Expression"/> to set the <see cref="ConditionalExpression.IfFalse"/> property equal to.</param> 165public static ConditionalExpression Condition(Expression test, Expression ifTrue, Expression ifFalse, Type type) 192/// <param name="test">An <see cref="Expression"/> to set the <see cref="ConditionalExpression.Test"/> property equal to.</param> 193/// <param name="ifTrue">An <see cref="Expression"/> to set the <see cref="ConditionalExpression.IfTrue"/> property equal to.</param> 198public static ConditionalExpression IfThen(Expression test, Expression ifTrue) 200return Condition(test, ifTrue, Expression.Empty(), typeof(void)); 206/// <param name="test">An <see cref="Expression"/> to set the <see cref="ConditionalExpression.Test"/> property equal to.</param> 207/// <param name="ifTrue">An <see cref="Expression"/> to set the <see cref="ConditionalExpression.IfTrue"/> property equal to.</param> 208/// <param name="ifFalse">An <see cref="Expression"/> to set the <see cref="ConditionalExpression.IfFalse"/> property equal to.</param> 213public static ConditionalExpression IfThenElse(Expression test, Expression ifTrue, Expression ifFalse)
System\Linq\Expressions\ConstantExpression.cs (2)
21/// Gets the static type of the expression that this <see cref="Expression"/> represents. 52protected internal override Expression Accept(ExpressionVisitor visitor)
System\Linq\Expressions\DebugInfoExpression.cs (6)
25/// Gets the static type of the expression that this <see cref="Expression"/> represents. (Inherited from <see cref="Expression"/>.) 31/// Returns the node type of this <see cref="Expression"/>. (Inherited from <see cref="Expression"/>.) 89protected internal override Expression Accept(ExpressionVisitor visitor) 120protected internal override Expression Accept(ExpressionVisitor visitor)
System\Linq\Expressions\DebugViewWriter.cs (39)
118internal static void WriteTo(Expression node, TextWriter writer) 126private void WriteTo(Expression node) 226private void VisitExpressions<T>(char open, IReadOnlyList<T> expressions) where T : Expression 231private void VisitExpressions<T>(char open, char separator, IReadOnlyList<T> expressions) where T : Expression 292protected internal override Expression VisitBinary(BinaryExpression node) 379protected internal override Expression VisitParameter(ParameterExpression node) 398protected internal override Expression VisitLambda<T>(Expression<T> node) 413private static bool IsSimpleExpression(Expression node) 424protected internal override Expression VisitConditional(ConditionalExpression node) 451protected internal override Expression VisitConstant(ConstantExpression node) 517protected internal override Expression VisitRuntimeVariables(RuntimeVariablesExpression node) 525private void OutMember(Expression node, Expression? instance, MemberInfo member) 539protected internal override Expression VisitMember(MemberExpression node) 545protected internal override Expression VisitInvocation(InvocationExpression node) 553private static bool NeedsParentheses(Expression parent, Expression? child) 631private static int GetOperatorPrecedence(Expression node) 751private void ParenthesizedVisit(Expression parent, Expression? nodeToVisit) 765protected internal override Expression VisitMethodCall(MethodCallExpression node) 786protected internal override Expression VisitNewArray(NewArrayExpression node) 803protected internal override Expression VisitNew(NewExpression node) 823protected internal override Expression VisitListInit(ListInitExpression node) 854protected internal override Expression VisitMemberInit(MemberInitExpression node) 861protected internal override Expression VisitTypeBinary(TypeBinaryExpression node) 877protected internal override Expression VisitUnary(UnaryExpression node) 966protected internal override Expression VisitBlock(BlockExpression node) 985protected internal override Expression VisitDefault(DefaultExpression node) 991protected internal override Expression VisitLabel(LabelExpression node) 1002protected internal override Expression VisitGoto(GotoExpression node) 1012protected internal override Expression VisitLoop(LoopExpression node) 1034foreach (Expression test in node.TestValues) 1047protected internal override Expression VisitSwitch(SwitchExpression node) 1086protected internal override Expression VisitTry(TryExpression node) 1112protected internal override Expression VisitIndex(IndexExpression node) 1127protected internal override Expression VisitExtension(Expression node) 1143protected internal override Expression VisitDebugInfo(DebugInfoExpression node)
System\Linq\Expressions\DefaultExpression.cs (2)
21/// Gets the static type of the expression that this <see cref="Expression"/> represents. 36protected internal override Expression Accept(ExpressionVisitor visitor)
System\Linq\Expressions\DynamicExpression.cs (155)
41public override Expression Reduce() 43var site = Expression.Constant(CallSite.Create(DelegateType, Binder)); 44return Expression.Invoke( 45Expression.Field( 51internal static DynamicExpression Make(Type returnType, Type delegateType, CallSiteBinder binder, ReadOnlyCollection<Expression> arguments) 63internal static DynamicExpression Make(Type returnType, Type delegateType, CallSiteBinder binder, Expression arg0) 75internal static DynamicExpression Make(Type returnType, Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1) 87internal static DynamicExpression Make(Type returnType, Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1, Expression arg2) 99internal static DynamicExpression Make(Type returnType, Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1, Expression arg2, Expression arg3) 112/// Gets the static type of the expression that this <see cref="Expression" /> represents. 138public ReadOnlyCollection<Expression> Arguments => GetOrMakeArguments(); 141internal virtual ReadOnlyCollection<Expression> GetOrMakeArguments() 149protected internal override Expression Accept(ExpressionVisitor visitor) 167internal virtual DynamicExpression Rewrite(Expression[] args) 179public DynamicExpression Update(IEnumerable<Expression>? arguments) 181ICollection<Expression>? args; 188args = arguments as ICollection<Expression>; 204internal virtual bool SameArguments(ICollection<Expression>? arguments) 212Expression IArgumentProvider.GetArgument(int index) 243[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 244public static new DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, params Expression[] arguments) 265[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 266public static new DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, IEnumerable<Expression> arguments) 287[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 288public static new DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, Expression arg0) 310[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 311public static new DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, Expression arg0, Expression arg1) 334[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 335public static new DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, Expression arg0, Expression arg1, Expression arg2) 359[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 360public static new DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, Expression arg0, Expression arg1, Expression arg2, Expression arg3) 378[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 379public static new DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, IEnumerable<Expression>? arguments) 397public static new DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, params Expression[]? arguments) 415public static new DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, Expression arg0) 434public static new DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1) 454public static new DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1, Expression arg2) 475public static new DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1, Expression arg2, Expression arg3) 482Expression IDynamicExpression.Rewrite(Expression[] args) => Rewrite(args); 494private IReadOnlyList<Expression> _arguments; // storage for the original IList or read-only collection. See IArgumentProvider for more info. 496internal DynamicExpressionN(Type delegateType, CallSiteBinder binder, IReadOnlyList<Expression> arguments) 502Expression IArgumentProvider.GetArgument(int index) => _arguments[index]; 504internal override bool SameArguments(ICollection<Expression>? arguments) => 509internal override ReadOnlyCollection<Expression> GetOrMakeArguments() 514internal override DynamicExpression Rewrite(Expression[] args) 524internal TypedDynamicExpressionN(Type returnType, Type delegateType, CallSiteBinder binder, IReadOnlyList<Expression> arguments) 538internal DynamicExpression1(Type delegateType, CallSiteBinder binder, Expression arg0) 544Expression IArgumentProvider.GetArgument(int index) => 5470 => ExpressionUtils.ReturnObject<Expression>(_arg0), 553internal override bool SameArguments(ICollection<Expression>? arguments) 557using (IEnumerator<Expression> en = arguments.GetEnumerator()) 560return en.Current == ExpressionUtils.ReturnObject<Expression>(_arg0); 567internal override ReadOnlyCollection<Expression> GetOrMakeArguments() 572internal override DynamicExpression Rewrite(Expression[] args) 582internal TypedDynamicExpression1(Type retType, Type delegateType, CallSiteBinder binder, Expression arg0) 594private readonly Expression _arg1; // storage for the 2nd argument 596internal DynamicExpression2(Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1) 603Expression IArgumentProvider.GetArgument(int index) => 6060 => ExpressionUtils.ReturnObject<Expression>(_arg0), 613internal override bool SameArguments(ICollection<Expression>? arguments) 617if (_arg0 is ReadOnlyCollection<Expression> alreadyCollection) 622using (IEnumerator<Expression> en = arguments.GetEnumerator()) 636internal override ReadOnlyCollection<Expression> GetOrMakeArguments() 641internal override DynamicExpression Rewrite(Expression[] args) 651internal TypedDynamicExpression2(Type retType, Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1) 663private readonly Expression _arg1, _arg2; // storage for the 2nd & 3rd arguments 665internal DynamicExpression3(Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1, Expression arg2) 673Expression IArgumentProvider.GetArgument(int index) => 6760 => ExpressionUtils.ReturnObject<Expression>(_arg0), 684internal override bool SameArguments(ICollection<Expression>? arguments) 688if (_arg0 is ReadOnlyCollection<Expression> alreadyCollection) 693using (IEnumerator<Expression> en = arguments.GetEnumerator()) 711internal override ReadOnlyCollection<Expression> GetOrMakeArguments() 716internal override DynamicExpression Rewrite(Expression[] args) 726internal TypedDynamicExpression3(Type retType, Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1, Expression arg2) 738private readonly Expression _arg1, _arg2, _arg3; // storage for the 2nd - 4th arguments 740internal DynamicExpression4(Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1, Expression arg2, Expression arg3) 749Expression IArgumentProvider.GetArgument(int index) => 7520 => ExpressionUtils.ReturnObject<Expression>(_arg0), 761internal override bool SameArguments(ICollection<Expression>? arguments) 765if (_arg0 is ReadOnlyCollection<Expression> alreadyCollection) 770using (IEnumerator<Expression> en = arguments.GetEnumerator()) 792internal override ReadOnlyCollection<Expression> GetOrMakeArguments() 797internal override DynamicExpression Rewrite(Expression[] args) 807internal TypedDynamicExpression4(Type retType, Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1, Expression arg2, Expression arg3) 833public static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, params Expression[]? arguments) 835return MakeDynamic(delegateType, binder, (IEnumerable<Expression>?)arguments); 851public static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, IEnumerable<Expression>? arguments) 853IReadOnlyList<Expression> argumentList = arguments as IReadOnlyList<Expression> ?? arguments.ToReadOnly(); 891public static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, Expression arg0) 921public static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1) 954public static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1, Expression arg2) 990public static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1, Expression arg2, Expression arg3) 1036[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 1037public static DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, params Expression[] arguments) 1039return Dynamic(binder, returnType, (IEnumerable<Expression>)arguments); 1058[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 1059public static DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, Expression arg0) 1094[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 1095public static DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, Expression arg0, Expression arg1) 1135[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 1136public static DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, Expression arg0, Expression arg1, Expression arg2) 1181[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 1182public static DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, Expression arg0, Expression arg1, Expression arg2, Expression arg3) 1228[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 1229public static DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, IEnumerable<Expression> arguments) 1239[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 1240private static DynamicExpression MakeDynamic(CallSiteBinder binder, Type returnType, ReadOnlyCollection<Expression> arguments) 1248Expression arg = arguments[i]; 1268private static void ValidateDynamicArgument(Expression arg, string paramName) 1273private static void ValidateDynamicArgument(Expression arg, string paramName, int index)
System\Linq\Expressions\DynamicExpressionVisitor.cs (2)
16protected internal override Expression VisitDynamic(DynamicExpression node) 18Expression[]? a = ExpressionVisitorUtils.VisitArguments(this, node);
System\Linq\Expressions\ElementInit.cs (10)
16internal ElementInit(MethodInfo addMethod, ReadOnlyCollection<Expression> arguments) 30public ReadOnlyCollection<Expression> Arguments { get; } 37public Expression GetArgument(int index) => Arguments[index]; 60public ElementInit Update(IEnumerable<Expression> arguments) 66return Expression.ElementInit(AddMethod, arguments); 78public static ElementInit ElementInit(MethodInfo addMethod, params Expression[] arguments) 80return ElementInit(addMethod, arguments as IEnumerable<Expression>); 87/// <param name="arguments">An <see cref="IEnumerable{T}"/> containing <see cref="Expression"/> elements to initialize the list.</param> 89public static ElementInit ElementInit(MethodInfo addMethod, IEnumerable<Expression> arguments) 94ReadOnlyCollection<Expression> argumentsRO = arguments.ToReadOnly();
System\Linq\Expressions\Expression.cs (56)
32private static volatile CacheDict<Type, Func<Expression, string?, bool, ReadOnlyCollection<ParameterExpression>, LambdaExpression>>? s_lambdaFactories; 53private static ConditionalWeakTable<Expression, ExtensionInfo>? s_legacyCtorSupportTable; 56/// Constructs a new instance of <see cref="Expression"/>. 58/// <param name="nodeType">The <see ctype="ExpressionType"/> of the <see cref="Expression"/>.</param> 59/// <param name="type">The <see cref="Type"/> of the <see cref="Expression"/>.</param> 68new ConditionalWeakTable<Expression, ExtensionInfo>(), 77/// Constructs a new instance of <see cref="Expression"/>. 84/// The <see cref="ExpressionType"/> of the <see cref="Expression"/>. 102/// The <see cref="Type"/> of the value represented by this <see cref="Expression"/>. 130public virtual Expression Reduce() 137/// Reduces the node and then calls the <see cref="ExpressionVisitor.Visit(Expression)"/> method passing the reduced expression. 148protected internal virtual Expression VisitChildren(ExpressionVisitor visitor) 168protected internal virtual Expression Accept(ExpressionVisitor visitor) 183public Expression ReduceAndCheck() 187Expression newNode = Reduce(); 201public Expression ReduceExtensions() 203Expression node = this; 238private static void RequiresCanRead(IReadOnlyList<Expression> items, string paramName) 248private static void RequiresCanWrite(Expression expression, string paramName) 303[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 304public static DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, IEnumerable<Expression> arguments) => 323[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 324public static DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, Expression arg0) => 344[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 345public static DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, Expression arg0, Expression arg1) => 366[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 367public static DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, Expression arg0, Expression arg1, Expression arg2) => 389[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 390public static DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, Expression arg0, Expression arg1, Expression arg2, Expression arg3) => 409[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 410public static DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, params Expression[] arguments) => 426[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 427public static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, IEnumerable<Expression>? arguments) => 443[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 444public static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, Expression arg0) => 461[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 462public static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1) => 480[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 481public static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1, Expression arg2) => 500[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 501public static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1, Expression arg2, Expression arg3) => 517[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 518public static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, params Expression[]? arguments) => 519MakeDynamic(delegateType, binder, (IEnumerable<Expression>?)arguments);
System\Linq\Expressions\Expression.DebuggerProxy.cs (31)
27public Expression Left => _node.Left; 30public Expression Right => _node.Right; 46public ReadOnlyCollection<Expression> Expressions => _node.Expressions; 48public Expression Result => _node.Result; 63public Expression Body => _node.Body; 64public Expression? Filter => _node.Filter; 81public Expression IfFalse => _node.IfFalse; 82public Expression IfTrue => _node.IfTrue; 84public Expression Test => _node.Test; 159public Expression? Value => _node.Value; 172public ReadOnlyCollection<Expression> Arguments => _node.Arguments; 177public Expression? Object => _node.Object; 191public ReadOnlyCollection<Expression> Arguments => _node.Arguments; 194public Expression Expression => _node.Expression; 211public Expression? DefaultValue => _node.DefaultValue; 227public Expression Body => _node.Body; 266public Expression Body => _node.Body; 287public Expression? Expression => _node.Expression; 321public ReadOnlyCollection<Expression> Arguments => _node.Arguments; 326public Expression? Object => _node.Object; 342public ReadOnlyCollection<Expression> Expressions => _node.Expressions; 357public ReadOnlyCollection<Expression> Arguments => _node.Arguments; 411public Expression Body => _node.Body; 412public ReadOnlyCollection<Expression> TestValues => _node.TestValues; 429public Expression? DefaultBody => _node.DefaultBody; 431public Expression SwitchValue => _node.SwitchValue; 445public Expression Body => _node.Body; 448public Expression? Fault => _node.Fault; 449public Expression? Finally => _node.Finally; 467public Expression Expression => _node.Expression; 489public Expression Operand => _node.Operand;
System\Linq\Expressions\ExpressionStringBuilder.cs (33)
69internal static string ExpressionToString(Expression node) 115private void VisitExpressions<T>(char open, ReadOnlyCollection<T> expressions, char close) where T : Expression 120private void VisitExpressions<T>(char open, ReadOnlyCollection<T> expressions, char close, string separator) where T : Expression 142protected internal override Expression VisitBinary(BinaryExpression node) 277protected internal override Expression VisitParameter(ParameterExpression node) 295protected internal override Expression VisitLambda<T>(Expression<T> node) 322protected internal override Expression VisitListInit(ListInitExpression node) 338protected internal override Expression VisitConditional(ConditionalExpression node) 350protected internal override Expression VisitConstant(ConstantExpression node) 379protected internal override Expression VisitDebugInfo(DebugInfoExpression node) 385protected internal override Expression VisitRuntimeVariables(RuntimeVariablesExpression node) 392private void OutMember(Expression? instance, MemberInfo member) 408protected internal override Expression VisitMember(MemberExpression node) 414protected internal override Expression VisitMemberInit(MemberInitExpression node) 497protected internal override Expression VisitInvocation(InvocationExpression node) 511protected internal override Expression VisitMethodCall(MethodCallExpression node) 514Expression? ob = node.Object; 539protected internal override Expression VisitNewArray(NewArrayExpression node) 558protected internal override Expression VisitNew(NewExpression node) 582protected internal override Expression VisitTypeBinary(TypeBinaryExpression node) 600protected internal override Expression VisitUnary(UnaryExpression node) 656protected internal override Expression VisitBlock(BlockExpression node) 669protected internal override Expression VisitDefault(DefaultExpression node) 677protected internal override Expression VisitLabel(LabelExpression node) 685protected internal override Expression VisitGoto(GotoExpression node) 707protected internal override Expression VisitLoop(LoopExpression node) 721protected internal override Expression VisitSwitch(SwitchExpression node) 743protected internal override Expression VisitTry(TryExpression node) 749protected internal override Expression VisitIndex(IndexExpression node) 780protected internal override Expression VisitExtension(Expression node) 784if (toString.DeclaringType != typeof(Expression) && !toString.IsStatic) 811private static bool IsBool(Expression node)
System\Linq\Expressions\ExpressionVisitor.cs (50)
35public virtual Expression? Visit(Expression? node) => node?.Accept(this); 43public ReadOnlyCollection<Expression> Visit(ReadOnlyCollection<Expression> nodes) 46Expression[]? newNodes = null; 49Expression node = Visit(nodes[i]); 57newNodes = new Expression[n]; 69return new TrueReadOnlyCollection<Expression>(newNodes); 72private Expression[]? VisitArguments(IArgumentProvider nodes) 130public T? VisitAndConvert<T>(T? node, string? callerName) where T : Expression 153public ReadOnlyCollection<T> VisitAndConvert<T>(ReadOnlyCollection<T> nodes, string? callerName) where T : Expression 192protected internal virtual Expression VisitBinary(BinaryExpression node) 211protected internal virtual Expression VisitBlock(BlockExpression node) 213Expression[]? nodes = ExpressionVisitorUtils.VisitBlockExpressions(this, node); 230protected internal virtual Expression VisitConditional(ConditionalExpression node) 241protected internal virtual Expression VisitConstant(ConstantExpression node) 252protected internal virtual Expression VisitDebugInfo(DebugInfoExpression node) 263protected internal virtual Expression VisitDefault(DefaultExpression node) 276/// If it is not overridden, this method will call <see cref="Expression.VisitChildren"/>, 278/// <see cref="Expression.VisitChildren"/> will try to reduce the node. 280protected internal virtual Expression VisitExtension(Expression node) 291protected internal virtual Expression VisitGoto(GotoExpression node) 302protected internal virtual Expression VisitInvocation(InvocationExpression node) 304Expression e = Visit(node.Expression); 305Expression[]? a = VisitArguments(node); 332protected internal virtual Expression VisitLabel(LabelExpression node) 344protected internal virtual Expression VisitLambda<T>(Expression<T> node) 346Expression body = Visit(node.Body); 363protected internal virtual Expression VisitLoop(LoopExpression node) 374protected internal virtual Expression VisitMember(MemberExpression node) 385protected internal virtual Expression VisitIndex(IndexExpression node) 387Expression o = Visit(node.Object)!; 388Expression[]? a = VisitArguments(node); 403protected internal virtual Expression VisitMethodCall(MethodCallExpression node) 405Expression o = Visit(node.Object)!; 406Expression[]? a = VisitArguments(node); 421protected internal virtual Expression VisitNewArray(NewArrayExpression node) 432protected internal virtual Expression VisitNew(NewExpression node) 434Expression[]? a = VisitArguments(node); 449protected internal virtual Expression VisitParameter(ParameterExpression node) 460protected internal virtual Expression VisitRuntimeVariables(RuntimeVariablesExpression node) 482protected internal virtual Expression VisitSwitch(SwitchExpression node) 511protected internal virtual Expression VisitTry(TryExpression node) 527protected internal virtual Expression VisitTypeBinary(TypeBinaryExpression node) 538protected internal virtual Expression VisitUnary(UnaryExpression node) 549protected internal virtual Expression VisitMemberInit(MemberInitExpression node) 563protected internal virtual Expression VisitListInit(ListInitExpression node) 712protected internal virtual Expression VisitDynamic(DynamicExpression node) 714Expression[]? a = VisitArguments((IArgumentProvider)node);
System\Linq\Expressions\GotoExpression.cs (18)
38internal GotoExpression(GotoExpressionKind kind, LabelTarget target, Expression? value, Type type) 47/// Gets the static type of the expression that this <see cref="Expression"/> represents. (Inherited from <see cref="Expression"/>.) 53/// Returns the node type of this <see cref="Expression"/>. (Inherited from <see cref="Expression"/>.) 62public Expression? Value { get; } 77protected internal override Expression Accept(ExpressionVisitor visitor) 90public GotoExpression Update(LabelTarget target, Expression? value) 96return Expression.MakeGoto(Kind, target, value, Type); 125public static GotoExpression Break(LabelTarget target, Expression? value) 158public static GotoExpression Break(LabelTarget target, Expression? value, Type type) 233public static GotoExpression Return(LabelTarget target, Expression? value) 251public static GotoExpression Return(LabelTarget target, Expression? value, Type type) 296public static GotoExpression Goto(LabelTarget target, Expression? value) 314public static GotoExpression Goto(LabelTarget target, Expression? value, Type type) 333public static GotoExpression MakeGoto(GotoExpressionKind kind, LabelTarget target, Expression? value, Type type) 339private static void ValidateGoto(LabelTarget target, ref Expression? value, string targetParameter, string valueParameter, Type? type) 358private static void ValidateGotoType(Type expectedType, ref Expression value, string paramName)
System\Linq\Expressions\IArgumentProvider.cs (4)
31/// the node is initially constructed this holds directly onto the <see cref="Expression"/> of the 34/// which handles the <see cref="Expression"/> or <see cref="Collections.ObjectModel.ReadOnlyCollection{T}"/> case. 38/// It is important that <see cref="Expression"/> properties consistently return the same 52Expression GetArgument(int index);
System\Linq\Expressions\IDynamicExpression.cs (2)
23Expression Rewrite(Expression[] args);
System\Linq\Expressions\IndexExpression.cs (56)
21private IReadOnlyList<Expression> _arguments; 24Expression? instance, 26IReadOnlyList<Expression> arguments) 40/// Returns the node type of this <see cref="Expression"/>. (Inherited from <see cref="Expression"/>.) 46/// Gets the static type of the expression that this <see cref="Expression"/> represents. (Inherited from <see cref="Expression"/>.) 64public Expression? Object { get; } 74public ReadOnlyCollection<Expression> Arguments 87public IndexExpression Update(Expression @object, IEnumerable<Expression>? arguments) 105public Expression GetArgument(int index) => _arguments[index]; 115protected internal override Expression Accept(ExpressionVisitor visitor) 120internal Expression Rewrite(Expression instance, Expression[]? arguments) 125return Expression.MakeIndex(instance, Indexer, arguments ?? _arguments); 135/// <param name="indexer">An <see cref="Expression"/> representing the property to index.</param> 138public static IndexExpression MakeIndex(Expression instance, PropertyInfo? indexer, IEnumerable<Expression>? arguments) 158/// or through <see cref="NewArrayBounds(Type, Expression[])"/> or <see cref="NewArrayInit(Type, Expression[])"/>.</remarks> 160public static IndexExpression ArrayAccess(Expression array, params Expression[]? indexes) 162return ArrayAccess(array, (IEnumerable<Expression>?)indexes); 171/// or through <see cref="NewArrayBounds(Type, IEnumerable{Expression})"/> or <see cref="NewArrayInit(Type, IEnumerable{Expression})"/>.</remarks> 173public static IndexExpression ArrayAccess(Expression array, IEnumerable<Expression>? indexes) 183ReadOnlyCollection<Expression> indexList = indexes.ToReadOnly(); 189foreach (Expression e in indexList) 210/// <param name="arguments">An array of <see cref="Expression"/> objects that are used to index the property.</param> 213public static IndexExpression Property(Expression instance, string propertyName, params Expression[]? arguments) 230Expression[]? arguments) 254private static string GetArgTypesString(Expression[] arguments) 273Expression[]? arguments, 296private static bool IsCompatible(PropertyInfo pi, Expression[]? args) 346/// <param name="arguments">An array of <see cref="Expression"/> objects that are used to index the property.</param> 348public static IndexExpression Property(Expression? instance, PropertyInfo indexer, params Expression[]? arguments) 350return Property(instance, indexer, (IEnumerable<Expression>?)arguments); 358/// <param name="arguments">An <see cref="IEnumerable{T}"/> of <see cref="Expression"/> objects that are used to index the property.</param> 360public static IndexExpression Property(Expression? instance, PropertyInfo indexer, IEnumerable<Expression>? arguments) => 363private static IndexExpression MakeIndexProperty(Expression? instance, PropertyInfo indexer, string paramName, ReadOnlyCollection<Expression> argList) 374private static void ValidateIndexedProperty(Expression? instance, PropertyInfo indexer, string paramName, ref ReadOnlyCollection<Expression> argList) 458private static void ValidateAccessor(Expression? instance, MethodInfo method, ParameterInfo[] indexes, ref ReadOnlyCollection<Expression> arguments, string? paramName) 489private static void ValidateAccessorArgumentTypes(MethodInfo method, ParameterInfo[] indexes, ref ReadOnlyCollection<Expression> arguments, string? paramName) 497Expression[]? newArgs = null; 500Expression arg = arguments[i]; 517newArgs = new Expression[arguments.Count]; 530arguments = new TrueReadOnlyCollection<Expression>(newArgs);
System\Linq\Expressions\Interpreter\ArrayOperations.cs (3)
8[RequiresDynamicCode(Expression.NewArrayRequiresDynamicCode)] 36[RequiresDynamicCode(Expression.NewArrayRequiresDynamicCode)] 61[RequiresDynamicCode(Expression.NewArrayRequiresDynamicCode)]
System\Linq\Expressions\Interpreter\CallInstruction.cs (1)
209[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)]
System\Linq\Expressions\Interpreter\CallInstruction.Generated.cs (4)
35[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 75[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 119[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 163[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)]
System\Linq\Expressions\Interpreter\InstructionList.cs (3)
636[RequiresDynamicCode(Expression.NewArrayRequiresDynamicCode)] 639[RequiresDynamicCode(Expression.NewArrayRequiresDynamicCode)] 645[RequiresDynamicCode(Expression.NewArrayRequiresDynamicCode)]
System\Linq\Expressions\Interpreter\LightCompiler.cs (100)
344private void CompileConstantExpression(Expression expr) 350private void CompileDefaultExpression(Expression expr) 509private void CompileParameterExpression(Expression expr) 515private void CompileBlockExpression(Expression expr, bool asVoid) 523Expression lastExpression = node.Expressions[node.Expressions.Count - 1]; 570private void CompileIndexExpression(Expression expr) 626local = _locals.DefineLocal(Expression.Parameter(node.Right.Type), _instructions.Count); 653Expression? expr = member.Expression; 662private void CompileMemberAssignment(bool asVoid, MemberInfo refMember, Expression value, bool forBinding) 677LocalDefinition local = _locals.DefineLocal(Expression.Parameter(value.Type), start); 708LocalDefinition local = _locals.DefineLocal(Expression.Parameter(value.Type), start); 729private void CompileAssignBinaryExpression(Expression expr, bool asVoid) 753private void CompileBinaryExpression(Expression expr) 769LocalDefinition leftTemp = _locals.DefineLocal(Expression.Parameter(node.Left.Type), _instructions.Count); 773LocalDefinition rightTemp = _locals.DefineLocal(Expression.Parameter(node.Right.Type), _instructions.Count); 963private static bool IsNullComparison(Expression left, Expression right) 970private static bool IsNullConstant(Expression e) 976private void CompileEqual(Expression left, Expression right, bool liftedToNull) 986private void CompileNotEqual(Expression left, Expression right, bool liftedToNull) 998Expression left = node.Left; 999Expression right = node.Right; 1015private void CompileArithmetic(ExpressionType nodeType, Expression left, Expression right) 1034private void CompileConvertUnaryExpression(Expression expr) 1045Expression operand = node.Operand; 1047LocalDefinition opTemp = _locals.DefineLocal(Expression.Parameter(operandType), _instructions.Count); 1225private void CompileUnaryExpression(Expression expr) 1323private void CompileAndAlsoBinaryExpression(Expression expr) 1328private void CompileOrElseBinaryExpression(Expression expr) 1378LocalDefinition result = _locals.DefineLocal(Expression.Parameter(node.Left.Type), _instructions.Count); 1379LocalDefinition leftTemp = _locals.DefineLocal(Expression.Parameter(node.Left.Type), _instructions.Count); 1403LocalDefinition rightTemp = _locals.DefineLocal(Expression.Parameter(node.Right.Type), _instructions.Count); 1473private void CompileConditionalExpression(Expression expr, bool asVoid) 1506private void CompileLoopExpression(Expression expr) 1527private void CompileSwitchExpression(Expression expr) 1599LocalDefinition temp = _locals.DefineLocal(Expression.Parameter(node.SwitchValue.Type), _instructions.Count); 1603LabelTarget doneLabel = Expression.Label(node.Type, "done"); 1607foreach (Expression val in @case.TestValues) 1613Expression.Condition( 1614Expression.Equal(temp.Parameter, val, false, node.Comparison), 1615Expression.Goto(doneLabel, @case.Body), 1623CompileLabelExpression(Expression.Label(doneLabel, node.DefaultBody)); 1724private void CompileLabelExpression(Expression expr) 1764private void CompileGotoExpression(Expression expr) 1818private bool TryPushLabelBlock(Expression node) 1894private void DefineBlockLabels(Expression? node) 1904Expression e = block.Expressions[i]; 1932private void CompileThrowUnaryExpression(Expression expr, bool asVoid) 1964private void CompileTryExpression(Expression expr) 2009ParameterExpression parameter = handler.Variable ?? Expression.Parameter(handler.Test); 2133private void CompileMethodCallExpression(Expression expr) 2139private void CompileMethodCallExpression(Expression @object, MethodInfo method, IArgumentProvider arguments) 2158Expression arg = arguments.GetArgument(i); 2203private ByRefUpdater CompileArrayIndexAddress(Expression array, Expression index, int argumentIndex) 2205LocalDefinition left = _locals.DefineLocal(Expression.Parameter(array.Type, nameof(array)), _instructions.Count); 2206LocalDefinition right = _locals.DefineLocal(Expression.Parameter(index.Type, nameof(index)), _instructions.Count); 2219private void EmitThisForMethodCall(Expression node) 2224private static bool ShouldWritebackNode(Expression node) 2249private ByRefUpdater? CompileAddress(Expression node, int index) 2270objTmp = _locals.DefineLocal(Expression.Parameter(indexNode.Object.Type), _instructions.Count); 2280Expression arg = indexNode.GetArgument(i); 2283LocalDefinition argTmp = _locals.DefineLocal(Expression.Parameter(arg.Type), _instructions.Count); 2308memberTemp = _locals.DefineLocal(Expression.Parameter(member.Expression.Type, "member"), _instructions.Count); 2357private ByRefUpdater CompileMultiDimArrayAccess(Expression array, IArgumentProvider arguments, int index) 2360LocalDefinition objTmp = _locals.DefineLocal(Expression.Parameter(array.Type), _instructions.Count); 2368Expression arg = arguments.GetArgument(i); 2371LocalDefinition argTmp = _locals.DefineLocal(Expression.Parameter(arg.Type), _instructions.Count); 2383private void CompileNewExpression(Expression expr) 2397Expression arg = node.GetArgument(i); 2438private void CompileMemberExpression(Expression expr) 2445private void CompileMember(Expression? from, MemberInfo member, bool forBinding) 2515private void CompileNewArrayExpression(Expression expr) 2520foreach (Expression arg in node.Expressions) 2546private void CompileDebugInfoExpression(Expression expr) 2561private void CompileRuntimeVariablesExpression(Expression expr) 2574private void CompileLambdaExpression(Expression expr) 2591private void CompileCoalesceBinaryExpression(Expression expr) 2642ParameterExpression temp = Expression.Parameter(node.Left.Type, "temp"); 2647Expression.Call(node.Conversion, node.Conversion.Type.GetInvokeMethod(), new[] { temp }) 2664private void CompileInvocationExpression(Expression expr) 2672Expression.Call( 2688private void CompileListInitExpression(Expression expr) 2702foreach (Expression arg in initializer.Arguments) 2713private void CompileMemberInitExpression(Expression expr) 2768private void CompileQuoteUnaryExpression(Expression expr) 2791protected internal override Expression VisitParameter(ParameterExpression node) 2800protected internal override Expression VisitBlock(BlockExpression node) 2826protected internal override Expression VisitLambda<T>(Expression<T> node) 2886private void CompileUnboxUnaryExpression(Expression expr) 2898private void CompileTypeEqualExpression(Expression expr) 2921private void CompileTypeIsExpression(Expression expr) 2965private void Compile(Expression expr, bool asVoid) 2977private void CompileAsVoid(Expression expr) 3016private void CompileNoLabelPush(Expression expr) 3023_guard.RunOnEmptyStack((LightCompiler @this, Expression e) => @this.CompileNoLabelPush(e), this, expr); 3103private void Compile(Expression expr)
System\Linq\Expressions\Interpreter\TypeOperations.cs (19)
467private readonly Expression _operand; 470public QuoteInstruction(Expression operand, Dictionary<ParameterExpression, LocalVariable>? hoistedVariables) 482Expression? operand = _operand; 513protected internal override Expression VisitLambda<T>(Expression<T> node) 526Expression? b = Visit(node.Body); 538protected internal override Expression VisitBlock(BlockExpression node) 544Expression[]? b = ExpressionVisitorUtils.VisitBlockExpressions(this, node); 562Expression? b = Visit(node.Body); 563Expression? f = Visit(node.Filter); 572return Expression.MakeCatchBlock(node.Test, node.Variable, b, f); 575protected internal override Expression VisitRuntimeVariables(RuntimeVariablesExpression node) 602ConstantExpression boxesConst = Expression.Constant(new RuntimeOps.RuntimeVariables(boxes.ToArray()), typeof(IRuntimeVariables)); 610return Expression.Invoke( 611Expression.Constant(new Func<IRuntimeVariables, IRuntimeVariables, int[], IRuntimeVariables>(MergeRuntimeVariables)), 612Expression.RuntimeVariables(new TrueReadOnlyCollection<ParameterExpression>(vars.ToArray())), 614Expression.Constant(indexes) 623protected internal override Expression VisitParameter(ParameterExpression node) 630return Expression.Convert(Utils.GetStrongBoxValueField(Expression.Constant(box)), node.Type);
System\Linq\Expressions\InvocationExpression.cs (157)
19internal InvocationExpression(Expression expression, Type returnType) 41public Expression Expression { get; } 46public ReadOnlyCollection<Expression> Arguments => GetOrMakeArguments(); 56public InvocationExpression Update(Expression expression, IEnumerable<Expression>? arguments) 70internal virtual ReadOnlyCollection<Expression> GetOrMakeArguments() 81public virtual Expression GetArgument(int index) 101protected internal override Expression Accept(ExpressionVisitor visitor) 107internal virtual InvocationExpression Rewrite(Expression lambda, Expression[]? arguments) 127private IReadOnlyList<Expression> _arguments; 129public InvocationExpressionN(Expression lambda, IReadOnlyList<Expression> arguments, Type returnType) 135internal override ReadOnlyCollection<Expression> GetOrMakeArguments() 140public override Expression GetArgument(int index) => _arguments[index]; 144internal override InvocationExpression Rewrite(Expression lambda, Expression[]? arguments) 149return Expression.Invoke(lambda, arguments ?? _arguments); 155public InvocationExpression0(Expression lambda, Type returnType) 160internal override ReadOnlyCollection<Expression> GetOrMakeArguments() 162return ReadOnlyCollection<Expression>.Empty; 165public override Expression GetArgument(int index) 172internal override InvocationExpression Rewrite(Expression lambda, Expression[]? arguments) 177return Expression.Invoke(lambda); 185public InvocationExpression1(Expression lambda, Type returnType, Expression arg0) 191internal override ReadOnlyCollection<Expression> GetOrMakeArguments() 196public override Expression GetArgument(int index) => 1990 => ExpressionUtils.ReturnObject<Expression>(_arg0), 205internal override InvocationExpression Rewrite(Expression lambda, Expression[]? arguments) 212return Expression.Invoke(lambda, arguments[0]); 214return Expression.Invoke(lambda, ExpressionUtils.ReturnObject<Expression>(_arg0)); 221private readonly Expression _arg1; // storage for the 2nd argument 223public InvocationExpression2(Expression lambda, Type returnType, Expression arg0, Expression arg1) 230internal override ReadOnlyCollection<Expression> GetOrMakeArguments() 235public override Expression GetArgument(int index) => 2380 => ExpressionUtils.ReturnObject<Expression>(_arg0), 245internal override InvocationExpression Rewrite(Expression lambda, Expression[]? arguments) 252return Expression.Invoke(lambda, arguments[0], arguments[1]); 254return Expression.Invoke(lambda, ExpressionUtils.ReturnObject<Expression>(_arg0), _arg1); 261private readonly Expression _arg1; // storage for the 2nd argument 262private readonly Expression _arg2; // storage for the 3rd argument 264public InvocationExpression3(Expression lambda, Type returnType, Expression arg0, Expression arg1, Expression arg2) 272internal override ReadOnlyCollection<Expression> GetOrMakeArguments() 277public override Expression GetArgument(int index) => 2800 => ExpressionUtils.ReturnObject<Expression>(_arg0), 288internal override InvocationExpression Rewrite(Expression lambda, Expression[]? arguments) 295return Expression.Invoke(lambda, arguments[0], arguments[1], arguments[2]); 297return Expression.Invoke(lambda, ExpressionUtils.ReturnObject<Expression>(_arg0), _arg1, _arg2); 304private readonly Expression _arg1; // storage for the 2nd argument 305private readonly Expression _arg2; // storage for the 3rd argument 306private readonly Expression _arg3; // storage for the 4th argument 308public InvocationExpression4(Expression lambda, Type returnType, Expression arg0, Expression arg1, Expression arg2, Expression arg3) 317internal override ReadOnlyCollection<Expression> GetOrMakeArguments() 322public override Expression GetArgument(int index) => 3250 => ExpressionUtils.ReturnObject<Expression>(_arg0), 334internal override InvocationExpression Rewrite(Expression lambda, Expression[]? arguments) 341return Expression.Invoke(lambda, arguments[0], arguments[1], arguments[2], arguments[3]); 343return Expression.Invoke(lambda, ExpressionUtils.ReturnObject<Expression>(_arg0), _arg1, _arg2, _arg3); 350private readonly Expression _arg1; // storage for the 2nd argument 351private readonly Expression _arg2; // storage for the 3rd argument 352private readonly Expression _arg3; // storage for the 4th argument 353private readonly Expression _arg4; // storage for the 5th argument 355public InvocationExpression5(Expression lambda, Type returnType, Expression arg0, Expression arg1, Expression arg2, Expression arg3, Expression arg4) 365internal override ReadOnlyCollection<Expression> GetOrMakeArguments() 370public override Expression GetArgument(int index) => 3730 => ExpressionUtils.ReturnObject<Expression>(_arg0), 383internal override InvocationExpression Rewrite(Expression lambda, Expression[]? arguments) 390return Expression.Invoke(lambda, arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]); 392return Expression.Invoke(lambda, ExpressionUtils.ReturnObject<Expression>(_arg0), _arg1, _arg2, _arg3, _arg4); 409/// An <see cref="Expression"/> that represents the delegate 418internal static InvocationExpression Invoke(Expression expression) 442/// An <see cref="Expression"/> that represents the delegate 446/// The <see cref="Expression"/> that represents the first argument. 451/// <paramref name="expression"/>.Type does not represent a delegate type or an <see cref="Expression{TDelegate}"/>.-or-The <see cref="Expression.Type"/> property of an argument expression is not assignable to the type of the corresponding parameter of the delegate represented by <paramref name="expression"/>.</exception> 454internal static InvocationExpression Invoke(Expression expression, Expression arg0) 480/// An <see cref="Expression"/> that represents the delegate 484/// The <see cref="Expression"/> that represents the first argument. 487/// The <see cref="Expression"/> that represents the second argument. 492/// <paramref name="expression"/>.Type does not represent a delegate type or an <see cref="Expression{TDelegate}"/>.-or-The <see cref="Expression.Type"/> property of an argument expression is not assignable to the type of the corresponding parameter of the delegate represented by <paramref name="expression"/>.</exception> 495internal static InvocationExpression Invoke(Expression expression, Expression arg0, Expression arg1) 521/// An <see cref="Expression"/> that represents the delegate 525/// The <see cref="Expression"/> that represents the first argument. 528/// The <see cref="Expression"/> that represents the second argument. 531/// The <see cref="Expression"/> that represents the third argument. 536/// <paramref name="expression"/>.Type does not represent a delegate type or an <see cref="Expression{TDelegate}"/>.-or-The <see cref="Expression.Type"/> property of an argument expression is not assignable to the type of the corresponding parameter of the delegate represented by <paramref name="expression"/>.</exception> 539internal static InvocationExpression Invoke(Expression expression, Expression arg0, Expression arg1, Expression arg2) 567/// An <see cref="Expression"/> that represents the delegate 571/// The <see cref="Expression"/> that represents the first argument. 574/// The <see cref="Expression"/> that represents the second argument. 577/// The <see cref="Expression"/> that represents the third argument. 580/// The <see cref="Expression"/> that represents the fourth argument. 585/// <paramref name="expression"/>.Type does not represent a delegate type or an <see cref="Expression{TDelegate}"/>.-or-The <see cref="Expression.Type"/> property of an argument expression is not assignable to the type of the corresponding parameter of the delegate represented by <paramref name="expression"/>.</exception> 588internal static InvocationExpression Invoke(Expression expression, Expression arg0, Expression arg1, Expression arg2, Expression arg3) 617/// An <see cref="Expression"/> that represents the delegate 621/// The <see cref="Expression"/> that represents the first argument. 624/// The <see cref="Expression"/> that represents the second argument. 627/// The <see cref="Expression"/> that represents the third argument. 630/// The <see cref="Expression"/> that represents the fourth argument. 633/// The <see cref="Expression"/> that represents the fifth argument. 638/// <paramref name="expression"/>.Type does not represent a delegate type or an <see cref="Expression{TDelegate}"/>.-or-The <see cref="Expression.Type"/> property of an argument expression is not assignable to the type of the corresponding parameter of the delegate represented by <paramref name="expression"/>.</exception> 641internal static InvocationExpression Invoke(Expression expression, Expression arg0, Expression arg1, Expression arg2, Expression arg3, Expression arg4) 671/// An <see cref="Expression"/> that represents the delegate 675/// An array of <see cref="Expression"/> objects 681/// <paramref name="expression"/>.Type does not represent a delegate type or an <see cref="Expression{TDelegate}"/>.-or-The <see cref="Expression.Type"/> property of an element of <paramref name="arguments"/> is not assignable to the type of the corresponding parameter of the delegate represented by <paramref name="expression"/>.</exception> 684public static InvocationExpression Invoke(Expression expression, params Expression[]? arguments) 686return Invoke(expression, (IEnumerable<Expression>?)arguments); 698/// An <see cref="Expression"/> that represents the delegate 702/// An <see cref="Collections.Generic.IEnumerable{TDelegate}"/> of <see cref="Expression"/> objects 708/// <paramref name="expression"/>.Type does not represent a delegate type or an <see cref="Expression{TDelegate}"/>.-or-The <see cref="Expression.Type"/> property of an element of <paramref name="arguments"/> is not assignable to the type of the corresponding parameter of the delegate represented by <paramref name="expression"/>.</exception> 711public static InvocationExpression Invoke(Expression expression, IEnumerable<Expression>? arguments) 713IReadOnlyList<Expression> argumentList = arguments as IReadOnlyList<Expression> ?? arguments.ToReadOnly(); 733ReadOnlyCollection<Expression> args = argumentList.ToReadOnly(); // Ensure is TrueReadOnlyCollection when count > 5. Returns fast if it already is. 743internal static MethodInfo GetInvokeMethod(Expression expression)
System\Linq\Expressions\LabelExpression.cs (11)
9/// Represents a label, which can be placed in any <see cref="Expression"/> context. If 17internal LabelExpression(LabelTarget label, Expression? defaultValue) 24/// Gets the static type of the expression that this <see cref="Expression"/> represents. (Inherited from <see cref="Expression"/>.) 30/// Returns the node type of this <see cref="Expression"/>. (Inherited from <see cref="Expression"/>.) 44public Expression? DefaultValue { get; } 49protected internal override Expression Accept(ExpressionVisitor visitor) 62public LabelExpression Update(LabelTarget target, Expression? defaultValue) 68return Expression.Label(target, defaultValue); 90public static LabelExpression Label(LabelTarget target, Expression? defaultValue)
System\Linq\Expressions\LambdaExpression.cs (86)
26private readonly Expression _body; 34internal LambdaExpression(Expression body) 40/// Gets the static type of the expression that this <see cref="Expression"/> represents. (Inherited from <see cref="Expression"/>.) 50/// Returns the node type of this <see cref="Expression"/>. (Inherited from <see cref="Expression"/>.) 71public Expression Body => _body; 204internal Expression(Expression body) 253public Expression<TDelegate> Update(Expression body, IEnumerable<ParameterExpression>? parameters) 289internal virtual Expression<TDelegate> Rewrite(Expression body, ParameterExpression[]? parameters) 297protected internal override Expression Accept(ExpressionVisitor visitor) 307internal static Expression<TDelegate> Create(Expression body, string? name, bool tailCall, IReadOnlyList<ParameterExpression> parameters) 338public static Expression<TDelegate> CreateExpressionFunc(Expression body, string? name, bool tailCall, ReadOnlyCollection<ParameterExpression> parameters) 358public Expression0(Expression body) 375internal override Expression<TDelegate> Rewrite(Expression body, ParameterExpression[]? parameters) 380return Expression.Lambda<TDelegate>(body, parameters); 388public Expression1(Expression body, ParameterExpression par0) 419internal override Expression<TDelegate> Rewrite(Expression body, ParameterExpression[]? parameters) 426return Expression.Lambda<TDelegate>(body, parameters); 429return Expression.Lambda<TDelegate>(body, ExpressionUtils.ReturnObject<ParameterExpression>(_par0)); 438public Expression2(Expression body, ParameterExpression par0, ParameterExpression par1) 481internal override Expression<TDelegate> Rewrite(Expression body, ParameterExpression[]? parameters) 488return Expression.Lambda<TDelegate>(body, parameters); 491return Expression.Lambda<TDelegate>(body, ExpressionUtils.ReturnObject<ParameterExpression>(_par0), _par1); 501public Expression3(Expression body, ParameterExpression par0, ParameterExpression par1, ParameterExpression par2) 549internal override Expression<TDelegate> Rewrite(Expression body, ParameterExpression[]? parameters) 556return Expression.Lambda<TDelegate>(body, parameters); 559return Expression.Lambda<TDelegate>(body, ExpressionUtils.ReturnObject<ParameterExpression>(_par0), _par1, _par2); 567public ExpressionN(Expression body, IReadOnlyList<ParameterExpression> parameters) 582internal override Expression<TDelegate> Rewrite(Expression body, ParameterExpression[]? parameters) 587return Expression.Lambda<TDelegate>(body, Name, TailCall, parameters ?? _parameters); 593public FullExpression(Expression body, string? name, bool tailCall, IReadOnlyList<ParameterExpression> parameters) 612internal static LambdaExpression CreateLambda(Type delegateType, Expression body, string? name, bool tailCall, ReadOnlyCollection<ParameterExpression> parameters) 617Func<Expression, string?, bool, ReadOnlyCollection<ParameterExpression>, LambdaExpression>? fastPath; 618CacheDict<Type, Func<Expression, string?, bool, ReadOnlyCollection<ParameterExpression>, LambdaExpression>>? factories = 619s_lambdaFactories ??= new CacheDict<Type, Func<Expression, string?, bool, ReadOnlyCollection<ParameterExpression>, LambdaExpression>>(50); 638factories[delegateType] = fastPath = (Func<Expression, string?, bool, ReadOnlyCollection<ParameterExpression>, LambdaExpression>)create.CreateDelegate(typeof(Func<Expression, string?, bool, ReadOnlyCollection<ParameterExpression>, LambdaExpression>)); 648/// <param name="body">An <see cref="Expression"/> to set the <see cref="LambdaExpression.Body"/> property equal to.</param> 651public static Expression<TDelegate> Lambda<TDelegate>(Expression body, params ParameterExpression[]? parameters) 660/// <param name="body">An <see cref="Expression"/> to set the <see cref="LambdaExpression.Body"/> property equal to.</param> 664public static Expression<TDelegate> Lambda<TDelegate>(Expression body, bool tailCall, params ParameterExpression[]? parameters) 673/// <param name="body">An <see cref="Expression"/> to set the <see cref="LambdaExpression.Body"/> property equal to.</param> 676public static Expression<TDelegate> Lambda<TDelegate>(Expression body, IEnumerable<ParameterExpression>? parameters) 685/// <param name="body">An <see cref="Expression"/> to set the <see cref="LambdaExpression.Body"/> property equal to.</param> 689public static Expression<TDelegate> Lambda<TDelegate>(Expression body, bool tailCall, IEnumerable<ParameterExpression>? parameters) 698/// <param name="body">An <see cref="Expression"/> to set the <see cref="LambdaExpression.Body"/> property equal to.</param> 702public static Expression<TDelegate> Lambda<TDelegate>(Expression body, string? name, IEnumerable<ParameterExpression>? parameters) 711/// <param name="body">An <see cref="Expression"/> to set the <see cref="LambdaExpression.Body"/> property equal to.</param> 716public static Expression<TDelegate> Lambda<TDelegate>(Expression body, string? name, bool tailCall, IEnumerable<ParameterExpression>? parameters) 733/// <param name="body">An <see cref="Expression"/> to set the <see cref="LambdaExpression.Body"/> property equal to.</param> 736[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 737public static LambdaExpression Lambda(Expression body, params ParameterExpression[]? parameters) 745/// <param name="body">An <see cref="Expression"/> to set the <see cref="LambdaExpression.Body"/> property equal to.</param> 749[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 750public static LambdaExpression Lambda(Expression body, bool tailCall, params ParameterExpression[]? parameters) 758/// <param name="body">An <see cref="Expression"/> to set the <see cref="LambdaExpression.Body"/> property equal to.</param> 761[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 762public static LambdaExpression Lambda(Expression body, IEnumerable<ParameterExpression>? parameters) 770/// <param name="body">An <see cref="Expression"/> to set the <see cref="LambdaExpression.Body"/> property equal to.</param> 774[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 775public static LambdaExpression Lambda(Expression body, bool tailCall, IEnumerable<ParameterExpression>? parameters) 783/// <param name="body">An <see cref="Expression"/> to set the <see cref="LambdaExpression.Body"/> property equal to.</param> 787public static LambdaExpression Lambda(Type delegateType, Expression body, params ParameterExpression[]? parameters) 795/// <param name="body">An <see cref="Expression"/> to set the <see cref="LambdaExpression.Body"/> property equal to.</param> 800public static LambdaExpression Lambda(Type delegateType, Expression body, bool tailCall, params ParameterExpression[]? parameters) 808/// <param name="body">An <see cref="Expression"/> to set the <see cref="LambdaExpression.Body"/> property equal to.</param> 812public static LambdaExpression Lambda(Type delegateType, Expression body, IEnumerable<ParameterExpression>? parameters) 820/// <param name="body">An <see cref="Expression"/> to set the <see cref="LambdaExpression.Body"/> property equal to.</param> 825public static LambdaExpression Lambda(Type delegateType, Expression body, bool tailCall, IEnumerable<ParameterExpression>? parameters) 833/// <param name="body">An <see cref="Expression"/> to set the <see cref="LambdaExpression.Body"/> property equal to.</param> 837[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 838public static LambdaExpression Lambda(Expression body, string? name, IEnumerable<ParameterExpression>? parameters) 846/// <param name="body">An <see cref="Expression"/> to set the <see cref="LambdaExpression.Body"/> property equal to.</param> 851[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 852public static LambdaExpression Lambda(Expression body, string? name, bool tailCall, IEnumerable<ParameterExpression>? parameters) 884/// <param name="body">An <see cref="Expression"/> to set the <see cref="LambdaExpression.Body"/> property equal to.</param> 889public static LambdaExpression Lambda(Type delegateType, Expression body, string? name, IEnumerable<ParameterExpression>? parameters) 901/// <param name="body">An <see cref="Expression"/> to set the <see cref="LambdaExpression.Body"/> property equal to.</param> 906public static LambdaExpression Lambda(Type delegateType, Expression body, string? name, bool tailCall, IEnumerable<ParameterExpression>? parameters) 914private static void ValidateLambdaArgs(Type delegateType, ref Expression body, ReadOnlyCollection<ParameterExpression> parameters, string paramName) 1026[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 1056[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 1073[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 1102[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)] 1124[RequiresDynamicCode(Expression.DelegateCreationRequiresDynamicCode)]
System\Linq\Expressions\ListInitExpression.cs (20)
18/// Use the <see cref="Expression.ListInit(NewExpression, Expression[])"/> factory methods to create a ListInitExpression. 31/// Returns the node type of this <see cref="Expression"/>. (Inherited from <see cref="Expression"/>.) 37/// Gets the static type of the expression that this <see cref="Expression"/> represents. (Inherited from <see cref="Expression"/>.) 60protected internal override Expression Accept(ExpressionVisitor visitor) 72public override Expression Reduce() 105/// <param name="initializers">An array of <see cref="Expression"/> objects to use to populate the <see cref="ListInitExpression.Initializers"/> collection.</param> 109public static ListInitExpression ListInit(NewExpression newExpression, params Expression[] initializers) 111return ListInit(newExpression, initializers as IEnumerable<Expression>); 122public static ListInitExpression ListInit(NewExpression newExpression, IEnumerable<Expression> initializers) 127ReadOnlyCollection<Expression> initializerlist = initializers.ToReadOnly(); 133MethodInfo? addMethod = FindMethod(newExpression.Type, "Add", null, new Expression[] { initializerlist[0] }, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); 142/// <param name="initializers">An array of <see cref="Expression"/> objects to use to populate the <see cref="ListInitExpression.Initializers"/> collection.</param> 146public static ListInitExpression ListInit(NewExpression newExpression, MethodInfo? addMethod, params Expression[] initializers) 148return ListInit(newExpression, addMethod, initializers as IEnumerable<Expression>); 156/// <param name="initializers">An <see cref="IEnumerable{T}"/> that contains <see cref="Expression"/> objects to use to populate the Initializers collection.</param> 160public static ListInitExpression ListInit(NewExpression newExpression, MethodInfo? addMethod, IEnumerable<Expression> initializers) 169ReadOnlyCollection<Expression> initializerlist = initializers.ToReadOnly();
System\Linq\Expressions\LoopExpression.cs (10)
15internal LoopExpression(Expression body, LabelTarget? @break, LabelTarget? @continue) 23/// Gets the static type of the expression that this <see cref="Expression"/> represents. 36/// Gets the <see cref="Expression"/> that is the body of the loop. 38public Expression Body { get; } 53protected internal override Expression Accept(ExpressionVisitor visitor) 67public LoopExpression Update(LabelTarget? breakLabel, LabelTarget? continueLabel, Expression body) 73return Expression.Loop(body, breakLabel, continueLabel); 84public static LoopExpression Loop(Expression body) 95public static LoopExpression Loop(Expression body, LabelTarget? @break) 107public static LoopExpression Loop(Expression body, LabelTarget? @break, LabelTarget? @continue)
System\Linq\Expressions\MemberAssignment.cs (7)
15private readonly Expression _expression; 17internal MemberAssignment(MemberInfo member, Expression expression) 28public Expression Expression => _expression; 37public MemberAssignment Update(Expression expression) 43return Expression.Bind(Member, expression); 59public static MemberAssignment Bind(MemberInfo member, Expression expression) 79public static MemberAssignment Bind(MethodInfo propertyAccessor, Expression expression)
System\Linq\Expressions\MemberExpression.cs (23)
25public Expression? Expression { get; } 28internal MemberExpression(Expression? expression) 33internal static PropertyExpression Make(Expression? expression, PropertyInfo property) 39internal static FieldExpression Make(Expression? expression, FieldInfo field) 45internal static MemberExpression Make(Expression? expression, MemberInfo member) 66protected internal override Expression Accept(ExpressionVisitor visitor) 78public MemberExpression Update(Expression? expression) 84return Expression.MakeMemberAccess(expression, Member); 92public FieldExpression(Expression? expression, FieldInfo member) 106public PropertyExpression(Expression? expression, PropertyInfo member) 127public static MemberExpression Field(Expression? expression, FieldInfo field) 154public static MemberExpression Field(Expression expression, string fieldName) 166return Expression.Field(expression, fi); 177Expression? expression, 192return Expression.Field(expression, fi); 206public static MemberExpression Property(Expression expression, string propertyName) 228Expression? expression, 250public static MemberExpression Property(Expression? expression, PropertyInfo property) 300public static MemberExpression Property(Expression? expression, MethodInfo propertyAccessor) 360public static MemberExpression PropertyOrField(Expression expression, string propertyOrFieldName) 386public static MemberExpression MakeMemberAccess(Expression? expression, MemberInfo member) 392return Expression.Field(expression, fi); 396return Expression.Property(expression, pi);
System\Linq\Expressions\MemberInitExpression.cs (17)
24/// Gets the static type of the expression that this <see cref="Expression"/> represents. 52protected internal override Expression Accept(ExpressionVisitor visitor) 64public override Expression Reduce() 69private static Expression ReduceMemberInit( 70Expression objExpression, ReadOnlyCollection<MemberBinding> bindings, bool keepOnStack) 74Expression[] block = new Expression[count + 2]; 81block[count + 1] = keepOnStack ? (Expression)objVar : Utils.Empty; 85internal static Expression ReduceListInit( 86Expression listExpression, ReadOnlyCollection<ElementInit> initializers, bool keepOnStack) 90Expression[] block = new Expression[count + 2]; 98block[count + 1] = keepOnStack ? (Expression)listVar : Utils.Empty; 102internal static Expression ReduceMemberBinding(ParameterExpression objVar, MemberBinding binding) 104MemberExpression member = Expression.MakeMemberAccess(objVar, binding.Member); 107MemberBindingType.Assignment => Expression.Assign(member, ((MemberAssignment)binding).Expression), 132return Expression.MemberInit(newExpression, bindings!);
System\Linq\Expressions\MemberListBinding.cs (1)
49return Expression.ListBind(Member, initializers!);
System\Linq\Expressions\MemberMemberBinding.cs (2)
17/// Use the <see cref="Expression.MemberBind(MemberInfo, MemberBinding[])"/> factory methods to create a <see cref="MemberMemberBinding"/>. 52return Expression.MemberBind(Member, bindings!);
System\Linq\Expressions\MethodCallExpression.cs (268)
24internal virtual Expression? GetInstance() => null; 27/// Returns the node type of this <see cref="Expression"/>. (Inherited from <see cref="Expression"/>.) 33/// Gets the static type of the expression that this <see cref="Expression"/> represents. (Inherited from <see cref="Expression"/>.) 44/// Gets the <see cref="Expression"/> that represents the instance 47public Expression? Object => GetInstance(); 52public ReadOnlyCollection<Expression> Arguments => GetOrMakeArguments(); 62public MethodCallExpression Update(Expression? @object, IEnumerable<Expression>? arguments) 68ICollection<Expression>? args; 75args = arguments as ICollection<Expression>; 92internal virtual bool SameArguments(ICollection<Expression>? arguments) 98internal virtual ReadOnlyCollection<Expression> GetOrMakeArguments() 106protected internal override Expression Accept(ExpressionVisitor visitor) 120internal virtual MethodCallExpression Rewrite(Expression instance, IReadOnlyList<Expression>? args) 133public virtual Expression GetArgument(int index) 154private readonly Expression _instance; 156public InstanceMethodCallExpression(MethodInfo method, Expression instance) 164internal override Expression GetInstance() => _instance; 169private IReadOnlyList<Expression> _arguments; 171public MethodCallExpressionN(MethodInfo method, IReadOnlyList<Expression> args) 177public override Expression GetArgument(int index) => _arguments[index]; 181internal override ReadOnlyCollection<Expression> GetOrMakeArguments() 186internal override bool SameArguments(ICollection<Expression>? arguments) => 189internal override MethodCallExpression Rewrite(Expression? instance, IReadOnlyList<Expression>? args) 194return Expression.Call(Method, args ?? _arguments); 200private IReadOnlyList<Expression> _arguments; 202public InstanceMethodCallExpressionN(MethodInfo method, Expression instance, IReadOnlyList<Expression> args) 208public override Expression GetArgument(int index) => _arguments[index]; 212internal override bool SameArguments(ICollection<Expression>? arguments) => 215internal override ReadOnlyCollection<Expression> GetOrMakeArguments() 220internal override MethodCallExpression Rewrite(Expression instance, IReadOnlyList<Expression>? args) 225return Expression.Call(instance, Method, args ?? _arguments); 236public override Expression GetArgument(int index) 243internal override ReadOnlyCollection<Expression> GetOrMakeArguments() 245return ReadOnlyCollection<Expression>.Empty; 248internal override bool SameArguments(ICollection<Expression>? arguments) => 251internal override MethodCallExpression Rewrite(Expression? instance, IReadOnlyList<Expression>? args) 256return Expression.Call(Method); 264public MethodCallExpression1(MethodInfo method, Expression arg0) 270public override Expression GetArgument(int index) => 2730 => ExpressionUtils.ReturnObject<Expression>(_arg0), 279internal override ReadOnlyCollection<Expression> GetOrMakeArguments() 284internal override bool SameArguments(ICollection<Expression>? arguments) 288using (IEnumerator<Expression> en = arguments.GetEnumerator()) 291return en.Current == ExpressionUtils.ReturnObject<Expression>(_arg0); 298internal override MethodCallExpression Rewrite(Expression? instance, IReadOnlyList<Expression>? args) 305return Expression.Call(Method, args[0]); 308return Expression.Call(Method, ExpressionUtils.ReturnObject<Expression>(_arg0)); 315private readonly Expression _arg1; // storage for the 2nd arg 317public MethodCallExpression2(MethodInfo method, Expression arg0, Expression arg1) 324public override Expression GetArgument(int index) 3280 => ExpressionUtils.ReturnObject<Expression>(_arg0), 336internal override bool SameArguments(ICollection<Expression>? arguments) 340if (_arg0 is ReadOnlyCollection<Expression> alreadyCollection) 345using (IEnumerator<Expression> en = arguments.GetEnumerator()) 359internal override ReadOnlyCollection<Expression> GetOrMakeArguments() 364internal override MethodCallExpression Rewrite(Expression? instance, IReadOnlyList<Expression>? args) 371return Expression.Call(Method, args[0], args[1]); 373return Expression.Call(Method, ExpressionUtils.ReturnObject<Expression>(_arg0), _arg1); 380private readonly Expression _arg1, _arg2; // storage for the 2nd - 3rd args. 382public MethodCallExpression3(MethodInfo method, Expression arg0, Expression arg1, Expression arg2) 390public override Expression GetArgument(int index) 3940 => ExpressionUtils.ReturnObject<Expression>(_arg0), 403internal override bool SameArguments(ICollection<Expression>? arguments) 407if (_arg0 is ReadOnlyCollection<Expression> alreadyCollection) 412using (IEnumerator<Expression> en = arguments.GetEnumerator()) 430internal override ReadOnlyCollection<Expression> GetOrMakeArguments() 435internal override MethodCallExpression Rewrite(Expression? instance, IReadOnlyList<Expression>? args) 442return Expression.Call(Method, args[0], args[1], args[2]); 444return Expression.Call(Method, ExpressionUtils.ReturnObject<Expression>(_arg0), _arg1, _arg2); 451private readonly Expression _arg1, _arg2, _arg3; // storage for the 2nd - 4th args. 453public MethodCallExpression4(MethodInfo method, Expression arg0, Expression arg1, Expression arg2, Expression arg3) 462public override Expression GetArgument(int index) 4660 => ExpressionUtils.ReturnObject<Expression>(_arg0), 476internal override bool SameArguments(ICollection<Expression>? arguments) 480if (_arg0 is ReadOnlyCollection<Expression> alreadyCollection) 485using (IEnumerator<Expression> en = arguments.GetEnumerator()) 507internal override ReadOnlyCollection<Expression> GetOrMakeArguments() 512internal override MethodCallExpression Rewrite(Expression? instance, IReadOnlyList<Expression>? args) 519return Expression.Call(Method, args[0], args[1], args[2], args[3]); 521return Expression.Call(Method, ExpressionUtils.ReturnObject<Expression>(_arg0), _arg1, _arg2, _arg3); 528private readonly Expression _arg1, _arg2, _arg3, _arg4; // storage for the 2nd - 5th args. 530public MethodCallExpression5(MethodInfo method, Expression arg0, Expression arg1, Expression arg2, Expression arg3, Expression arg4) 540public override Expression GetArgument(int index) 5440 => ExpressionUtils.ReturnObject<Expression>(_arg0), 555internal override bool SameArguments(ICollection<Expression>? arguments) 559if (_arg0 is ReadOnlyCollection<Expression> alreadyCollection) 564using (IEnumerator<Expression> en = arguments.GetEnumerator()) 590internal override ReadOnlyCollection<Expression> GetOrMakeArguments() 595internal override MethodCallExpression Rewrite(Expression? instance, IReadOnlyList<Expression>? args) 602return Expression.Call(Method, args[0], args[1], args[2], args[3], args[4]); 605return Expression.Call(Method, ExpressionUtils.ReturnObject<Expression>(_arg0), _arg1, _arg2, _arg3, _arg4); 611public InstanceMethodCallExpression0(MethodInfo method, Expression instance) 616public override Expression GetArgument(int index) 623internal override ReadOnlyCollection<Expression> GetOrMakeArguments() 625return ReadOnlyCollection<Expression>.Empty; 628internal override bool SameArguments(ICollection<Expression>? arguments) => 631internal override MethodCallExpression Rewrite(Expression instance, IReadOnlyList<Expression>? args) 636return Expression.Call(instance, Method); 644public InstanceMethodCallExpression1(MethodInfo method, Expression instance, Expression arg0) 650public override Expression GetArgument(int index) 6540 => ExpressionUtils.ReturnObject<Expression>(_arg0), 661internal override bool SameArguments(ICollection<Expression>? arguments) 665using (IEnumerator<Expression> en = arguments.GetEnumerator()) 668return en.Current == ExpressionUtils.ReturnObject<Expression>(_arg0); 675internal override ReadOnlyCollection<Expression> GetOrMakeArguments() 680internal override MethodCallExpression Rewrite(Expression instance, IReadOnlyList<Expression>? args) 687return Expression.Call(instance, Method, args[0]); 689return Expression.Call(instance, Method, ExpressionUtils.ReturnObject<Expression>(_arg0)); 696private readonly Expression _arg1; // storage for the 2nd argument 698public InstanceMethodCallExpression2(MethodInfo method, Expression instance, Expression arg0, Expression arg1) 705public override Expression GetArgument(int index) 7090 => ExpressionUtils.ReturnObject<Expression>(_arg0), 717internal override bool SameArguments(ICollection<Expression>? arguments) 721if (_arg0 is ReadOnlyCollection<Expression> alreadyCollection) 726using (IEnumerator<Expression> en = arguments.GetEnumerator()) 740internal override ReadOnlyCollection<Expression> GetOrMakeArguments() 745internal override MethodCallExpression Rewrite(Expression instance, IReadOnlyList<Expression>? args) 752return Expression.Call(instance, Method, args[0], args[1]); 754return Expression.Call(instance, Method, ExpressionUtils.ReturnObject<Expression>(_arg0), _arg1); 761private readonly Expression _arg1, _arg2; // storage for the 2nd - 3rd argument 763public InstanceMethodCallExpression3(MethodInfo method, Expression instance, Expression arg0, Expression arg1, Expression arg2) 771public override Expression GetArgument(int index) 7750 => ExpressionUtils.ReturnObject<Expression>(_arg0), 784internal override bool SameArguments(ICollection<Expression>? arguments) 788if (_arg0 is ReadOnlyCollection<Expression> alreadyCollection) 793using (IEnumerator<Expression> en = arguments.GetEnumerator()) 811internal override ReadOnlyCollection<Expression> GetOrMakeArguments() 816internal override MethodCallExpression Rewrite(Expression instance, IReadOnlyList<Expression>? args) 823return Expression.Call(instance, Method, args[0], args[1], args[2]); 825return Expression.Call(instance, Method, ExpressionUtils.ReturnObject<Expression>(_arg0), _arg1, _arg2); 856/// <param name="arg0">The <see cref="Expression"/> that represents the first argument.</param> 859public static MethodCallExpression Call(MethodInfo method, Expression arg0) 876/// <param name="arg0">The <see cref="Expression"/> that represents the first argument.</param> 877/// <param name="arg1">The <see cref="Expression"/> that represents the second argument.</param> 880public static MethodCallExpression Call(MethodInfo method, Expression arg0, Expression arg1) 899/// <param name="arg0">The <see cref="Expression"/> that represents the first argument.</param> 900/// <param name="arg1">The <see cref="Expression"/> that represents the second argument.</param> 901/// <param name="arg2">The <see cref="Expression"/> that represents the third argument.</param> 904public static MethodCallExpression Call(MethodInfo method, Expression arg0, Expression arg1, Expression arg2) 925/// <param name="arg0">The <see cref="Expression"/> that represents the first argument.</param> 926/// <param name="arg1">The <see cref="Expression"/> that represents the second argument.</param> 927/// <param name="arg2">The <see cref="Expression"/> that represents the third argument.</param> 928/// <param name="arg3">The <see cref="Expression"/> that represents the fourth argument.</param> 931public static MethodCallExpression Call(MethodInfo method, Expression arg0, Expression arg1, Expression arg2, Expression arg3) 954/// <param name="arg0">The <see cref="Expression"/> that represents the first argument.</param> 955/// <param name="arg1">The <see cref="Expression"/> that represents the second argument.</param> 956/// <param name="arg2">The <see cref="Expression"/> that represents the third argument.</param> 957/// <param name="arg3">The <see cref="Expression"/> that represents the fourth argument.</param> 958/// <param name="arg4">The <see cref="Expression"/> that represents the fifth argument.</param> 962public static MethodCallExpression Call(MethodInfo method, Expression arg0, Expression arg1, Expression arg2, Expression arg3, Expression arg4) 988/// <param name="arguments">The array of one or more of <see cref="Expression"/> that represents the call arguments.</param> 990public static MethodCallExpression Call(MethodInfo method, params Expression[]? arguments) 999/// <param name="arguments">A collection of <see cref="Expression"/> that represents the call arguments.</param> 1001public static MethodCallExpression Call(MethodInfo method, IEnumerable<Expression>? arguments) 1009/// <param name="instance">An <see cref="Expression"/> that specifies the instance for an instance call. (pass null for a static (Shared in Visual Basic) method).</param> 1012public static MethodCallExpression Call(Expression? instance, MethodInfo method) 1031/// <param name="instance">An <see cref="Expression"/> that specifies the instance for an instance call. (pass null for a static (Shared in Visual Basic) method).</param> 1033/// <param name="arguments">An array of one or more of <see cref="Expression"/> that represents the call arguments.</param> 1035public static MethodCallExpression Call(Expression? instance, MethodInfo method, params Expression[]? arguments) 1037return Call(instance, method, (IEnumerable<Expression>?)arguments); 1043/// <param name="instance">An <see cref="Expression"/> that specifies the instance for an instance call. (pass null for a static (Shared in Visual Basic) method).</param> 1045/// <param name="arg0">The <see cref="Expression"/> that represents the first argument.</param> 1047internal static MethodCallExpression Call(Expression? instance, MethodInfo method, Expression arg0) 1071/// <param name="instance">An <see cref="Expression"/> that specifies the instance for an instance call. (pass null for a static (Shared in Visual Basic) method).</param> 1073/// <param name="arg0">The <see cref="Expression"/> that represents the first argument.</param> 1074/// <param name="arg1">The <see cref="Expression"/> that represents the second argument.</param> 1076public static MethodCallExpression Call(Expression? instance, MethodInfo method, Expression arg0, Expression arg1) 1100/// <param name="instance">An <see cref="Expression"/> that specifies the instance for an instance call. (pass null for a static (Shared in Visual Basic) method).</param> 1102/// <param name="arg0">The <see cref="Expression"/> that represents the first argument.</param> 1103/// <param name="arg1">The <see cref="Expression"/> that represents the second argument.</param> 1104/// <param name="arg2">The <see cref="Expression"/> that represents the third argument.</param> 1106public static MethodCallExpression Call(Expression? instance, MethodInfo method, Expression arg0, Expression arg1, Expression arg2) 1130/// <param name="instance">An <see cref="Expression"/> whose <see cref="Type"/> property value will be searched for a specific method.</param> 1136/// <param name="arguments">An array of <see cref="Expression"/> objects that represents the arguments to the method.</param> 1142public static MethodCallExpression Call(Expression instance, string methodName, Type[]? typeArguments, params Expression[]? arguments) 1146arguments ??= Array.Empty<Expression>(); 1149return Expression.Call(instance, FindMethod(instance.Type, methodName, typeArguments, arguments, flags)!, arguments); 1160/// <param name="arguments">An array of <see cref="Expression"/> objects that represent the arguments to the method.</param> 1170params Expression[]? arguments) 1175arguments ??= Array.Empty<Expression>(); 1177return Expression.Call(null, FindMethod(type, methodName, typeArguments, arguments, Flags)!, arguments); 1182/// <param name="instance">An <see cref="Expression"/> to set the <see cref="MethodCallExpression.Object"/> property equal to (pass null for a static (Shared in Visual Basic) method).</param> 1184/// <param name="arguments">An <see cref="IEnumerable{Expression}"/> that contains <see cref="Expression"/> objects to use to populate the <see cref="MethodCallExpression.Arguments"/> collection.</param> 1189public static MethodCallExpression Call(Expression? instance, MethodInfo method, IEnumerable<Expression>? arguments) 1191IReadOnlyList<Expression> argumentList = arguments as IReadOnlyList<Expression> ?? arguments.ToReadOnly(); 1223ReadOnlyCollection<Expression> argList = argumentList.ToReadOnly(); 1239private static ParameterInfo[] ValidateMethodAndGetParameters(Expression? instance, MethodInfo method) 1247private static void ValidateStaticOrInstanceMethod(Expression? instance, MethodInfo method) 1269private static void ValidateArgumentTypes(MethodBase method, ExpressionType nodeKind, ref ReadOnlyCollection<Expression> arguments, string methodParamName) 1284private static Expression ValidateOneArgument(MethodBase method, ExpressionType nodeKind, Expression arg, ParameterInfo pi, string methodParamName, string argumentParamName) 1290private static bool TryQuote(Type parameterType, ref Expression argument) 1301Expression[] args, 1347private static bool IsCompatible(MethodBase m, Expression[] arguments) 1354Expression arg = arguments[i]; 1394/// <param name="array">An array of <see cref="Expression"/> instances - indexes for the array index operation.</param> 1395/// <param name="indexes">An array that contains <see cref="Expression"/> objects to use to populate the <see cref="MethodCallExpression.Arguments"/> collection.</param> 1396public static MethodCallExpression ArrayIndex(Expression array, params Expression[] indexes) 1398return ArrayIndex(array, (IEnumerable<Expression>)indexes); 1403/// <param name="array">An <see cref="Expression"/> to set the <see cref="MethodCallExpression.Object"/> property equal to.</param> 1404/// <param name="indexes">An <see cref="IEnumerable{T}"/> that contains <see cref="Expression"/> objects to use to populate the <see cref="MethodCallExpression.Arguments"/> collection.</param> 1408/// <paramref name="array"/>.Type does not represent an array type.-or-The rank of <paramref name="array"/>.Type does not match the number of elements in <paramref name="indexes"/>.-or-The <see cref="Expression.Type"/> property of one or more elements of <paramref name="indexes"/> does not represent the <see cref="int"/> type.</exception> 1409public static MethodCallExpression ArrayIndex(Expression array, IEnumerable<Expression> indexes) 1420ReadOnlyCollection<Expression> indexList = indexes.ToReadOnly(); 1428Expression e = indexList[i];
System\Linq\Expressions\NewArrayExpression.cs (36)
17[RequiresDynamicCode(Expression.NewArrayRequiresDynamicCode)] 20internal NewArrayExpression(Type type, ReadOnlyCollection<Expression> expressions) 26internal static NewArrayExpression Make(ExpressionType nodeType, Type type, ReadOnlyCollection<Expression> expressions) 40/// Gets the static type of the expression that this <see cref="Expression"/> represents. (Inherited from <see cref="Expression"/>.) 46/// Gets the bounds of the array if the value of the <see cref="ExpressionType"/> property is NewArrayBounds, or the values to initialize the elements of the new array if the value of the <see cref="Expression.NodeType"/> property is NewArrayInit. 48public ReadOnlyCollection<Expression> Expressions { get; } 53protected internal override Expression Accept(ExpressionVisitor visitor) 65public NewArrayExpression Update(IEnumerable<Expression> expressions) 81[RequiresDynamicCode(Expression.NewArrayRequiresDynamicCode)] 84internal NewArrayInitExpression(Type type, ReadOnlyCollection<Expression> expressions) 91/// Returns the node type of this <see cref="Expression"/>. (Inherited from <see cref="Expression"/>.) 97[RequiresDynamicCode(Expression.NewArrayRequiresDynamicCode)] 100internal NewArrayBoundsExpression(Type type, ReadOnlyCollection<Expression> expressions) 106/// Returns the node type of this <see cref="Expression"/>. (Inherited from <see cref="Expression"/>.) 122[RequiresDynamicCode(Expression.NewArrayRequiresDynamicCode)] 123public static NewArrayExpression NewArrayInit(Type type, params Expression[] initializers) 125return NewArrayInit(type, (IEnumerable<Expression>)initializers); 134[RequiresDynamicCode(Expression.NewArrayRequiresDynamicCode)] 135public static NewArrayExpression NewArrayInit(Type type, IEnumerable<Expression> initializers) 145ReadOnlyCollection<Expression> initializerList = initializers.ToReadOnly(); 147Expression[]? newList = null; 150Expression expr = initializerList[i]; 161newList = new Expression[initializerList.Count]; 175initializerList = new TrueReadOnlyCollection<Expression>(newList); 183internal static NewArrayExpression NewObjectArrayInit(IEnumerable<Expression> initializers) 198[RequiresDynamicCode(Expression.NewArrayRequiresDynamicCode)] 199public static NewArrayExpression NewArrayBounds(Type type, params Expression[] bounds) 201return NewArrayBounds(type, (IEnumerable<Expression>)bounds); 208/// <param name="bounds">An <see cref="IEnumerable{T}"/> that contains <see cref="Expression"/> objects to use to populate the <see cref="NewArrayExpression.Expressions"/> collection.</param> 210[RequiresDynamicCode(Expression.NewArrayRequiresDynamicCode)] 211public static NewArrayExpression NewArrayBounds(Type type, IEnumerable<Expression> bounds) 223ReadOnlyCollection<Expression> boundsList = bounds.ToReadOnly(); 230Expression expr = boundsList[i];
System\Linq\Expressions\NewExpression.cs (29)
20private IReadOnlyList<Expression> _arguments; 22internal NewExpression(ConstructorInfo? constructor, IReadOnlyList<Expression> arguments, ReadOnlyCollection<MemberInfo>? members) 30/// Gets the static type of the expression that this <see cref="Expression"/> represents. (Inherited from <see cref="Expression"/>.) 36/// Returns the node type of this <see cref="Expression"/>. (Inherited from <see cref="Expression"/>.) 49public ReadOnlyCollection<Expression> Arguments => ExpressionUtils.ReturnReadOnly(ref _arguments); 56public Expression GetArgument(int index) => _arguments[index]; 71protected internal override Expression Accept(ExpressionVisitor visitor) 85public NewExpression Update(IEnumerable<Expression>? arguments) 98internal NewValueTypeExpression(Type type, ReadOnlyCollection<Expression> arguments, ReadOnlyCollection<MemberInfo>? members) 116return New(constructor, (IEnumerable<Expression>?)null); 123/// <param name="arguments">An array of <see cref="Expression"/> objects to use to populate the Arguments collection.</param> 125public static NewExpression New(ConstructorInfo constructor, params Expression[]? arguments) 127return New(constructor, (IEnumerable<Expression>?)arguments); 134/// <param name="arguments">An <see cref="IEnumerable{T}"/> of <see cref="Expression"/> objects to use to populate the <see cref="NewExpression.Arguments"/> collection.</param> 136public static NewExpression New(ConstructorInfo constructor, IEnumerable<Expression>? arguments) 148ReadOnlyCollection<Expression> argList = arguments.ToReadOnly(); 158/// <param name="arguments">An <see cref="IEnumerable{T}"/> of <see cref="Expression"/> objects to use to populate the <see cref="NewExpression.Arguments"/> collection.</param> 162public static NewExpression New(ConstructorInfo constructor, IEnumerable<Expression>? arguments, IEnumerable<MemberInfo>? members) 174ReadOnlyCollection<Expression> argList = arguments.ToReadOnly(); 183/// <param name="arguments">An <see cref="IEnumerable{T}"/> of <see cref="Expression"/> objects to use to populate the <see cref="NewExpression.Arguments"/> collection.</param> 187public static NewExpression New(ConstructorInfo constructor, IEnumerable<Expression>? arguments, params MemberInfo[]? members) 216return new NewValueTypeExpression(type, ReadOnlyCollection<Expression>.Empty, null); 220private static void ValidateNewArgs(ConstructorInfo constructor, ref ReadOnlyCollection<Expression> arguments, ref ReadOnlyCollection<MemberInfo> members) 233Expression[]? newArguments = null; 237Expression arg = arguments[i]; 269newArguments = new Expression[arguments.Count]; 295arguments = new TrueReadOnlyCollection<Expression>(newArguments);
System\Linq\Expressions\ParameterExpression.cs (5)
72/// Gets the static type of the expression that this <see cref="Expression"/> represents. (Inherited from <see cref="Expression"/>.) 78/// Returns the node type of this <see cref="Expression"/>. (Inherited from <see cref="Expression"/>.) 98protected internal override Expression Accept(ExpressionVisitor visitor)
System\Linq\Expressions\RuntimeVariablesExpression.cs (2)
26/// Gets the static type of the expression that this <see cref="Expression"/> represents. 46protected internal override Expression Accept(ExpressionVisitor visitor)
System\Linq\Expressions\SwitchCase.cs (14)
14[DebuggerTypeProxy(typeof(Expression.SwitchCaseProxy))] 17internal SwitchCase(Expression body, ReadOnlyCollection<Expression> testValues) 26public ReadOnlyCollection<Expression> TestValues { get; } 31public Expression Body { get; } 50public SwitchCase Update(IEnumerable<Expression> testValues, Expression body) 60return Expression.SwitchCase(body, testValues!); 72public static SwitchCase SwitchCase(Expression body, params Expression[] testValues) 74return SwitchCase(body, (IEnumerable<Expression>)testValues); 83public static SwitchCase SwitchCase(Expression body, IEnumerable<Expression> testValues) 87ReadOnlyCollection<Expression> values = testValues.ToReadOnly();
System\Linq\Expressions\SwitchExpression.cs (22)
18internal SwitchExpression(Type type, Expression switchValue, Expression? defaultBody, MethodInfo? comparison, ReadOnlyCollection<SwitchCase> cases) 28/// Gets the static type of the expression that this <see cref="Expression"/> represents. 43public Expression SwitchValue { get; } 53public Expression? DefaultBody { get; } 63protected internal override Expression Accept(ExpressionVisitor visitor) 90public SwitchExpression Update(Expression switchValue, IEnumerable<SwitchCase>? cases, Expression? defaultBody) 99return Expression.Switch(Type, switchValue, defaultBody, Comparison, cases); 111public static SwitchExpression Switch(Expression switchValue, params SwitchCase[]? cases) 123public static SwitchExpression Switch(Expression switchValue, Expression? defaultBody, params SwitchCase[]? cases) 136public static SwitchExpression Switch(Expression switchValue, Expression? defaultBody, MethodInfo? comparison, params SwitchCase[]? cases) 150public static SwitchExpression Switch(Type? type, Expression switchValue, Expression? defaultBody, MethodInfo? comparison, params SwitchCase[]? cases) 163public static SwitchExpression Switch(Expression switchValue, Expression? defaultBody, MethodInfo? comparison, IEnumerable<SwitchCase>? cases) 177public static SwitchExpression Switch(Type? type, Expression switchValue, Expression? defaultBody, MethodInfo? comparison, IEnumerable<SwitchCase>? cases) 253Expression firstTestValue = caseList[0].TestValues[0]; 294private static void ValidateSwitchCaseType(Expression @case, bool customType, Type resultType, string parameterName)
System\Linq\Expressions\TryExpression.cs (28)
24internal TryExpression(Type type, Expression body, Expression? @finally, Expression? fault, ReadOnlyCollection<CatchBlock> handlers) 34/// Gets the static type of the expression that this <see cref="Expression"/> represents. (Inherited from <see cref="Expression"/>.) 40/// Returns the node type of this <see cref="Expression"/>. (Inherited from <see cref="Expression"/>.) 46/// Gets the <see cref="Expression"/> representing the body of the try block. 48public Expression Body { get; } 56/// Gets the <see cref="Expression"/> representing the finally block. 58public Expression? Finally { get; } 61/// Gets the <see cref="Expression"/> representing the fault block. 63public Expression? Fault { get; } 68protected internal override Expression Accept(ExpressionVisitor visitor) 83public TryExpression Update(Expression body, IEnumerable<CatchBlock>? handlers, Expression? @finally, Expression? fault) 105public static TryExpression TryFault(Expression body, Expression? fault) 116public static TryExpression TryFinally(Expression body, Expression? @finally) 127public static TryExpression TryCatch(Expression body, params CatchBlock[]? handlers) 139public static TryExpression TryCatchFinally(Expression body, Expression? @finally, params CatchBlock[]? handlers) 153public static TryExpression MakeTry(Type? type, Expression body, Expression? @finally, Expression? fault, IEnumerable<CatchBlock>? handlers) 182private static void ValidateTryAndCatchHaveSameType(Type? type, Expression tryBody, ReadOnlyCollection<CatchBlock> handlers)
System\Linq\Expressions\TypeBinaryExpression.cs (33)
17internal TypeBinaryExpression(Expression expression, Type typeOperand, ExpressionType nodeType) 40public Expression Expression { get; } 49internal Expression ReduceTypeEqual() 62return Expression.Block(Expression, Utils.Constant(value: false)); 66return Expression.NotEqual(Expression, Expression.Constant(null, Expression.Type)); 73return Expression.Block(Expression, Utils.Constant(cType == TypeOperand.GetNonNullableType())); 93parameter = Expression.Parameter(typeof(object)); 95return Expression.Block( 97new TrueReadOnlyCollection<Expression>( 98Expression.Assign(parameter, Expression), 105private Expression ByValParameterTypeEqual(ParameterExpression value) 107Expression getType = Expression.Call(value, Object_GetType); 116ParameterExpression temp = Expression.Parameter(typeof(Type)); 117getType = Expression.Block( 119new TrueReadOnlyCollection<Expression>( 120Expression.Assign(temp, getType), 129return Expression.AndAlso( 130Expression.ReferenceNotEqual(value, Utils.Null), 131Expression.ReferenceEqual( 133Expression.Constant(TypeOperand.GetNonNullableType(), typeof(Type)) 138private Expression ReduceConstantTypeEqual() 157protected internal override Expression Accept(ExpressionVisitor visitor) 169public TypeBinaryExpression Update(Expression expression) 177return Expression.TypeIs(expression, TypeOperand); 179return Expression.TypeEqual(expression, TypeOperand); 188/// <param name="expression">An <see cref="Expression"/> to set the <see cref="Expression"/> property equal to.</param> 191public static TypeBinaryExpression TypeIs(Expression expression, Type type) 203/// <param name="expression">An <see cref="Expression"/> to set the <see cref="Expression"/> property equal to.</param> 206public static TypeBinaryExpression TypeEqual(Expression expression, Type type)
System\Linq\Expressions\UnaryExpression.cs (111)
18internal UnaryExpression(ExpressionType nodeType, Expression expression, Type type, MethodInfo? method) 27/// Gets the static type of the expression that this <see cref="Expression"/> represents. (Inherited from <see cref="Expression"/>.) 33/// Returns the node type of this <see cref="Expression"/>. (Inherited from <see cref="Expression"/>.) 41/// <returns> An <see cref="Expression"/> that represents the operand of the unary operation. Returns null if node type is <see cref="ExpressionType.Throw"/> with no operand.</returns> 42public Expression Operand { get; } 82protected internal override Expression Accept(ExpressionVisitor visitor) 113public override Expression Reduce() 136private UnaryExpression FunctionalOp(Expression operand) 151private Expression ReduceVariable() 168new TrueReadOnlyCollection<Expression>( 176private Expression ReduceMember() 198new TrueReadOnlyCollection<Expression>( 214new TrueReadOnlyCollection<Expression>( 224private Expression ReduceIndex() 241var block = new Expression[count + (prefix ? 2 : 4)]; 251Expression arg = index.GetArgument(i - 1); 256index = MakeIndex(temps[0], index.Indexer, new TrueReadOnlyCollection<Expression>(args)); 272return Block(new TrueReadOnlyCollection<ParameterExpression>(temps), new TrueReadOnlyCollection<Expression>(block)); 282public UnaryExpression Update(Expression operand) 288return Expression.MakeUnary(NodeType, operand, Type, Method); 298/// <param name="operand">An <see cref="Expression"/> that represents the operand.</param> 303public static UnaryExpression MakeUnary(ExpressionType unaryType, Expression operand, Type type) 312/// <param name="operand">An <see cref="Expression"/> that represents the operand.</param> 318public static UnaryExpression MakeUnary(ExpressionType unaryType, Expression operand, Type type, MethodInfo? method) => 344private static UnaryExpression GetUserDefinedUnaryOperatorOrThrow(ExpressionType unaryType, string name, Expression operand) 357private static UnaryExpression? GetUserDefinedUnaryOperator(ExpressionType unaryType, string name, Expression operand) 380private static UnaryExpression GetMethodBasedUnaryOperator(ExpressionType unaryType, Expression operand, MethodInfo method) 403private static UnaryExpression GetUserDefinedCoercionOrThrow(ExpressionType coercionType, Expression expression, Type convertToType) 413private static UnaryExpression? GetUserDefinedCoercion(ExpressionType coercionType, Expression expression, Type convertToType) 426private static UnaryExpression GetMethodBasedCoercionOperator(ExpressionType unaryType, Expression operand, Type convertToType, MethodInfo method) 453/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param> 457public static UnaryExpression Negate(Expression expression) 465/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param> 471public static UnaryExpression Negate(Expression expression, MethodInfo? method) 488/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param> 492public static UnaryExpression UnaryPlus(Expression expression) 500/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param> 506public static UnaryExpression UnaryPlus(Expression expression, MethodInfo? method) 522/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param> 525public static UnaryExpression NegateChecked(Expression expression) 532/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param> 540public static UnaryExpression NegateChecked(Expression expression, MethodInfo? method) 556/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param> 560public static UnaryExpression Not(Expression expression) 567/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param> 575public static UnaryExpression Not(Expression expression, MethodInfo? method) 597/// <param name="expression">An <see cref="Expression"/> to evaluate.</param> 599public static UnaryExpression IsFalse(Expression expression) 607/// <param name="expression">An <see cref="Expression"/> to evaluate.</param> 610public static UnaryExpression IsFalse(Expression expression, MethodInfo? method) 627/// <param name="expression">An <see cref="Expression"/> to evaluate.</param> 629public static UnaryExpression IsTrue(Expression expression) 637/// <param name="expression">An <see cref="Expression"/> to evaluate.</param> 640public static UnaryExpression IsTrue(Expression expression, MethodInfo? method) 657/// <param name="expression">An <see cref="Expression"/>.</param> 659public static UnaryExpression OnesComplement(Expression expression) 667/// <param name="expression">An <see cref="Expression"/>.</param> 670public static UnaryExpression OnesComplement(Expression expression, MethodInfo? method) 685/// <returns>A <see cref="UnaryExpression"/> that has the <see cref="NodeType"/> property equal to <see cref="ExpressionType.TypeAs"/> and the <see cref="UnaryExpression.Operand"/> and <see cref="Expression.Type"/> properties set to the specified values.</returns> 686/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param> 690public static UnaryExpression TypeAs(Expression expression, Type type) 706/// <param name="expression">An <see cref="Expression"/> to unbox.</param> 709public static UnaryExpression Unbox(Expression expression, Type type) 723/// <returns>A <see cref="UnaryExpression"/> that has the <see cref="NodeType"/> property equal to <see cref="ExpressionType.Convert"/> and the <see cref="UnaryExpression.Operand"/> and <see cref="Expression.Type"/> properties set to the specified values.</returns> 724/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param> 729public static UnaryExpression Convert(Expression expression, Type type) 735/// <returns>A <see cref="UnaryExpression"/> that has the <see cref="NodeType"/> property equal to <see cref="ExpressionType.Convert"/> and the <see cref="UnaryExpression.Operand"/>, <see cref="Expression.Type"/>, and <see cref="UnaryExpression.Method"/> properties set to the specified values.</returns> 736/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param> 745public static UnaryExpression Convert(Expression expression, Type type, MethodInfo? method) 763/// <returns>A <see cref="UnaryExpression"/> that has the <see cref="NodeType"/> property equal to <see cref="ExpressionType.ConvertChecked"/> and the <see cref="UnaryExpression.Operand"/> and <see cref="Expression.Type"/> properties set to the specified values.</returns> 764/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param> 769public static UnaryExpression ConvertChecked(Expression expression, Type type) 775/// <returns>A <see cref="UnaryExpression"/> that has the <see cref="NodeType"/> property equal to <see cref="ExpressionType.ConvertChecked"/> and the <see cref="UnaryExpression.Operand"/>, <see cref="Expression.Type"/>, and <see cref="UnaryExpression.Method"/> properties set to the specified values.</returns> 776/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param> 785public static UnaryExpression ConvertChecked(Expression expression, Type type, MethodInfo? method) 807/// <param name="array">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param> 812public static UnaryExpression ArrayLength(Expression array) 828/// <summary>Creates a <see cref="UnaryExpression"/> that represents an expression that has a constant value of type <see cref="Expression"/>.</summary> 830/// <param name="expression">An <see cref="Expression"/> to set the <see cref="UnaryExpression.Operand"/> property equal to.</param> 833public static UnaryExpression Quote(Expression expression) 867/// <param name="value">An <see cref="Expression"/>.</param> 869public static UnaryExpression Throw(Expression? value) 877/// <param name="value">An <see cref="Expression"/>.</param> 880public static UnaryExpression Throw(Expression? value, Type type) 895/// <param name="expression">An <see cref="Expression"/> to increment.</param> 897public static UnaryExpression Increment(Expression expression) 905/// <param name="expression">An <see cref="Expression"/> to increment.</param> 908public static UnaryExpression Increment(Expression expression, MethodInfo? method) 925/// <param name="expression">An <see cref="Expression"/> to decrement.</param> 927public static UnaryExpression Decrement(Expression expression) 935/// <param name="expression">An <see cref="Expression"/> to decrement.</param> 938public static UnaryExpression Decrement(Expression expression, MethodInfo? method) 956/// <param name="expression">An <see cref="Expression"/> to apply the operations on.</param> 958public static UnaryExpression PreIncrementAssign(Expression expression) 967/// <param name="expression">An <see cref="Expression"/> to apply the operations on.</param> 970public static UnaryExpression PreIncrementAssign(Expression expression, MethodInfo? method) 979/// <param name="expression">An <see cref="Expression"/> to apply the operations on.</param> 981public static UnaryExpression PreDecrementAssign(Expression expression) 990/// <param name="expression">An <see cref="Expression"/> to apply the operations on.</param> 993public static UnaryExpression PreDecrementAssign(Expression expression, MethodInfo? method) 1002/// <param name="expression">An <see cref="Expression"/> to apply the operations on.</param> 1004public static UnaryExpression PostIncrementAssign(Expression expression) 1013/// <param name="expression">An <see cref="Expression"/> to apply the operations on.</param> 1016public static UnaryExpression PostIncrementAssign(Expression expression, MethodInfo? method) 1025/// <param name="expression">An <see cref="Expression"/> to apply the operations on.</param> 1027public static UnaryExpression PostDecrementAssign(Expression expression) 1036/// <param name="expression">An <see cref="Expression"/> to apply the operations on.</param> 1039public static UnaryExpression PostDecrementAssign(Expression expression, MethodInfo? method) 1044private static UnaryExpression MakeOpAssignUnary(ExpressionType kind, Expression expression, MethodInfo? method)
System\Linq\Expressions\Utils.cs (12)
33private static readonly ConstantExpression s_true = Expression.Constant(BoxedTrue); 34private static readonly ConstantExpression s_false = Expression.Constant(BoxedFalse); 36private static readonly ConstantExpression s_m1 = Expression.Constant(BoxedIntM1); 37private static readonly ConstantExpression s_0 = Expression.Constant(BoxedInt0); 38private static readonly ConstantExpression s_1 = Expression.Constant(BoxedInt1); 39private static readonly ConstantExpression s_2 = Expression.Constant(BoxedInt2); 40private static readonly ConstantExpression s_3 = Expression.Constant(BoxedInt3); 42public static readonly DefaultExpression Empty = Expression.Empty(); 43public static readonly ConstantExpression Null = Expression.Constant(null); 55_ => Expression.Constant(value), 61public static MemberExpression GetStrongBoxValueField(Expression strongbox) 63return Expression.Field(strongbox, "Value");
System\Linq\IQueryable.cs (5)
18Expression Expression { get; } 56IQueryable CreateQuery(Expression expression); 67IQueryable<TElement> CreateQuery<TElement>(Expression expression); 77object? Execute(Expression expression); 89TResult Execute<TResult>(Expression expression);
System\Runtime\CompilerServices\CallSite.cs (127)
167[RequiresDynamicCode(Expression.NewArrayRequiresDynamicCode)] 214[RequiresDynamicCode(Expression.NewArrayRequiresDynamicCode)] 222[RequiresDynamicCode(Expression.NewArrayRequiresDynamicCode)] 231[RequiresDynamicCode(Expression.NewArrayRequiresDynamicCode)] 283[RequiresDynamicCode(Expression.NewArrayRequiresDynamicCode)] 301[RequiresDynamicCode(Expression.GenericMethodRequiresDynamicCode)] 359[RequiresDynamicCode(Expression.NewArrayRequiresDynamicCode)] 365var body = new ArrayBuilder<Expression>(13); 368ParameterExpression[] @params = Array.ConvertAll(invoke.GetParametersCached(), p => Expression.Parameter(p.ParameterType, p.Name)); 369LabelTarget @return = Expression.Label(returnType); 375ParameterExpression @this = Expression.Variable(typeof(CallSite<T>), "this"); 377body.UncheckedAdd(Expression.Assign(@this, Expression.Convert(site, @this.Type))); 379ParameterExpression applicable = Expression.Variable(typeof(T[]), "applicable"); 382ParameterExpression rule = Expression.Variable(typeof(T), "rule"); 385ParameterExpression originalRule = Expression.Variable(typeof(T), "originalRule"); 388Expression target = Expression.Field(@this, typeof(CallSite<T>).GetField(nameof(Target))!); 389body.UncheckedAdd(Expression.Assign(originalRule, target)); 394vars.UncheckedAdd(result = Expression.Variable(@return.Type, "result")); 397ParameterExpression count = Expression.Variable(typeof(int), "count"); 399ParameterExpression index = Expression.Variable(typeof(int), "index"); 403Expression.Assign( 405Expression.Call( 414Expression processRule; 416Expression getMatch = Expression.Call(CallSiteOps_GetMatch, site); 418Expression resetMatch = Expression.Call(CallSiteOps_ClearMatch, site); 420Expression invokeRule = Expression.Invoke(rule, new TrueReadOnlyCollection<Expression>(@params)); 422Expression onMatch = Expression.Call( 432processRule = Expression.Block( 434Expression.IfThen( 436Expression.Block(onMatch, Expression.Return(@return)) 442processRule = Expression.Block( 443Expression.Assign(result!, invokeRule), 444Expression.IfThen( 446Expression.Block(onMatch, Expression.Return(@return, result)) 451Expression getApplicableRuleAtIndex = Expression.Assign(rule, Expression.ArrayAccess(applicable, new TrueReadOnlyCollection<Expression>(index))); 452Expression getRule = getApplicableRuleAtIndex; 454LabelTarget @break = Expression.Label(); 456Expression breakIfDone = Expression.IfThen( 457Expression.Equal(index, count), 458Expression.Break(@break) 461Expression incrementIndex = Expression.PreIncrementAssign(index); 464Expression.IfThen( 465Expression.NotEqual( 466Expression.Assign( 468Expression.Call( 475Expression.Constant(null, applicable.Type) 477Expression.Block( 478Expression.Assign(count, Expression.ArrayLength(applicable)), 479Expression.Assign(index, Utils.Constant(0)), 480Expression.Loop( 481Expression.Block( 484Expression.IfThen( 485Expression.NotEqual( 486Expression.Convert(rule, typeof(object)), 487Expression.Convert(originalRule, typeof(object)) 489Expression.Block( 490Expression.Assign( 514ParameterExpression cache = Expression.Variable(typeof(RuleCache<T>), "cache"); 518Expression.Assign( 521Expression.Call(CallSiteOpsReflectionCache<T>.GetRuleCache, @this) 527Expression.Assign( 530Expression.Call(CallSiteOpsReflectionCache<T>.GetCachedRules, cache) 538processRule = Expression.Block( 540Expression.IfThen( 542Expression.Return(@return) 548processRule = Expression.Block( 549Expression.Assign(result!, invokeRule), 550Expression.IfThen( 552Expression.Return(@return, result) 557Expression tryRule = Expression.TryFinally( 559Expression.IfThen( 561Expression.Block( 563Expression.Call(CallSiteOpsReflectionCache<T>.AddRule, @this, rule), 564Expression.Call(CallSiteOpsReflectionCache<T>.MoveRule, cache, rule, index) 570getRule = Expression.Assign( 575body.UncheckedAdd(Expression.Assign(index, Utils.Constant(0))); 576body.UncheckedAdd(Expression.Assign(count, Expression.ArrayLength(applicable))); 578Expression.Loop( 579Expression.Block( 594body.UncheckedAdd(Expression.Assign(rule, Expression.Constant(null, rule.Type))); 596ParameterExpression args = Expression.Variable(typeof(object[]), "args"); 597Expression[] argsElements = Array.ConvertAll(arguments, p => Convert(p, typeof(object))); 600Expression.Assign( 602Expression.NewObjectArrayInit(new TrueReadOnlyCollection<Expression>(argsElements)) 606Expression setOldTarget = Expression.Assign( 611getRule = Expression.Assign( 613Expression.Assign( 615Expression.Call( 619Expression.Property(@this, typeof(CallSite).GetProperty(nameof(Binder))!), 626tryRule = Expression.TryFinally( 628Expression.IfThen( 630Expression.Call( 641Expression.Loop( 642Expression.Block(setOldTarget, getRule, tryRule, resetMatch), 648body.UncheckedAdd(Expression.Default(@return.Type)); 650Expression<T> lambda = Expression.Lambda<T>( 651Expression.Label( 653Expression.Block( 668[RequiresDynamicCode(Expression.NewArrayRequiresDynamicCode)] 671ParameterExpression[] @params = Array.ConvertAll(invoke.GetParametersCached(), p => Expression.Parameter(p.ParameterType, p.Name)); 672return Expression.Lambda<T>( 673Expression.Block( 674Expression.Call( 678Expression.Default(invoke.GetReturnType()) 684private static Expression Convert(Expression arg, Type type) 690return Expression.Convert(arg, type);
System\Runtime\CompilerServices\CallSiteBinder.cs (24)
39public static LabelTarget UpdateLabel { get; } = Expression.Label("CallSiteBinder.UpdateLabel"); 68@params[i] = Expression.Parameter(pis[i + 1].ParameterType, "$arg" + i); 72ReturnLabel = Expression.Label(invoke.GetReturnType()); 86/// to produce a new <see cref="Expression"/> for the new argument types. 88public abstract Expression Bind(object[] args, ReadOnlyCollection<ParameterExpression> parameters, LabelTarget returnLabel); 104[RequiresDynamicCode(Expression.NewArrayRequiresDynamicCode)] 120Expression binding = Bind(args, signature.Parameters, signature.ReturnLabel); 153private static Expression<T> Stitch<T>(Expression binding, LambdaSignature<T> signature) where T : class 157var body = new ReadOnlyCollectionBuilder<Expression>(3); 160var site = Expression.Parameter(typeof(CallSite), "$site"); 163Expression updLabel = Expression.Label(UpdateLabel); 167updLabel = Expression.Block( 168Expression.Constant(binding, typeof(Expression)), 175Expression.Label( 177Expression.Condition( 178Expression.Call( 182Expression.Default(signature.ReturnLabel.Type), 183Expression.Invoke( 184Expression.Property( 185Expression.Convert(site, siteType), 194return Expression.Lambda<T>( 195Expression.Block(body),
System\Runtime\CompilerServices\CallSiteOps.cs (1)
156[RequiresDynamicCode(Expression.NewArrayRequiresDynamicCode)]
System\Runtime\CompilerServices\RuntimeOps.ExpressionQuoter.cs (16)
26public static Expression? Quote(Expression? expression, object hoistedLocals, object[] locals) 68protected internal override Expression VisitLambda<T>(Expression<T> node) 81Expression b = Visit(node.Body); 93protected internal override Expression VisitBlock(BlockExpression node) 99Expression[]? b = ExpressionVisitorUtils.VisitBlockExpressions(this, node); 117Expression b = Visit(node.Body); 118Expression? f = Visit(node.Filter); 127return Expression.MakeCatchBlock(node.Test, node.Variable, b, f); 130protected internal override Expression VisitRuntimeVariables(RuntimeVariablesExpression node) 157ConstantExpression boxesConst = Expression.Constant(new RuntimeVariables(boxes.ToArray()), typeof(IRuntimeVariables)); 165return Expression.Call( 167Expression.RuntimeVariables(new TrueReadOnlyCollection<ParameterExpression>(vars.ToArray())), 169Expression.Constant(indexes) 173protected internal override Expression VisitParameter(ParameterExpression node) 180return Utils.GetStrongBoxValueField(Expression.Constant(box));
System.Linq.Queryable (388)
System\Linq\EnumerableExecutor.cs (5)
19internal static EnumerableExecutor Create(Expression expression) 28private readonly Expression _expression; 30public EnumerableExecutor(Expression expression) 44Expression body = rewriter.Visit(_expression); 45Expression<Func<T>> f = Expression.Lambda<Func<T>>(body, (IEnumerable<ParameterExpression>?)null);
System\Linq\EnumerableQuery.cs (13)
13internal abstract Expression Expression { get; } 28internal static IQueryable Create(Type elementType, Expression expression) 39private readonly Expression _expression; 47_expression = Expression.Constant(this); 50public EnumerableQuery(Expression expression) 55internal override Expression Expression => _expression; 59Expression IQueryable.Expression => _expression; 63IQueryable IQueryProvider.CreateQuery(Expression expression) 73IQueryable<TElement> IQueryProvider.CreateQuery<TElement>(Expression expression) 84object? IQueryProvider.Execute(Expression expression) 91TElement IQueryProvider.Execute<TElement>(Expression expression) 109Expression body = rewriter.Visit(_expression); 110Expression<Func<IEnumerable<T>>> f = Expression.Lambda<Func<IEnumerable<T>>>(body, (IEnumerable<ParameterExpression>?)null);
System\Linq\EnumerableRewriter.cs (40)
28protected override Expression VisitMethodCall(MethodCallExpression m) 30Expression? obj = Visit(m.Object); 31ReadOnlyCollection<Expression> args = Visit(m.Arguments); 43return Expression.Call(obj, mInfo, args); 50return Expression.Call(obj, seqMethod, args); 57return Expression.Call(obj, method, args); 63private static ReadOnlyCollection<Expression> FixupQuotedArgs(MethodInfo mi, ReadOnlyCollection<Expression> argList) 68List<Expression>? newArgs = null; 71Expression arg = argList[i]; 76newArgs = new List<Expression>(argList.Count); 91private static Expression FixupQuotedExpression(Type type, Expression expression) 93Expression expr = expression; 109List<Expression> exprs = new List<Expression>(na.Expressions.Count); 114expression = Expression.NewArrayInit(elementType, exprs); 120protected override Expression VisitLambda<T>(Expression<T> node) => node; 201protected override Expression VisitConstant(ConstantExpression c) 208return Expression.Constant(sq.Enumerable, t); 210Expression exp = sq.Expression; 218private static MethodInfo FindEnumerableMethodForQueryable(string name, ReadOnlyCollection<Expression> args, params Type[]? typeArgs) 297private static MethodInfo FindMethod(Type type, string name, ReadOnlyCollection<Expression> args, Type[]? typeArgs) 313private static bool ArgsMatch(MethodInfo m, ReadOnlyCollection<Expression> args, Type[]? typeArgs) 345Expression arg = args[i]; 378protected override Expression VisitConditional(ConditionalExpression c) 383Expression test = Visit(c.Test); 384Expression ifTrue = Visit(c.IfTrue); 385Expression ifFalse = Visit(c.IfFalse); 389return Expression.Condition(test, ifTrue, ifFalse, trueType); 391return Expression.Condition(test, ifTrue, ifFalse, falseType); 392return Expression.Condition(test, ifTrue, ifFalse, GetEquivalentType(type)); 395protected override Expression VisitBlock(BlockExpression node) 400ReadOnlyCollection<Expression> nodes = Visit(node.Expressions); 403return Expression.Block(variables, nodes); 404return Expression.Block(GetEquivalentType(type), variables, nodes); 407protected override Expression VisitGoto(GotoExpression node) 413Expression value = Visit(node.Value); 414return Expression.MakeGoto(node.Kind, target, value, GetEquivalentType(typeof(EnumerableQuery).IsAssignableFrom(type) ? value.Type : type)); 433newTarget = Expression.Label(GetEquivalentType(type), node.Name);
System\Linq\Queryable.cs (330)
52Expression.Call( 55source.Expression, Expression.Quote(predicate))); 65Expression.Call( 68source.Expression, Expression.Quote(predicate))); 77Expression.Call( 89Expression.Call( 102Expression.Call( 105source.Expression, Expression.Quote(selector))); 115Expression.Call( 118source.Expression, Expression.Quote(selector))); 128Expression.Call( 131source.Expression, Expression.Quote(selector))); 141Expression.Call( 144source.Expression, Expression.Quote(selector))); 155Expression.Call( 158source.Expression, Expression.Quote(collectionSelector), Expression.Quote(resultSelector))); 169Expression.Call( 172source.Expression, Expression.Quote(collectionSelector), Expression.Quote(resultSelector))); 175private static Expression GetSourceExpression<TSource>(IEnumerable<TSource> source) 178return q != null ? q.Expression : Expression.Constant(source, typeof(IEnumerable<TSource>)); 191Expression.Call( 194outer.Expression, GetSourceExpression(inner), Expression.Quote(outerKeySelector), Expression.Quote(innerKeySelector), Expression.Quote(resultSelector))); 207Expression.Call( 210outer.Expression, GetSourceExpression(inner), Expression.Quote(outerKeySelector), Expression.Quote(innerKeySelector), Expression.Quote(resultSelector), Expression.Constant(comparer, typeof(IEqualityComparer<TKey>)))); 223Expression.Call( 226outer.Expression, GetSourceExpression(inner), Expression.Quote(outerKeySelector), Expression.Quote(innerKeySelector), Expression.Quote(resultSelector))); 239Expression.Call( 242outer.Expression, GetSourceExpression(inner), Expression.Quote(outerKeySelector), Expression.Quote(innerKeySelector), Expression.Quote(resultSelector), Expression.Constant(comparer, typeof(IEqualityComparer<TKey>)))); 259/// It then passes the <see cref="MethodCallExpression"/> to the <see cref="IQueryProvider.CreateQuery{TElement}(Expression)"/> method 261/// parameter. The result of calling <see cref="IQueryProvider.CreateQuery{TElement}(Expression)"/> is cast to 275Expression.Call( 296/// It then passes the <see cref="MethodCallExpression"/> to the <see cref="IQueryProvider.CreateQuery{TElement}(Expression)"/> method 298/// parameter. The result of calling <see cref="IQueryProvider.CreateQuery{TElement}(Expression)"/> is cast to 312Expression.Call( 315source.Expression, Expression.Constant(comparer, typeof(IComparer<T>)))); 325Expression.Call( 328source.Expression, Expression.Quote(keySelector))); 338Expression.Call( 341source.Expression, Expression.Quote(keySelector), Expression.Constant(comparer, typeof(IComparer<TKey>)))); 358/// It then passes the <see cref="MethodCallExpression"/> to the <see cref="IQueryProvider.CreateQuery{TElement}(Expression)"/> method 360/// parameter. The result of calling <see cref="IQueryProvider.CreateQuery{TElement}(Expression)"/> is cast to 374Expression.Call( 395/// It then passes the <see cref="MethodCallExpression"/> to the <see cref="IQueryProvider.CreateQuery{TElement}(Expression)"/> method 397/// parameter. The result of calling <see cref="IQueryProvider.CreateQuery{TElement}(Expression)"/> is cast to 411Expression.Call( 414source.Expression, Expression.Constant(comparer, typeof(IComparer<T>)))); 424Expression.Call( 427source.Expression, Expression.Quote(keySelector))); 437Expression.Call( 440source.Expression, Expression.Quote(keySelector), Expression.Constant(comparer, typeof(IComparer<TKey>)))); 450Expression.Call( 453source.Expression, Expression.Quote(keySelector))); 463Expression.Call( 466source.Expression, Expression.Quote(keySelector), Expression.Constant(comparer, typeof(IComparer<TKey>)))); 476Expression.Call( 479source.Expression, Expression.Quote(keySelector))); 489Expression.Call( 492source.Expression, Expression.Quote(keySelector), Expression.Constant(comparer, typeof(IComparer<TKey>)))); 501Expression.Call( 504source.Expression, Expression.Constant(count))); 519Expression.Call( 522source.Expression, Expression.Constant(range))); 532Expression.Call( 535source.Expression, Expression.Quote(predicate))); 545Expression.Call( 548source.Expression, Expression.Quote(predicate))); 557Expression.Call( 560source.Expression, Expression.Constant(count))); 570Expression.Call( 573source.Expression, Expression.Quote(predicate))); 583Expression.Call( 586source.Expression, Expression.Quote(predicate))); 596Expression.Call( 599source.Expression, Expression.Quote(keySelector))); 610Expression.Call( 613source.Expression, Expression.Quote(keySelector), Expression.Quote(elementSelector))); 623Expression.Call( 626source.Expression, Expression.Quote(keySelector), Expression.Constant(comparer, typeof(IEqualityComparer<TKey>)))); 637Expression.Call( 640source.Expression, Expression.Quote(keySelector), Expression.Quote(elementSelector), Expression.Constant(comparer, typeof(IEqualityComparer<TKey>)))); 652Expression.Call( 655source.Expression, Expression.Quote(keySelector), Expression.Quote(elementSelector), Expression.Quote(resultSelector))); 666Expression.Call( 669source.Expression, Expression.Quote(keySelector), Expression.Quote(resultSelector))); 680Expression.Call( 683source.Expression, Expression.Quote(keySelector), Expression.Quote(resultSelector), Expression.Constant(comparer, typeof(IEqualityComparer<TKey>)))); 695Expression.Call( 698source.Expression, Expression.Quote(keySelector), Expression.Quote(elementSelector), Expression.Quote(resultSelector), Expression.Constant(comparer, typeof(IEqualityComparer<TKey>)))); 707Expression.Call( 719Expression.Call( 722source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer<TSource>)))); 739Expression.Call( 742source.Expression, Expression.Quote(keySelector))); 760Expression.Call( 763source.Expression, Expression.Quote(keySelector), Expression.Constant(comparer, typeof(IEqualityComparer<TKey>)))); 783Expression.Call( 786source.Expression, Expression.Constant(size))); 796Expression.Call( 809Expression.Call( 823Expression.Call( 826source1.Expression, GetSourceExpression(source2), Expression.Quote(resultSelector))); 847Expression.Call( 860Expression.Call( 873Expression.Call( 878Expression.Constant(comparer, typeof(IEqualityComparer<TSource>)))); 897Expression.Call( 900source1.Expression, GetSourceExpression(source2), Expression.Quote(keySelector))); 920Expression.Call( 925Expression.Quote(keySelector), 926Expression.Constant(comparer, typeof(IEqualityComparer<TKey>)))); 940Expression.Call( 953Expression.Call( 966Expression.Call( 971Expression.Constant(comparer, typeof(IEqualityComparer<TSource>)))); 990Expression.Call( 995Expression.Quote(keySelector))); 1015Expression.Call( 1020Expression.Quote(keySelector), 1021Expression.Constant(comparer, typeof(IEqualityComparer<TKey>)))); 1031Expression.Call( 1044Expression.Call( 1049Expression.Constant(comparer, typeof(IEqualityComparer<TSource>)))); 1069Expression.Call( 1074Expression.Quote(keySelector))); 1095Expression.Call( 1100Expression.Quote(keySelector), 1101Expression.Constant(comparer, typeof(IEqualityComparer<TKey>)))); 1110Expression.Call( 1123Expression.Call( 1126source.Expression, Expression.Quote(predicate))); 1135Expression.Call( 1153Expression.Call( 1156source.Expression, Expression.Constant(defaultValue, typeof(TSource)))); 1166Expression.Call( 1169source.Expression, Expression.Quote(predicate))); 1186Expression.Call( 1189source.Expression, Expression.Quote(predicate), Expression.Constant(defaultValue, typeof(TSource)))); 1198Expression.Call( 1211Expression.Call( 1214source.Expression, Expression.Quote(predicate))); 1223Expression.Call( 1241Expression.Call( 1244source.Expression, Expression.Constant(defaultValue, typeof(TSource)))); 1254Expression.Call( 1257source.Expression, Expression.Quote(predicate))); 1274Expression.Call( 1277source.Expression, Expression.Quote(predicate), Expression.Constant(defaultValue, typeof(TSource)) 1287Expression.Call( 1300Expression.Call( 1303source.Expression, Expression.Quote(predicate))); 1312Expression.Call( 1331Expression.Call( 1334source.Expression, Expression.Constant(defaultValue, typeof(TSource)))); 1344Expression.Call( 1347source.Expression, Expression.Quote(predicate))); 1365Expression.Call( 1368source.Expression, Expression.Quote(predicate), Expression.Constant(defaultValue, typeof(TSource)))); 1380Expression.Call( 1383source.Expression, Expression.Constant(index))); 1402Expression.Call( 1405source.Expression, Expression.Constant(index))); 1414Expression.Call( 1417source.Expression, Expression.Constant(index))); 1432Expression.Call( 1435source.Expression, Expression.Constant(index))); 1444Expression.Call( 1456Expression.Call( 1459source.Expression, Expression.Constant(defaultValue, typeof(TSource)))); 1468Expression.Call( 1471source.Expression, Expression.Constant(item, typeof(TSource)))); 1480Expression.Call( 1483source.Expression, Expression.Constant(item, typeof(TSource)), Expression.Constant(comparer, typeof(IEqualityComparer<TSource>)))); 1492Expression.Call( 1505Expression.Call( 1518Expression.Call( 1523Expression.Constant(comparer, typeof(IEqualityComparer<TSource>)))); 1532Expression.Call( 1545Expression.Call( 1548source.Expression, Expression.Quote(predicate))); 1558Expression.Call( 1561source.Expression, Expression.Quote(predicate))); 1570Expression.Call( 1583Expression.Call( 1586source.Expression, Expression.Quote(predicate))); 1604Expression.Call( 1607source.Expression, Expression.Quote(keySelector), Expression.Constant(comparer, typeof(IEqualityComparer<TKey>)))); 1616Expression.Call( 1629Expression.Call( 1632source.Expression, Expression.Quote(predicate))); 1641Expression.Call( 1660Expression.Call( 1664Expression.Constant(comparer, typeof(IComparer<TSource>)))); 1674Expression.Call( 1677source.Expression, Expression.Quote(selector))); 1695Expression.Call( 1699Expression.Quote(keySelector))); 1718Expression.Call( 1722Expression.Quote(keySelector), 1723Expression.Constant(comparer, typeof(IComparer<TSource>)))); 1732Expression.Call( 1750Expression.Call( 1754Expression.Constant(comparer, typeof(IComparer<TSource>)))); 1764Expression.Call( 1767source.Expression, Expression.Quote(selector))); 1785Expression.Call( 1789Expression.Quote(keySelector))); 1808Expression.Call( 1812Expression.Quote(keySelector), 1813Expression.Constant(comparer, typeof(IComparer<TSource>)))); 1822Expression.Call( 1834Expression.Call( 1846Expression.Call( 1858Expression.Call( 1870Expression.Call( 1882Expression.Call( 1894Expression.Call( 1906Expression.Call( 1918Expression.Call( 1930Expression.Call( 1943Expression.Call( 1946source.Expression, Expression.Quote(selector))); 1956Expression.Call( 1959source.Expression, Expression.Quote(selector))); 1969Expression.Call( 1972source.Expression, Expression.Quote(selector))); 1982Expression.Call( 1985source.Expression, Expression.Quote(selector))); 1995Expression.Call( 1998source.Expression, Expression.Quote(selector))); 2008Expression.Call( 2011source.Expression, Expression.Quote(selector))); 2021Expression.Call( 2024source.Expression, Expression.Quote(selector))); 2034Expression.Call( 2037source.Expression, Expression.Quote(selector))); 2047Expression.Call( 2050source.Expression, Expression.Quote(selector))); 2060Expression.Call( 2063source.Expression, Expression.Quote(selector))); 2072Expression.Call( 2084Expression.Call( 2096Expression.Call( 2108Expression.Call( 2120Expression.Call( 2132Expression.Call( 2144Expression.Call( 2156Expression.Call( 2168Expression.Call( 2180Expression.Call( 2193Expression.Call( 2196source.Expression, Expression.Quote(selector))); 2206Expression.Call( 2209source.Expression, Expression.Quote(selector))); 2219Expression.Call( 2222source.Expression, Expression.Quote(selector))); 2232Expression.Call( 2235source.Expression, Expression.Quote(selector))); 2245Expression.Call( 2248source.Expression, Expression.Quote(selector))); 2258Expression.Call( 2261source.Expression, Expression.Quote(selector))); 2271Expression.Call( 2274source.Expression, Expression.Quote(selector))); 2284Expression.Call( 2287source.Expression, Expression.Quote(selector))); 2297Expression.Call( 2300source.Expression, Expression.Quote(selector))); 2310Expression.Call( 2313source.Expression, Expression.Quote(selector))); 2323Expression.Call( 2326source.Expression, Expression.Quote(func))); 2336Expression.Call( 2339source.Expression, Expression.Constant(seed), Expression.Quote(func))); 2350Expression.Call( 2353source.Expression, Expression.Constant(seed), Expression.Quote(func), Expression.Quote(selector))); 2380Expression.Call( 2383source.Expression, Expression.Quote(keySelector), Expression.Constant(seed), Expression.Quote(func), Expression.Constant(keyComparer, typeof(IEqualityComparer<TKey>)))); 2411Expression.Call( 2414source.Expression, Expression.Quote(keySelector), Expression.Quote(seedSelector), Expression.Quote(func), Expression.Constant(keyComparer, typeof(IEqualityComparer<TKey>)))); 2423Expression.Call( 2426source.Expression, Expression.Constant(count) 2436Expression.Call( 2439source.Expression, Expression.Constant(count))); 2448Expression.Call( 2451source.Expression, Expression.Constant(element))); 2460Expression.Call( 2463source.Expression, Expression.Constant(element)));
System.Private.Xml (5)
System\Xml\Serialization\ReflectionXmlSerializationReader.cs (5)
2134var objectParam = Expression.Parameter(typeof(TObj)); 2135var valueParam = Expression.Parameter(typeof(TParam)); 2136var fieldExpr = Expression.Field(objectParam, fieldInfo); 2137var assignExpr = Expression.Assign(fieldExpr, valueParam); 2138setTypedDelegate = Expression.Lambda<Action<TObj, TParam>>(assignExpr, objectParam, valueParam).Compile();
System.ServiceModel.Primitives (30)
System\IdentityModel\CryptoHelper.cs (2)
308Linq.Expressions.NewExpression algorithmCreationExpression = Linq.Expressions.Expression.New(algorithmType); 309Linq.Expressions.LambdaExpression creationFunction = Linq.Expressions.Expression.Lambda<Func<object>>(algorithmCreationExpression);
System\ServiceModel\Dispatcher\InvokerUtil.cs (28)
114var targetParam = Expression.Parameter(typeof(object), "target"); 115var inputsParam = Expression.Parameter(typeof(object[]), "inputs"); 116var outputsParam = Expression.Parameter(typeof(object[]), "outputs"); 119var result = Expression.Variable(typeof(object), "result"); 124List<Expression> expressions = new(); 131ParameterExpression variable = Expression.Variable(variableType, $"p{i}"); 135expressions.Add(Expression.Assign(variable, Expression.Convert(Expression.ArrayIndex(inputsParam, Expression.Constant(inputParameterCount)), variableType))); 149var castTargetParam = Expression.Convert(targetParam, method.DeclaringType); 155expressions.Add(Expression.Assign(result, Expression.Convert(Expression.Call(castTargetParam, method, invocationParameters), typeof(object)))); 159expressions.Add(Expression.Assign(result, Expression.Call(castTargetParam, method, invocationParameters))); 164expressions.Add(Expression.Call(castTargetParam, method, invocationParameters)); 165expressions.Add(Expression.Assign(result, Expression.Constant(null, typeof(object)))); 173expressions.Add(Expression.Assign( 174Expression.ArrayAccess(outputsParam, Expression.Constant(j)), 175Expression.Convert(outputVariable.OutputExpression, typeof(object)))); 179expressions.Add(Expression.Assign( 180Expression.ArrayAccess(outputsParam, Expression.Constant(j)), 188BlockExpression finalBlock = Expression.Block(variables: variables, expressions: expressions); 190Expression<InvokeDelegate> lambda = Expression.Lambda<InvokeDelegate>(