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