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