29 overrides of Type
System.Linq.Expressions (29)
System\Linq\Expressions\BinaryExpression.cs (4)
466
public sealed override Type
Type
=> typeof(bool);
493
public sealed override Type
Type
=> Left.Type;
525
public sealed override Type
Type
=> Right.Type;
557
public sealed override Type
Type
{ get; }
System\Linq\Expressions\BlockExpression.cs (1)
57
public override Type
Type
=> GetExpression(ExpressionCount - 1).Type;
System\Linq\Expressions\ConditionalExpression.cs (1)
49
public override Type
Type
=> IfTrue.Type;
System\Linq\Expressions\ConstantExpression.cs (1)
24
public override Type
Type
System\Linq\Expressions\DebugInfoExpression.cs (1)
28
public sealed override Type
Type
=> typeof(void);
System\Linq\Expressions\DefaultExpression.cs (1)
24
public sealed override Type
Type
{ get; }
System\Linq\Expressions\DynamicExpression.cs (1)
115
public override Type
Type
=> typeof(object);
System\Linq\Expressions\GotoExpression.cs (1)
50
public sealed override Type
Type
{ get; }
System\Linq\Expressions\IndexExpression.cs (1)
49
public sealed override Type
Type
System\Linq\Expressions\InvocationExpression.cs (1)
29
public sealed override Type
Type
{ get; }
System\Linq\Expressions\LabelExpression.cs (1)
27
public sealed override Type
Type
=> Target.Type;
System\Linq\Expressions\LambdaExpression.cs (1)
43
public sealed override Type
Type
=> TypeCore;
System\Linq\Expressions\ListInitExpression.cs (1)
40
public sealed override Type
Type
=> NewExpression.Type;
System\Linq\Expressions\LoopExpression.cs (1)
26
public sealed override Type
Type
=> BreakLabel == null ? typeof(void) : BreakLabel.Type;
System\Linq\Expressions\MemberExpression.cs (2)
100
public sealed override Type
Type
=> _field.FieldType;
114
public sealed override Type
Type
=> _property.PropertyType;
System\Linq\Expressions\MemberInitExpression.cs (1)
27
public sealed override Type
Type
=> NewExpression.Type;
System\Linq\Expressions\MethodCallExpression.cs (1)
36
public sealed override Type
Type
=> Method.ReturnType;
System\Linq\Expressions\NewArrayExpression.cs (1)
43
public sealed override Type
Type
{ get; }
System\Linq\Expressions\NewExpression.cs (1)
33
public override Type
Type
=> Constructor!.DeclaringType!;
System\Linq\Expressions\ParameterExpression.cs (1)
75
public override Type
Type
=> typeof(object);
System\Linq\Expressions\RuntimeVariablesExpression.cs (1)
29
public sealed override Type
Type
=> typeof(IRuntimeVariables);
System\Linq\Expressions\SwitchExpression.cs (1)
31
public sealed override Type
Type
{ get; }
System\Linq\Expressions\TryExpression.cs (1)
37
public sealed override Type
Type
{ get; }
System\Linq\Expressions\TypeBinaryExpression.cs (1)
28
public sealed override Type
Type
=> typeof(bool);
System\Linq\Expressions\UnaryExpression.cs (1)
30
public sealed override Type
Type
{ get; }
758 references to Type
Microsoft.AspNetCore.Components.Forms (1)
src\Components\Shared\src\ExpressionFormatting\ExpressionFormatter.cs (1)
248
var memberType = memberExpression.
Type
;
Microsoft.AspNetCore.Components.Web (1)
src\Components\Shared\src\ExpressionFormatting\ExpressionFormatter.cs (1)
248
var memberType = memberExpression.
Type
;
Microsoft.AspNetCore.JsonPatch (1)
JsonPatchDocumentOfT.cs (1)
715
var jsonObjectContract = ContractResolver.ResolveContract(memberExpression.Expression.
Type
) as JsonObjectContract;
Microsoft.AspNetCore.Mvc.ViewFeatures (6)
CachedExpressionCompiler.cs (4)
216
if (body.
Type
.IsValueType)
223
Debug.Assert(combinedNullTest.
Type
== typeof(bool));
226
Expression.Constant(value: null, body.
Type
),
236
var type = invokingExpression.
Type
;
ExpressionMetadataProvider.cs (2)
47
memberExpression.
Type
== typeof(TModel) &&
60
containerType = memberExpression.Expression?.
Type
;
Microsoft.CodeAnalysis.VisualBasic.Emit.UnitTests (1)
ExpressionTrees\Sources\ExprLambdaUtils.vb (1)
95
_s.AppendLine(indent + _indentStep + "type: " + node.
Type
.ToString())
Microsoft.CSharp (8)
Microsoft\CSharp\RuntimeBinder\BinderHelper.cs (4)
85
Expression e = Expression.Equal(o.Expression, Expression.Constant(o.Value, o.Expression.
Type
));
120
Expression.Assign(arg0.Expression, Expression.Convert(tempForIncrement, arg0.Expression.
Type
)));
260
if (binding.
Type
== typeof(void))
271
if (binding.
Type
.IsValueType && !action.ReturnType.IsValueType)
Microsoft\CSharp\RuntimeBinder\ExpressionTreeCallRewriter.cs (2)
334
if (e.
Type
.MakeByRefType() == t)
362
if (e.
Type
.MakeByRefType() == t)
Microsoft\CSharp\RuntimeBinder\RuntimeBinder.cs (2)
205
Type t = argInfo.UseCompileTimeType ? param.
Type
: arg.LimitType;
340
CType type = SymbolTable.GetCTypeFromType(parameter.
Type
);
Microsoft.Extensions.DependencyInjection (2)
ServiceLookup\Expressions\ExpressionResolverBuilder.cs (2)
198
if (type.IsAssignableFrom(expression.
Type
)
199
&& (!expression.
Type
.IsValueType || !forceValueTypeConversion))
Microsoft.VisualBasic.Core (1)
Microsoft\VisualBasic\CompilerServices\IDOBinder.vb (1)
1326
Return If(valueExpression.
Type
.Equals(GetType(Object)), valueExpression, Expression.Convert(valueExpression, GetType(Object)))
System.Linq.Expressions (721)
System\Dynamic\BindingRestrictions.cs (1)
113
ContractUtils.Requires(expression.
Type
== typeof(bool), nameof(expression));
System\Dynamic\DynamicMetaObject.cs (2)
80
Type ct = Expression.
Type
;
100
public Type LimitType => RuntimeType ?? Expression.
Type
;
System\Dynamic\DynamicMetaObjectBinder.cs (4)
95
!TypeUtils.AreReferenceAssignable(expectedResult, body.
Type
))
103
throw System.Linq.Expressions.Error.DynamicObjectResultNotAssignable(body.
Type
, target.Value.GetType(), this, expectedResult);
107
throw System.Linq.Expressions.Error.DynamicBinderResultNotAssignable(body.
Type
, this, expectedResult);
169
/// <param name="type">The <see cref="Expression.
Type
">Type</see> property of the resulting expression; any type is allowed.</param>
System\Dynamic\DynamicObject.cs (1)
847
if (TypeUtils.AreEquivalent(Expression.
Type
, typeof(DynamicObject)))
System\Dynamic\ExpandoObject.cs (2)
953
binder.GetUpdateExpression(ifTestSucceeds.
Type
)
997
if (TypeUtils.AreEquivalent(Expression.
Type
, LimitType))
System\Dynamic\Utils\ExpressionUtils.cs (4)
164
if (!TypeUtils.AreReferenceAssignable(pType, arguments.
Type
))
172
throw Error.ExpressionTypeDoesNotMatchConstructorParameter(arguments.
Type
, pType, argumentParamName, index);
174
throw Error.ExpressionTypeDoesNotMatchParameter(arguments.
Type
, pType, argumentParamName, index);
177
throw Error.ExpressionTypeDoesNotMatchMethodParameter(arguments.
Type
, pType, method, argumentParamName, index);
System\Linq\Expressions\BinaryExpression.cs (237)
190
ParameterExpression temp1 = Variable(member.Expression.
Type
, "temp1");
203
ParameterExpression temp2 = Variable(e2.
Type
, "temp2");
237
ParameterExpression tempObj = Expression.Variable(index.Object!.
Type
, "tempObj");
246
ParameterExpression tempArg = Expression.Variable(arg.
Type
, "tempArg" + i);
262
ParameterExpression tempValue = Expression.Variable(op.
Type
, "tempValue");
290
if (Left.
Type
.IsNullableType())
294
!TypeUtils.AreEquivalent(method.GetParametersCached()[0].ParameterType.GetNonRefType(), Left.
Type
);
303
public bool IsLiftedToNull => IsLifted &&
Type
.IsNullableType();
318
Debug.Assert(method == null && TypeUtils.AreEquivalent(type, right.
Type
) && nodeType == ExpressionType.Coalesce);
336
Type left = Left.
Type
;
337
Type right = Right.
Type
;
354
Type left = Left.
Type
;
355
Type right = Right.
Type
;
397
ParameterExpression left = Parameter(Left.
Type
, "left");
398
ParameterExpression right = Parameter(Right.
Type
, "right");
424
Type
426
Constant(null,
Type
)
431
Constant(null,
Type
)
493
public sealed override Type Type => Left.
Type
;
525
public sealed override Type Type => Right.
Type
;
591
TypeUtils.ValidateType(left.
Type
, nameof(left), allowByRef: true, allowPointer: true);
592
TypeUtils.ValidateType(right.
Type
, nameof(right), allowByRef: true, allowPointer: true);
593
if (!TypeUtils.AreReferenceAssignable(left.
Type
, right.
Type
))
595
throw Error.ExpressionTypeDoesNotMatchAssignment(right.
Type
, left.
Type
);
605
MethodInfo? method = GetUserDefinedBinaryOperator(binaryType, left.
Type
, right.
Type
, name);
611
if (left.
Type
.IsNullableType() && right.
Type
.IsNullableType())
613
Type nnLeftType = left.
Type
.GetNonNullableType();
614
Type nnRightType = right.
Type
.GetNonNullableType();
638
if (ParameterIsAssignable(pms[0], left.
Type
) && ParameterIsAssignable(pms[1], right.
Type
))
640
ValidateParamsWithOperandsOrThrow(pms[0].ParameterType, left.
Type
, binaryType, method.Name);
641
ValidateParamsWithOperandsOrThrow(pms[1].ParameterType, right.
Type
, binaryType, method.Name);
645
if (left.
Type
.IsNullableType() && right.
Type
.IsNullableType() &&
646
ParameterIsAssignable(pms[0], left.
Type
.GetNonNullableType()) &&
647
ParameterIsAssignable(pms[1], right.
Type
.GetNonNullableType()) &&
668
if (!TypeUtils.AreReferenceAssignable(left.
Type
, b.
Type
))
677
b = new OpAssignMethodConversionBinaryExpression(b.NodeType, b.Left, b.Right, b.Left.
Type
, b.Method!, conversion);
688
ValidateParamsWithOperandsOrThrow(pis[0].ParameterType, left.
Type
, binaryType, name);
689
ValidateParamsWithOperandsOrThrow(pis[1].ParameterType, right.
Type
, binaryType, name);
692
throw Error.BinaryOperatorNotDefined(binaryType, left.
Type
, right.
Type
);
701
if (!TypeUtils.AreReferenceAssignable(left.
Type
, b.
Type
))
710
b = new OpAssignMethodConversionBinaryExpression(b.NodeType, b.Left, b.Right, b.Left.
Type
, b.Method!, conversion);
784
? !IsNullConstant(right) && right.
Type
.IsNullableType()
785
: IsNullConstant(right) && left.
Type
.IsNullableType();
992
if (TypeUtils.HasReferenceEquality(left.
Type
, right.
Type
))
996
throw Error.ReferenceEqualityNotDefined(left.
Type
, right.
Type
);
1044
if (TypeUtils.HasReferenceEquality(left.
Type
, right.
Type
))
1048
throw Error.ReferenceEqualityNotDefined(left.
Type
, right.
Type
);
1054
if (left.
Type
== right.
Type
&& (left.
Type
.IsNumeric() ||
1055
left.
Type
== typeof(object) ||
1056
left.
Type
.IsBool() ||
1057
left.
Type
.GetNonNullableType().IsEnum))
1059
if (left.
Type
.IsNullableType() && liftToNull)
1074
if (TypeUtils.HasBuiltInEqualityOperator(left.
Type
, right.
Type
) || IsNullComparison(left, right))
1076
if (left.
Type
.IsNullableType() && liftToNull)
1085
throw Error.BinaryOperatorNotDefined(binaryType, left.
Type
, right.
Type
);
1227
if (left.
Type
== right.
Type
&& left.
Type
.IsNumeric())
1229
if (left.
Type
.IsNullableType() && liftToNull)
1273
if (left.
Type
== right.
Type
)
1275
if (left.
Type
== typeof(bool))
1279
else if (left.
Type
== typeof(bool?))
1281
return new SimpleBinaryExpression(ExpressionType.AndAlso, left, right, left.
Type
);
1284
method = GetUserDefinedBinaryOperator(ExpressionType.AndAlso, left.
Type
, right.
Type
, "op_BitwiseAnd");
1287
ValidateUserDefinedConditionalLogicOperator(ExpressionType.AndAlso, left.
Type
, right.
Type
, method);
1288
returnType = (left.
Type
.IsNullableType() && TypeUtils.AreEquivalent(method.ReturnType, left.
Type
.GetNonNullableType())) ? left.
Type
: method.ReturnType;
1291
throw Error.BinaryOperatorNotDefined(ExpressionType.AndAlso, left.
Type
, right.
Type
);
1293
ValidateUserDefinedConditionalLogicOperator(ExpressionType.AndAlso, left.
Type
, right.
Type
, method);
1294
returnType = (left.
Type
.IsNullableType() && TypeUtils.AreEquivalent(method.ReturnType, left.
Type
.GetNonNullableType())) ? left.
Type
: method.ReturnType;
1326
if (left.
Type
== right.
Type
)
1328
if (left.
Type
== typeof(bool))
1332
else if (left.
Type
== typeof(bool?))
1334
return new SimpleBinaryExpression(ExpressionType.OrElse, left, right, left.
Type
);
1337
method = GetUserDefinedBinaryOperator(ExpressionType.OrElse, left.
Type
, right.
Type
, "op_BitwiseOr");
1340
ValidateUserDefinedConditionalLogicOperator(ExpressionType.OrElse, left.
Type
, right.
Type
, method);
1341
returnType = (left.
Type
.IsNullableType() && method.ReturnType == left.
Type
.GetNonNullableType()) ? left.
Type
: method.ReturnType;
1344
throw Error.BinaryOperatorNotDefined(ExpressionType.OrElse, left.
Type
, right.
Type
);
1346
ValidateUserDefinedConditionalLogicOperator(ExpressionType.OrElse, left.
Type
, right.
Type
, method);
1347
returnType = (left.
Type
.IsNullableType() && method.ReturnType == left.
Type
.GetNonNullableType()) ? left.
Type
: method.ReturnType;
1383
Type resultType = ValidateCoalesceArgTypes(left.
Type
, right.
Type
);
1387
if (left.
Type
.IsValueType && !left.
Type
.IsNullableType())
1409
if (!TypeUtils.AreEquivalent(method.ReturnType, right.
Type
))
1415
if (!ParameterIsAssignable(pms[0], left.
Type
.GetNonNullableType()) &&
1416
!ParameterIsAssignable(pms[0], left.
Type
))
1479
if (left.
Type
== right.
Type
&& left.
Type
.IsArithmetic())
1481
return new SimpleBinaryExpression(ExpressionType.Add, left, right, left.
Type
);
1532
if (left.
Type
== right.
Type
&& left.
Type
.IsArithmetic())
1539
return new SimpleBinaryExpression(ExpressionType.AddAssign, left, right, left.
Type
);
1557
if (!TypeUtils.AreEquivalent(mi.ReturnType, left.
Type
))
1616
if (left.
Type
== right.
Type
&& left.
Type
.IsArithmetic())
1623
return new SimpleBinaryExpression(ExpressionType.AddAssignChecked, left, right, left.
Type
);
1657
if (left.
Type
== right.
Type
&& left.
Type
.IsArithmetic())
1659
return new SimpleBinaryExpression(ExpressionType.AddChecked, left, right, left.
Type
);
1693
if (left.
Type
== right.
Type
&& left.
Type
.IsArithmetic())
1695
return new SimpleBinaryExpression(ExpressionType.Subtract, left, right, left.
Type
);
1746
if (left.
Type
== right.
Type
&& left.
Type
.IsArithmetic())
1753
return new SimpleBinaryExpression(ExpressionType.SubtractAssign, left, right, left.
Type
);
1804
if (left.
Type
== right.
Type
&& left.
Type
.IsArithmetic())
1811
return new SimpleBinaryExpression(ExpressionType.SubtractAssignChecked, left, right, left.
Type
);
1845
if (left.
Type
== right.
Type
&& left.
Type
.IsArithmetic())
1847
return new SimpleBinaryExpression(ExpressionType.SubtractChecked, left, right, left.
Type
);
1881
if (left.
Type
== right.
Type
&& left.
Type
.IsArithmetic())
1883
return new SimpleBinaryExpression(ExpressionType.Divide, left, right, left.
Type
);
1934
if (left.
Type
== right.
Type
&& left.
Type
.IsArithmetic())
1941
return new SimpleBinaryExpression(ExpressionType.DivideAssign, left, right, left.
Type
);
1975
if (left.
Type
== right.
Type
&& left.
Type
.IsArithmetic())
1977
return new SimpleBinaryExpression(ExpressionType.Modulo, left, right, left.
Type
);
2028
if (left.
Type
== right.
Type
&& left.
Type
.IsArithmetic())
2035
return new SimpleBinaryExpression(ExpressionType.ModuloAssign, left, right, left.
Type
);
2069
if (left.
Type
== right.
Type
&& left.
Type
.IsArithmetic())
2071
return new SimpleBinaryExpression(ExpressionType.Multiply, left, right, left.
Type
);
2122
if (left.
Type
== right.
Type
&& left.
Type
.IsArithmetic())
2129
return new SimpleBinaryExpression(ExpressionType.MultiplyAssign, left, right, left.
Type
);
2180
if (left.
Type
== right.
Type
&& left.
Type
.IsArithmetic())
2187
return new SimpleBinaryExpression(ExpressionType.MultiplyAssignChecked, left, right, left.
Type
);
2221
if (left.
Type
== right.
Type
&& left.
Type
.IsArithmetic())
2223
return new SimpleBinaryExpression(ExpressionType.MultiplyChecked, left, right, left.
Type
);
2273
if (IsSimpleShift(left.
Type
, right.
Type
))
2275
Type resultType = GetResultTypeOfShift(left.
Type
, right.
Type
);
2327
if (IsSimpleShift(left.
Type
, right.
Type
))
2334
Type resultType = GetResultTypeOfShift(left.
Type
, right.
Type
);
2369
if (IsSimpleShift(left.
Type
, right.
Type
))
2371
Type resultType = GetResultTypeOfShift(left.
Type
, right.
Type
);
2423
if (IsSimpleShift(left.
Type
, right.
Type
))
2430
Type resultType = GetResultTypeOfShift(left.
Type
, right.
Type
);
2465
if (left.
Type
== right.
Type
&& left.
Type
.IsIntegerOrBool())
2467
return new SimpleBinaryExpression(ExpressionType.And, left, right, left.
Type
);
2518
if (left.
Type
== right.
Type
&& left.
Type
.IsIntegerOrBool())
2525
return new SimpleBinaryExpression(ExpressionType.AndAssign, left, right, left.
Type
);
2559
if (left.
Type
== right.
Type
&& left.
Type
.IsIntegerOrBool())
2561
return new SimpleBinaryExpression(ExpressionType.Or, left, right, left.
Type
);
2612
if (left.
Type
== right.
Type
&& left.
Type
.IsIntegerOrBool())
2619
return new SimpleBinaryExpression(ExpressionType.OrAssign, left, right, left.
Type
);
2653
if (left.
Type
== right.
Type
&& left.
Type
.IsIntegerOrBool())
2655
return new SimpleBinaryExpression(ExpressionType.ExclusiveOr, left, right, left.
Type
);
2706
if (left.
Type
== right.
Type
&& left.
Type
.IsIntegerOrBool())
2713
return new SimpleBinaryExpression(ExpressionType.ExclusiveOrAssign, left, right, left.
Type
);
2747
if (left.
Type
== right.
Type
&& left.
Type
.IsArithmetic())
2764
throw Error.BinaryOperatorNotDefined(ExpressionType.Power, left.
Type
, right.
Type
);
2769
ValidateParamsWithOperandsOrThrow(pis[0].ParameterType, left.
Type
, ExpressionType.Power, name);
2770
ValidateParamsWithOperandsOrThrow(pis[1].ParameterType, right.
Type
, ExpressionType.Power, name);
2825
throw Error.BinaryOperatorNotDefined(ExpressionType.PowerAssign, left.
Type
, right.
Type
);
2846
if (index.
Type
!= typeof(int))
2851
Type arrayType = array.
Type
;
System\Linq\Expressions\BlockExpression.cs (4)
57
public override Type Type => GetExpression(ExpressionCount - 1).
Type
;
1017
if (lastExpression.
Type
== type)
1045
if (!TypeUtils.AreReferenceAssignable(type, last.
Type
))
1051
if (!TypeUtils.AreEquivalent(type, last.
Type
))
System\Linq\Expressions\CatchBlock.cs (5)
76
/// The <see cref="
Type
"/> of object to be caught can be specified but no reference to the object
79
/// <param name="type">The <see cref="
Type
"/> of <see cref="Exception"/> this <see cref="CatchBlock"/> will handle.</param>
103
/// <param name="type">The <see cref="
Type
"/> of <see cref="Exception"/> this <see cref="CatchBlock"/> will handle.</param>
129
/// <param name="type">The <see cref="
Type
"/> of <see cref="Exception"/> this <see cref="CatchBlock"/> will handle.</param>
151
if (filter.
Type
!= typeof(bool)) throw Error.ArgumentMustBeBoolean(nameof(filter));
System\Linq\Expressions\Common\ConstantCheck.cs (2)
23
ExpressionType.Default => e.
Type
.IsNullableOrReferenceType(),
52
Type operandType = operand.
Type
;
System\Linq\Expressions\Compiler\DelegateHelpers.cs (3)
35
curTypeInfo = NextTypeInfo(types[i].
Type
, curTypeInfo);
71
Type paramType = mo.Expression.
Type
;
93
Type paramType = mo.Expression.
Type
;
System\Linq\Expressions\Compiler\LambdaCompiler.Address.cs (12)
70
if (TypeUtils.AreEquivalent(type, node.
Type
))
74
Debug.Assert(node.Right.
Type
== typeof(int));
75
_ilg.Emit(OpCodes.Ldelema, node.
Type
);
114
if (TypeUtils.AreEquivalent(type, node.
Type
))
173
node.Object!.
Type
.IsArray &&
174
node.Method == TypeUtils.GetArrayGetMethod(node.Object.
Type
))
176
MethodInfo mi = TypeUtils.GetArrayAddressMethod(node.Object.
Type
);
202
MethodInfo address = TypeUtils.GetArrayAddressMethod(node.Object!.
Type
);
219
Debug.Assert(TypeUtils.AreReferenceAssignable(type, node.
Type
));
237
if (TypeUtils.AreEquivalent(type, node.
Type
))
290
LocalBuilder valueLocal = GetLocal(node.
Type
);
342
LocalBuilder argLocal = GetLocal(arg.
Type
);
System\Linq\Expressions\Compiler\LambdaCompiler.Binary.cs (15)
37
(b.
Type
== typeof(bool) || b.
Type
== typeof(bool?)))
41
Debug.Assert(!b.IsLiftedToNull || b.
Type
== typeof(bool?));
42
if (ConstantCheck.IsNull(b.Left) && !ConstantCheck.IsNull(b.Right) && b.Right.
Type
.IsNullableType())
47
if (ConstantCheck.IsNull(b.Right) && !ConstantCheck.IsNull(b.Left) && b.Left.
Type
.IsNullableType())
65
EmitBinaryOperator(b.NodeType, b.Left.
Type
, b.Right.
Type
, b.
Type
, b.IsLiftedToNull);
71
Debug.Assert(e.
Type
.IsNullableType());
82
EmitAddress(e, e.
Type
);
83
_ilg.EmitHasValue(e.
Type
);
97
ParameterExpression p1 = Expression.Variable(b.Left.
Type
.GetNonNullableType(), name: null);
98
ParameterExpression p2 = Expression.Variable(b.Right.
Type
.GetNonNullableType(), name: null);
118
Debug.Assert(TypeUtils.AreReferenceAssignable(p1.Type, b.Left.
Type
.GetNonNullableType()));
119
Debug.Assert(TypeUtils.AreReferenceAssignable(p2.Type, b.Right.
Type
.GetNonNullableType()));
System\Linq\Expressions\Compiler\LambdaCompiler.ControlFlow.cs (3)
133
if (node.
Type
!= typeof(void) && (flags & CompilationFlags.EmitAsVoidType) == 0)
135
_ilg.EmitDefault(node.
Type
, this);
205
if (node.
Type
!= typeof(void))
System\Linq\Expressions\Compiler\LambdaCompiler.Expressions.cs (22)
109
if (node.
Type
== typeof(void))
133
if (!TypeUtils.AreEquivalent(node.
Type
, type))
136
Debug.Assert(TypeUtils.AreReferenceAssignable(type, node.
Type
));
186
if (typeof(LambdaExpression).IsAssignableFrom(expr.
Type
))
189
expr = Expression.Call(expr, LambdaExpression.GetCompileMethod(expr.
Type
));
192
EmitMethodCall(expr, expr.
Type
.GetInvokeMethod(), node, CompilationFlags.EmitAsNoTail | CompilationFlags.EmitExpressionStart);
381
if (obj != null && obj.
Type
.IsValueType)
425
types[i] = args.GetArgument(i).
Type
;
655
Type type = node.Expression.
Type
;
708
EmitAddress(node.Right, node.Right.
Type
);
871
type = instance.
Type
;
923
_ilg.EmitConvertToType(x.
Type
, typeof(int), isChecked: true, locals: this);
1133
if (arg.
Type
.IsNullableType())
1136
EmitAddress(arg, arg.
Type
);
1138
_ilg.EmitHasValue(arg.
Type
);
1142
_ilg.EmitGetValueOrDefault(arg.
Type
);
1149
if (!arg.
Type
.IsValueType)
1220
if (arg.
Type
.IsNullableType())
1222
EmitAddress(arg, arg.
Type
);
1224
_ilg.EmitHasValue(arg.
Type
);
1234
_ilg.EmitGetValueOrDefault(arg.
Type
);
1239
if (!arg.
Type
.IsValueType)
System\Linq\Expressions\Compiler\LambdaCompiler.Logical.cs (42)
18
Debug.Assert(node.Test.
Type
== typeof(bool));
91
if (b.Left.
Type
.IsNullableType())
97
Debug.Assert(!b.Left.
Type
.IsValueType);
114
LocalBuilder loc = GetLocal(b.Left.
Type
);
120
_ilg.EmitHasValue(b.Left.
Type
);
123
Type nnLeftType = b.Left.
Type
.GetNonNullableType();
128
Debug.Assert(p.Type.IsAssignableFrom(b.Left.
Type
) ||
135
if (!p.Type.IsAssignableFrom(b.Left.
Type
))
138
_ilg.EmitGetValueOrDefault(b.Left.
Type
);
148
else if (TypeUtils.AreEquivalent(b.
Type
, b.Left.
Type
))
155
_ilg.EmitGetValueOrDefault(b.Left.
Type
);
156
if (!TypeUtils.AreEquivalent(b.
Type
, nnLeftType))
158
_ilg.EmitConvertToType(nnLeftType, b.
Type
, isChecked: true, locals: this);
167
if (!TypeUtils.AreEquivalent(b.Right.
Type
, b.
Type
))
169
_ilg.EmitConvertToType(b.Right.
Type
, b.
Type
, isChecked: true, locals: this);
177
LocalBuilder loc = GetLocal(b.Left.
Type
);
214
if (!TypeUtils.AreEquivalent(b.Right.
Type
, b.
Type
))
216
if (b.Right.
Type
.IsValueType)
218
_ilg.Emit(OpCodes.Box, b.Right.
Type
);
220
_ilg.Emit(OpCodes.Castclass, b.
Type
);
224
if (!TypeUtils.AreEquivalent(b.Left.
Type
, b.
Type
))
226
Debug.Assert(!b.Left.
Type
.IsValueType);
227
_ilg.Emit(OpCodes.Castclass, b.
Type
);
325
else if (b.Left.
Type
== typeof(bool?))
419
else if (b.Left.
Type
== typeof(bool?))
458
Debug.Assert(node.
Type
== typeof(bool));
523
if (node.Right.
Type
.IsNullableType())
525
EmitAddress(node.Right, node.Right.
Type
);
526
_ilg.EmitHasValue(node.Right.
Type
);
530
Debug.Assert(!node.Right.
Type
.IsValueType);
537
if (node.Left.
Type
.IsNullableType())
539
EmitAddress(node.Left, node.Left.
Type
);
540
_ilg.EmitHasValue(node.Left.
Type
);
544
Debug.Assert(!node.Left.
Type
.IsValueType);
549
else if (node.Left.
Type
.IsNullableType() || node.Right.
Type
.IsNullableType())
573
if (TypeUtils.AreReferenceAssignable(convert.Type, convert.Operand.
Type
))
System\Linq\Expressions\Compiler\LambdaCompiler.Statements.cs (8)
202
ParameterExpression switchValue = Expression.Parameter(node.SwitchValue.
Type
, "switchValue");
222
Debug.Assert(TypeUtils.AreReferenceAssignable(testValue.Type, test.
Type
));
244
return node.Cases[0].TestValues[0].
Type
;
286
Type = Node.SwitchValue.
Type
;
373
Type type = node.SwitchValue.
Type
;
375
!TypeUtils.AreEquivalent(type, node.Cases[0].TestValues[0].
Type
))
427
LocalBuilder value = GetLocal(node.SwitchValue.
Type
);
694
Expression.Equal(dictField, Expression.Constant(null, dictField.
Type
)),
System\Linq\Expressions\Compiler\LambdaCompiler.Unary.cs (7)
72
else if (node.NodeType == ExpressionType.NegateChecked && node.Operand.
Type
.IsInteger())
75
Debug.Assert(type == node.Operand.
Type
);
116
EmitUnaryOperator(node.NodeType, node.Operand.
Type
, node.Type);
306
if (node.IsLifted && (!node.Type.IsValueType || !node.Operand.
Type
.IsValueType))
336
if (TypeUtils.AreEquivalent(node.Operand.
Type
, node.Type))
344
_ilg.EmitConvertToType(node.Operand.
Type
, node.Type, node.NodeType == ExpressionType.ConvertChecked, this);
354
ParameterExpression v = Expression.Variable(node.Operand.
Type
.GetNonNullableType(), name: null);
System\Linq\Expressions\Compiler\StackSpiller.Bindings.cs (5)
100
Expression memberTemp = _spiller.MakeTemp(member.
Type
);
113
if (memberTemp.
Type
.IsValueType)
185
Expression memberTemp = _spiller.MakeTemp(member.
Type
);
199
if (memberTemp.
Type
.IsValueType)
238
Expression memberTemp = _spiller.MakeTemp(member.
Type
);
System\Linq\Expressions\Compiler\StackSpiller.cs (9)
151
TypeUtils.AreReferenceAssignable(node.
Type
, result.Node.
Type
),
235
node.
Type
,
274
node.
Type
,
674
ParameterExpression tempNew = MakeTemp(rewrittenNew.
Type
);
744
ParameterExpression tempNew = MakeTemp(rewrittenNew.
Type
);
1092
throw Error.TryNotSupportedForValueTypeInstances(instance.
Type
);
1101
return instance != null && instance.
Type
.IsValueType && instance.
Type
.GetTypeCode() == TypeCode.Object;
System\Linq\Expressions\Compiler\StackSpiller.Temps.cs (2)
68
Type tempType = byRef ? expression.
Type
.MakeByRefType() : expression.
Type
;
System\Linq\Expressions\Compiler\TypeInfoExtensions.cs (1)
28
paramTypes[i + 1] = args[i].
Type
;
System\Linq\Expressions\ConditionalExpression.cs (13)
24
if (ifTrue.
Type
!= type || ifFalse.
Type
!= type)
28
if (ifFalse is DefaultExpression && ifFalse.
Type
== typeof(void))
49
public override Type Type => IfTrue.
Type
;
140
if (test.
Type
!= typeof(bool))
144
if (!TypeUtils.AreEquivalent(ifTrue.
Type
, ifFalse.
Type
))
149
return ConditionalExpression.Make(test, ifTrue, ifFalse, ifTrue.
Type
);
158
/// <param name="type">A <see cref="
Type
"/> to set the <see cref="
Type
"/> property equal to.</param>
172
if (test.
Type
!= typeof(bool))
179
if (!TypeUtils.AreReferenceAssignable(type, ifTrue.
Type
) ||
180
!TypeUtils.AreReferenceAssignable(type, ifFalse.
Type
))
System\Linq\Expressions\ConstantExpression.cs (3)
89
/// <param name="type">A <see cref="
Type
"/> to set the <see cref="
Type
"/> property equal to.</param>
93
/// <see cref="
Type
"/> properties set to the specified values.
System\Linq\Expressions\DebugViewWriter.cs (1)
972
if (node.Type != node.GetExpression(node.ExpressionCount - 1).
Type
)
System\Linq\Expressions\DefaultExpression.cs (5)
49
/// <see cref="ExpressionType.Default"/> and the <see cref="
Type
"/> property set to <see cref="Void"/>.
57
/// Creates a <see cref="DefaultExpression"/> that has the <see cref="
Type
"/> property set to the specified type.
59
/// <param name="type">A <see cref="
Type
"/> to set the <see cref="
Type
"/> property equal to.</param>
62
/// <see cref="ExpressionType.Default"/> and the <see cref="
Type
"/> property set to the specified type.
System\Linq\Expressions\DynamicExpression.cs (11)
1067
arg0.
Type
,
1104
arg1.
Type
,
1106
arg0.
Type
,
1146
arg2.
Type
,
1148
arg1.
Type
,
1150
arg0.
Type
,
1193
arg3.
Type
,
1195
arg2.
Type
,
1197
arg1.
Type
,
1199
arg0.
Type
,
1276
var type = arg.
Type
;
System\Linq\Expressions\Expression.cs (4)
59
/// <param name="type">The <see cref="
Type
"/> of the <see cref="Expression"/>.</param>
102
/// The <see cref="
Type
"/> of the value represented by this <see cref="Expression"/>.
192
if (!TypeUtils.AreReferenceAssignable(
Type
, newNode.
Type
)) throw Error.ReducedNotCompatible();
System\Linq\Expressions\Expression.DebuggerProxy.cs (2)
31
public Type Type => _node.
Type
;
290
public Type Type => _node.
Type
;
System\Linq\Expressions\ExpressionStringBuilder.cs (2)
813
return node.
Type
== typeof(bool) || node.
Type
== typeof(bool?);
System\Linq\Expressions\ExpressionVisitor.cs (6)
651
ValidateChildType(before.Operand.
Type
, after.Operand.
Type
, nameof(VisitUnary));
666
ValidateChildType(before.Left.
Type
, after.Left.
Type
, nameof(VisitBinary));
667
ValidateChildType(before.Right.
Type
, after.Right.
Type
, nameof(VisitBinary));
System\Linq\Expressions\GotoExpression.cs (18)
134
/// <param name="type">A <see cref="System.Type"/> to set the <see cref="
Type
"/> property equal to.</param>
138
/// and the <see cref="
Type
"/> property set to <paramref name="type"/>.
151
/// <param name="type">A <see cref="System.Type"/> to set the <see cref="
Type
"/> property equal to.</param>
155
/// the <see cref="
Type
"/> property set to <paramref name="type"/>,
181
/// <param name="type">A <see cref="System.Type"/> to set the <see cref="
Type
"/> property equal to.</param>
185
/// the <see cref="
Type
"/> property set to <paramref name="type"/>,
211
/// <param name="type">A <see cref="System.Type"/> to set the <see cref="
Type
"/> property equal to.</param>
215
/// the <see cref="
Type
"/> property set to <paramref name="type"/>,
244
/// <param name="type">A <see cref="System.Type"/> to set the <see cref="
Type
"/> property equal to.</param>
248
/// the <see cref="
Type
"/> property set to <paramref name="type"/>,
274
/// <param name="type">A <see cref="System.Type"/> to set the <see cref="
Type
"/> property equal to.</param>
278
/// the <see cref="
Type
"/> property set to <paramref name="type"/>,
307
/// <param name="type">A <see cref="System.Type"/> to set the <see cref="
Type
"/> property equal to.</param>
311
/// the <see cref="
Type
"/> property set to <paramref name="type"/>,
326
/// <param name="type">A <see cref="System.Type"/> to set the <see cref="
Type
"/> property equal to.</param>
330
/// the <see cref="
Type
"/> property set to <paramref name="type"/>,
363
if (!TypeUtils.AreReferenceAssignable(expectedType, value.
Type
))
368
throw Error.ExpressionTypeDoesNotMatchLabel(value.
Type
, expectedType);
System\Linq\Expressions\IndexExpression.cs (11)
30
Debug.Assert(instance != null && instance.
Type
.IsArray);
31
Debug.Assert(instance.
Type
.GetArrayRank() == arguments.Count);
57
return Object!.
Type
.GetElementType()!;
177
Type arrayType = array.
Type
;
192
if (e.
Type
!= typeof(int))
217
PropertyInfo pi = FindInstanceProperty(instance.
Type
, propertyName, arguments);
264
argTypesStr.Append(arguments[i]?.
Type
.Name);
331
if (!TypeUtils.AreReferenceAssignable(parms[i].ParameterType, args[i].
Type
))
483
ValidateCallInstanceType(instance.
Type
, method);
508
if (!TypeUtils.AreReferenceAssignable(pType, arg.
Type
))
512
throw Error.ExpressionTypeDoesNotMatchMethodParameter(arg.
Type
, pType, method, nameof(arguments), i);
System\Linq\Expressions\Interpreter\LightCompiler.cs (98)
324
if (node.Body.
Type
!= typeof(void) && node.ReturnType == typeof(void))
352
CompileDefaultExpression(expr.
Type
);
597
_instructions.EmitCall(TypeUtils.GetArrayGetMethod(index.Object!.
Type
));
626
local = _locals.DefineLocal(Expression.Parameter(node.Right.
Type
), _instructions.Count);
636
_instructions.EmitCall(TypeUtils.GetArraySetMethod(index.Object!.
Type
));
677
LocalDefinition local = _locals.DefineLocal(Expression.Parameter(value.
Type
), start);
708
LocalDefinition local = _locals.DefineLocal(Expression.Parameter(value.
Type
), start);
769
LocalDefinition leftTemp = _locals.DefineLocal(Expression.Parameter(node.Left.
Type
), _instructions.Count);
773
LocalDefinition rightTemp = _locals.DefineLocal(Expression.Parameter(node.Right.
Type
), _instructions.Count);
840
if (node.Left.
Type
.IsNullableOrReferenceType())
848
if (node.Right.
Type
.IsNullableOrReferenceType())
898
Debug.Assert(node.Right.
Type
== typeof(int));
918
_instructions.EmitExclusiveOr(node.Left.
Type
);
923
_instructions.EmitOr(node.Left.
Type
);
928
_instructions.EmitAnd(node.Left.
Type
);
949
_instructions.EmitLeftShift(node.Left.
Type
);
954
_instructions.EmitRightShift(node.Left.
Type
);
966
? !IsNullConstant(right) && right.
Type
.IsNullableType()
967
: IsNullConstant(right) && left.
Type
.IsNullableType();
979
Debug.Assert(IsNullComparison(left, right) || left.
Type
== right.
Type
|| !left.
Type
.IsValueType && !right.
Type
.IsValueType);
983
_instructions.EmitEqual(left.
Type
, liftedToNull);
989
Debug.Assert(IsNullComparison(left, right) || left.
Type
== right.
Type
|| !left.
Type
.IsValueType && !right.
Type
.IsValueType);
993
_instructions.EmitNotEqual(left.
Type
, liftedToNull);
1000
Debug.Assert(left.
Type
== right.
Type
&& left.
Type
.IsNumeric());
1007
case ExpressionType.LessThan: _instructions.EmitLessThan(left.
Type
, node.IsLiftedToNull); break;
1008
case ExpressionType.LessThanOrEqual: _instructions.EmitLessThanOrEqual(left.
Type
, node.IsLiftedToNull); break;
1009
case ExpressionType.GreaterThan: _instructions.EmitGreaterThan(left.
Type
, node.IsLiftedToNull); break;
1010
case ExpressionType.GreaterThanOrEqual: _instructions.EmitGreaterThanOrEqual(left.
Type
, node.IsLiftedToNull); break;
1017
Debug.Assert(left.
Type
== right.
Type
&& left.
Type
.IsArithmetic());
1022
case ExpressionType.Add: _instructions.EmitAdd(left.
Type
, @checked: false); break;
1023
case ExpressionType.AddChecked: _instructions.EmitAdd(left.
Type
, @checked: true); break;
1024
case ExpressionType.Subtract: _instructions.EmitSub(left.
Type
, @checked: false); break;
1025
case ExpressionType.SubtractChecked: _instructions.EmitSub(left.
Type
, @checked: true); break;
1026
case ExpressionType.Multiply: _instructions.EmitMul(left.
Type
, @checked: false); break;
1027
case ExpressionType.MultiplyChecked: _instructions.EmitMul(left.
Type
, @checked: true); break;
1028
case ExpressionType.Divide: _instructions.EmitDiv(left.
Type
); break;
1029
case ExpressionType.Modulo: _instructions.EmitModulo(left.
Type
); break;
1046
Type operandType = operand.
Type
;
1109
CompileConvertToType(node.Operand.
Type
, node.Type, node.NodeType == ExpressionType.ConvertChecked, node.IsLiftedToNull);
1222
_instructions.EmitNot(node.Operand.
Type
);
1339
else if (b.Left.
Type
== typeof(bool?))
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);
1553
TypeCode switchType = node.SwitchValue.
Type
.GetTypeCode();
1599
LocalDefinition temp = _locals.DefineLocal(Expression.Parameter(node.SwitchValue.
Type
), _instructions.Count);
1776
node.Value != null && node.Value.
Type
!= typeof(void),
1878
if (node.
Type
!= typeof(void))
2179
@object.
Type
.IsNullableType())
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);
2226
if (node.
Type
.IsValueType)
2235
return ((IndexExpression)node).Object!.
Type
.IsArray;
2270
objTmp = _locals.DefineLocal(Expression.Parameter(indexNode.Object.
Type
), _instructions.Count);
2283
LocalDefinition argTmp = _locals.DefineLocal(Expression.Parameter(arg.
Type
), _instructions.Count);
2308
memberTemp = _locals.DefineLocal(Expression.Parameter(member.Expression.
Type
, "member"), _instructions.Count);
2340
call.Object!.
Type
.IsArray &&
2341
call.Method == TypeUtils.GetArrayGetMethod(call.Object.
Type
))
2360
LocalDefinition objTmp = _locals.DefineLocal(Expression.Parameter(array.
Type
), _instructions.Count);
2371
LocalDefinition argTmp = _locals.DefineLocal(Expression.Parameter(arg.
Type
), _instructions.Count);
2378
_instructions.EmitCall(TypeUtils.GetArrayGetMethod(array.
Type
));
2380
return new IndexMethodByRefUpdater(objTmp, indexLocals, TypeUtils.GetArraySetMethod(array.
Type
), index);
2498
(from != null && from.
Type
.IsNullableType()))
2597
if (!hasConversion && node.Left.
Type
.IsNullableType())
2604
Type typeToCompare = node.Left.
Type
;
2605
if (!node.
Type
.IsNullableType())
2610
if (!TypeUtils.AreEquivalent(node.
Type
, typeToCompare))
2631
else if (node.Right.
Type
.IsValueType && !TypeUtils.AreEquivalent(node.
Type
, node.Right.
Type
))
2635
CompileConvertToType(node.Right.
Type
, node.
Type
, isChecked: true, isLiftedToNull: node.
Type
.IsNullableType());
2642
ParameterExpression temp = Expression.Parameter(node.Left.
Type
, "temp");
2654
Type nnLeftType = node.Left.
Type
.GetNonNullableType();
2655
CompileConvertToType(nnLeftType, node.
Type
, isChecked: true, isLiftedToNull: false);
2668
if (typeof(LambdaExpression).IsAssignableFrom(node.Expression.
Type
))
2670
MethodInfo compMethod = LambdaExpression.GetCompileMethod(node.Expression.
Type
);
2683
node.Expression, node.Expression.
Type
.GetInvokeMethod(), node
2904
if (node.Expression.
Type
== typeof(void))
2937
if (node.Expression.
Type
!= typeof(void))
3003
if (expr.
Type
!= typeof(void))
3068
case ExpressionType.Throw: CompileThrowUnaryExpression(expr, expr.
Type
== typeof(void)); break;
3071
case ExpressionType.Conditional: CompileConditionalExpression(expr, expr.
Type
== typeof(void)); break;
3084
case ExpressionType.Assign: CompileAssignBinaryExpression(expr, expr.
Type
== typeof(void)); break;
3085
case ExpressionType.Block: CompileBlockExpression(expr, expr.
Type
== typeof(void)); break;
3099
Debug.Assert(_instructions.CurrentStackDepth == startingStackDepth + (expr.
Type
== typeof(void) ? 0 : 1),
3100
$"{_instructions.CurrentStackDepth} vs {startingStackDepth + (expr.
Type
== typeof(void) ? 0 : 1)} for {expr.NodeType}");
System\Linq\Expressions\InvocationExpression.cs (11)
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>
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>
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>
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>
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>
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>
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>
745
Type delegateType = expression.
Type
;
746
if (!expression.
Type
.IsSubclassOf(typeof(MulticastDelegate)))
748
Type? exprType = TypeUtils.FindGenericType(typeof(Expression<>), expression.
Type
);
751
throw Error.ExpressionTypeNotInvocable(expression.
Type
, nameof(expression));
System\Linq\Expressions\LambdaExpression.cs (9)
785
/// <param name="delegateType">A <see cref="
Type
"/> representing the delegate signature for the lambda.</param>
798
/// <param name="delegateType">A <see cref="
Type
"/> representing the delegate signature for the lambda.</param>
810
/// <param name="delegateType">A <see cref="
Type
"/> representing the delegate signature for the lambda.</param>
823
/// <param name="delegateType">A <see cref="
Type
"/> representing the delegate signature for the lambda.</param>
874
typeArgs[paramCount] = body.
Type
;
887
/// <param name="delegateType">A <see cref="
Type
"/> representing the delegate signature for the lambda.</param>
900
/// <param name="delegateType">A <see cref="
Type
"/> representing the delegate signature for the lambda.</param>
974
if (mi.ReturnType != typeof(void) && !TypeUtils.AreReferenceAssignable(mi.ReturnType, body.
Type
))
978
throw Error.ExpressionTypeDoesNotMatchReturn(body.
Type
, mi.ReturnType);
System\Linq\Expressions\ListInitExpression.cs (4)
188
/// The <see cref="
Type
"/> property of <paramref name="newExpression"/> must represent a type that implements <see cref="Collections.IEnumerable"/>.
189
/// The <see cref="
Type
"/> property of the resulting <see cref="ListInitExpression"/> is equal to <paramref name="newExpression"/>.Type.
203
/// The <see cref="
Type
"/> property of <paramref name="newExpression"/> must represent a type that implements <see cref="Collections.IEnumerable"/>.
204
/// The <see cref="
Type
"/> property of the resulting <see cref="ListInitExpression"/> is equal to <paramref name="newExpression"/>.Type.
System\Linq\Expressions\MemberAssignment.cs (1)
65
if (!memberType.IsAssignableFrom(expression.
Type
))
System\Linq\Expressions\MemberExpression.cs (17)
139
if (!TypeUtils.AreReferenceAssignable(field.DeclaringType!, expression.
Type
))
141
throw Error.FieldInfoNotDefinedForType(field.DeclaringType, field.Name, expression.
Type
);
160
FieldInfo? fi = expression.
Type
.GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase | BindingFlags.FlattenHierarchy)
161
?? expression.
Type
.GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.IgnoreCase | BindingFlags.FlattenHierarchy);
164
throw Error.InstanceFieldNotDefinedForType(fieldName, expression.
Type
);
173
/// <param name="type">The <see cref="
Type
"/> containing the field.</param>
211
PropertyInfo? pi = expression.
Type
.GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase | BindingFlags.FlattenHierarchy)
212
?? expression.
Type
.GetProperty(propertyName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.IgnoreCase | BindingFlags.FlattenHierarchy);
215
throw Error.InstancePropertyNotDefinedForType(propertyName, expression.
Type
, nameof(propertyName));
224
/// <param name="type">The <see cref="
Type
"/> containing the property.</param>
282
if (!TypeUtils.IsValidInstanceType(property, expression.
Type
))
284
throw Error.PropertyNotDefinedForType(property, expression.
Type
, nameof(property));
364
PropertyInfo? pi = expression.
Type
.GetProperty(propertyOrFieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase | BindingFlags.FlattenHierarchy);
367
FieldInfo? fi = expression.
Type
.GetField(propertyOrFieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase | BindingFlags.FlattenHierarchy);
370
pi = expression.
Type
.GetProperty(propertyOrFieldName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.IgnoreCase | BindingFlags.FlattenHierarchy);
373
fi = expression.
Type
.GetField(propertyOrFieldName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.IgnoreCase | BindingFlags.FlattenHierarchy);
377
throw Error.NotAMemberOfType(propertyOrFieldName, expression.
Type
, nameof(propertyOrFieldName));
System\Linq\Expressions\MemberInitExpression.cs (2)
72
ParameterExpression objVar = Variable(objExpression.
Type
);
88
ParameterExpression listVar = Variable(listExpression.
Type
);
System\Linq\Expressions\MethodCallExpression.cs (11)
1130
/// <param name="instance">An <see cref="Expression"/> whose <see cref="
Type
"/> property value will be searched for a specific method.</param>
1133
///An array of <see cref="
Type
"/> objects that specify the type parameters of the generic method.
1149
return Expression.Call(instance, FindMethod(instance.
Type
, methodName, typeArguments, arguments, flags)!, arguments);
1154
/// <param name="type">The <see cref="
Type
"/> that specifies the type that contains the specified static (Shared in Visual Basic) method.</param>
1157
///An array of <see cref="
Type
"/> objects that specify the type parameters of the generic method.
1257
ValidateCallInstanceType(instance.
Type
, method);
1356
Type argType = arg.
Type
;
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>
1414
Type arrayType = array.
Type
;
1431
if (e.
Type
!= typeof(int))
1437
MethodInfo mi = TypeUtils.GetArrayGetMethod(array.
Type
);
System\Linq\Expressions\NewArrayExpression.cs (3)
153
if (!TypeUtils.AreReferenceAssignable(type, expr.
Type
))
157
throw Error.ExpressionTypeCannotInitializeArrayType(expr.
Type
, type);
232
if (!expr.
Type
.IsInteger())
System\Linq\Expressions\NewExpression.cs (5)
195
/// <param name="type">A <see cref="
Type
"/> that has a constructor that takes no arguments.</param>
247
if (!TypeUtils.AreReferenceAssignable(memberType, arg.
Type
))
251
throw Error.ArgumentTypeDoesNotMatchMember(arg.
Type
, memberType, nameof(arguments), i);
260
if (!TypeUtils.AreReferenceAssignable(pType, arg.
Type
))
264
throw Error.ExpressionTypeDoesNotMatchConstructorParameter(arg.
Type
, pType, nameof(arguments), i);
System\Linq\Expressions\SwitchExpression.cs (13)
72
if (SwitchValue.
Type
.IsNullableType())
75
!TypeUtils.AreEquivalent(SwitchValue.
Type
, Comparison.GetParametersCached()[0].ParameterType.GetNonRefType());
180
if (switchValue.
Type
== typeof(void)) throw Error.ArgumentCannotBeOfTypeVoid(nameof(switchValue));
190
resultType = caseList[0].Body.
Type
;
192
resultType = defaultBody.
Type
;
209
if (!ParameterIsAssignable(leftParam, switchValue.
Type
))
211
liftedCall = ParameterIsAssignable(leftParam, switchValue.
Type
.GetNonNullableType());
214
throw Error.SwitchValueTypeDoesNotMatchComparisonMethodParameter(switchValue.
Type
, leftParam.ParameterType);
227
Type rightOperandType = c.TestValues[i].
Type
;
261
if (!TypeUtils.AreEquivalent(firstTestValue.
Type
, c.TestValues[i].
Type
))
300
if (!TypeUtils.AreReferenceAssignable(resultType, @case.
Type
))
308
if (!TypeUtils.AreEquivalent(resultType, @case.
Type
))
System\Linq\Expressions\TryExpression.cs (7)
178
return new TryExpression(type ?? body.
Type
, body, @finally, fault, @catch);
190
if (!TypeUtils.AreReferenceAssignable(type, tryBody.
Type
))
196
if (!TypeUtils.AreReferenceAssignable(type, cb.Body.
Type
))
203
else if (tryBody.
Type
== typeof(void))
209
if (cb.Body.
Type
!= typeof(void))
218
type = tryBody.
Type
;
222
if (!TypeUtils.AreEquivalent(cb.Body.
Type
, type))
System\Linq\Expressions\TypeBinaryExpression.cs (5)
51
Type cType = Expression.
Type
;
66
return Expression.NotEqual(Expression, Expression.Constant(null, Expression.
Type
));
77
Debug.Assert(TypeUtils.AreReferenceAssignable(typeof(object), Expression.
Type
), "Expecting reference types only after this point.");
189
/// <param name="type">A <see cref="
Type
"/> to set the <see cref="TypeBinaryExpression.TypeOperand"/> property equal to.</param>
204
/// <param name="type">A <see cref="
Type
"/> to set the <see cref="TypeBinaryExpression.TypeOperand"/> property equal to.</param>
System\Linq\Expressions\UnaryExpression.cs (67)
62
bool operandIsNullable = Operand.
Type
.IsNullableType();
66
return (operandIsNullable && !TypeUtils.AreEquivalent(Method.GetParametersCached()[0].ParameterType, Operand.
Type
)) ||
148
return new UnaryExpression(functional, operand, operand.
Type
, Method);
165
ParameterExpression temp = Parameter(Operand.
Type
, name: null);
186
ParameterExpression temp1 = Parameter(member.Expression.
Type
, name: null);
211
ParameterExpression temp2 = Parameter(member.
Type
, name: null);
246
temps[i] = Parameter(index.Object!.
Type
, name: null);
252
args[i - 1] = temps[i] = Parameter(arg.
Type
, name: null);
299
/// <param name="type">The <see cref="
Type
"/> that specifies the type to be converted to (pass null if not applicable).</param>
313
/// <param name="type">The <see cref="
Type
"/> that specifies the type to be converted to (pass null if not applicable).</param>
349
ValidateParamsWithOperandsOrThrow(u.Method!.GetParametersCached()[0].ParameterType, operand.
Type
, unaryType, name);
352
throw Error.UnaryOperatorNotDefined(unaryType, operand.
Type
);
359
Type operandType = operand.
Type
;
387
if (ParameterIsAssignable(pms[0], operand.
Type
))
389
ValidateParamsWithOperandsOrThrow(pms[0].ParameterType, operand.
Type
, unaryType, method.Name);
393
if (operand.
Type
.IsNullableType() &&
394
ParameterIsAssignable(pms[0], operand.
Type
.GetNonNullableType()) &&
410
throw Error.CoercionOperatorNotDefined(expression.
Type
, convertToType);
415
MethodInfo? method = TypeUtils.GetUserDefinedCoercionMethod(expression.
Type
, convertToType);
435
if (ParameterIsAssignable(pms[0], operand.
Type
) && TypeUtils.AreEquivalent(method.ReturnType, convertToType))
440
if ((operand.
Type
.IsNullableType() || convertToType.IsNullableType()) &&
441
ParameterIsAssignable(pms[0], operand.
Type
.GetNonNullableType()) &&
476
if (expression.
Type
.IsArithmetic() && !expression.
Type
.IsUnsignedInt())
478
return new UnaryExpression(ExpressionType.Negate, expression, expression.
Type
, null);
511
if (expression.
Type
.IsArithmetic())
513
return new UnaryExpression(ExpressionType.UnaryPlus, expression, expression.
Type
, null);
545
if (expression.
Type
.IsArithmetic() && !expression.
Type
.IsUnsignedInt())
547
return new UnaryExpression(ExpressionType.NegateChecked, expression, expression.
Type
, null);
580
if (expression.
Type
.IsIntegerOrBool())
582
return new UnaryExpression(ExpressionType.Not, expression, expression.
Type
, null);
615
if (expression.
Type
.IsBool())
617
return new UnaryExpression(ExpressionType.IsFalse, expression, expression.
Type
, null);
645
if (expression.
Type
.IsBool())
647
return new UnaryExpression(ExpressionType.IsTrue, expression, expression.
Type
, null);
675
if (expression.
Type
.IsInteger())
677
return new UnaryExpression(ExpressionType.OnesComplement, expression, expression.
Type
, null);
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>
687
/// <param name="type">A <see cref="System.Type"/> to set the <see cref="
Type
"/> property equal to.</param>
713
if (!expression.
Type
.IsInterface && expression.
Type
!= typeof(object))
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>
725
/// <param name="type">A <see cref="System.Type"/> to set the <see cref="
Type
"/> property equal to.</param>
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>
737
/// <param name="type">A <see cref="System.Type"/> to set the <see cref="
Type
"/> property equal to.</param>
752
if (expression.
Type
.HasIdentityPrimitiveOrNullableConversionTo(type) ||
753
expression.
Type
.HasReferenceConversionTo(type))
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>
765
/// <param name="type">A <see cref="System.Type"/> to set the <see cref="
Type
"/> property equal to.</param>
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>
777
/// <param name="type">A <see cref="System.Type"/> to set the <see cref="
Type
"/> property equal to.</param>
792
if (expression.
Type
.HasIdentityPrimitiveOrNullableConversionTo(type))
796
if (expression.
Type
.HasReferenceConversionTo(type))
815
if (!array.
Type
.IsSZArray)
817
if (!array.
Type
.IsArray || !typeof(Array).IsAssignableFrom(array.
Type
))
857
/// <param name="type">The new <see cref="
Type
"/> of the expression.</param>
878
/// <param name="type">The new <see cref="
Type
"/> of the expression.</param>
887
if (value.
Type
.IsValueType) throw Error.ArgumentMustNotHaveValueType(nameof(value));
913
if (expression.
Type
.IsArithmetic())
915
return new UnaryExpression(ExpressionType.Increment, expression, expression.
Type
, null);
943
if (expression.
Type
.IsArithmetic())
945
return new UnaryExpression(ExpressionType.Decrement, expression, expression.
Type
, null);
1052
if (expression.
Type
.IsArithmetic())
1054
return new UnaryExpression(kind, expression, expression.
Type
, null);
1073
if (!TypeUtils.AreReferenceAssignable(expression.
Type
, result.Type))
System\Runtime\CompilerServices\CallSite.cs (1)
686
if (TypeUtils.AreReferenceAssignable(type, arg.
Type
))
System.Linq.Queryable (16)
System\Linq\EnumerableExecutor.cs (1)
21
Type execType = typeof(EnumerableExecutor<>).MakeGenericType(expression.
Type
);
System\Linq\EnumerableQuery.cs (3)
67
Type? iqType = TypeHelper.FindGenericType(typeof(IQueryable<>), expression.
Type
);
77
if (!typeof(IQueryable<TElement>).IsAssignableFrom(expression.
Type
))
95
if (!typeof(TElement).IsAssignableFrom(expression.
Type
))
System\Linq\EnumerableRewriter.cs (12)
39
if ((mInfo.IsStatic || mInfo.DeclaringType!.IsAssignableFrom(obj!.
Type
))
96
if (type.IsAssignableFrom(expr.
Type
))
102
if (!type.IsAssignableFrom(expr.
Type
) && type.IsArray && expr.NodeType == ExpressionType.NewArrayInit)
104
Type strippedType = StripExpression(expr.
Type
);
346
if (!parameterType.IsAssignableFrom(arg.
Type
))
352
if (!parameterType.IsAssignableFrom(arg.
Type
) &&
353
!parameterType.IsAssignableFrom(StripExpression(arg.
Type
)))
386
Type trueType = ifTrue.
Type
;
387
Type falseType = ifFalse.
Type
;
402
if (type == node.Expressions.Last().
Type
)
409
Type type = node.Value!.
Type
;
414
return Expression.MakeGoto(node.Kind, target, value, GetEquivalentType(typeof(EnumerableQuery).IsAssignableFrom(type) ? value.
Type
: type));