Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Expression.cs
Go to the documentation of this file.
7using System.IO;
12using System.Text;
14
16
17public abstract class Expression
18{
19 private sealed class ExtensionInfo
20 {
21 internal readonly ExpressionType NodeType;
22
23 internal readonly Type Type;
24
26 {
27 NodeType = nodeType;
28 Type = type;
29 }
30 }
31
32 internal sealed class BinaryExpressionProxy
33 {
34 private readonly BinaryExpression _node;
35
36 public bool CanReduce => _node.CanReduce;
37
39
40 public string DebugView => _node.DebugView;
41
42 public bool IsLifted => _node.IsLifted;
43
45
47
49
51
53
54 public Type Type => _node.Type;
55
61 }
62
87
88 internal sealed class CatchBlockProxy
89 {
90 private readonly CatchBlock _node;
91
93
95
96 public Type Test => _node.Test;
97
99
101 {
103 _node = node;
104 }
105 }
106
107 internal sealed class ConditionalExpressionProxy
108 {
109 private readonly ConditionalExpression _node;
110
111 public bool CanReduce => _node.CanReduce;
112
113 public string DebugView => _node.DebugView;
114
116
118
120
122
123 public Type Type => _node.Type;
124
130 }
131
132 internal sealed class ConstantExpressionProxy
133 {
134 private readonly ConstantExpression _node;
135
136 public bool CanReduce => _node.CanReduce;
137
138 public string DebugView => _node.DebugView;
139
141
142 public Type Type => _node.Type;
143
144 public object Value => _node.Value;
145
151 }
152
153 internal sealed class DebugInfoExpressionProxy
154 {
155 private readonly DebugInfoExpression _node;
156
157 public bool CanReduce => _node.CanReduce;
158
159 public string DebugView => _node.DebugView;
160
162
163 public int EndColumn => _node.EndColumn;
164
165 public int EndLine => _node.EndLine;
166
167 public bool IsClear => _node.IsClear;
168
170
172
173 public int StartLine => _node.StartLine;
174
175 public Type Type => _node.Type;
176
182 }
183
184 internal sealed class DefaultExpressionProxy
185 {
186 private readonly DefaultExpression _node;
187
188 public bool CanReduce => _node.CanReduce;
189
190 public string DebugView => _node.DebugView;
191
193
194 public Type Type => _node.Type;
195
201 }
202
203 internal sealed class GotoExpressionProxy
204 {
205 private readonly GotoExpression _node;
206
207 public bool CanReduce => _node.CanReduce;
208
209 public string DebugView => _node.DebugView;
210
212
214
216
217 public Type Type => _node.Type;
218
220
226 }
227
228 internal sealed class IndexExpressionProxy
229 {
230 private readonly IndexExpression _node;
231
233
234 public bool CanReduce => _node.CanReduce;
235
236 public string DebugView => _node.DebugView;
237
239
241
243
244 public Type Type => _node.Type;
245
251 }
252
275
276 internal sealed class LabelExpressionProxy
277 {
278 private readonly LabelExpression _node;
279
280 public bool CanReduce => _node.CanReduce;
281
282 public string DebugView => _node.DebugView;
283
285
287
289
290 public Type Type => _node.Type;
291
297 }
298
299 internal sealed class LambdaExpressionProxy
300 {
301 private readonly LambdaExpression _node;
302
304
305 public bool CanReduce => _node.CanReduce;
306
307 public string DebugView => _node.DebugView;
308
309 public string Name => _node.Name;
310
312
314
316
317 public bool TailCall => _node.TailCall;
318
319 public Type Type => _node.Type;
320
326 }
327
328 internal sealed class ListInitExpressionProxy
329 {
330 private readonly ListInitExpression _node;
331
332 public bool CanReduce => _node.CanReduce;
333
334 public string DebugView => _node.DebugView;
335
337
339
341
342 public Type Type => _node.Type;
343
349 }
350
351 internal sealed class LoopExpressionProxy
352 {
353 private readonly LoopExpression _node;
354
356
358
359 public bool CanReduce => _node.CanReduce;
360
362
363 public string DebugView => _node.DebugView;
364
366
367 public Type Type => _node.Type;
368
374 }
375
376 internal sealed class MemberExpressionProxy
377 {
378 private readonly MemberExpression _node;
379
380 public bool CanReduce => _node.CanReduce;
381
382 public string DebugView => _node.DebugView;
383
385
387
389
390 public Type Type => _node.Type;
391
397 }
398
421
446
447 internal sealed class NewArrayExpressionProxy
448 {
449 private readonly NewArrayExpression _node;
450
451 public bool CanReduce => _node.CanReduce;
452
453 public string DebugView => _node.DebugView;
454
456
458
459 public Type Type => _node.Type;
460
466 }
467
492
493 internal sealed class ParameterExpressionProxy
494 {
495 private readonly ParameterExpression _node;
496
497 public bool CanReduce => _node.CanReduce;
498
499 public string DebugView => _node.DebugView;
500
501 public bool IsByRef => _node.IsByRef;
502
503 public string Name => _node.Name;
504
506
507 public Type Type => _node.Type;
508
514 }
515
536
537 internal sealed class SwitchCaseProxy
538 {
539 private readonly SwitchCase _node;
540
542
544
546 {
548 _node = node;
549 }
550 }
551
578
579 internal sealed class TryExpressionProxy
580 {
581 private readonly TryExpression _node;
582
584
585 public bool CanReduce => _node.CanReduce;
586
587 public string DebugView => _node.DebugView;
588
590
592
594
596
597 public Type Type => _node.Type;
598
604 }
605
606 internal sealed class TypeBinaryExpressionProxy
607 {
608 private readonly TypeBinaryExpression _node;
609
610 public bool CanReduce => _node.CanReduce;
611
612 public string DebugView => _node.DebugView;
613
615
617
618 public Type Type => _node.Type;
619
621
627 }
628
629 internal sealed class UnaryExpressionProxy
630 {
631 private readonly UnaryExpression _node;
632
633 public bool CanReduce => _node.CanReduce;
634
635 public string DebugView => _node.DebugView;
636
637 public bool IsLifted => _node.IsLifted;
638
640
642
644
646
647 public Type Type => _node.Type;
648
654 }
655
657 {
658 Valid,
660 ByRef,
662 }
663
665
667
669
671 {
672 get
673 {
674 if (s_legacyCtorSupportTable != null && s_legacyCtorSupportTable.TryGetValue(this, out var value))
675 {
676 return value.NodeType;
677 }
678 throw Error.ExtensionNodeMustOverrideProperty("Expression.NodeType");
679 }
680 }
681
682 public virtual Type Type
683 {
684 get
685 {
686 if (s_legacyCtorSupportTable != null && s_legacyCtorSupportTable.TryGetValue(this, out var value))
687 {
688 return value.Type;
689 }
690 throw Error.ExtensionNodeMustOverrideProperty("Expression.Type");
691 }
692 }
693
694 public virtual bool CanReduce => false;
695
696 private string DebugView
697 {
698 get
699 {
702 return stringWriter.ToString();
703 }
704 }
705
706 public static BinaryExpression Assign(Expression left, Expression right)
707 {
708 RequiresCanWrite(left, "left");
709 ExpressionUtils.RequiresCanRead(right, "right");
710 TypeUtils.ValidateType(left.Type, "left", allowByRef: true, allowPointer: true);
711 TypeUtils.ValidateType(right.Type, "right", allowByRef: true, allowPointer: true);
712 if (!TypeUtils.AreReferenceAssignable(left.Type, right.Type))
713 {
714 throw Error.ExpressionTypeDoesNotMatchAssignment(right.Type, left.Type);
715 }
716 return new AssignBinaryExpression(left, right);
717 }
718
720 {
722 if (userDefinedBinaryOperator != null)
723 {
725 }
726 if (left.Type.IsNullableType() && right.Type.IsNullableType())
727 {
728 Type nonNullableType = left.Type.GetNonNullableType();
729 Type nonNullableType2 = right.Type.GetNonNullableType();
731 if (userDefinedBinaryOperator != null && userDefinedBinaryOperator.ReturnType.IsValueType && !userDefinedBinaryOperator.ReturnType.IsNullableType())
732 {
733 if (userDefinedBinaryOperator.ReturnType != typeof(bool) || liftToNull)
734 {
735 return new MethodBinaryExpression(binaryType, left, right, userDefinedBinaryOperator.ReturnType.GetNullableType(), userDefinedBinaryOperator);
736 }
737 return new MethodBinaryExpression(binaryType, left, right, typeof(bool), userDefinedBinaryOperator);
738 }
739 }
740 return null;
741 }
742
744 {
746 ParameterInfo[] parametersCached = method.GetParametersCached();
747 if (parametersCached.Length != 2)
748 {
750 }
752 {
753 ValidateParamswithOperandsOrThrow(parametersCached[0].ParameterType, left.Type, binaryType, method.Name);
754 ValidateParamswithOperandsOrThrow(parametersCached[1].ParameterType, right.Type, binaryType, method.Name);
755 return new MethodBinaryExpression(binaryType, left, right, method.ReturnType, method);
756 }
757 if (left.Type.IsNullableType() && right.Type.IsNullableType() && ParameterIsAssignable(parametersCached[0], left.Type.GetNonNullableType()) && ParameterIsAssignable(parametersCached[1], right.Type.GetNonNullableType()) && method.ReturnType.IsValueType && !method.ReturnType.IsNullableType())
758 {
759 if (method.ReturnType != typeof(bool) || liftToNull)
760 {
761 return new MethodBinaryExpression(binaryType, left, right, method.ReturnType.GetNullableType(), method);
762 }
763 return new MethodBinaryExpression(binaryType, left, right, typeof(bool), method);
764 }
766 }
767
785
787 {
789 if (userDefinedBinaryOperator != null)
790 {
791 ParameterInfo[] parametersCached = userDefinedBinaryOperator.Method.GetParametersCached();
792 ValidateParamswithOperandsOrThrow(parametersCached[0].ParameterType, left.Type, binaryType, name);
793 ValidateParamswithOperandsOrThrow(parametersCached[1].ParameterType, right.Type, binaryType, name);
795 }
796 throw Error.BinaryOperatorNotDefined(binaryType, left.Type, right.Type);
797 }
798
816
817 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2072:UnrecognizedReflectionPattern", Justification = "The trimmer doesn't remove operators when System.Linq.Expressions is used. See https://github.com/mono/linker/pull/2125.")]
819 {
820 Type[] types = new Type[2] { leftType, rightType };
821 Type nonNullableType = leftType.GetNonNullableType();
822 Type nonNullableType2 = rightType.GetNonNullableType();
823 MethodInfo methodInfo = nonNullableType.GetAnyStaticMethodValidated(name, types);
825 {
826 methodInfo = nonNullableType2.GetAnyStaticMethodValidated(name, types);
827 }
829 {
831 }
832 return methodInfo;
833 }
834
836 {
837 if (right.IsNullableType() && left.IsNullableType() && method == null)
838 {
839 if (binaryType != ExpressionType.AndAlso)
840 {
841 return binaryType == ExpressionType.OrElse;
842 }
843 return true;
844 }
845 return false;
846 }
847
849 {
850 Type type = pi.ParameterType;
851 if (type.IsByRef)
852 {
853 type = type.GetElementType();
854 }
856 }
857
859 {
860 if (paramType.IsNullableType() && !operandType.IsNullableType())
861 {
863 }
864 }
865
866 private static void ValidateOperator(MethodInfo method)
867 {
868 ValidateMethodInfo(method, "method");
869 if (!method.IsStatic)
870 {
872 }
873 if (method.ReturnType == typeof(void))
874 {
876 }
877 }
878
879 private static void ValidateMethodInfo(MethodInfo method, string paramName)
880 {
881 if (method.ContainsGenericParameters)
882 {
883 throw method.IsGenericMethodDefinition ? Error.MethodIsGeneric(method, paramName) : Error.MethodContainsGenericParameters(method, paramName);
884 }
885 }
886
887 private static bool IsNullComparison(Expression left, Expression right)
888 {
889 if (!IsNullConstant(left))
890 {
891 if (IsNullConstant(right))
892 {
893 return left.Type.IsNullableType();
894 }
895 return false;
896 }
897 if (!IsNullConstant(right))
898 {
899 return right.Type.IsNullableType();
900 }
901 return false;
902 }
903
904 private static bool IsNullConstant(Expression e)
905 {
907 {
908 return constantExpression.Value == null;
909 }
910 return false;
911 }
912
914 {
916 ParameterInfo[] parametersCached = method.GetParametersCached();
917 if (parametersCached.Length != 2)
918 {
920 }
921 if (!ParameterIsAssignable(parametersCached[0], left) && (!left.IsNullableType() || !ParameterIsAssignable(parametersCached[0], left.GetNonNullableType())))
922 {
923 throw Error.OperandTypesDoNotMatchParameters(nodeType, method.Name);
924 }
925 if (!ParameterIsAssignable(parametersCached[1], right) && (!right.IsNullableType() || !ParameterIsAssignable(parametersCached[1], right.GetNonNullableType())))
926 {
927 throw Error.OperandTypesDoNotMatchParameters(nodeType, method.Name);
928 }
929 if (parametersCached[0].ParameterType != parametersCached[1].ParameterType)
930 {
932 }
933 if (method.ReturnType != parametersCached[0].ParameterType)
934 {
936 }
938 {
939 left = left.GetNonNullableType();
940 }
941 Type declaringType = method.DeclaringType;
942 if (declaringType == null)
943 {
945 }
948 if (booleanOperator == null || booleanOperator.ReturnType != typeof(bool) || booleanOperator2 == null || booleanOperator2.ReturnType != typeof(bool))
949 {
951 }
952 VerifyOpTrueFalse(nodeType, left, booleanOperator2, "method");
953 VerifyOpTrueFalse(nodeType, left, booleanOperator, "method");
954 }
955
956 private static void VerifyOpTrueFalse(ExpressionType nodeType, Type left, MethodInfo opTrue, string paramName)
957 {
958 ParameterInfo[] parametersCached = opTrue.GetParametersCached();
959 if (parametersCached.Length != 1)
960 {
962 }
963 if (!ParameterIsAssignable(parametersCached[0], left) && (!left.IsNullableType() || !ParameterIsAssignable(parametersCached[0], left.GetNonNullableType())))
964 {
965 throw Error.OperandTypesDoNotMatchParameters(nodeType, opTrue.Name);
966 }
967 }
968
970 {
971 if (TypeUtils.AreEquivalent(left, right) && right.IsNullableType())
972 {
973 return TypeUtils.AreEquivalent(pms[1].ParameterType, right.GetNonNullableType());
974 }
975 return false;
976 }
977
979 {
980 return MakeBinary(binaryType, left, right, liftToNull: false, null, null);
981 }
982
984 {
985 return MakeBinary(binaryType, left, right, liftToNull, method, null);
986 }
987
989 {
990 return binaryType switch
991 {
992 ExpressionType.Add => Add(left, right, method),
993 ExpressionType.AddChecked => AddChecked(left, right, method),
994 ExpressionType.Subtract => Subtract(left, right, method),
995 ExpressionType.SubtractChecked => SubtractChecked(left, right, method),
996 ExpressionType.Multiply => Multiply(left, right, method),
997 ExpressionType.MultiplyChecked => MultiplyChecked(left, right, method),
998 ExpressionType.Divide => Divide(left, right, method),
999 ExpressionType.Modulo => Modulo(left, right, method),
1000 ExpressionType.Power => Power(left, right, method),
1001 ExpressionType.And => And(left, right, method),
1002 ExpressionType.AndAlso => AndAlso(left, right, method),
1003 ExpressionType.Or => Or(left, right, method),
1004 ExpressionType.OrElse => OrElse(left, right, method),
1005 ExpressionType.LessThan => LessThan(left, right, liftToNull, method),
1006 ExpressionType.LessThanOrEqual => LessThanOrEqual(left, right, liftToNull, method),
1007 ExpressionType.GreaterThan => GreaterThan(left, right, liftToNull, method),
1008 ExpressionType.GreaterThanOrEqual => GreaterThanOrEqual(left, right, liftToNull, method),
1009 ExpressionType.Equal => Equal(left, right, liftToNull, method),
1010 ExpressionType.NotEqual => NotEqual(left, right, liftToNull, method),
1011 ExpressionType.ExclusiveOr => ExclusiveOr(left, right, method),
1012 ExpressionType.Coalesce => Coalesce(left, right, conversion),
1013 ExpressionType.ArrayIndex => ArrayIndex(left, right),
1014 ExpressionType.RightShift => RightShift(left, right, method),
1015 ExpressionType.LeftShift => LeftShift(left, right, method),
1016 ExpressionType.Assign => Assign(left, right),
1017 ExpressionType.AddAssign => AddAssign(left, right, method, conversion),
1018 ExpressionType.AndAssign => AndAssign(left, right, method, conversion),
1019 ExpressionType.DivideAssign => DivideAssign(left, right, method, conversion),
1020 ExpressionType.ExclusiveOrAssign => ExclusiveOrAssign(left, right, method, conversion),
1021 ExpressionType.LeftShiftAssign => LeftShiftAssign(left, right, method, conversion),
1022 ExpressionType.ModuloAssign => ModuloAssign(left, right, method, conversion),
1023 ExpressionType.MultiplyAssign => MultiplyAssign(left, right, method, conversion),
1024 ExpressionType.OrAssign => OrAssign(left, right, method, conversion),
1025 ExpressionType.PowerAssign => PowerAssign(left, right, method, conversion),
1026 ExpressionType.RightShiftAssign => RightShiftAssign(left, right, method, conversion),
1027 ExpressionType.SubtractAssign => SubtractAssign(left, right, method, conversion),
1028 ExpressionType.AddAssignChecked => AddAssignChecked(left, right, method, conversion),
1029 ExpressionType.SubtractAssignChecked => SubtractAssignChecked(left, right, method, conversion),
1030 ExpressionType.MultiplyAssignChecked => MultiplyAssignChecked(left, right, method, conversion),
1031 _ => throw Error.UnhandledBinary(binaryType, "binaryType"),
1032 };
1033 }
1034
1035 public static BinaryExpression Equal(Expression left, Expression right)
1036 {
1037 return Equal(left, right, liftToNull: false, null);
1038 }
1039
1041 {
1042 ExpressionUtils.RequiresCanRead(left, "left");
1043 ExpressionUtils.RequiresCanRead(right, "right");
1044 if (method == null)
1045 {
1046 return GetEqualityComparisonOperator(ExpressionType.Equal, "op_Equality", left, right, liftToNull);
1047 }
1048 return GetMethodBasedBinaryOperator(ExpressionType.Equal, left, right, method, liftToNull);
1049 }
1050
1052 {
1053 ExpressionUtils.RequiresCanRead(left, "left");
1054 ExpressionUtils.RequiresCanRead(right, "right");
1055 if (TypeUtils.HasReferenceEquality(left.Type, right.Type))
1056 {
1057 return new LogicalBinaryExpression(ExpressionType.Equal, left, right);
1058 }
1059 throw Error.ReferenceEqualityNotDefined(left.Type, right.Type);
1060 }
1061
1063 {
1064 return NotEqual(left, right, liftToNull: false, null);
1065 }
1066
1068 {
1069 ExpressionUtils.RequiresCanRead(left, "left");
1070 ExpressionUtils.RequiresCanRead(right, "right");
1071 if (method == null)
1072 {
1073 return GetEqualityComparisonOperator(ExpressionType.NotEqual, "op_Inequality", left, right, liftToNull);
1074 }
1075 return GetMethodBasedBinaryOperator(ExpressionType.NotEqual, left, right, method, liftToNull);
1076 }
1077
1079 {
1080 ExpressionUtils.RequiresCanRead(left, "left");
1081 ExpressionUtils.RequiresCanRead(right, "right");
1082 if (TypeUtils.HasReferenceEquality(left.Type, right.Type))
1083 {
1084 return new LogicalBinaryExpression(ExpressionType.NotEqual, left, right);
1085 }
1086 throw Error.ReferenceEqualityNotDefined(left.Type, right.Type);
1087 }
1088
1090 {
1091 if (left.Type == right.Type && (left.Type.IsNumeric() || left.Type == typeof(object) || left.Type.IsBool() || left.Type.GetNonNullableType().IsEnum))
1092 {
1093 if (left.Type.IsNullableType() && liftToNull)
1094 {
1095 return new SimpleBinaryExpression(binaryType, left, right, typeof(bool?));
1096 }
1097 return new LogicalBinaryExpression(binaryType, left, right);
1098 }
1100 if (userDefinedBinaryOperator != null)
1101 {
1103 }
1104 if (TypeUtils.HasBuiltInEqualityOperator(left.Type, right.Type) || IsNullComparison(left, right))
1105 {
1106 if (left.Type.IsNullableType() && liftToNull)
1107 {
1108 return new SimpleBinaryExpression(binaryType, left, right, typeof(bool?));
1109 }
1110 return new LogicalBinaryExpression(binaryType, left, right);
1111 }
1112 throw Error.BinaryOperatorNotDefined(binaryType, left.Type, right.Type);
1113 }
1114
1116 {
1117 return GreaterThan(left, right, liftToNull: false, null);
1118 }
1119
1121 {
1122 ExpressionUtils.RequiresCanRead(left, "left");
1123 ExpressionUtils.RequiresCanRead(right, "right");
1124 if (method == null)
1125 {
1126 return GetComparisonOperator(ExpressionType.GreaterThan, "op_GreaterThan", left, right, liftToNull);
1127 }
1128 return GetMethodBasedBinaryOperator(ExpressionType.GreaterThan, left, right, method, liftToNull);
1129 }
1130
1132 {
1133 return LessThan(left, right, liftToNull: false, null);
1134 }
1135
1137 {
1138 ExpressionUtils.RequiresCanRead(left, "left");
1139 ExpressionUtils.RequiresCanRead(right, "right");
1140 if (method == null)
1141 {
1142 return GetComparisonOperator(ExpressionType.LessThan, "op_LessThan", left, right, liftToNull);
1143 }
1144 return GetMethodBasedBinaryOperator(ExpressionType.LessThan, left, right, method, liftToNull);
1145 }
1146
1148 {
1149 return GreaterThanOrEqual(left, right, liftToNull: false, null);
1150 }
1151
1153 {
1154 ExpressionUtils.RequiresCanRead(left, "left");
1155 ExpressionUtils.RequiresCanRead(right, "right");
1156 if (method == null)
1157 {
1158 return GetComparisonOperator(ExpressionType.GreaterThanOrEqual, "op_GreaterThanOrEqual", left, right, liftToNull);
1159 }
1160 return GetMethodBasedBinaryOperator(ExpressionType.GreaterThanOrEqual, left, right, method, liftToNull);
1161 }
1162
1164 {
1165 return LessThanOrEqual(left, right, liftToNull: false, null);
1166 }
1167
1169 {
1170 ExpressionUtils.RequiresCanRead(left, "left");
1171 ExpressionUtils.RequiresCanRead(right, "right");
1172 if (method == null)
1173 {
1174 return GetComparisonOperator(ExpressionType.LessThanOrEqual, "op_LessThanOrEqual", left, right, liftToNull);
1175 }
1176 return GetMethodBasedBinaryOperator(ExpressionType.LessThanOrEqual, left, right, method, liftToNull);
1177 }
1178
1180 {
1181 if (left.Type == right.Type && left.Type.IsNumeric())
1182 {
1183 if (left.Type.IsNullableType() && liftToNull)
1184 {
1185 return new SimpleBinaryExpression(binaryType, left, right, typeof(bool?));
1186 }
1187 return new LogicalBinaryExpression(binaryType, left, right);
1188 }
1190 }
1191
1193 {
1194 return AndAlso(left, right, null);
1195 }
1196
1198 {
1199 ExpressionUtils.RequiresCanRead(left, "left");
1200 ExpressionUtils.RequiresCanRead(right, "right");
1201 Type type;
1202 if (method == null)
1203 {
1204 if (left.Type == right.Type)
1205 {
1206 if (left.Type == typeof(bool))
1207 {
1208 return new LogicalBinaryExpression(ExpressionType.AndAlso, left, right);
1209 }
1210 if (left.Type == typeof(bool?))
1211 {
1212 return new SimpleBinaryExpression(ExpressionType.AndAlso, left, right, left.Type);
1213 }
1214 }
1215 method = GetUserDefinedBinaryOperator(ExpressionType.AndAlso, left.Type, right.Type, "op_BitwiseAnd");
1216 if (method != null)
1217 {
1218 ValidateUserDefinedConditionalLogicOperator(ExpressionType.AndAlso, left.Type, right.Type, method);
1219 type = ((left.Type.IsNullableType() && TypeUtils.AreEquivalent(method.ReturnType, left.Type.GetNonNullableType())) ? left.Type : method.ReturnType);
1220 return new MethodBinaryExpression(ExpressionType.AndAlso, left, right, type, method);
1221 }
1222 throw Error.BinaryOperatorNotDefined(ExpressionType.AndAlso, left.Type, right.Type);
1223 }
1224 ValidateUserDefinedConditionalLogicOperator(ExpressionType.AndAlso, left.Type, right.Type, method);
1225 type = ((left.Type.IsNullableType() && TypeUtils.AreEquivalent(method.ReturnType, left.Type.GetNonNullableType())) ? left.Type : method.ReturnType);
1226 return new MethodBinaryExpression(ExpressionType.AndAlso, left, right, type, method);
1227 }
1228
1230 {
1231 return OrElse(left, right, null);
1232 }
1233
1235 {
1236 ExpressionUtils.RequiresCanRead(left, "left");
1237 ExpressionUtils.RequiresCanRead(right, "right");
1238 Type type;
1239 if (method == null)
1240 {
1241 if (left.Type == right.Type)
1242 {
1243 if (left.Type == typeof(bool))
1244 {
1245 return new LogicalBinaryExpression(ExpressionType.OrElse, left, right);
1246 }
1247 if (left.Type == typeof(bool?))
1248 {
1249 return new SimpleBinaryExpression(ExpressionType.OrElse, left, right, left.Type);
1250 }
1251 }
1252 method = GetUserDefinedBinaryOperator(ExpressionType.OrElse, left.Type, right.Type, "op_BitwiseOr");
1253 if (method != null)
1254 {
1256 type = ((left.Type.IsNullableType() && method.ReturnType == left.Type.GetNonNullableType()) ? left.Type : method.ReturnType);
1257 return new MethodBinaryExpression(ExpressionType.OrElse, left, right, type, method);
1258 }
1259 throw Error.BinaryOperatorNotDefined(ExpressionType.OrElse, left.Type, right.Type);
1260 }
1262 type = ((left.Type.IsNullableType() && method.ReturnType == left.Type.GetNonNullableType()) ? left.Type : method.ReturnType);
1263 return new MethodBinaryExpression(ExpressionType.OrElse, left, right, type, method);
1264 }
1265
1267 {
1268 return Coalesce(left, right, null);
1269 }
1270
1272 {
1273 ExpressionUtils.RequiresCanRead(left, "left");
1274 ExpressionUtils.RequiresCanRead(right, "right");
1275 if (conversion == null)
1276 {
1277 Type type = ValidateCoalesceArgTypes(left.Type, right.Type);
1278 return new SimpleBinaryExpression(ExpressionType.Coalesce, left, right, type);
1279 }
1280 if (left.Type.IsValueType && !left.Type.IsNullableType())
1281 {
1283 }
1284 Type type2 = conversion.Type;
1285 MethodInfo invokeMethod = type2.GetInvokeMethod();
1286 if (invokeMethod.ReturnType == typeof(void))
1287 {
1289 }
1290 ParameterInfo[] parametersCached = invokeMethod.GetParametersCached();
1291 if (parametersCached.Length != 1)
1292 {
1294 }
1295 if (!TypeUtils.AreEquivalent(invokeMethod.ReturnType, right.Type))
1296 {
1298 }
1299 if (!ParameterIsAssignable(parametersCached[0], left.Type.GetNonNullableType()) && !ParameterIsAssignable(parametersCached[0], left.Type))
1300 {
1302 }
1303 return new CoalesceConversionBinaryExpression(left, right, conversion);
1304 }
1305
1306 private static Type ValidateCoalesceArgTypes(Type left, Type right)
1307 {
1308 Type nonNullableType = left.GetNonNullableType();
1309 if (left.IsValueType && !left.IsNullableType())
1310 {
1312 }
1313 if (left.IsNullableType() && right.IsImplicitlyConvertibleTo(nonNullableType))
1314 {
1315 return nonNullableType;
1316 }
1317 if (right.IsImplicitlyConvertibleTo(left))
1318 {
1319 return left;
1320 }
1321 if (nonNullableType.IsImplicitlyConvertibleTo(right))
1322 {
1323 return right;
1324 }
1326 }
1327
1328 public static BinaryExpression Add(Expression left, Expression right)
1329 {
1330 return Add(left, right, null);
1331 }
1332
1334 {
1335 ExpressionUtils.RequiresCanRead(left, "left");
1336 ExpressionUtils.RequiresCanRead(right, "right");
1337 if (method == null)
1338 {
1339 if (left.Type == right.Type && left.Type.IsArithmetic())
1340 {
1341 return new SimpleBinaryExpression(ExpressionType.Add, left, right, left.Type);
1342 }
1343 return GetUserDefinedBinaryOperatorOrThrow(ExpressionType.Add, "op_Addition", left, right, liftToNull: true);
1344 }
1345 return GetMethodBasedBinaryOperator(ExpressionType.Add, left, right, method, liftToNull: true);
1346 }
1347
1349 {
1350 return AddAssign(left, right, null, null);
1351 }
1352
1354 {
1355 return AddAssign(left, right, method, null);
1356 }
1357
1359 {
1360 ExpressionUtils.RequiresCanRead(left, "left");
1361 RequiresCanWrite(left, "left");
1362 ExpressionUtils.RequiresCanRead(right, "right");
1363 if (method == null)
1364 {
1365 if (left.Type == right.Type && left.Type.IsArithmetic())
1366 {
1367 if (conversion != null)
1368 {
1370 }
1371 return new SimpleBinaryExpression(ExpressionType.AddAssign, left, right, left.Type);
1372 }
1373 return GetUserDefinedAssignOperatorOrThrow(ExpressionType.AddAssign, "op_Addition", left, right, conversion, liftToNull: true);
1374 }
1375 return GetMethodBasedAssignOperator(ExpressionType.AddAssign, left, right, method, conversion, liftToNull: true);
1376 }
1377
1379 {
1380 Type type = conversion.Type;
1381 MethodInfo invokeMethod = type.GetInvokeMethod();
1382 ParameterInfo[] parametersCached = invokeMethod.GetParametersCached();
1383 if (parametersCached.Length != 1)
1384 {
1386 }
1387 if (!TypeUtils.AreEquivalent(invokeMethod.ReturnType, left.Type))
1388 {
1389 throw Error.OperandTypesDoNotMatchParameters(nodeType, conversion.ToString());
1390 }
1391 if (!TypeUtils.AreEquivalent(parametersCached[0].ParameterType, method.ReturnType))
1392 {
1394 }
1395 }
1396
1398 {
1399 return AddAssignChecked(left, right, null);
1400 }
1401
1403 {
1404 return AddAssignChecked(left, right, method, null);
1405 }
1406
1408 {
1409 ExpressionUtils.RequiresCanRead(left, "left");
1410 RequiresCanWrite(left, "left");
1411 ExpressionUtils.RequiresCanRead(right, "right");
1412 if (method == null)
1413 {
1414 if (left.Type == right.Type && left.Type.IsArithmetic())
1415 {
1416 if (conversion != null)
1417 {
1419 }
1420 return new SimpleBinaryExpression(ExpressionType.AddAssignChecked, left, right, left.Type);
1421 }
1422 return GetUserDefinedAssignOperatorOrThrow(ExpressionType.AddAssignChecked, "op_Addition", left, right, conversion, liftToNull: true);
1423 }
1424 return GetMethodBasedAssignOperator(ExpressionType.AddAssignChecked, left, right, method, conversion, liftToNull: true);
1425 }
1426
1428 {
1429 return AddChecked(left, right, null);
1430 }
1431
1433 {
1434 ExpressionUtils.RequiresCanRead(left, "left");
1435 ExpressionUtils.RequiresCanRead(right, "right");
1436 if (method == null)
1437 {
1438 if (left.Type == right.Type && left.Type.IsArithmetic())
1439 {
1440 return new SimpleBinaryExpression(ExpressionType.AddChecked, left, right, left.Type);
1441 }
1442 return GetUserDefinedBinaryOperatorOrThrow(ExpressionType.AddChecked, "op_Addition", left, right, liftToNull: true);
1443 }
1444 return GetMethodBasedBinaryOperator(ExpressionType.AddChecked, left, right, method, liftToNull: true);
1445 }
1446
1448 {
1449 return Subtract(left, right, null);
1450 }
1451
1453 {
1454 ExpressionUtils.RequiresCanRead(left, "left");
1455 ExpressionUtils.RequiresCanRead(right, "right");
1456 if (method == null)
1457 {
1458 if (left.Type == right.Type && left.Type.IsArithmetic())
1459 {
1460 return new SimpleBinaryExpression(ExpressionType.Subtract, left, right, left.Type);
1461 }
1462 return GetUserDefinedBinaryOperatorOrThrow(ExpressionType.Subtract, "op_Subtraction", left, right, liftToNull: true);
1463 }
1464 return GetMethodBasedBinaryOperator(ExpressionType.Subtract, left, right, method, liftToNull: true);
1465 }
1466
1468 {
1469 return SubtractAssign(left, right, null, null);
1470 }
1471
1473 {
1474 return SubtractAssign(left, right, method, null);
1475 }
1476
1478 {
1479 ExpressionUtils.RequiresCanRead(left, "left");
1480 RequiresCanWrite(left, "left");
1481 ExpressionUtils.RequiresCanRead(right, "right");
1482 if (method == null)
1483 {
1484 if (left.Type == right.Type && left.Type.IsArithmetic())
1485 {
1486 if (conversion != null)
1487 {
1489 }
1490 return new SimpleBinaryExpression(ExpressionType.SubtractAssign, left, right, left.Type);
1491 }
1492 return GetUserDefinedAssignOperatorOrThrow(ExpressionType.SubtractAssign, "op_Subtraction", left, right, conversion, liftToNull: true);
1493 }
1494 return GetMethodBasedAssignOperator(ExpressionType.SubtractAssign, left, right, method, conversion, liftToNull: true);
1495 }
1496
1498 {
1499 return SubtractAssignChecked(left, right, null);
1500 }
1501
1503 {
1504 return SubtractAssignChecked(left, right, method, null);
1505 }
1506
1508 {
1509 ExpressionUtils.RequiresCanRead(left, "left");
1510 RequiresCanWrite(left, "left");
1511 ExpressionUtils.RequiresCanRead(right, "right");
1512 if (method == null)
1513 {
1514 if (left.Type == right.Type && left.Type.IsArithmetic())
1515 {
1516 if (conversion != null)
1517 {
1519 }
1520 return new SimpleBinaryExpression(ExpressionType.SubtractAssignChecked, left, right, left.Type);
1521 }
1522 return GetUserDefinedAssignOperatorOrThrow(ExpressionType.SubtractAssignChecked, "op_Subtraction", left, right, conversion, liftToNull: true);
1523 }
1524 return GetMethodBasedAssignOperator(ExpressionType.SubtractAssignChecked, left, right, method, conversion, liftToNull: true);
1525 }
1526
1528 {
1529 return SubtractChecked(left, right, null);
1530 }
1531
1533 {
1534 ExpressionUtils.RequiresCanRead(left, "left");
1535 ExpressionUtils.RequiresCanRead(right, "right");
1536 if (method == null)
1537 {
1538 if (left.Type == right.Type && left.Type.IsArithmetic())
1539 {
1540 return new SimpleBinaryExpression(ExpressionType.SubtractChecked, left, right, left.Type);
1541 }
1542 return GetUserDefinedBinaryOperatorOrThrow(ExpressionType.SubtractChecked, "op_Subtraction", left, right, liftToNull: true);
1543 }
1544 return GetMethodBasedBinaryOperator(ExpressionType.SubtractChecked, left, right, method, liftToNull: true);
1545 }
1546
1548 {
1549 return Divide(left, right, null);
1550 }
1551
1553 {
1554 ExpressionUtils.RequiresCanRead(left, "left");
1555 ExpressionUtils.RequiresCanRead(right, "right");
1556 if (method == null)
1557 {
1558 if (left.Type == right.Type && left.Type.IsArithmetic())
1559 {
1560 return new SimpleBinaryExpression(ExpressionType.Divide, left, right, left.Type);
1561 }
1562 return GetUserDefinedBinaryOperatorOrThrow(ExpressionType.Divide, "op_Division", left, right, liftToNull: true);
1563 }
1564 return GetMethodBasedBinaryOperator(ExpressionType.Divide, left, right, method, liftToNull: true);
1565 }
1566
1568 {
1569 return DivideAssign(left, right, null, null);
1570 }
1571
1573 {
1574 return DivideAssign(left, right, method, null);
1575 }
1576
1578 {
1579 ExpressionUtils.RequiresCanRead(left, "left");
1580 RequiresCanWrite(left, "left");
1581 ExpressionUtils.RequiresCanRead(right, "right");
1582 if (method == null)
1583 {
1584 if (left.Type == right.Type && left.Type.IsArithmetic())
1585 {
1586 if (conversion != null)
1587 {
1589 }
1590 return new SimpleBinaryExpression(ExpressionType.DivideAssign, left, right, left.Type);
1591 }
1592 return GetUserDefinedAssignOperatorOrThrow(ExpressionType.DivideAssign, "op_Division", left, right, conversion, liftToNull: true);
1593 }
1594 return GetMethodBasedAssignOperator(ExpressionType.DivideAssign, left, right, method, conversion, liftToNull: true);
1595 }
1596
1598 {
1599 return Modulo(left, right, null);
1600 }
1601
1603 {
1604 ExpressionUtils.RequiresCanRead(left, "left");
1605 ExpressionUtils.RequiresCanRead(right, "right");
1606 if (method == null)
1607 {
1608 if (left.Type == right.Type && left.Type.IsArithmetic())
1609 {
1610 return new SimpleBinaryExpression(ExpressionType.Modulo, left, right, left.Type);
1611 }
1612 return GetUserDefinedBinaryOperatorOrThrow(ExpressionType.Modulo, "op_Modulus", left, right, liftToNull: true);
1613 }
1614 return GetMethodBasedBinaryOperator(ExpressionType.Modulo, left, right, method, liftToNull: true);
1615 }
1616
1618 {
1619 return ModuloAssign(left, right, null, null);
1620 }
1621
1623 {
1624 return ModuloAssign(left, right, method, null);
1625 }
1626
1628 {
1629 ExpressionUtils.RequiresCanRead(left, "left");
1630 RequiresCanWrite(left, "left");
1631 ExpressionUtils.RequiresCanRead(right, "right");
1632 if (method == null)
1633 {
1634 if (left.Type == right.Type && left.Type.IsArithmetic())
1635 {
1636 if (conversion != null)
1637 {
1639 }
1640 return new SimpleBinaryExpression(ExpressionType.ModuloAssign, left, right, left.Type);
1641 }
1642 return GetUserDefinedAssignOperatorOrThrow(ExpressionType.ModuloAssign, "op_Modulus", left, right, conversion, liftToNull: true);
1643 }
1644 return GetMethodBasedAssignOperator(ExpressionType.ModuloAssign, left, right, method, conversion, liftToNull: true);
1645 }
1646
1648 {
1649 return Multiply(left, right, null);
1650 }
1651
1653 {
1654 ExpressionUtils.RequiresCanRead(left, "left");
1655 ExpressionUtils.RequiresCanRead(right, "right");
1656 if (method == null)
1657 {
1658 if (left.Type == right.Type && left.Type.IsArithmetic())
1659 {
1660 return new SimpleBinaryExpression(ExpressionType.Multiply, left, right, left.Type);
1661 }
1662 return GetUserDefinedBinaryOperatorOrThrow(ExpressionType.Multiply, "op_Multiply", left, right, liftToNull: true);
1663 }
1664 return GetMethodBasedBinaryOperator(ExpressionType.Multiply, left, right, method, liftToNull: true);
1665 }
1666
1668 {
1669 return MultiplyAssign(left, right, null, null);
1670 }
1671
1673 {
1674 return MultiplyAssign(left, right, method, null);
1675 }
1676
1678 {
1679 ExpressionUtils.RequiresCanRead(left, "left");
1680 RequiresCanWrite(left, "left");
1681 ExpressionUtils.RequiresCanRead(right, "right");
1682 if (method == null)
1683 {
1684 if (left.Type == right.Type && left.Type.IsArithmetic())
1685 {
1686 if (conversion != null)
1687 {
1689 }
1690 return new SimpleBinaryExpression(ExpressionType.MultiplyAssign, left, right, left.Type);
1691 }
1692 return GetUserDefinedAssignOperatorOrThrow(ExpressionType.MultiplyAssign, "op_Multiply", left, right, conversion, liftToNull: true);
1693 }
1694 return GetMethodBasedAssignOperator(ExpressionType.MultiplyAssign, left, right, method, conversion, liftToNull: true);
1695 }
1696
1698 {
1699 return MultiplyAssignChecked(left, right, null);
1700 }
1701
1703 {
1704 return MultiplyAssignChecked(left, right, method, null);
1705 }
1706
1708 {
1709 ExpressionUtils.RequiresCanRead(left, "left");
1710 RequiresCanWrite(left, "left");
1711 ExpressionUtils.RequiresCanRead(right, "right");
1712 if (method == null)
1713 {
1714 if (left.Type == right.Type && left.Type.IsArithmetic())
1715 {
1716 if (conversion != null)
1717 {
1719 }
1720 return new SimpleBinaryExpression(ExpressionType.MultiplyAssignChecked, left, right, left.Type);
1721 }
1722 return GetUserDefinedAssignOperatorOrThrow(ExpressionType.MultiplyAssignChecked, "op_Multiply", left, right, conversion, liftToNull: true);
1723 }
1724 return GetMethodBasedAssignOperator(ExpressionType.MultiplyAssignChecked, left, right, method, conversion, liftToNull: true);
1725 }
1726
1728 {
1729 return MultiplyChecked(left, right, null);
1730 }
1731
1733 {
1734 ExpressionUtils.RequiresCanRead(left, "left");
1735 ExpressionUtils.RequiresCanRead(right, "right");
1736 if (method == null)
1737 {
1738 if (left.Type == right.Type && left.Type.IsArithmetic())
1739 {
1740 return new SimpleBinaryExpression(ExpressionType.MultiplyChecked, left, right, left.Type);
1741 }
1742 return GetUserDefinedBinaryOperatorOrThrow(ExpressionType.MultiplyChecked, "op_Multiply", left, right, liftToNull: true);
1743 }
1744 return GetMethodBasedBinaryOperator(ExpressionType.MultiplyChecked, left, right, method, liftToNull: true);
1745 }
1746
1747 private static bool IsSimpleShift(Type left, Type right)
1748 {
1749 if (left.IsInteger())
1750 {
1751 return right.GetNonNullableType() == typeof(int);
1752 }
1753 return false;
1754 }
1755
1756 private static Type GetResultTypeOfShift(Type left, Type right)
1757 {
1758 if (!left.IsNullableType() && right.IsNullableType())
1759 {
1760 return typeof(Nullable<>).MakeGenericType(left);
1761 }
1762 return left;
1763 }
1764
1766 {
1767 return LeftShift(left, right, null);
1768 }
1769
1771 {
1772 ExpressionUtils.RequiresCanRead(left, "left");
1773 ExpressionUtils.RequiresCanRead(right, "right");
1774 if (method == null)
1775 {
1776 if (IsSimpleShift(left.Type, right.Type))
1777 {
1778 Type resultTypeOfShift = GetResultTypeOfShift(left.Type, right.Type);
1779 return new SimpleBinaryExpression(ExpressionType.LeftShift, left, right, resultTypeOfShift);
1780 }
1781 return GetUserDefinedBinaryOperatorOrThrow(ExpressionType.LeftShift, "op_LeftShift", left, right, liftToNull: true);
1782 }
1783 return GetMethodBasedBinaryOperator(ExpressionType.LeftShift, left, right, method, liftToNull: true);
1784 }
1785
1787 {
1788 return LeftShiftAssign(left, right, null, null);
1789 }
1790
1792 {
1793 return LeftShiftAssign(left, right, method, null);
1794 }
1795
1797 {
1798 ExpressionUtils.RequiresCanRead(left, "left");
1799 RequiresCanWrite(left, "left");
1800 ExpressionUtils.RequiresCanRead(right, "right");
1801 if (method == null)
1802 {
1803 if (IsSimpleShift(left.Type, right.Type))
1804 {
1805 if (conversion != null)
1806 {
1808 }
1809 Type resultTypeOfShift = GetResultTypeOfShift(left.Type, right.Type);
1810 return new SimpleBinaryExpression(ExpressionType.LeftShiftAssign, left, right, resultTypeOfShift);
1811 }
1812 return GetUserDefinedAssignOperatorOrThrow(ExpressionType.LeftShiftAssign, "op_LeftShift", left, right, conversion, liftToNull: true);
1813 }
1814 return GetMethodBasedAssignOperator(ExpressionType.LeftShiftAssign, left, right, method, conversion, liftToNull: true);
1815 }
1816
1818 {
1819 return RightShift(left, right, null);
1820 }
1821
1823 {
1824 ExpressionUtils.RequiresCanRead(left, "left");
1825 ExpressionUtils.RequiresCanRead(right, "right");
1826 if (method == null)
1827 {
1828 if (IsSimpleShift(left.Type, right.Type))
1829 {
1830 Type resultTypeOfShift = GetResultTypeOfShift(left.Type, right.Type);
1831 return new SimpleBinaryExpression(ExpressionType.RightShift, left, right, resultTypeOfShift);
1832 }
1833 return GetUserDefinedBinaryOperatorOrThrow(ExpressionType.RightShift, "op_RightShift", left, right, liftToNull: true);
1834 }
1835 return GetMethodBasedBinaryOperator(ExpressionType.RightShift, left, right, method, liftToNull: true);
1836 }
1837
1839 {
1840 return RightShiftAssign(left, right, null, null);
1841 }
1842
1844 {
1845 return RightShiftAssign(left, right, method, null);
1846 }
1847
1849 {
1850 ExpressionUtils.RequiresCanRead(left, "left");
1851 RequiresCanWrite(left, "left");
1852 ExpressionUtils.RequiresCanRead(right, "right");
1853 if (method == null)
1854 {
1855 if (IsSimpleShift(left.Type, right.Type))
1856 {
1857 if (conversion != null)
1858 {
1860 }
1861 Type resultTypeOfShift = GetResultTypeOfShift(left.Type, right.Type);
1862 return new SimpleBinaryExpression(ExpressionType.RightShiftAssign, left, right, resultTypeOfShift);
1863 }
1864 return GetUserDefinedAssignOperatorOrThrow(ExpressionType.RightShiftAssign, "op_RightShift", left, right, conversion, liftToNull: true);
1865 }
1866 return GetMethodBasedAssignOperator(ExpressionType.RightShiftAssign, left, right, method, conversion, liftToNull: true);
1867 }
1868
1869 public static BinaryExpression And(Expression left, Expression right)
1870 {
1871 return And(left, right, null);
1872 }
1873
1875 {
1876 ExpressionUtils.RequiresCanRead(left, "left");
1877 ExpressionUtils.RequiresCanRead(right, "right");
1878 if (method == null)
1879 {
1880 if (left.Type == right.Type && left.Type.IsIntegerOrBool())
1881 {
1882 return new SimpleBinaryExpression(ExpressionType.And, left, right, left.Type);
1883 }
1884 return GetUserDefinedBinaryOperatorOrThrow(ExpressionType.And, "op_BitwiseAnd", left, right, liftToNull: true);
1885 }
1886 return GetMethodBasedBinaryOperator(ExpressionType.And, left, right, method, liftToNull: true);
1887 }
1888
1890 {
1891 return AndAssign(left, right, null, null);
1892 }
1893
1895 {
1896 return AndAssign(left, right, method, null);
1897 }
1898
1900 {
1901 ExpressionUtils.RequiresCanRead(left, "left");
1902 RequiresCanWrite(left, "left");
1903 ExpressionUtils.RequiresCanRead(right, "right");
1904 if (method == null)
1905 {
1906 if (left.Type == right.Type && left.Type.IsIntegerOrBool())
1907 {
1908 if (conversion != null)
1909 {
1911 }
1912 return new SimpleBinaryExpression(ExpressionType.AndAssign, left, right, left.Type);
1913 }
1914 return GetUserDefinedAssignOperatorOrThrow(ExpressionType.AndAssign, "op_BitwiseAnd", left, right, conversion, liftToNull: true);
1915 }
1916 return GetMethodBasedAssignOperator(ExpressionType.AndAssign, left, right, method, conversion, liftToNull: true);
1917 }
1918
1919 public static BinaryExpression Or(Expression left, Expression right)
1920 {
1921 return Or(left, right, null);
1922 }
1923
1925 {
1926 ExpressionUtils.RequiresCanRead(left, "left");
1927 ExpressionUtils.RequiresCanRead(right, "right");
1928 if (method == null)
1929 {
1930 if (left.Type == right.Type && left.Type.IsIntegerOrBool())
1931 {
1932 return new SimpleBinaryExpression(ExpressionType.Or, left, right, left.Type);
1933 }
1934 return GetUserDefinedBinaryOperatorOrThrow(ExpressionType.Or, "op_BitwiseOr", left, right, liftToNull: true);
1935 }
1936 return GetMethodBasedBinaryOperator(ExpressionType.Or, left, right, method, liftToNull: true);
1937 }
1938
1940 {
1941 return OrAssign(left, right, null, null);
1942 }
1943
1945 {
1946 return OrAssign(left, right, method, null);
1947 }
1948
1950 {
1951 ExpressionUtils.RequiresCanRead(left, "left");
1952 RequiresCanWrite(left, "left");
1953 ExpressionUtils.RequiresCanRead(right, "right");
1954 if (method == null)
1955 {
1956 if (left.Type == right.Type && left.Type.IsIntegerOrBool())
1957 {
1958 if (conversion != null)
1959 {
1961 }
1962 return new SimpleBinaryExpression(ExpressionType.OrAssign, left, right, left.Type);
1963 }
1964 return GetUserDefinedAssignOperatorOrThrow(ExpressionType.OrAssign, "op_BitwiseOr", left, right, conversion, liftToNull: true);
1965 }
1966 return GetMethodBasedAssignOperator(ExpressionType.OrAssign, left, right, method, conversion, liftToNull: true);
1967 }
1968
1970 {
1971 return ExclusiveOr(left, right, null);
1972 }
1973
1975 {
1976 ExpressionUtils.RequiresCanRead(left, "left");
1977 ExpressionUtils.RequiresCanRead(right, "right");
1978 if (method == null)
1979 {
1980 if (left.Type == right.Type && left.Type.IsIntegerOrBool())
1981 {
1982 return new SimpleBinaryExpression(ExpressionType.ExclusiveOr, left, right, left.Type);
1983 }
1984 return GetUserDefinedBinaryOperatorOrThrow(ExpressionType.ExclusiveOr, "op_ExclusiveOr", left, right, liftToNull: true);
1985 }
1986 return GetMethodBasedBinaryOperator(ExpressionType.ExclusiveOr, left, right, method, liftToNull: true);
1987 }
1988
1990 {
1991 return ExclusiveOrAssign(left, right, null, null);
1992 }
1993
1995 {
1996 return ExclusiveOrAssign(left, right, method, null);
1997 }
1998
2000 {
2001 ExpressionUtils.RequiresCanRead(left, "left");
2002 RequiresCanWrite(left, "left");
2003 ExpressionUtils.RequiresCanRead(right, "right");
2004 if (method == null)
2005 {
2006 if (left.Type == right.Type && left.Type.IsIntegerOrBool())
2007 {
2008 if (conversion != null)
2009 {
2011 }
2012 return new SimpleBinaryExpression(ExpressionType.ExclusiveOrAssign, left, right, left.Type);
2013 }
2014 return GetUserDefinedAssignOperatorOrThrow(ExpressionType.ExclusiveOrAssign, "op_ExclusiveOr", left, right, conversion, liftToNull: true);
2015 }
2016 return GetMethodBasedAssignOperator(ExpressionType.ExclusiveOrAssign, left, right, method, conversion, liftToNull: true);
2017 }
2018
2019 public static BinaryExpression Power(Expression left, Expression right)
2020 {
2021 return Power(left, right, null);
2022 }
2023
2025 {
2026 ExpressionUtils.RequiresCanRead(left, "left");
2027 ExpressionUtils.RequiresCanRead(right, "right");
2028 if (method == null)
2029 {
2030 if (!(left.Type == right.Type) || !left.Type.IsArithmetic())
2031 {
2032 string name = "op_Exponent";
2034 if (userDefinedBinaryOperator == null)
2035 {
2036 name = "op_Exponentiation";
2038 if (userDefinedBinaryOperator == null)
2039 {
2040 throw Error.BinaryOperatorNotDefined(ExpressionType.Power, left.Type, right.Type);
2041 }
2042 }
2043 ParameterInfo[] parametersCached = userDefinedBinaryOperator.Method.GetParametersCached();
2044 ValidateParamswithOperandsOrThrow(parametersCached[0].ParameterType, left.Type, ExpressionType.Power, name);
2045 ValidateParamswithOperandsOrThrow(parametersCached[1].ParameterType, right.Type, ExpressionType.Power, name);
2047 }
2049 }
2050 return GetMethodBasedBinaryOperator(ExpressionType.Power, left, right, method, liftToNull: true);
2051 }
2052
2054 {
2055 return PowerAssign(left, right, null, null);
2056 }
2057
2059 {
2060 return PowerAssign(left, right, method, null);
2061 }
2062
2064 {
2065 ExpressionUtils.RequiresCanRead(left, "left");
2066 RequiresCanWrite(left, "left");
2067 ExpressionUtils.RequiresCanRead(right, "right");
2068 if (method == null)
2069 {
2071 if (method == null)
2072 {
2073 throw Error.BinaryOperatorNotDefined(ExpressionType.PowerAssign, left.Type, right.Type);
2074 }
2075 }
2076 return GetMethodBasedAssignOperator(ExpressionType.PowerAssign, left, right, method, conversion, liftToNull: true);
2077 }
2078
2080 {
2083 if (index.Type != typeof(int))
2084 {
2085 throw Error.ArgumentMustBeArrayIndexType("index");
2086 }
2087 Type type = array.Type;
2088 if (!type.IsArray)
2089 {
2090 throw Error.ArgumentMustBeArray("array");
2091 }
2092 if (type.GetArrayRank() != 1)
2093 {
2095 }
2096 return new SimpleBinaryExpression(ExpressionType.ArrayIndex, array, index, type.GetElementType());
2097 }
2098
2100 {
2103 return new Block2(arg0, arg1);
2104 }
2105
2113
2122
2132
2139
2144
2150
2155
2160
2165
2180
2202
2204 {
2205 ValidateVariables(variables, "variables");
2206 if (type != null)
2207 {
2208 if (expressions.Count == 0)
2209 {
2210 if (type != typeof(void))
2211 {
2213 }
2215 }
2218 {
2220 }
2222 {
2224 }
2225 }
2226 return expressions.Count switch
2227 {
2228 0 => new ScopeWithType(variables, expressions, typeof(void)),
2229 1 => new Scope1(variables, expressions[0]),
2230 _ => new ScopeN(variables, expressions),
2231 };
2232 }
2233
2235 {
2236 int count = varList.Count;
2237 if (count == 0)
2238 {
2239 return;
2240 }
2242 for (int i = 0; i < count; i++)
2243 {
2246 if (parameterExpression.IsByRef)
2247 {
2249 }
2251 {
2253 }
2254 }
2255 }
2256
2258 {
2259 switch (expressions.Count)
2260 {
2261 case 0:
2263 case 2:
2264 return new Block2(expressions[0], expressions[1]);
2265 case 3:
2266 return new Block3(expressions[0], expressions[1], expressions[2]);
2267 case 4:
2268 return new Block4(expressions[0], expressions[1], expressions[2], expressions[3]);
2269 case 5:
2270 return new Block5(expressions[0], expressions[1], expressions[2], expressions[3], expressions[4]);
2271 default:
2272 {
2274 return new BlockN(readOnlyList ?? expressions.ToArray());
2275 }
2276 }
2277 }
2278
2279 public static CatchBlock Catch(Type type, Expression body)
2280 {
2281 return MakeCatchBlock(type, null, body, null);
2282 }
2283
2285 {
2287 return MakeCatchBlock(variable.Type, variable, body, null);
2288 }
2289
2291 {
2292 return MakeCatchBlock(type, null, body, filter);
2293 }
2294
2296 {
2298 return MakeCatchBlock(variable.Type, variable, body, filter);
2299 }
2300
2302 {
2304 ContractUtils.Requires(variable == null || TypeUtils.AreEquivalent(variable.Type, type), "variable");
2305 if (variable == null)
2306 {
2307 TypeUtils.ValidateType(type, "type");
2308 }
2309 else if (variable.IsByRef)
2310 {
2311 throw Error.VariableMustNotBeByRef(variable, variable.Type, "variable");
2312 }
2313 ExpressionUtils.RequiresCanRead(body, "body");
2314 if (filter != null)
2315 {
2317 if (filter.Type != typeof(bool))
2318 {
2319 throw Error.ArgumentMustBeBoolean("filter");
2320 }
2321 }
2322 return new CatchBlock(type, variable, body, filter);
2323 }
2324
2326 {
2330 if (test.Type != typeof(bool))
2331 {
2332 throw Error.ArgumentMustBeBoolean("test");
2333 }
2334 if (!TypeUtils.AreEquivalent(ifTrue.Type, ifFalse.Type))
2335 {
2337 }
2339 }
2340
2342 {
2347 if (test.Type != typeof(bool))
2348 {
2349 throw Error.ArgumentMustBeBoolean("test");
2350 }
2352 {
2354 }
2356 }
2357
2359 {
2360 return Condition(test, ifTrue, Empty(), typeof(void));
2361 }
2362
2367
2368 public static ConstantExpression Constant(object? value)
2369 {
2370 return new ConstantExpression(value);
2371 }
2372
2374 {
2376 TypeUtils.ValidateType(type, "type");
2377 if (value == null)
2378 {
2379 if (type == typeof(object))
2380 {
2381 return new ConstantExpression(null);
2382 }
2383 if (!type.IsValueType || type.IsNullableType())
2384 {
2385 return new TypedConstantExpression(null, type);
2386 }
2387 }
2388 else
2389 {
2390 Type type2 = value.GetType();
2391 if (type == type2)
2392 {
2393 return new ConstantExpression(value);
2394 }
2395 if (type.IsAssignableFrom(type2))
2396 {
2397 return new TypedConstantExpression(value, type);
2398 }
2399 }
2401 }
2402
2404 {
2406 if (startLine == 16707566 && startColumn == 0 && endLine == 16707566 && endColumn == 0)
2407 {
2409 }
2412 }
2413
2419
2420 private static void ValidateSpan(int startLine, int startColumn, int endLine, int endColumn)
2421 {
2422 if (startLine < 1)
2423 {
2424 throw Error.OutOfRange("startLine", 1);
2425 }
2426 if (startColumn < 1)
2427 {
2428 throw Error.OutOfRange("startColumn", 1);
2429 }
2430 if (endLine < 1)
2431 {
2432 throw Error.OutOfRange("endLine", 1);
2433 }
2434 if (endColumn < 1)
2435 {
2436 throw Error.OutOfRange("endColumn", 1);
2437 }
2438 if (startLine > endLine)
2439 {
2441 }
2443 {
2445 }
2446 }
2447
2448 public static DefaultExpression Empty()
2449 {
2450 return new DefaultExpression(typeof(void));
2451 }
2452
2454 {
2456 TypeUtils.ValidateType(type, "type");
2457 return new DefaultExpression(type);
2458 }
2459
2464
2475
2477 {
2479 ParameterInfo[] parametersCached = addMethod.GetParametersCached();
2480 if (parametersCached.Length == 0)
2481 {
2483 }
2484 if (!addMethod.Name.Equals("Add", StringComparison.OrdinalIgnoreCase))
2485 {
2487 }
2488 if (addMethod.IsStatic)
2489 {
2491 }
2493 foreach (ParameterInfo parameterInfo in array)
2494 {
2495 if (parameterInfo.ParameterType.IsByRef)
2496 {
2498 }
2499 }
2500 }
2501
2502 [Obsolete("This constructor has been deprecated. Use a different constructor that does not take ExpressionType. Then override NodeType and Type properties to provide the values that would be specified to this constructor.")]
2511
2512 protected Expression()
2513 {
2514 }
2515
2516 public virtual Expression Reduce()
2517 {
2518 if (CanReduce)
2519 {
2521 }
2522 return this;
2523 }
2524
2526 {
2527 if (!CanReduce)
2528 {
2529 throw Error.MustBeReducible();
2530 }
2531 return visitor.Visit(ReduceAndCheck());
2532 }
2533
2534 protected internal virtual Expression Accept(ExpressionVisitor visitor)
2535 {
2536 return visitor.VisitExtension(this);
2537 }
2538
2540 {
2541 if (!CanReduce)
2542 {
2543 throw Error.MustBeReducible();
2544 }
2546 if (expression == null || expression == this)
2547 {
2549 }
2551 {
2553 }
2554 return expression;
2555 }
2556
2558 {
2559 Expression expression = this;
2560 while (expression.NodeType == ExpressionType.Extension)
2561 {
2562 expression = expression.ReduceAndCheck();
2563 }
2564 return expression;
2565 }
2566
2567 public override string ToString()
2568 {
2570 }
2571
2572 private static void RequiresCanRead(IReadOnlyList<Expression> items, string paramName)
2573 {
2574 int i = 0;
2575 for (int count = items.Count; i < count; i++)
2576 {
2578 }
2579 }
2580
2582 {
2583 if (expression == null)
2584 {
2586 }
2587 switch (expression.NodeType)
2588 {
2589 case ExpressionType.Index:
2590 {
2592 if (indexer == null || indexer.CanWrite)
2593 {
2594 return;
2595 }
2596 break;
2597 }
2598 case ExpressionType.MemberAccess:
2599 {
2600 MemberInfo member = ((MemberExpression)expression).Member;
2601 if (member is PropertyInfo propertyInfo)
2602 {
2603 if (propertyInfo.CanWrite)
2604 {
2605 return;
2606 }
2607 break;
2608 }
2609 FieldInfo fieldInfo = (FieldInfo)member;
2610 if (!fieldInfo.IsInitOnly && !fieldInfo.IsLiteral)
2611 {
2612 return;
2613 }
2614 break;
2615 }
2616 case ExpressionType.Parameter:
2617 return;
2618 }
2620 }
2621
2626
2631
2636
2641
2646
2651
2656
2661
2666
2671
2676
2681
2682 public static GotoExpression Break(LabelTarget target)
2683 {
2684 return MakeGoto(GotoExpressionKind.Break, target, null, typeof(void));
2685 }
2686
2688 {
2689 return MakeGoto(GotoExpressionKind.Break, target, value, typeof(void));
2690 }
2691
2693 {
2694 return MakeGoto(GotoExpressionKind.Break, target, null, type);
2695 }
2696
2698 {
2699 return MakeGoto(GotoExpressionKind.Break, target, value, type);
2700 }
2701
2703 {
2704 return MakeGoto(GotoExpressionKind.Continue, target, null, typeof(void));
2705 }
2706
2708 {
2709 return MakeGoto(GotoExpressionKind.Continue, target, null, type);
2710 }
2711
2712 public static GotoExpression Return(LabelTarget target)
2713 {
2714 return MakeGoto(GotoExpressionKind.Return, target, null, typeof(void));
2715 }
2716
2718 {
2719 return MakeGoto(GotoExpressionKind.Return, target, null, type);
2720 }
2721
2723 {
2724 return MakeGoto(GotoExpressionKind.Return, target, value, typeof(void));
2725 }
2726
2728 {
2729 return MakeGoto(GotoExpressionKind.Return, target, value, type);
2730 }
2731
2732 public static GotoExpression Goto(LabelTarget target)
2733 {
2734 return MakeGoto(GotoExpressionKind.Goto, target, null, typeof(void));
2735 }
2736
2737 public static GotoExpression Goto(LabelTarget target, Type type)
2738 {
2739 return MakeGoto(GotoExpressionKind.Goto, target, null, type);
2740 }
2741
2743 {
2744 return MakeGoto(GotoExpressionKind.Goto, target, value, typeof(void));
2745 }
2746
2748 {
2749 return MakeGoto(GotoExpressionKind.Goto, target, value, type);
2750 }
2751
2753 {
2754 ValidateGoto(target, ref value, "target", "value", type);
2755 return new GotoExpression(kind, target, value, type);
2756 }
2757
2759 {
2761 if (value == null)
2762 {
2763 if (target.Type != typeof(void))
2764 {
2765 throw Error.LabelMustBeVoidOrHaveExpression("target");
2766 }
2767 if (type != null)
2768 {
2769 TypeUtils.ValidateType(type, "type");
2770 }
2771 }
2772 else
2773 {
2775 }
2776 }
2777
2786
2788 {
2789 if (indexer != null)
2790 {
2791 return Property(instance, indexer, arguments);
2792 }
2793 return ArrayAccess(instance, arguments);
2794 }
2795
2800
2802 {
2804 Type type = array.Type;
2805 if (!type.IsArray)
2806 {
2807 throw Error.ArgumentMustBeArray("array");
2808 }
2810 if (type.GetArrayRank() != readOnlyCollection.Count)
2811 {
2813 }
2815 {
2817 if (item.Type != typeof(int))
2818 {
2819 throw Error.ArgumentMustBeArrayIndexType("indexes");
2820 }
2821 }
2822 return new IndexExpression(array, null, readOnlyCollection);
2823 }
2824
2825 [RequiresUnreferencedCode("Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.")]
2827 {
2828 ExpressionUtils.RequiresCanRead(instance, "instance");
2831 return MakeIndexProperty(instance, indexer, "propertyName", arguments.ToReadOnly());
2832 }
2833
2835 {
2836 BindingFlags flags = BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy;
2837 PropertyInfo propertyInfo = FindProperty(type, propertyName, arguments, flags);
2838 if (propertyInfo == null)
2839 {
2840 flags = BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy;
2841 propertyInfo = FindProperty(type, propertyName, arguments, flags);
2842 }
2843 if (propertyInfo == null)
2844 {
2845 if (arguments == null || arguments.Length == 0)
2846 {
2848 }
2850 }
2851 return propertyInfo;
2852 }
2853
2854 private static string GetArgTypesString(Expression[] arguments)
2855 {
2857 stringBuilder.Append('(');
2858 for (int i = 0; i < arguments.Length; i++)
2859 {
2860 if (i != 0)
2861 {
2862 stringBuilder.Append(", ");
2863 }
2864 stringBuilder.Append(arguments[i]?.Type.Name);
2865 }
2866 stringBuilder.Append(')');
2867 return stringBuilder.ToString();
2868 }
2869
2871 {
2872 PropertyInfo propertyInfo = null;
2873 PropertyInfo[] properties = type.GetProperties(flags);
2874 foreach (PropertyInfo propertyInfo2 in properties)
2875 {
2876 if (propertyInfo2.Name.Equals(propertyName, StringComparison.OrdinalIgnoreCase) && IsCompatible(propertyInfo2, arguments))
2877 {
2878 if (!(propertyInfo == null))
2879 {
2881 }
2882 propertyInfo = propertyInfo2;
2883 }
2884 }
2885 return propertyInfo;
2886 }
2887
2889 {
2890 MethodInfo getMethod = pi.GetGetMethod(nonPublic: true);
2892 if (getMethod != null)
2893 {
2894 array = getMethod.GetParametersCached();
2895 }
2896 else
2897 {
2898 getMethod = pi.GetSetMethod(nonPublic: true);
2899 if (getMethod == null)
2900 {
2901 return false;
2902 }
2903 array = getMethod.GetParametersCached();
2904 if (array.Length == 0)
2905 {
2906 return false;
2907 }
2908 array = array.RemoveLast();
2909 }
2910 if (args == null)
2911 {
2912 return array.Length == 0;
2913 }
2914 if (array.Length != args.Length)
2915 {
2916 return false;
2917 }
2918 for (int i = 0; i < args.Length; i++)
2919 {
2920 if (args[i] == null)
2921 {
2922 return false;
2923 }
2924 if (!TypeUtils.AreReferenceAssignable(array[i].ParameterType, args[i].Type))
2925 {
2926 return false;
2927 }
2928 }
2929 return true;
2930 }
2931
2936
2938 {
2939 return MakeIndexProperty(instance, indexer, "indexer", arguments.ToReadOnly());
2940 }
2941
2947
2949 {
2951 if (indexer.PropertyType.IsByRef)
2952 {
2954 }
2955 if (indexer.PropertyType == typeof(void))
2956 {
2958 }
2959 ParameterInfo[] array = null;
2960 MethodInfo getMethod = indexer.GetGetMethod(nonPublic: true);
2961 if (getMethod != null)
2962 {
2963 if (getMethod.ReturnType != indexer.PropertyType)
2964 {
2966 }
2967 array = getMethod.GetParametersCached();
2969 }
2970 MethodInfo setMethod = indexer.GetSetMethod(nonPublic: true);
2971 if (setMethod != null)
2972 {
2973 ParameterInfo[] parametersCached = setMethod.GetParametersCached();
2974 if (parametersCached.Length == 0)
2975 {
2977 }
2978 Type parameterType = parametersCached[^1].ParameterType;
2979 if (parameterType.IsByRef)
2980 {
2982 }
2983 if (setMethod.ReturnType != typeof(void))
2984 {
2986 }
2987 if (indexer.PropertyType != parameterType)
2988 {
2990 }
2991 if (getMethod != null)
2992 {
2993 if (getMethod.IsStatic ^ setMethod.IsStatic)
2994 {
2996 }
2997 if (array.Length != parametersCached.Length - 1)
2998 {
3000 }
3001 for (int i = 0; i < array.Length; i++)
3002 {
3003 if (array[i].ParameterType != parametersCached[i].ParameterType)
3004 {
3006 }
3007 }
3008 }
3009 else
3010 {
3012 }
3013 }
3014 else if (getMethod == null)
3015 {
3017 }
3018 }
3019
3021 {
3023 ValidateMethodInfo(method, "method");
3024 if ((method.CallingConvention & CallingConventions.VarArgs) != 0)
3025 {
3027 }
3028 if (method.IsStatic)
3029 {
3030 if (instance != null)
3031 {
3033 }
3034 }
3035 else
3036 {
3037 if (instance == null)
3038 {
3040 }
3041 ExpressionUtils.RequiresCanRead(instance, "instance");
3042 ValidateCallInstanceType(instance.Type, method);
3043 }
3045 }
3046
3048 {
3049 if (indexes.Length != 0)
3050 {
3051 if (indexes.Length != arguments.Count)
3052 {
3054 }
3055 Expression[] array = null;
3056 int i = 0;
3057 for (int num = indexes.Length; i < num; i++)
3058 {
3061 ExpressionUtils.RequiresCanRead(argument, "arguments", i);
3062 Type parameterType = parameterInfo.ParameterType;
3063 if (parameterType.IsByRef)
3064 {
3065 throw Error.AccessorsCannotHaveByRefArgs("indexes", i);
3066 }
3067 TypeUtils.ValidateType(parameterType, "indexes", i);
3069 {
3071 }
3072 if (array == null && argument != arguments[i])
3073 {
3075 for (int j = 0; j < i; j++)
3076 {
3077 array[j] = arguments[j];
3078 }
3079 }
3080 if (array != null)
3081 {
3082 array[i] = argument;
3083 }
3084 }
3085 if (array != null)
3086 {
3088 }
3089 }
3090 else if (arguments.Count > 0)
3091 {
3093 }
3094 }
3095
3104
3114
3125
3137
3150
3164
3169
3171 {
3173 switch (readOnlyList.Count)
3174 {
3175 case 0:
3176 return Invoke(expression);
3177 case 1:
3178 return Invoke(expression, readOnlyList[0]);
3179 case 2:
3181 case 3:
3183 case 4:
3185 case 5:
3187 default:
3188 {
3194 }
3195 }
3196 }
3197
3199 {
3201 if (!expression.Type.IsSubclassOf(typeof(MulticastDelegate)))
3202 {
3204 if (type == null)
3205 {
3206 throw Error.ExpressionTypeNotInvocable(expression.Type, "expression");
3207 }
3208 delegateType = type.GetGenericArguments()[0];
3209 }
3210 return delegateType.GetInvokeMethod();
3211 }
3212
3213 public static LabelExpression Label(LabelTarget target)
3214 {
3215 return Label(target, null);
3216 }
3217
3219 {
3220 ValidateGoto(target, ref defaultValue, "target", "defaultValue", null);
3221 return new LabelExpression(target, defaultValue);
3222 }
3223
3224 public static LabelTarget Label()
3225 {
3226 return Label(typeof(void), null);
3227 }
3228
3229 public static LabelTarget Label(string? name)
3230 {
3231 return Label(typeof(void), name);
3232 }
3233
3235 {
3236 return Label(type, null);
3237 }
3238
3239 public static LabelTarget Label(Type type, string? name)
3240 {
3242 TypeUtils.ValidateType(type, "type");
3243 return new LabelTarget(type, name);
3244 }
3245
3264
3266 {
3267 return Expression.Lambda<TDelegate>(body, tailCall: false, (IEnumerable<ParameterExpression>?)parameters);
3268 }
3269
3271 {
3273 }
3274
3276 {
3277 return Lambda<TDelegate>(body, null, tailCall: false, parameters);
3278 }
3279
3281 {
3282 return Lambda<TDelegate>(body, null, tailCall, parameters);
3283 }
3284
3286 {
3287 return Lambda<TDelegate>(body, name, tailCall: false, parameters);
3288 }
3289
3291 {
3292 ReadOnlyCollection<ParameterExpression> parameters2 = parameters.ToReadOnly();
3293 ValidateLambdaArgs(typeof(TDelegate), ref body, parameters2, "TDelegate");
3294 return Expression<TDelegate>.Create(body, name, tailCall, parameters2);
3295 }
3296
3298 {
3299 return Lambda(body, tailCall: false, (IEnumerable<ParameterExpression>?)parameters);
3300 }
3301
3302 public static LambdaExpression Lambda(Expression body, bool tailCall, params ParameterExpression[]? parameters)
3303 {
3304 return Lambda(body, tailCall, (IEnumerable<ParameterExpression>?)parameters);
3305 }
3306
3308 {
3309 return Lambda(body, null, tailCall: false, parameters);
3310 }
3311
3313 {
3314 return Lambda(body, null, tailCall, parameters);
3315 }
3316
3318 {
3319 return Lambda(delegateType, body, null, tailCall: false, parameters);
3320 }
3321
3323 {
3324 return Lambda(delegateType, body, null, tailCall, parameters);
3325 }
3326
3328 {
3329 return Lambda(delegateType, body, null, tailCall: false, parameters);
3330 }
3331
3333 {
3334 return Lambda(delegateType, body, null, tailCall, parameters);
3335 }
3336
3337 public static LambdaExpression Lambda(Expression body, string? name, IEnumerable<ParameterExpression>? parameters)
3338 {
3339 return Lambda(body, name, tailCall: false, parameters);
3340 }
3341
3342 public static LambdaExpression Lambda(Expression body, string? name, bool tailCall, IEnumerable<ParameterExpression>? parameters)
3343 {
3344 ContractUtils.RequiresNotNull(body, "body");
3347 Type[] array = new Type[count + 1];
3348 if (count > 0)
3349 {
3351 for (int i = 0; i < count; i++)
3352 {
3355 array[i] = (parameterExpression.IsByRef ? parameterExpression.Type.MakeByRefType() : parameterExpression.Type);
3357 {
3358 throw Error.DuplicateVariable(parameterExpression, "parameters", i);
3359 }
3360 }
3361 }
3362 array[count] = body.Type;
3365 }
3366
3368 {
3369 ReadOnlyCollection<ParameterExpression> parameters2 = parameters.ToReadOnly();
3370 ValidateLambdaArgs(delegateType, ref body, parameters2, "delegateType");
3371 return CreateLambda(delegateType, body, name, tailCall: false, parameters2);
3372 }
3373
3375 {
3376 ReadOnlyCollection<ParameterExpression> parameters2 = parameters.ToReadOnly();
3377 ValidateLambdaArgs(delegateType, ref body, parameters2, "delegateType");
3378 return CreateLambda(delegateType, body, name, tailCall, parameters2);
3379 }
3380
3382 {
3384 ExpressionUtils.RequiresCanRead(body, "body");
3386 {
3388 }
3389 TypeUtils.ValidateType(delegateType, "delegateType", allowByRef: true, allowPointer: true);
3392 {
3393 value = delegateType.GetInvokeMethod();
3394 if (!delegateType.IsCollectible)
3395 {
3397 }
3398 }
3399 ParameterInfo[] parametersCached = value.GetParametersCached();
3400 if (parametersCached.Length != 0)
3401 {
3402 if (parametersCached.Length != parameters.Count)
3403 {
3405 }
3407 int i = 0;
3408 for (int num = parametersCached.Length; i < num; i++)
3409 {
3413 Type type = parameterInfo.ParameterType;
3414 if (parameterExpression.IsByRef)
3415 {
3416 if (!type.IsByRef)
3417 {
3419 }
3420 type = type.GetElementType();
3421 }
3423 {
3425 }
3427 {
3428 throw Error.DuplicateVariable(parameterExpression, "parameters", i);
3429 }
3430 }
3431 }
3432 else if (parameters.Count > 0)
3433 {
3435 }
3436 if (value.ReturnType != typeof(void) && !TypeUtils.AreReferenceAssignable(value.ReturnType, body.Type) && !TryQuote(value.ReturnType, ref body))
3437 {
3438 throw Error.ExpressionTypeDoesNotMatchReturn(body.Type, value.ReturnType);
3439 }
3440 }
3441
3443 {
3444 if (typeArgs == null)
3445 {
3446 return TryGetFuncActionArgsResult.ArgumentNull;
3447 }
3448 foreach (Type type in typeArgs)
3449 {
3450 if (type == null)
3451 {
3452 return TryGetFuncActionArgsResult.ArgumentNull;
3453 }
3454 if (type.IsByRef)
3455 {
3456 return TryGetFuncActionArgsResult.ByRef;
3457 }
3458 if (type == typeof(void) || type.IsPointer)
3459 {
3460 return TryGetFuncActionArgsResult.PointerOrVoid;
3461 }
3462 }
3463 return TryGetFuncActionArgsResult.Valid;
3464 }
3465
3467 {
3469 {
3470 case TryGetFuncActionArgsResult.ArgumentNull:
3471 throw new ArgumentNullException("typeArgs");
3472 case TryGetFuncActionArgsResult.ByRef:
3473 throw Error.TypeMustNotBeByRef("typeArgs");
3474 default:
3475 {
3477 if (funcType == null)
3478 {
3479 throw Error.IncorrectNumberOfTypeArgsForFunc("typeArgs");
3480 }
3481 return funcType;
3482 }
3483 }
3484 }
3485
3486 public static bool TryGetFuncType(Type[] typeArgs, [NotNullWhen(true)] out Type? funcType)
3487 {
3489 {
3491 }
3492 funcType = null;
3493 return false;
3494 }
3495
3497 {
3499 {
3500 case TryGetFuncActionArgsResult.ArgumentNull:
3501 throw new ArgumentNullException("typeArgs");
3502 case TryGetFuncActionArgsResult.ByRef:
3503 throw Error.TypeMustNotBeByRef("typeArgs");
3504 default:
3505 {
3507 if (actionType == null)
3508 {
3509 throw Error.IncorrectNumberOfTypeArgsForAction("typeArgs");
3510 }
3511 return actionType;
3512 }
3513 }
3514 }
3515
3517 {
3519 {
3521 }
3522 actionType = null;
3523 return false;
3524 }
3525
3527 {
3528 ContractUtils.RequiresNotEmpty(typeArgs, "typeArgs");
3529 ContractUtils.RequiresNotNullItems(typeArgs, "typeArgs");
3531 }
3532
3533 [RequiresUnreferencedCode("Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.")]
3538
3539 [RequiresUnreferencedCode("Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.")]
3552
3553 [RequiresUnreferencedCode("Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.")]
3558
3559 [RequiresUnreferencedCode("Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.")]
3576
3581
3590
3591 public static LoopExpression Loop(Expression body)
3592 {
3593 return Loop(body, null);
3594 }
3595
3596 public static LoopExpression Loop(Expression body, LabelTarget? @break)
3597 {
3598 return Loop(body, @break, null);
3599 }
3600
3601 public static LoopExpression Loop(Expression body, LabelTarget? @break, LabelTarget? @continue)
3602 {
3603 ExpressionUtils.RequiresCanRead(body, "body");
3604 if (@continue != null && @continue.Type != typeof(void))
3605 {
3606 throw Error.LabelTypeMustBeVoid("continue");
3607 }
3608 return new LoopExpression(body, @break, @continue);
3609 }
3610
3612 {
3613 ContractUtils.RequiresNotNull(member, "member");
3616 if (!memberType.IsAssignableFrom(expression.Type))
3617 {
3619 }
3620 return new MemberAssignment(member, expression);
3621 }
3622
3623 [RequiresUnreferencedCode("The Property metadata or other accessor may be trimmed.")]
3625 {
3626 ContractUtils.RequiresNotNull(propertyAccessor, "propertyAccessor");
3628 ValidateMethodInfo(propertyAccessor, "propertyAccessor");
3629 return Bind(GetProperty(propertyAccessor, "propertyAccessor"), expression);
3630 }
3631
3633 {
3635 if (declaringType == null)
3636 {
3637 throw Error.NotAMemberOfAnyType(member, "member");
3638 }
3640 if (!(member is PropertyInfo propertyInfo))
3641 {
3642 if (!(member is FieldInfo fieldInfo))
3643 {
3645 }
3646 memberType = fieldInfo.FieldType;
3647 }
3648 else
3649 {
3650 if (!propertyInfo.CanWrite)
3651 {
3652 throw Error.PropertyDoesNotHaveSetter(propertyInfo, "member");
3653 }
3654 memberType = propertyInfo.PropertyType;
3655 }
3656 }
3657
3659 {
3661 if (field.IsStatic)
3662 {
3663 if (expression != null)
3664 {
3665 throw Error.OnlyStaticFieldsHaveNullInstance("expression");
3666 }
3667 }
3668 else
3669 {
3670 if (expression == null)
3671 {
3673 }
3675 if (!TypeUtils.AreReferenceAssignable(field.DeclaringType, expression.Type))
3676 {
3677 throw Error.FieldInfoNotDefinedForType(field.DeclaringType, field.Name, expression.Type);
3678 }
3679 }
3681 }
3682
3683 [RequiresUnreferencedCode("Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.")]
3685 {
3688 FieldInfo fieldInfo = expression.Type.GetField(fieldName, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy) ?? expression.Type.GetField(fieldName, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
3689 if (fieldInfo == null)
3690 {
3692 }
3693 return Field(expression, fieldInfo);
3694 }
3695
3697 {
3700 FieldInfo fieldInfo = type.GetField(fieldName, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy) ?? type.GetField(fieldName, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
3701 if (fieldInfo == null)
3702 {
3704 }
3705 return Field(expression, fieldInfo);
3706 }
3707
3708 [RequiresUnreferencedCode("Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.")]
3710 {
3713 PropertyInfo propertyInfo = expression.Type.GetProperty(propertyName, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy) ?? expression.Type.GetProperty(propertyName, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
3714 if (propertyInfo == null)
3715 {
3717 }
3718 return Property(expression, propertyInfo);
3719 }
3720
3722 {
3725 PropertyInfo propertyInfo = type.GetProperty(propertyName, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy) ?? type.GetProperty(propertyName, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
3726 if (propertyInfo == null)
3727 {
3728 throw Error.PropertyNotDefinedForType(propertyName, type, "propertyName");
3729 }
3730 return Property(expression, propertyInfo);
3731 }
3732
3734 {
3736 MethodInfo methodInfo = property.GetGetMethod(nonPublic: true);
3737 if (methodInfo == null)
3738 {
3739 methodInfo = property.GetSetMethod(nonPublic: true);
3740 if (methodInfo == null)
3741 {
3742 throw Error.PropertyDoesNotHaveAccessor(property, "property");
3743 }
3744 if (methodInfo.GetParametersCached().Length != 1)
3745 {
3747 }
3748 }
3749 else if (methodInfo.GetParametersCached().Length != 0)
3750 {
3752 }
3753 if (methodInfo.IsStatic)
3754 {
3755 if (expression != null)
3756 {
3757 throw Error.OnlyStaticPropertiesHaveNullInstance("expression");
3758 }
3759 }
3760 else
3761 {
3762 if (expression == null)
3763 {
3765 }
3768 {
3769 throw Error.PropertyNotDefinedForType(property, expression.Type, "property");
3770 }
3771 }
3772 ValidateMethodInfo(methodInfo, "property");
3774 }
3775
3776 [RequiresUnreferencedCode("The Property metadata or other accessor may be trimmed.")]
3778 {
3779 ContractUtils.RequiresNotNull(propertyAccessor, "propertyAccessor");
3780 ValidateMethodInfo(propertyAccessor, "propertyAccessor");
3781 return Property(expression, GetProperty(propertyAccessor, "propertyAccessor"));
3782 }
3783
3784 [RequiresUnreferencedCode("The Property metadata or other accessor may be trimmed.")]
3785 private static PropertyInfo GetProperty(MethodInfo mi, string paramName, int index = -1)
3786 {
3787 Type declaringType = mi.DeclaringType;
3788 if (declaringType != null)
3789 {
3790 BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.NonPublic;
3791 bindingFlags |= (mi.IsStatic ? BindingFlags.Static : BindingFlags.Instance);
3792 PropertyInfo[] properties = declaringType.GetProperties(bindingFlags);
3793 PropertyInfo[] array = properties;
3794 foreach (PropertyInfo propertyInfo in array)
3795 {
3796 if (propertyInfo.CanRead && CheckMethod(mi, propertyInfo.GetGetMethod(nonPublic: true)))
3797 {
3798 return propertyInfo;
3799 }
3800 if (propertyInfo.CanWrite && CheckMethod(mi, propertyInfo.GetSetMethod(nonPublic: true)))
3801 {
3802 return propertyInfo;
3803 }
3804 }
3805 }
3806 throw Error.MethodNotPropertyAccessor(mi.DeclaringType, mi.Name, paramName, index);
3807 }
3808
3809 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2075:UnrecognizedReflectionPattern", Justification = "Since the methods are already supplied, they won't be trimmed. Just checking for method equality.")]
3811 {
3812 if (method.Equals(propertyMethod))
3813 {
3814 return true;
3815 }
3816 Type declaringType = method.DeclaringType;
3817 if (declaringType.IsInterface && method.Name == propertyMethod.Name && declaringType.GetMethod(method.Name) == propertyMethod)
3818 {
3819 return true;
3820 }
3821 return false;
3822 }
3823
3824 [RequiresUnreferencedCode("Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.")]
3826 {
3828 PropertyInfo property = expression.Type.GetProperty(propertyOrFieldName, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy);
3829 if (property != null)
3830 {
3831 return Property(expression, property);
3832 }
3833 FieldInfo field = expression.Type.GetField(propertyOrFieldName, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy);
3834 if (field != null)
3835 {
3836 return Field(expression, field);
3837 }
3838 property = expression.Type.GetProperty(propertyOrFieldName, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
3839 if (property != null)
3840 {
3841 return Property(expression, property);
3842 }
3843 field = expression.Type.GetField(propertyOrFieldName, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
3844 if (field != null)
3845 {
3846 return Field(expression, field);
3847 }
3848 throw Error.NotAMemberOfType(propertyOrFieldName, expression.Type, "propertyOrFieldName");
3849 }
3850
3852 {
3853 ContractUtils.RequiresNotNull(member, "member");
3854 if (member is FieldInfo field)
3855 {
3856 return Field(expression, field);
3857 }
3858 if (member is PropertyInfo property)
3859 {
3860 return Property(expression, property);
3861 }
3862 throw Error.MemberNotFieldOrProperty(member, "member");
3863 }
3864
3869
3878
3883
3893
3894 [RequiresUnreferencedCode("The Property metadata or other accessor may be trimmed.")]
3899
3900 [RequiresUnreferencedCode("The Property metadata or other accessor may be trimmed.")]
3907
3909 {
3910 if (!typeof(IEnumerable).IsAssignableFrom(listType))
3911 {
3913 }
3914 int i = 0;
3915 for (int count = initializers.Count; i < count; i++)
3916 {
3918 ContractUtils.RequiresNotNull(elementInit, "initializers", i);
3920 }
3921 }
3922
3924 {
3925 return MemberBind(member, (IEnumerable<MemberBinding>)bindings);
3926 }
3927
3929 {
3930 ContractUtils.RequiresNotNull(member, "member");
3931 ContractUtils.RequiresNotNull(bindings, "bindings");
3932 ReadOnlyCollection<MemberBinding> bindings2 = bindings.ToReadOnly();
3935 return new MemberMemberBinding(member, bindings2);
3936 }
3937
3938 [RequiresUnreferencedCode("The Property metadata or other accessor may be trimmed.")]
3943
3944 [RequiresUnreferencedCode("The Property metadata or other accessor may be trimmed.")]
3946 {
3947 ContractUtils.RequiresNotNull(propertyAccessor, "propertyAccessor");
3948 return MemberBind(GetProperty(propertyAccessor, "propertyAccessor"), bindings);
3949 }
3950
3952 {
3954 if (declaringType == null)
3955 {
3956 throw Error.NotAMemberOfAnyType(member, "member");
3957 }
3959 if (!(member is PropertyInfo propertyInfo))
3960 {
3961 if (!(member is FieldInfo fieldInfo))
3962 {
3964 }
3965 memberType = fieldInfo.FieldType;
3966 }
3967 else
3968 {
3969 if (!propertyInfo.CanRead)
3970 {
3971 throw Error.PropertyDoesNotHaveGetter(propertyInfo, "member");
3972 }
3973 memberType = propertyInfo.PropertyType;
3974 }
3975 }
3976
3978 {
3979 int i = 0;
3980 for (int count = bindings.Count; i < count; i++)
3981 {
3982 MemberBinding memberBinding = bindings[i];
3984 memberBinding.ValidateAsDefinedHere(i);
3985 if (!memberBinding.Member.DeclaringType.IsAssignableFrom(type))
3986 {
3987 throw Error.NotAMemberOfType(memberBinding.Member.Name, type, "bindings", i);
3988 }
3989 }
3990 }
3991
3999
4009
4021
4035
4051
4069
4071 {
4072 return Call(null, method, arguments);
4073 }
4074
4079
4081 {
4085 if (instance != null)
4086 {
4087 return new InstanceMethodCallExpression0(method, instance);
4088 }
4089 return new MethodCallExpression0(method);
4090 }
4091
4093 {
4094 return Call(instance, method, (IEnumerable<Expression>?)arguments);
4095 }
4096
4098 {
4103 arg0 = ValidateOneArgument(method, ExpressionType.Call, arg0, array[0], "method", "arg0");
4104 if (instance != null)
4105 {
4106 return new InstanceMethodCallExpression1(method, instance, arg0);
4107 }
4108 return new MethodCallExpression1(method, arg0);
4109 }
4110
4112 {
4118 arg0 = ValidateOneArgument(method, ExpressionType.Call, arg0, array[0], "method", "arg0");
4119 arg1 = ValidateOneArgument(method, ExpressionType.Call, arg1, array[1], "method", "arg1");
4120 if (instance != null)
4121 {
4122 return new InstanceMethodCallExpression2(method, instance, arg0, arg1);
4123 }
4124 return new MethodCallExpression2(method, arg0, arg1);
4125 }
4126
4128 {
4135 arg0 = ValidateOneArgument(method, ExpressionType.Call, arg0, array[0], "method", "arg0");
4136 arg1 = ValidateOneArgument(method, ExpressionType.Call, arg1, array[1], "method", "arg1");
4137 arg2 = ValidateOneArgument(method, ExpressionType.Call, arg2, array[2], "method", "arg2");
4138 if (instance != null)
4139 {
4140 return new InstanceMethodCallExpression3(method, instance, arg0, arg1, arg2);
4141 }
4142 return new MethodCallExpression3(method, arg0, arg1, arg2);
4143 }
4144
4145 [RequiresUnreferencedCode("Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.")]
4147 {
4148 ContractUtils.RequiresNotNull(instance, "instance");
4150 if (arguments == null)
4151 {
4152 arguments = Array.Empty<Expression>();
4153 }
4154 BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy;
4155 return Call(instance, FindMethod(instance.Type, methodName, typeArguments, arguments, flags), arguments);
4156 }
4157
4158 [RequiresUnreferencedCode("Calling a generic method cannot be statically analyzed. It's not possible to guarantee the availability of requirements of the generic method. This can be suppressed if the method is not generic.")]
4160 {
4163 if (arguments == null)
4164 {
4165 arguments = Array.Empty<Expression>();
4166 }
4167 BindingFlags flags = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy;
4169 }
4170
4172 {
4174 int count = readOnlyList.Count;
4175 switch (count)
4176 {
4177 case 0:
4178 return Call(instance, method);
4179 case 1:
4180 return Call(instance, method, readOnlyList[0]);
4181 case 2:
4182 return Call(instance, method, readOnlyList[0], readOnlyList[1]);
4183 case 3:
4184 return Call(instance, method, readOnlyList[0], readOnlyList[1], readOnlyList[2]);
4185 default:
4186 {
4187 if (instance == null)
4188 {
4189 switch (count)
4190 {
4191 case 4:
4193 case 5:
4195 }
4196 }
4199 ValidateMethodInfo(method, "method");
4202 if (instance == null)
4203 {
4205 }
4206 return new InstanceMethodCallExpressionN(method, instance, arguments2);
4207 }
4208 }
4209 }
4210
4217
4219 {
4220 if (method.IsStatic)
4221 {
4222 if (instance != null)
4223 {
4225 }
4226 return;
4227 }
4228 if (instance == null)
4229 {
4231 }
4232 ExpressionUtils.RequiresCanRead(instance, "instance");
4233 ValidateCallInstanceType(instance.Type, method);
4234 }
4235
4243
4248
4253
4258
4263
4268
4269 [RequiresUnreferencedCode("Calling a generic method cannot be statically analyzed. It's not possible to guarantee the availability of requirements of the generic method. This can be suppressed if the method is not generic.")]
4271 {
4272 int num = 0;
4273 MethodInfo methodInfo = null;
4274 MethodInfo[] methods = type.GetMethods(flags);
4275 foreach (MethodInfo methodInfo2 in methods)
4276 {
4277 if (!methodInfo2.Name.Equals(methodName, StringComparison.OrdinalIgnoreCase))
4278 {
4279 continue;
4280 }
4282 if (methodInfo3 != null && IsCompatible(methodInfo3, args))
4283 {
4284 if (methodInfo == null || (!methodInfo.IsPublic && methodInfo3.IsPublic))
4285 {
4287 num = 1;
4288 }
4289 else if (methodInfo.IsPublic == methodInfo3.IsPublic)
4290 {
4291 num++;
4292 }
4293 }
4294 }
4295 if (num == 0)
4296 {
4297 if (typeArgs != null && typeArgs.Length != 0)
4298 {
4300 }
4302 }
4303 if (num > 1)
4304 {
4306 }
4307 return methodInfo;
4308 }
4309
4311 {
4312 ParameterInfo[] parametersCached = m.GetParametersCached();
4313 if (parametersCached.Length != arguments.Length)
4314 {
4315 return false;
4316 }
4317 for (int i = 0; i < arguments.Length; i++)
4318 {
4321 Type type = expression.Type;
4322 Type type2 = parametersCached[i].ParameterType;
4323 if (type2.IsByRef)
4324 {
4325 type2 = type2.GetElementType();
4326 }
4328 {
4329 return false;
4330 }
4331 }
4332 return true;
4333 }
4334
4335 [RequiresUnreferencedCode("Calling a generic method cannot be statically analyzed. It's not possible to guarantee the availability of requirements of the generic method. This can be suppressed if the method is not generic.")]
4337 {
4338 if (typeArgs == null || typeArgs.Length == 0)
4339 {
4340 if (!m.IsGenericMethodDefinition)
4341 {
4342 return m;
4343 }
4344 }
4345 else if (m.IsGenericMethodDefinition && m.GetGenericArguments().Length == typeArgs.Length)
4346 {
4347 return m.MakeGenericMethod(typeArgs);
4348 }
4349 return null;
4350 }
4351
4356
4358 {
4361 Type type = array.Type;
4362 if (!type.IsArray)
4363 {
4364 throw Error.ArgumentMustBeArray("array");
4365 }
4367 if (type.GetArrayRank() != readOnlyCollection.Count)
4368 {
4370 }
4371 int i = 0;
4372 for (int count = readOnlyCollection.Count; i < count; i++)
4373 {
4376 if (expression.Type != typeof(int))
4377 {
4378 throw Error.ArgumentMustBeArrayIndexType("indexes", i);
4379 }
4380 }
4383 }
4384
4389
4391 {
4394 if (type == typeof(void))
4395 {
4396 throw Error.ArgumentCannotBeOfTypeVoid("type");
4397 }
4398 TypeUtils.ValidateType(type, "type");
4400 Expression[] array = null;
4401 int i = 0;
4402 for (int count = readOnlyCollection.Count; i < count; i++)
4403 {
4405 ExpressionUtils.RequiresCanRead(argument, "initializers", i);
4407 {
4408 if (!TryQuote(type, ref argument))
4409 {
4411 }
4412 if (array == null)
4413 {
4415 for (int j = 0; j < i; j++)
4416 {
4418 }
4419 }
4420 }
4421 if (array != null)
4422 {
4423 array[i] = argument;
4424 }
4425 }
4426 if (array != null)
4427 {
4429 }
4430 return NewArrayExpression.Make(ExpressionType.NewArrayInit, type.MakeArrayType(), readOnlyCollection);
4431 }
4432
4437
4439 {
4442 if (type == typeof(void))
4443 {
4444 throw Error.ArgumentCannotBeOfTypeVoid("type");
4445 }
4446 TypeUtils.ValidateType(type, "type");
4449 if (count <= 0)
4450 {
4451 throw Error.BoundsCannotBeLessThanOne("bounds");
4452 }
4453 for (int i = 0; i < count; i++)
4454 {
4457 if (!expression.Type.IsInteger())
4458 {
4459 throw Error.ArgumentMustBeInteger("bounds", i);
4460 }
4461 }
4462 Type type2 = ((count != 1) ? type.MakeArrayType(count) : type.MakeArrayType());
4464 }
4465
4467 {
4468 return New(constructor, (IEnumerable<Expression>?)null);
4469 }
4470
4475
4477 {
4479 ContractUtils.RequiresNotNull(constructor.DeclaringType, "constructor.DeclaringType");
4480 TypeUtils.ValidateType(constructor.DeclaringType, "constructor", allowByRef: true, allowPointer: true);
4481 ValidateConstructor(constructor, "constructor");
4484 return new NewExpression(constructor, arguments2, null);
4485 }
4486
4487 [RequiresUnreferencedCode("The Property metadata or other accessor may be trimmed.")]
4499
4500 [RequiresUnreferencedCode("The Property metadata or other accessor may be trimmed.")]
4505
4507 {
4509 if (type == typeof(void))
4510 {
4511 throw Error.ArgumentCannotBeOfTypeVoid("type");
4512 }
4513 TypeUtils.ValidateType(type, "type");
4514 ConstructorInfo constructorInfo = type.GetConstructors(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).SingleOrDefault((ConstructorInfo c) => c.GetParametersCached().Length == 0);
4515 if (constructorInfo != null)
4516 {
4517 return New(constructorInfo);
4518 }
4519 if (!type.IsValueType)
4520 {
4522 }
4524 }
4525
4526 [RequiresUnreferencedCode("The Property metadata or other accessor may be trimmed.")]
4528 {
4530 if ((parametersCached = constructor.GetParametersCached()).Length != 0)
4531 {
4532 if (arguments.Count != parametersCached.Length)
4533 {
4535 }
4537 {
4539 }
4540 Expression[] array = null;
4541 MemberInfo[] array2 = null;
4542 int i = 0;
4543 for (int count = arguments.Count; i < count; i++)
4544 {
4546 ExpressionUtils.RequiresCanRead(argument, "arguments", i);
4547 MemberInfo member = members[i];
4548 ContractUtils.RequiresNotNull(member, "members", i);
4549 if (!TypeUtils.AreEquivalent(member.DeclaringType, constructor.DeclaringType))
4550 {
4551 throw Error.ArgumentMemberNotDeclOnType(member.Name, constructor.DeclaringType.Name, "members", i);
4552 }
4553 ValidateAnonymousTypeMember(ref member, out var memberType, "members", i);
4555 {
4556 throw Error.ArgumentTypeDoesNotMatchMember(argument.Type, memberType, "arguments", i);
4557 }
4559 Type type = parameterInfo.ParameterType;
4560 if (type.IsByRef)
4561 {
4562 type = type.GetElementType();
4563 }
4565 {
4567 }
4568 if (array == null && argument != arguments[i])
4569 {
4571 for (int j = 0; j < i; j++)
4572 {
4573 array[j] = arguments[j];
4574 }
4575 }
4576 if (array != null)
4577 {
4578 array[i] = argument;
4579 }
4580 if (array2 == null && member != members[i])
4581 {
4583 for (int k = 0; k < i; k++)
4584 {
4585 array2[k] = members[k];
4586 }
4587 }
4588 if (array2 != null)
4589 {
4590 array2[i] = member;
4591 }
4592 }
4593 if (array != null)
4594 {
4596 }
4597 if (array2 != null)
4598 {
4600 }
4601 }
4602 else
4603 {
4604 if (arguments != null && arguments.Count > 0)
4605 {
4607 }
4608 if (members != null && members.Count > 0)
4609 {
4611 }
4612 }
4613 }
4614
4615 [RequiresUnreferencedCode("The Property metadata or other accessor may be trimmed.")]
4617 {
4618 if (member is FieldInfo fieldInfo)
4619 {
4620 if (fieldInfo.IsStatic)
4621 {
4623 }
4624 memberType = fieldInfo.FieldType;
4625 }
4626 else if (member is PropertyInfo propertyInfo)
4627 {
4628 if (!propertyInfo.CanRead)
4629 {
4630 throw Error.PropertyDoesNotHaveGetter(propertyInfo, paramName, index);
4631 }
4632 if (propertyInfo.GetGetMethod().IsStatic)
4633 {
4635 }
4636 memberType = propertyInfo.PropertyType;
4637 }
4638 else
4639 {
4640 if (!(member is MethodInfo methodInfo))
4641 {
4643 }
4644 if (methodInfo.IsStatic)
4645 {
4647 }
4648 memberType = ((PropertyInfo)(member = GetProperty(methodInfo, paramName, index))).PropertyType;
4649 }
4650 }
4651
4653 {
4654 if (constructor.IsStatic)
4655 {
4657 }
4658 }
4659
4661 {
4662 return Parameter(type, null);
4663 }
4664
4666 {
4667 return Variable(type, null);
4668 }
4669
4670 public static ParameterExpression Parameter(Type type, string? name)
4671 {
4672 Validate(type, allowByRef: true);
4673 bool isByRef = type.IsByRef;
4674 if (isByRef)
4675 {
4676 type = type.GetElementType();
4677 }
4678 return ParameterExpression.Make(type, name, isByRef);
4679 }
4680
4681 public static ParameterExpression Variable(Type type, string? name)
4682 {
4683 Validate(type, allowByRef: false);
4684 return ParameterExpression.Make(type, name, isByRef: false);
4685 }
4686
4687 private static void Validate(Type type, bool allowByRef)
4688 {
4691 if (type == typeof(void))
4692 {
4693 throw Error.ArgumentCannotBeOfTypeVoid("type");
4694 }
4695 }
4696
4701
4712
4717
4719 {
4720 ExpressionUtils.RequiresCanRead(body, "body");
4722 ContractUtils.RequiresNotEmpty(readOnlyCollection, "testValues");
4723 RequiresCanRead(readOnlyCollection, "testValues");
4724 return new SwitchCase(body, readOnlyCollection);
4725 }
4726
4731
4736
4741
4746
4751
4753 {
4755 if (switchValue.Type == typeof(void))
4756 {
4757 throw Error.ArgumentCannotBeOfTypeVoid("switchValue");
4758 }
4760 ContractUtils.RequiresNotNullItems(readOnlyCollection, "cases");
4761 Type type2 = ((type != null) ? type : ((readOnlyCollection.Count != 0) ? readOnlyCollection[0].Body.Type : ((defaultBody == null) ? typeof(void) : defaultBody.Type)));
4762 bool customType = type != null;
4763 if (comparison != null)
4764 {
4765 ValidateMethodInfo(comparison, "comparison");
4766 ParameterInfo[] parametersCached = comparison.GetParametersCached();
4767 if (parametersCached.Length != 2)
4768 {
4770 }
4772 bool flag = false;
4774 {
4775 flag = ParameterIsAssignable(parameterInfo, switchValue.Type.GetNonNullableType());
4776 if (!flag)
4777 {
4779 }
4780 }
4783 {
4786 int i = 0;
4787 for (int count = item.TestValues.Count; i < count; i++)
4788 {
4789 Type type3 = item.TestValues[i].Type;
4790 if (flag)
4791 {
4792 if (!type3.IsNullableType())
4793 {
4795 }
4796 type3 = type3.GetNonNullableType();
4797 }
4799 {
4801 }
4802 }
4803 }
4804 if (comparison.ReturnType != typeof(bool))
4805 {
4806 throw Error.EqualityMustReturnBoolean(comparison, "comparison");
4807 }
4808 }
4809 else if (readOnlyCollection.Count != 0)
4810 {
4811 Expression expression = readOnlyCollection[0].TestValues[0];
4813 {
4816 int j = 0;
4817 for (int count2 = item2.TestValues.Count; j < count2; j++)
4818 {
4819 if (!TypeUtils.AreEquivalent(expression.Type, item2.TestValues[j].Type))
4820 {
4821 throw Error.AllTestValuesMustHaveSameType("cases");
4822 }
4823 }
4824 }
4827 }
4828 if (defaultBody == null)
4829 {
4830 if (type2 != typeof(void))
4831 {
4832 throw Error.DefaultBodyMustBeSupplied("defaultBody");
4833 }
4834 }
4835 else
4836 {
4838 }
4840 }
4841
4843 {
4844 if (customType)
4845 {
4846 if (resultType != typeof(void) && !TypeUtils.AreReferenceAssignable(resultType, @case.Type))
4847 {
4849 }
4850 }
4851 else if (!TypeUtils.AreEquivalent(resultType, @case.Type))
4852 {
4854 }
4855 }
4856
4858 {
4859 return new SymbolDocumentInfo(fileName);
4860 }
4861
4863 {
4865 }
4866
4871
4876
4878 {
4879 return MakeTry(null, body, null, fault, null);
4880 }
4881
4882 public static TryExpression TryFinally(Expression body, Expression? @finally)
4883 {
4884 return MakeTry(null, body, @finally, null, null);
4885 }
4886
4888 {
4889 return MakeTry(null, body, null, null, handlers);
4890 }
4891
4893 {
4894 return MakeTry(null, body, @finally, null, handlers);
4895 }
4896
4898 {
4899 ExpressionUtils.RequiresCanRead(body, "body");
4901 ContractUtils.RequiresNotNullItems(readOnlyCollection, "handlers");
4903 if (fault != null)
4904 {
4905 if (@finally != null || readOnlyCollection.Count > 0)
4906 {
4907 throw Error.FaultCannotHaveCatchOrFinally("fault");
4908 }
4910 }
4911 else if (@finally != null)
4912 {
4913 ExpressionUtils.RequiresCanRead(@finally, "finally");
4914 }
4915 else if (readOnlyCollection.Count == 0)
4916 {
4918 }
4919 return new TryExpression(type ?? body.Type, body, @finally, fault, readOnlyCollection);
4920 }
4921
4923 {
4924 if (type != null)
4925 {
4926 if (!(type != typeof(void)))
4927 {
4928 return;
4929 }
4931 {
4933 }
4934 {
4935 foreach (CatchBlock handler in handlers)
4936 {
4938 {
4940 }
4941 }
4942 return;
4943 }
4944 }
4945 if (tryBody.Type == typeof(void))
4946 {
4947 foreach (CatchBlock handler2 in handlers)
4948 {
4949 if (handler2.Body.Type != typeof(void))
4950 {
4952 }
4953 }
4954 return;
4955 }
4956 type = tryBody.Type;
4957 foreach (CatchBlock handler3 in handlers)
4958 {
4959 if (!TypeUtils.AreEquivalent(handler3.Body.Type, type))
4960 {
4962 }
4963 }
4964 }
4965
4967 {
4970 if (type.IsByRef)
4971 {
4972 throw Error.TypeMustNotBeByRef("type");
4973 }
4975 }
4976
4978 {
4981 if (type.IsByRef)
4982 {
4983 throw Error.TypeMustNotBeByRef("type");
4984 }
4985 return new TypeBinaryExpression(expression, type, ExpressionType.TypeEqual);
4986 }
4987
4992
4994 {
4995 return unaryType switch
4996 {
4997 ExpressionType.Negate => Negate(operand, method),
4998 ExpressionType.NegateChecked => NegateChecked(operand, method),
4999 ExpressionType.Not => Not(operand, method),
5000 ExpressionType.IsFalse => IsFalse(operand, method),
5001 ExpressionType.IsTrue => IsTrue(operand, method),
5002 ExpressionType.OnesComplement => OnesComplement(operand, method),
5003 ExpressionType.ArrayLength => ArrayLength(operand),
5004 ExpressionType.Convert => Convert(operand, type, method),
5005 ExpressionType.ConvertChecked => ConvertChecked(operand, type, method),
5006 ExpressionType.Throw => Throw(operand, type),
5007 ExpressionType.TypeAs => TypeAs(operand, type),
5008 ExpressionType.Quote => Quote(operand),
5009 ExpressionType.UnaryPlus => UnaryPlus(operand, method),
5010 ExpressionType.Unbox => Unbox(operand, type),
5011 ExpressionType.Increment => Increment(operand, method),
5012 ExpressionType.Decrement => Decrement(operand, method),
5013 ExpressionType.PreIncrementAssign => PreIncrementAssign(operand, method),
5014 ExpressionType.PostIncrementAssign => PostIncrementAssign(operand, method),
5015 ExpressionType.PreDecrementAssign => PreDecrementAssign(operand, method),
5016 ExpressionType.PostDecrementAssign => PostDecrementAssign(operand, method),
5017 _ => throw Error.UnhandledUnary(unaryType, "unaryType"),
5018 };
5019 }
5020
5031
5032 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2072:UnrecognizedReflectionPattern", Justification = "The trimmer doesn't remove operators when System.Linq.Expressions is used. See https://github.com/mono/linker/pull/2125.")]
5034 {
5035 Type type = operand.Type;
5036 Type[] array = new Type[1] { type };
5037 Type nonNullableType = type.GetNonNullableType();
5038 MethodInfo anyStaticMethodValidated = nonNullableType.GetAnyStaticMethodValidated(name, array);
5039 if (anyStaticMethodValidated != null)
5040 {
5042 }
5043 if (type.IsNullableType())
5044 {
5046 anyStaticMethodValidated = nonNullableType.GetAnyStaticMethodValidated(name, array);
5047 if (anyStaticMethodValidated != null && anyStaticMethodValidated.ReturnType.IsValueType && !anyStaticMethodValidated.ReturnType.IsNullableType())
5048 {
5049 return new UnaryExpression(unaryType, operand, anyStaticMethodValidated.ReturnType.GetNullableType(), anyStaticMethodValidated);
5050 }
5051 }
5052 return null;
5053 }
5054
5056 {
5058 ParameterInfo[] parametersCached = method.GetParametersCached();
5059 if (parametersCached.Length != 1)
5060 {
5062 }
5064 {
5066 return new UnaryExpression(unaryType, operand, method.ReturnType, method);
5067 }
5068 if (operand.Type.IsNullableType() && ParameterIsAssignable(parametersCached[0], operand.Type.GetNonNullableType()) && method.ReturnType.IsValueType && !method.ReturnType.IsNullableType())
5069 {
5070 return new UnaryExpression(unaryType, operand, method.ReturnType.GetNullableType(), method);
5071 }
5073 }
5074
5084
5094
5096 {
5098 ParameterInfo[] parametersCached = method.GetParametersCached();
5099 if (parametersCached.Length != 1)
5100 {
5102 }
5104 {
5105 return new UnaryExpression(unaryType, operand, method.ReturnType, method);
5106 }
5107 if ((operand.Type.IsNullableType() || convertToType.IsNullableType()) && ParameterIsAssignable(parametersCached[0], operand.Type.GetNonNullableType()) && (TypeUtils.AreEquivalent(method.ReturnType, convertToType.GetNonNullableType()) || TypeUtils.AreEquivalent(method.ReturnType, convertToType)))
5108 {
5110 }
5112 }
5113
5115 {
5116 return Negate(expression, null);
5117 }
5118
5120 {
5122 if (method == null)
5123 {
5124 if (expression.Type.IsArithmetic() && !expression.Type.IsUnsignedInt())
5125 {
5126 return new UnaryExpression(ExpressionType.Negate, expression, expression.Type, null);
5127 }
5128 return GetUserDefinedUnaryOperatorOrThrow(ExpressionType.Negate, "op_UnaryNegation", expression);
5129 }
5131 }
5132
5134 {
5135 return UnaryPlus(expression, null);
5136 }
5137
5139 {
5141 if (method == null)
5142 {
5143 if (expression.Type.IsArithmetic())
5144 {
5145 return new UnaryExpression(ExpressionType.UnaryPlus, expression, expression.Type, null);
5146 }
5147 return GetUserDefinedUnaryOperatorOrThrow(ExpressionType.UnaryPlus, "op_UnaryPlus", expression);
5148 }
5150 }
5151
5153 {
5154 return NegateChecked(expression, null);
5155 }
5156
5158 {
5160 if (method == null)
5161 {
5162 if (expression.Type.IsArithmetic() && !expression.Type.IsUnsignedInt())
5163 {
5164 return new UnaryExpression(ExpressionType.NegateChecked, expression, expression.Type, null);
5165 }
5166 return GetUserDefinedUnaryOperatorOrThrow(ExpressionType.NegateChecked, "op_UnaryNegation", expression);
5167 }
5169 }
5170
5172 {
5173 return Not(expression, null);
5174 }
5175
5177 {
5179 if (method == null)
5180 {
5181 if (expression.Type.IsIntegerOrBool())
5182 {
5183 return new UnaryExpression(ExpressionType.Not, expression, expression.Type, null);
5184 }
5186 if (userDefinedUnaryOperator != null)
5187 {
5189 }
5190 return GetUserDefinedUnaryOperatorOrThrow(ExpressionType.Not, "op_OnesComplement", expression);
5191 }
5193 }
5194
5196 {
5197 return IsFalse(expression, null);
5198 }
5199
5201 {
5203 if (method == null)
5204 {
5205 if (expression.Type.IsBool())
5206 {
5207 return new UnaryExpression(ExpressionType.IsFalse, expression, expression.Type, null);
5208 }
5210 }
5212 }
5213
5215 {
5216 return IsTrue(expression, null);
5217 }
5218
5220 {
5222 if (method == null)
5223 {
5224 if (expression.Type.IsBool())
5225 {
5226 return new UnaryExpression(ExpressionType.IsTrue, expression, expression.Type, null);
5227 }
5229 }
5231 }
5232
5234 {
5235 return OnesComplement(expression, null);
5236 }
5237
5239 {
5241 if (method == null)
5242 {
5243 if (expression.Type.IsInteger())
5244 {
5245 return new UnaryExpression(ExpressionType.OnesComplement, expression, expression.Type, null);
5246 }
5247 return GetUserDefinedUnaryOperatorOrThrow(ExpressionType.OnesComplement, "op_OnesComplement", expression);
5248 }
5250 }
5251
5253 {
5256 TypeUtils.ValidateType(type, "type");
5257 if (type.IsValueType && !type.IsNullableType())
5258 {
5259 throw Error.IncorrectTypeForTypeAs(type, "type");
5260 }
5261 return new UnaryExpression(ExpressionType.TypeAs, expression, type, null);
5262 }
5263
5265 {
5268 if (!expression.Type.IsInterface && expression.Type != typeof(object))
5269 {
5270 throw Error.InvalidUnboxType("expression");
5271 }
5272 if (!type.IsValueType)
5273 {
5274 throw Error.InvalidUnboxType("type");
5275 }
5276 TypeUtils.ValidateType(type, "type");
5277 return new UnaryExpression(ExpressionType.Unbox, expression, type, null);
5278 }
5279
5281 {
5282 return Convert(expression, type, null);
5283 }
5284
5286 {
5289 TypeUtils.ValidateType(type, "type");
5290 if (method == null)
5291 {
5292 if (expression.Type.HasIdentityPrimitiveOrNullableConversionTo(type) || expression.Type.HasReferenceConversionTo(type))
5293 {
5294 return new UnaryExpression(ExpressionType.Convert, expression, type, null);
5295 }
5297 }
5299 }
5300
5302 {
5303 return ConvertChecked(expression, type, null);
5304 }
5305
5307 {
5310 TypeUtils.ValidateType(type, "type");
5311 if (method == null)
5312 {
5313 if (expression.Type.HasIdentityPrimitiveOrNullableConversionTo(type))
5314 {
5315 return new UnaryExpression(ExpressionType.ConvertChecked, expression, type, null);
5316 }
5317 if (expression.Type.HasReferenceConversionTo(type))
5318 {
5319 return new UnaryExpression(ExpressionType.Convert, expression, type, null);
5320 }
5322 }
5324 }
5325
5327 {
5329 if (!array.Type.IsSZArray)
5330 {
5331 if (!array.Type.IsArray || !typeof(Array).IsAssignableFrom(array.Type))
5332 {
5333 throw Error.ArgumentMustBeArray("array");
5334 }
5336 }
5337 return new UnaryExpression(ExpressionType.ArrayLength, array, typeof(int), null);
5338 }
5339
5341 {
5344 {
5345 throw Error.QuotedExpressionMustBeLambda("expression");
5346 }
5347 return new UnaryExpression(ExpressionType.Quote, lambdaExpression, lambdaExpression.PublicType, null);
5348 }
5349
5350 public static UnaryExpression Rethrow()
5351 {
5352 return Throw(null);
5353 }
5354
5356 {
5357 return Throw(null, type);
5358 }
5359
5361 {
5362 return Throw(value, typeof(void));
5363 }
5364
5366 {
5368 TypeUtils.ValidateType(type, "type");
5369 if (value != null)
5370 {
5372 if (value.Type.IsValueType)
5373 {
5374 throw Error.ArgumentMustNotHaveValueType("value");
5375 }
5376 }
5377 return new UnaryExpression(ExpressionType.Throw, value, type, null);
5378 }
5379
5381 {
5382 return Increment(expression, null);
5383 }
5384
5386 {
5388 if (method == null)
5389 {
5390 if (expression.Type.IsArithmetic())
5391 {
5392 return new UnaryExpression(ExpressionType.Increment, expression, expression.Type, null);
5393 }
5394 return GetUserDefinedUnaryOperatorOrThrow(ExpressionType.Increment, "op_Increment", expression);
5395 }
5397 }
5398
5400 {
5401 return Decrement(expression, null);
5402 }
5403
5405 {
5407 if (method == null)
5408 {
5409 if (expression.Type.IsArithmetic())
5410 {
5411 return new UnaryExpression(ExpressionType.Decrement, expression, expression.Type, null);
5412 }
5413 return GetUserDefinedUnaryOperatorOrThrow(ExpressionType.Decrement, "op_Decrement", expression);
5414 }
5416 }
5417
5419 {
5420 return MakeOpAssignUnary(ExpressionType.PreIncrementAssign, expression, null);
5421 }
5422
5427
5429 {
5430 return MakeOpAssignUnary(ExpressionType.PreDecrementAssign, expression, null);
5431 }
5432
5437
5439 {
5440 return MakeOpAssignUnary(ExpressionType.PostIncrementAssign, expression, null);
5441 }
5442
5447
5449 {
5450 return MakeOpAssignUnary(ExpressionType.PostDecrementAssign, expression, null);
5451 }
5452
5457
5459 {
5461 RequiresCanWrite(expression, "expression");
5463 if (method == null)
5464 {
5465 if (expression.Type.IsArithmetic())
5466 {
5467 return new UnaryExpression(kind, expression, expression.Type, null);
5468 }
5469 string name = ((kind != ExpressionType.PreIncrementAssign && kind != ExpressionType.PostIncrementAssign) ? "op_Decrement" : "op_Increment");
5471 }
5472 else
5473 {
5475 }
5477 {
5479 }
5480 return unaryExpression;
5481 }
5482}
5484{
5485 internal sealed override Type TypeCore => typeof(TDelegate);
5486
5488
5489 internal Expression(Expression body)
5490 : base(body)
5491 {
5492 }
5493
5494 public new TDelegate Compile()
5495 {
5496 return (TDelegate)(object)LambdaCompiler.Compile(this);
5497 }
5498
5500 {
5502 {
5503 return (TDelegate)(object)new LightCompiler().CompileTop(this).CreateDelegate();
5504 }
5505 return Compile();
5506 }
5507
5509 {
5510 if (body == base.Body)
5511 {
5513 if (parameters == null)
5514 {
5515 collection = null;
5516 }
5517 else
5518 {
5520 if (collection == null)
5521 {
5522 parameters = (collection = parameters.ToReadOnly());
5523 }
5524 }
5526 {
5527 return this;
5528 }
5529 }
5530 return Expression.Lambda<TDelegate>(body, base.Name, base.TailCall, parameters);
5531 }
5532
5533 [ExcludeFromCodeCoverage(Justification = "Unreachable")]
5534 internal virtual bool SameParameters(ICollection<ParameterExpression> parameters)
5535 {
5537 }
5538
5539 [ExcludeFromCodeCoverage(Justification = "Unreachable")]
5541 {
5543 }
5544
5545 protected internal override Expression Accept(ExpressionVisitor visitor)
5546 {
5547 return visitor.VisitLambda(this);
5548 }
5549
5551 {
5552 return spiller.Rewrite(this);
5553 }
5554
5555 internal static Expression<TDelegate> Create(Expression body, string name, bool tailCall, IReadOnlyList<ParameterExpression> parameters)
5556 {
5557 if (name == null && !tailCall)
5558 {
5559 return parameters.Count switch
5560 {
5561 0 => new Expression0<TDelegate>(body),
5562 1 => new Expression1<TDelegate>(body, parameters[0]),
5563 2 => new Expression2<TDelegate>(body, parameters[0], parameters[1]),
5564 3 => new Expression3<TDelegate>(body, parameters[0], parameters[1], parameters[2]),
5565 _ => new ExpressionN<TDelegate>(body, parameters),
5566 };
5567 }
5568 return new FullExpression<TDelegate>(body, name, tailCall, parameters);
5569 }
5570
5572 {
5573 return Compile();
5574 }
5575}
bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value)
void Add(TKey key, TValue value)
static void Requires([DoesNotReturnIf(false)] bool precondition, string paramName)
static void RequiresNotNull(object value, string paramName)
static void ValidateArgumentCount(MethodBase method, ExpressionType nodeKind, int count, ParameterInfo[] pis)
static void RequiresCanRead(Expression expression, string paramName)
static bool TryQuote(Type parameterType, ref Expression argument)
static ParameterInfo[] GetParametersForValidation(MethodBase method, ExpressionType nodeKind)
static void ValidateArgumentTypes(MethodBase method, ExpressionType nodeKind, ref ReadOnlyCollection< Expression > arguments, string methodParamName)
static Expression ValidateOneArgument(MethodBase method, ExpressionType nodeKind, Expression arguments, ParameterInfo pi, string methodParamName, string argumentParamName, int index=-1)
static bool HasReferenceEquality(Type left, Type right)
Definition TypeUtils.cs:439
static bool IsSameOrSubclass(Type type, Type subType)
Definition TypeUtils.cs:686
static MethodInfo GetArrayGetMethod(Type arrayType)
Definition TypeUtils.cs:769
static Type FindGenericType(Type definition, Type type)
Definition TypeUtils.cs:626
static bool HasBuiltInEqualityOperator(Type left, Type right)
Definition TypeUtils.cs:452
static void ValidateType(Type type, string paramName)
Definition TypeUtils.cs:695
static bool AreEquivalent(Type t1, Type t2)
Definition TypeUtils.cs:664
static MethodInfo GetBooleanOperator(Type type, string name)
Definition TypeUtils.cs:640
static bool AreReferenceAssignable(Type dest, Type src)
Definition TypeUtils.cs:673
static bool IsValidInstanceType(MemberInfo member, Type instanceType)
Definition TypeUtils.cs:157
static MethodInfo GetUserDefinedCoercionMethod(Type convertFrom, Type convertToType)
Definition TypeUtils.cs:488
static CultureInfo CurrentCulture
ReadOnlyCollection< Expression > Expressions
ReadOnlyCollection< ParameterExpression > Variables
ParameterExpression? Variable
Definition CatchBlock.cs:8
static Delegate Compile(LambdaExpression lambda)
static ConditionalExpression Make(Expression test, Expression ifTrue, Expression ifFalse, Type type)
static void WriteTo(Expression node, TextWriter writer)
static new DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, IEnumerable< Expression >? arguments)
static new DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, params Expression[] arguments)
static Exception OverloadOperatorTypeDoesNotMatchConversionType(object p0, object p1)
Definition Error.cs:318
static Exception IndexesOfSetGetMustMatch(string paramName)
Definition Error.cs:93
static Exception AllCaseBodiesMustHaveSameType(string paramName)
Definition Error.cs:213
static Exception ExtensionNodeMustOverrideProperty(object p0)
Definition Error.cs:278
static Exception ElementInitializerMethodNotAdd(string paramName)
Definition Error.cs:608
static Exception ExpressionMustBeWriteable(string paramName)
Definition Error.cs:193
static Exception OutOfRange(string paramName, object p1)
Definition Error.cs:708
static Exception BodyOfCatchMustHaveSameTypeAsBodyOfTry()
Definition Error.cs:273
static Exception MethodWithMoreThanOneMatch(object p0, object p1)
Definition Error.cs:683
static Exception ExpressionTypeDoesNotMatchReturn(object p0, object p1)
Definition Error.cs:453
static Exception ArgumentMustBeInstanceMember(string paramName)
Definition Error.cs:363
static Exception MethodIsGeneric(object p0, string paramName)
Definition Error.cs:523
static Exception ReducibleMustOverrideReduce()
Definition Error.cs:8
static Exception FaultCannotHaveCatchOrFinally(string paramName)
Definition Error.cs:263
static Exception ExpressionTypeCannotInitializeArrayType(object p0, object p1)
Definition Error.cs:428
static Exception InstancePropertyWithoutParameterNotDefinedForType(object p0, object p1)
Definition Error.cs:588
static Exception ReferenceEqualityNotDefined(object p0, object p1)
Definition Error.cs:308
static Exception InstancePropertyNotDefinedForType(object p0, object p1, string paramName)
Definition Error.cs:583
static Exception ElementInitializerMethodNoRefOutParam(object p0, object p1, string paramName)
Definition Error.cs:613
static Exception DuplicateVariable(object p0, string paramName)
Definition Error.cs:248
static Exception UserDefinedOperatorMustBeStatic(object p0, string paramName)
Definition Error.cs:283
static Exception StartEndMustBeOrdered()
Definition Error.cs:258
static Exception ArgumentTypeDoesNotMatchMember(object p0, object p1, string paramName)
Definition Error.cs:433
static Exception SetterMustBeVoid(string paramName)
Definition Error.cs:148
static Exception UserDefinedOpMustHaveValidReturnType(object p0, object p1)
Definition Error.cs:663
static Exception PropertyDoesNotHaveGetter(object p0, string paramName)
Definition Error.cs:538
static Exception ArgumentMustBeInteger(string paramName)
Definition Error.cs:373
static Exception IncorrectNumberOfLambdaDeclarationParameters()
Definition Error.cs:493
static Exception IncorrectNumberOfMembersForGivenConstructor()
Definition Error.cs:498
static Exception IncorrectTypeForTypeAs(object p0, string paramName)
Definition Error.cs:418
static Exception InstanceAndMethodTypeMismatch(object p0, object p1, object p2)
Definition Error.cs:598
static Exception ArgumentMemberNotDeclOnType(object p0, object p1, string paramName)
Definition Error.cs:443
static Exception ArgumentMustBeArray(string paramName)
Definition Error.cs:333
static Exception ElementInitializerMethodStatic(string paramName)
Definition Error.cs:623
static Exception VariableMustNotBeByRef(object p0, object p1, string paramName)
Definition Error.cs:238
static Exception IncorrectNumberOfArgumentsForMembers()
Definition Error.cs:503
static Exception ElementInitializerMethodWithZeroArgs(string paramName)
Definition Error.cs:618
static Exception TypeMissingDefaultConstructor(object p0, string paramName)
Definition Error.cs:603
static Exception AccessorsCannotHaveByRefArgs(string paramName)
Definition Error.cs:113
static Exception NotAMemberOfAnyType(object p0, string paramName)
Definition Error.cs:568
static Exception PropertyTypeMustMatchGetter(string paramName)
Definition Error.cs:153
static Exception PropertyNotDefinedForType(object p0, object p1, string paramName)
Definition Error.cs:578
static Exception LabelTypeMustBeVoid(string paramName)
Definition Error.cs:228
static Exception ExpressionTypeDoesNotMatchLabel(object p0, object p1)
Definition Error.cs:463
static Exception ConversionIsNotSupportedForArithmeticTypes()
Definition Error.cs:323
static Exception ExpressionTypeDoesNotMatchAssignment(object p0, object p1)
Definition Error.cs:458
static Exception AccessorsCannotHaveVarArgs(string paramName)
Definition Error.cs:108
static Exception TryMustHaveCatchFinallyOrFault()
Definition Error.cs:268
static Exception IncorrectNumberOfIndexes()
Definition Error.cs:488
static Exception BoundsCannotBeLessThanOne(string paramName)
Definition Error.cs:133
static Exception AllTestValuesMustHaveSameType(string paramName)
Definition Error.cs:208
static Exception FieldNotDefinedForType(object p0, object p1)
Definition Error.cs:473
static Exception PropertyDoesNotHaveSetter(object p0, string paramName)
Definition Error.cs:548
static Exception ArgumentMustBeFieldInfoOrPropertyInfoOrMethod(string paramName)
Definition Error.cs:353
static Exception BinaryOperatorNotDefined(object p0, object p1, object p2)
Definition Error.cs:303
static Exception TestValueTypeDoesNotMatchComparisonMethodParameter(object p0, object p1)
Definition Error.cs:808
static Exception MustReduceToDifferent()
Definition Error.cs:48
static Exception ExpressionTypeNotInvocable(object p0, string paramName)
Definition Error.cs:468
static Exception SwitchValueTypeDoesNotMatchComparisonMethodParameter(object p0, object p1)
Definition Error.cs:813
static Exception PropertyTypeMustMatchSetter(string paramName)
Definition Error.cs:158
static Exception BothAccessorsMustBeStatic(string paramName)
Definition Error.cs:163
static Exception ArgumentMustBeSingleDimensionalArrayType(string paramName)
Definition Error.cs:393
static Exception UserDefinedOperatorMustNotBeVoid(object p0, string paramName)
Definition Error.cs:288
static Exception DefaultBodyMustBeSupplied(string paramName)
Definition Error.cs:218
static Exception MethodContainsGenericParameters(object p0, string paramName)
Definition Error.cs:518
static Exception IncorrectNumberOfConstructorArguments()
Definition Error.cs:868
static Exception OnlyStaticPropertiesHaveNullInstance(string paramName)
Definition Error.cs:173
static Exception MustBeReducible()
Definition Error.cs:203
static Exception LogicalOperatorMustHaveBooleanOperators(object p0, object p1)
Definition Error.cs:668
static Exception ArgumentMustBeBoolean(string paramName)
Definition Error.cs:338
static Exception IncorrectNumberOfTypeArgsForAction(string paramName)
Definition Error.cs:698
static Exception MemberNotFieldOrProperty(object p0, string paramName)
Definition Error.cs:513
static Exception UserDefinedOpMustHaveConsistentTypes(object p0, object p1)
Definition Error.cs:658
static Exception PropertyTypeCannotBeVoid(string paramName)
Definition Error.cs:183
static Exception EqualityMustReturnBoolean(object p0, string paramName)
Definition Error.cs:343
static Exception ArgumentTypesMustMatch()
Definition Error.cs:398
static Exception ArgumentCannotBeOfTypeVoid(string paramName)
Definition Error.cs:703
static Exception PropertyWithMoreThanOneMatch(object p0, object p1)
Definition Error.cs:688
static Exception PropertyCannotHaveRefType(string paramName)
Definition Error.cs:88
static Exception UnhandledUnary(object p0, string paramName)
Definition Error.cs:648
static Exception UnhandledBinary(object p0, string paramName)
Definition Error.cs:633
static Exception ExpressionTypeDoesNotMatchMethodParameter(object p0, object p1, object p2, string paramName)
Definition Error.cs:873
static Exception ArgumentMustNotHaveValueType(string paramName)
Definition Error.cs:198
static Exception IncorrectNumberOfMethodCallArguments(object p0, string paramName)
Definition Error.cs:898
static Exception ArgumentMustBeFieldInfoOrPropertyInfo(string paramName)
Definition Error.cs:348
static Exception TypeNotIEnumerable(object p0, string paramName)
Definition Error.cs:628
static Exception IncorrectNumberOfTypeArgsForFunc(string paramName)
Definition Error.cs:693
static Exception InvalidUnboxType(string paramName)
Definition Error.cs:188
static Exception UnaryOperatorNotDefined(object p0, object p1)
Definition Error.cs:298
static Exception MethodNotPropertyAccessor(object p0, object p1, string paramName)
Definition Error.cs:528
static Exception ArgumentMustBeArrayIndexType(string paramName)
Definition Error.cs:383
static Exception GenericMethodWithArgsDoesNotExistOnType(object p0, object p1)
Definition Error.cs:678
static Exception TypeMustNotBeByRef(string paramName)
Definition Error.cs:138
static Exception PropertyDoesNotHaveAccessor(object p0, string paramName)
Definition Error.cs:553
static Exception ReducedNotCompatible()
Definition Error.cs:78
static Exception ExpressionTypeDoesNotMatchConstructorParameter(object p0, object p1, string paramName)
Definition Error.cs:903
static Exception InstancePropertyWithSpecifiedParametersNotDefinedForType(object p0, object p1, object p2, string paramName)
Definition Error.cs:593
static Exception NonStaticConstructorRequired(string paramName)
Definition Error.cs:828
static Exception LambdaTypeMustBeDerivedFromSystemDelegate(string paramName)
Definition Error.cs:508
static Exception OnlyStaticFieldsHaveNullInstance(string paramName)
Definition Error.cs:168
static Exception LabelMustBeVoidOrHaveExpression(string paramName)
Definition Error.cs:223
static Exception QuotedExpressionMustBeLambda(string paramName)
Definition Error.cs:233
static Exception CoercionOperatorNotDefined(object p0, object p1)
Definition Error.cs:293
static Exception CoalesceUsedOnNonNullType()
Definition Error.cs:423
static Exception OperandTypesDoNotMatchParameters(object p0, object p1)
Definition Error.cs:313
static Exception OnlyStaticMethodsHaveNullInstance()
Definition Error.cs:178
static Exception InstanceFieldNotDefinedForType(object p0, object p1)
Definition Error.cs:478
static Exception NotAMemberOfType(object p0, object p1, string paramName)
Definition Error.cs:558
static Exception FieldInfoNotDefinedForType(object p0, object p1, object p2)
Definition Error.cs:483
static Exception ParameterExpressionNotValidAsDelegate(object p0, object p1)
Definition Error.cs:573
static Exception MethodWithArgsDoesNotExistOnType(object p0, object p1)
Definition Error.cs:673
static Exception SetterHasNoParams(string paramName)
Definition Error.cs:83
ReadOnlyCollection< ParameterExpression > Variables
Definition Expression.cs:79
ExtensionInfo(ExpressionType nodeType, Type type)
Definition Expression.cs:25
ReadOnlyCollection< ParameterExpression > Parameters
ReadOnlyCollection< ParameterExpression > Variables
ReadOnlyCollection< Expression > TestValues
static BinaryExpression GreaterThan(Expression left, Expression right)
static SwitchExpression Switch(Expression switchValue, params SwitchCase[]? cases)
static CatchBlock Catch(Type type, Expression body)
static ConstantExpression Constant(object? value)
static BlockExpression Block(Expression arg0, Expression arg1)
static void ValidateAccessor(Expression instance, MethodInfo method, ParameterInfo[] indexes, ref ReadOnlyCollection< Expression > arguments, string paramName)
static ListInitExpression ListInit(NewExpression newExpression, MethodInfo? addMethod, IEnumerable< Expression > initializers)
static Type GetFuncType(params Type[]? typeArgs)
static bool IsValidLiftedConditionalLogicalOperator(Type left, Type right, ParameterInfo[] pms)
static BinaryExpression GetUserDefinedBinaryOperator(ExpressionType binaryType, string name, Expression left, Expression right, bool liftToNull)
static UnaryExpression GetUserDefinedCoercionOrThrow(ExpressionType coercionType, Expression expression, Type convertToType)
static MethodInfo GetInvokeMethod(Expression expression)
static IndexExpression ArrayAccess(Expression array, IEnumerable< Expression >? indexes)
static GotoExpression Return(LabelTarget target, Expression? value)
static bool IsCompatible(PropertyInfo pi, Expression[] args)
static BinaryExpression ModuloAssign(Expression left, Expression right, MethodInfo? method)
static MemberExpression PropertyOrField(Expression expression, string propertyOrFieldName)
static void ValidateLambdaArgs(Type delegateType, ref Expression body, ReadOnlyCollection< ParameterExpression > parameters, string paramName)
static NewExpression New(ConstructorInfo constructor, params Expression[]? arguments)
static UnaryExpression IsTrue(Expression expression)
static BinaryExpression MultiplyAssignChecked(Expression left, Expression right)
static SwitchExpression Switch(Type? type, Expression switchValue, Expression? defaultBody, MethodInfo? comparison, IEnumerable< SwitchCase >? cases)
static BinaryExpression GetUserDefinedAssignOperatorOrThrow(ExpressionType binaryType, string name, Expression left, Expression right, LambdaExpression conversion, bool liftToNull)
static BinaryExpression MultiplyChecked(Expression left, Expression right, MethodInfo? method)
static BinaryExpression SubtractAssignChecked(Expression left, Expression right, MethodInfo? method, LambdaExpression? conversion)
static void ValidateOpAssignConversionLambda(LambdaExpression conversion, Expression left, MethodInfo method, ExpressionType nodeType)
static UnaryExpression MakeUnary(ExpressionType unaryType, Expression operand, Type type)
static RuntimeVariablesExpression RuntimeVariables(IEnumerable< ParameterExpression > variables)
static BinaryExpression DivideAssign(Expression left, Expression right, MethodInfo? method, LambdaExpression? conversion)
static DefaultExpression Default(Type type)
static BinaryExpression NotEqual(Expression left, Expression right)
static BinaryExpression Add(Expression left, Expression right)
static BinaryExpression SubtractAssign(Expression left, Expression right, MethodInfo? method, LambdaExpression? conversion)
static LambdaExpression Lambda(Expression body, params ParameterExpression[]? parameters)
static LambdaExpression Lambda(Expression body, string? name, bool tailCall, IEnumerable< ParameterExpression >? parameters)
static BlockExpression Block(IEnumerable< Expression > expressions)
static BinaryExpression LeftShiftAssign(Expression left, Expression right)
static UnaryExpression ArrayLength(Expression array)
static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, params Expression[]? arguments)
static GotoExpression Break(LabelTarget target, Expression? value)
static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1)
static UnaryExpression IsFalse(Expression expression, MethodInfo? method)
static LoopExpression Loop(Expression body, LabelTarget? @break, LabelTarget? @continue)
static void ValidateNewArgs(ConstructorInfo constructor, ref ReadOnlyCollection< Expression > arguments, ref ReadOnlyCollection< MemberInfo > members)
static GotoExpression Break(LabelTarget target, Expression? value, Type type)
static MethodCallExpression Call(Expression instance, string methodName, Type[]? typeArguments, params Expression[]? arguments)
static void ValidateSettableFieldOrPropertyMember(MemberInfo member, out Type memberType)
static TryExpression TryFault(Expression body, Expression? fault)
static void ValidateListInitArgs(Type listType, ReadOnlyCollection< ElementInit > initializers, string listTypeParamName)
static UnaryExpression MakeOpAssignUnary(ExpressionType kind, Expression expression, MethodInfo method)
static PropertyInfo GetProperty(MethodInfo mi, string paramName, int index=-1)
new TDelegate Compile(DebugInfoGenerator debugInfoGenerator)
virtual Expression Accept(ExpressionVisitor visitor)
static void Validate(Type type, bool allowByRef)
static void ValidateUserDefinedConditionalLogicOperator(ExpressionType nodeType, Type left, Type right, MethodInfo method)
static GotoExpression Return(LabelTarget target)
static BinaryExpression LeftShiftAssign(Expression left, Expression right, MethodInfo? method)
static BinaryExpression ExclusiveOrAssign(Expression left, Expression right, MethodInfo? method)
static GotoExpression Goto(LabelTarget target, Type type)
static LambdaExpression Lambda(Type delegateType, Expression body, bool tailCall, IEnumerable< ParameterExpression >? parameters)
static GotoExpression Goto(LabelTarget target, Expression? value)
static MethodCallExpression Call(MethodInfo method)
static MemberListBinding ListBind(MethodInfo propertyAccessor, params ElementInit[] initializers)
static BinaryExpression MultiplyAssign(Expression left, Expression right)
static BinaryExpression Multiply(Expression left, Expression right)
static NewArrayExpression NewArrayBounds(Type type, params Expression[] bounds)
static GotoExpression Return(LabelTarget target, Expression? value, Type type)
static ConditionalExpression Condition(Expression test, Expression ifTrue, Expression ifFalse, Type type)
static BinaryExpression Assign(Expression left, Expression right)
static string GetArgTypesString(Expression[] arguments)
static BinaryExpression GetMethodBasedBinaryOperator(ExpressionType binaryType, Expression left, Expression right, MethodInfo method, bool liftToNull)
static UnaryExpression PreIncrementAssign(Expression expression, MethodInfo? method)
static InvocationExpression Invoke(Expression expression, IEnumerable< Expression >? arguments)
static void ValidateGoto(LabelTarget target, ref Expression value, string targetParameter, string valueParameter, Type type)
static BinaryExpression AddAssignChecked(Expression left, Expression right)
static BlockExpression Block(Type type, params Expression[] expressions)
static UnaryExpression GetUserDefinedUnaryOperator(ExpressionType unaryType, string name, Expression operand)
static LambdaExpression Lambda(Expression body, bool tailCall, IEnumerable< ParameterExpression >? parameters)
static InvocationExpression Invoke(Expression expression, Expression arg0, Expression arg1, Expression arg2)
static BinaryExpression RightShift(Expression left, Expression right)
static BinaryExpression Divide(Expression left, Expression right, MethodInfo? method)
static BinaryExpression AddChecked(Expression left, Expression right)
static void ValidateCallInstanceType(Type instanceType, MethodInfo method)
static BinaryExpression Add(Expression left, Expression right, MethodInfo? method)
static LoopExpression Loop(Expression body, LabelTarget? @break)
static UnaryExpression PreDecrementAssign(Expression expression, MethodInfo? method)
static BinaryExpression Subtract(Expression left, Expression right)
static NewExpression New(ConstructorInfo constructor, IEnumerable< Expression >? arguments)
static MethodCallExpression Call(MethodInfo method, Expression arg0, Expression arg1, Expression arg2, Expression arg3, Expression arg4)
static UnaryExpression MakeUnary(ExpressionType unaryType, Expression operand, Type type, MethodInfo? method)
static GotoExpression Break(LabelTarget target, Type type)
static DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, Expression arg0)
static MemberExpression Field(Expression expression, string fieldName)
static BinaryExpression ModuloAssign(Expression left, Expression right)
static BinaryExpression And(Expression left, Expression right, MethodInfo? method)
static BlockExpression GetOptimizedBlockExpression(IReadOnlyList< Expression > expressions)
static MethodCallExpression Call([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods|DynamicallyAccessedMemberTypes.NonPublicMethods)] Type type, string methodName, Type[]? typeArguments, params Expression[]? arguments)
static BinaryExpression LeftShift(Expression left, Expression right)
static BinaryExpression OrAssign(Expression left, Expression right, MethodInfo? method, LambdaExpression? conversion)
static BlockExpression Block(IEnumerable< ParameterExpression >? variables, params Expression[] expressions)
static BinaryExpression PowerAssign(Expression left, Expression right)
static SwitchCase SwitchCase(Expression body, params Expression[] testValues)
static MemberAssignment Bind(MethodInfo propertyAccessor, Expression expression)
static UnaryExpression Increment(Expression expression, MethodInfo? method)
static BinaryExpression OrElse(Expression left, Expression right)
static BinaryExpression GetEqualityComparisonOperator(ExpressionType binaryType, string opName, Expression left, Expression right, bool liftToNull)
static MemberExpression Property(Expression? expression, PropertyInfo property)
static MethodCallExpression Call(Expression? instance, MethodInfo method, Expression arg0, Expression arg1, Expression arg2)
static Expression< TDelegate > Create(Expression body, string name, bool tailCall, IReadOnlyList< ParameterExpression > parameters)
static Type ValidateCoalesceArgTypes(Type left, Type right)
static BinaryExpression SubtractAssignChecked(Expression left, Expression right)
static MemberMemberBinding MemberBind(MethodInfo propertyAccessor, params MemberBinding[] bindings)
static InvocationExpression Invoke(Expression expression, Expression arg0, Expression arg1, Expression arg2, Expression arg3, Expression arg4)
static MemberListBinding ListBind(MethodInfo propertyAccessor, IEnumerable< ElementInit > initializers)
static BinaryExpression ExclusiveOr(Expression left, Expression right, MethodInfo? method)
static UnaryExpression PostDecrementAssign(Expression expression)
static TypeBinaryExpression TypeEqual(Expression expression, Type type)
static MethodCallExpression Call(MethodInfo method, params Expression[]? arguments)
static BinaryExpression Power(Expression left, Expression right)
static GotoExpression Continue(LabelTarget target)
static UnaryExpression PreDecrementAssign(Expression expression)
static UnaryExpression Unbox(Expression expression, Type type)
static BinaryExpression AddAssign(Expression left, Expression right)
static Type GetActionType(params Type[]? typeArgs)
static MemberAssignment Bind(MemberInfo member, Expression expression)
static BinaryExpression ExclusiveOrAssign(Expression left, Expression right, MethodInfo? method, LambdaExpression? conversion)
static MethodInfo GetUserDefinedBinaryOperator(ExpressionType binaryType, Type leftType, Type rightType, string name)
static BinaryExpression MultiplyAssignChecked(Expression left, Expression right, MethodInfo? method, LambdaExpression? conversion)
override Expression Accept(ExpressionVisitor visitor)
static SwitchExpression Switch(Expression switchValue, Expression? defaultBody, MethodInfo? comparison, params SwitchCase[]? cases)
static ParameterExpression Parameter(Type type)
static UnaryExpression Quote(Expression expression)
static void ValidateTryAndCatchHaveSameType(Type type, Expression tryBody, ReadOnlyCollection< CatchBlock > handlers)
static MemberListBinding ListBind(MemberInfo member, IEnumerable< ElementInit > initializers)
static ParameterExpression Parameter(Type type, string? name)
static UnaryExpression PreIncrementAssign(Expression expression)
static BinaryExpression LeftShift(Expression left, Expression right, MethodInfo? method)
static SwitchExpression Switch(Expression switchValue, Expression? defaultBody, MethodInfo? comparison, IEnumerable< SwitchCase >? cases)
static GotoExpression Break(LabelTarget target)
static Expression ValidateOneArgument(MethodBase method, ExpressionType nodeKind, Expression arg, ParameterInfo pi, string methodParamName, string argumentParamName)
static DefaultExpression Empty()
static UnaryExpression OnesComplement(Expression expression)
static UnaryExpression GetMethodBasedCoercionOperator(ExpressionType unaryType, Expression operand, Type convertToType, MethodInfo method)
static void ValidateParamswithOperandsOrThrow(Type paramType, Type operandType, ExpressionType exprType, string name)
static BinaryExpression ModuloAssign(Expression left, Expression right, MethodInfo? method, LambdaExpression? conversion)
static UnaryExpression Not(Expression expression, MethodInfo? method)
static NewExpression New([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors|DynamicallyAccessedMemberTypes.NonPublicConstructors)] Type type)
static BinaryExpression LeftShiftAssign(Expression left, Expression right, MethodInfo? method, LambdaExpression? conversion)
Expression(ExpressionType nodeType, Type type)
static NewArrayExpression NewArrayInit(Type type, IEnumerable< Expression > initializers)
static UnaryExpression Increment(Expression expression)
static BinaryExpression Coalesce(Expression left, Expression right, LambdaExpression? conversion)
static PropertyInfo FindInstanceProperty([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties|DynamicallyAccessedMemberTypes.NonPublicProperties)] Type type, string propertyName, Expression[] arguments)
static UnaryExpression PostIncrementAssign(Expression expression)
static volatile CacheDict< Type, Func< Expression, string, bool, ReadOnlyCollection< ParameterExpression >, LambdaExpression > > s_lambdaFactories
static UnaryExpression Negate(Expression expression)
static void ValidateMethodInfo(MethodInfo method, string paramName)
static void ValidateArgumentCount(MethodBase method, ExpressionType nodeKind, int count, ParameterInfo[] pis)
static IndexExpression Property(Expression? instance, PropertyInfo indexer, IEnumerable< Expression >? arguments)
static CatchBlock Catch(ParameterExpression variable, Expression body, Expression? filter)
static CatchBlock Catch(ParameterExpression variable, Expression body)
static CatchBlock MakeCatchBlock(Type type, ParameterExpression? variable, Expression body, Expression? filter)
static LambdaExpression CreateLambda(Type delegateType, Expression body, string name, bool tailCall, ReadOnlyCollection< ParameterExpression > parameters)
static void RequiresCanRead(IReadOnlyList< Expression > items, string paramName)
static MemberExpression MakeMemberAccess(Expression? expression, MemberInfo member)
static DebugInfoExpression ClearDebugInfo(SymbolDocumentInfo document)
static BinaryExpression RightShiftAssign(Expression left, Expression right, MethodInfo? method, LambdaExpression? conversion)
static BinaryExpression ReferenceEqual(Expression left, Expression right)
static BinaryExpression GetComparisonOperator(ExpressionType binaryType, string opName, Expression left, Expression right, bool liftToNull)
static BinaryExpression Or(Expression left, Expression right)
static UnaryExpression TypeAs(Expression expression, Type type)
static BinaryExpression AddAssignChecked(Expression left, Expression right, MethodInfo? method)
static ListInitExpression ListInit(NewExpression newExpression, params Expression[] initializers)
static MethodCallExpression Call(Expression? instance, MethodInfo method, params Expression[]? arguments)
virtual Expression VisitChildren(ExpressionVisitor visitor)
static SymbolDocumentInfo SymbolDocument(string fileName, Guid language)
static bool IsLiftingConditionalLogicalOperator(Type left, Type right, MethodInfo method, ExpressionType binaryType)
static TryExpression TryCatchFinally(Expression body, Expression? @finally, params CatchBlock[]? handlers)
static Type GetDelegateType(params Type[] typeArgs)
static ConditionalExpression IfThenElse(Expression test, Expression ifTrue, Expression ifFalse)
static BinaryExpression NotEqual(Expression left, Expression right, bool liftToNull, MethodInfo? method)
static BinaryExpression Divide(Expression left, Expression right)
static LambdaExpression Lambda(Type delegateType, Expression body, string? name, bool tailCall, IEnumerable< ParameterExpression >? parameters)
static IndexExpression MakeIndexProperty(Expression instance, PropertyInfo indexer, string paramName, ReadOnlyCollection< Expression > argList)
static MethodCallExpression Call(MethodInfo method, Expression arg0, Expression arg1, Expression arg2, Expression arg3)
static ElementInit ElementInit(MethodInfo addMethod, params Expression[] arguments)
static MemberMemberBinding MemberBind(MemberInfo member, params MemberBinding[] bindings)
static bool IsCompatible(MethodBase m, Expression[] arguments)
static BinaryExpression RightShift(Expression left, Expression right, MethodInfo? method)
static BlockExpression Block(Type type, IEnumerable< ParameterExpression >? variables, params Expression[] expressions)
static IndexExpression Property(Expression instance, string propertyName, params Expression[]? arguments)
static void ValidateAccessorArgumentTypes(MethodInfo method, ParameterInfo[] indexes, ref ReadOnlyCollection< Expression > arguments, string paramName)
static UnaryExpression GetUserDefinedCoercion(ExpressionType coercionType, Expression expression, Type convertToType)
static BinaryExpression Multiply(Expression left, Expression right, MethodInfo? method)
static UnaryExpression Rethrow()
static BinaryExpression AddAssignChecked(Expression left, Expression right, MethodInfo? method, LambdaExpression? conversion)
static UnaryExpression Decrement(Expression expression)
static ParameterExpression Variable(Type type, string? name)
static UnaryExpression Not(Expression expression)
static void RequiresCanWrite(Expression expression, string paramName)
static InvocationExpression Invoke(Expression expression, Expression arg0, Expression arg1)
static DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, Expression arg0, Expression arg1)
static GotoExpression Goto(LabelTarget target, Expression? value, Type type)
static DebugInfoExpression DebugInfo(SymbolDocumentInfo document, int startLine, int startColumn, int endLine, int endColumn)
static readonly CacheDict< Type, MethodInfo > s_lambdaDelegateCache
static void ValidateSpan(int startLine, int startColumn, int endLine, int endColumn)
static GotoExpression Return(LabelTarget target, Type type)
static bool TryGetActionType(Type[] typeArgs, [NotNullWhen(true)] out Type? actionType)
static BinaryExpression SubtractChecked(Expression left, Expression right, MethodInfo? method)
virtual ExpressionType NodeType
static CatchBlock Catch(Type type, Expression body, Expression? filter)
static MethodCallExpression ArrayIndex(Expression array, params Expression[] indexes)
static BinaryExpression GreaterThan(Expression left, Expression right, bool liftToNull, MethodInfo? method)
static BinaryExpression Or(Expression left, Expression right, MethodInfo? method)
virtual Expression< TDelegate > Rewrite(Expression body, ParameterExpression[] parameters)
static MethodCallExpression Call(MethodInfo method, Expression arg0, Expression arg1)
static MethodCallExpression Call(Expression? instance, MethodInfo method, IEnumerable< Expression >? arguments)
static void ValidateArgumentTypes(MethodBase method, ExpressionType nodeKind, ref ReadOnlyCollection< Expression > arguments, string methodParamName)
static LabelExpression Label(LabelTarget target)
static DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, IEnumerable< Expression > arguments)
static LabelExpression Label(LabelTarget target, Expression? defaultValue)
static void ValidateOperator(MethodInfo method)
static BinaryExpression MakeBinary(ExpressionType binaryType, Expression left, Expression right, bool liftToNull, MethodInfo? method, LambdaExpression? conversion)
static void ValidateGettableFieldOrPropertyMember(MemberInfo member, out Type memberType)
static ConditionalExpression Condition(Expression test, Expression ifTrue, Expression ifFalse)
static TypeBinaryExpression TypeIs(Expression expression, Type type)
static void ValidateGotoType(Type expectedType, ref Expression value, string paramName)
static BinaryExpression Equal(Expression left, Expression right, bool liftToNull, MethodInfo? method)
static NewExpression New(ConstructorInfo constructor)
static LambdaExpression Lambda(Expression body, bool tailCall, params ParameterExpression[]? parameters)
static BlockExpression Block(params Expression[] expressions)
virtual bool SameParameters(ICollection< ParameterExpression > parameters)
static BinaryExpression SubtractAssign(Expression left, Expression right)
static ConditionalExpression IfThen(Expression test, Expression ifTrue)
static LambdaExpression Lambda(Type delegateType, Expression body, string? name, IEnumerable< ParameterExpression >? parameters)
static BinaryExpression ExclusiveOr(Expression left, Expression right)
static InvocationExpression Invoke(Expression expression, Expression arg0)
static MemberExpression Field(Expression? expression, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields|DynamicallyAccessedMemberTypes.NonPublicFields)] Type type, string fieldName)
static LoopExpression Loop(Expression body)
static BlockExpression BlockCore(Type type, ReadOnlyCollection< ParameterExpression > variables, ReadOnlyCollection< Expression > expressions)
static BinaryExpression PowerAssign(Expression left, Expression right, MethodInfo? method, LambdaExpression? conversion)
static SymbolDocumentInfo SymbolDocument(string fileName, Guid language, Guid languageVendor)
static MethodCallExpression Call(MethodInfo method, Expression arg0, Expression arg1, Expression arg2)
static SwitchCase SwitchCase(Expression body, IEnumerable< Expression > testValues)
static NewExpression New(ConstructorInfo constructor, IEnumerable< Expression >? arguments, params MemberInfo[]? members)
static UnaryExpression ConvertChecked(Expression expression, Type type)
static UnaryExpression GetUserDefinedUnaryOperatorOrThrow(ExpressionType unaryType, string name, Expression operand)
static BinaryExpression MultiplyAssign(Expression left, Expression right, MethodInfo? method)
static UnaryExpression Convert(Expression expression, Type type)
static bool IsSimpleShift(Type left, Type right)
static MethodCallExpression ArrayIndex(Expression array, IEnumerable< Expression > indexes)
static BlockExpression Block(Expression arg0, Expression arg1, Expression arg2)
static BinaryExpression GetMethodBasedAssignOperator(ExpressionType binaryType, Expression left, Expression right, MethodInfo method, LambdaExpression conversion, bool liftToNull)
static MemberExpression Field(Expression? expression, FieldInfo field)
static void ValidateMemberInitArgs(Type type, ReadOnlyCollection< MemberBinding > bindings)
static BlockExpression Block(Type type, IEnumerable< Expression > expressions)
static void VerifyOpTrueFalse(ExpressionType nodeType, Type left, MethodInfo opTrue, string paramName)
static MemberExpression Property(Expression? expression, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties|DynamicallyAccessedMemberTypes.NonPublicProperties)] Type type, string propertyName)
static UnaryExpression Decrement(Expression expression, MethodInfo? method)
static BinaryExpression AddChecked(Expression left, Expression right, MethodInfo? method)
static InvocationExpression Invoke(Expression expression, Expression arg0, Expression arg1, Expression arg2, Expression arg3)
static BinaryExpression AndAssign(Expression left, Expression right, MethodInfo? method, LambdaExpression? conversion)
static BinaryExpression GetUserDefinedBinaryOperatorOrThrow(ExpressionType binaryType, string name, Expression left, Expression right, bool liftToNull)
static void ValidateVariables(ReadOnlyCollection< ParameterExpression > varList, string collectionName)
static ListInitExpression ListInit(NewExpression newExpression, params ElementInit[] initializers)
static BinaryExpression MakeBinary(ExpressionType binaryType, Expression left, Expression right)
static BinaryExpression SubtractChecked(Expression left, Expression right)
static ListInitExpression ListInit(NewExpression newExpression, MethodInfo? addMethod, params Expression[] initializers)
static UnaryExpression UnaryPlus(Expression expression, MethodInfo? method)
static ListInitExpression ListInit(NewExpression newExpression, IEnumerable< Expression > initializers)
static MethodInfo FindMethod([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods|DynamicallyAccessedMemberTypes.NonPublicMethods)] Type type, string methodName, Type[] typeArgs, Expression[] args, BindingFlags flags)
static BinaryExpression GreaterThanOrEqual(Expression left, Expression right)
static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1, Expression arg2)
static LambdaExpression Lambda(Expression body, IEnumerable< ParameterExpression >? parameters)
static TryExpression MakeTry(Type? type, Expression body, Expression? @finally, Expression? fault, IEnumerable< CatchBlock >? handlers)
static LambdaExpression Lambda(Type delegateType, Expression body, bool tailCall, params ParameterExpression[]? parameters)
static MemberInitExpression MemberInit(NewExpression newExpression, IEnumerable< MemberBinding > bindings)
static ParameterInfo[] ValidateMethodAndGetParameters(Expression instance, MethodInfo method)
static BinaryExpression AndAssign(Expression left, Expression right)
static BinaryExpression PowerAssign(Expression left, Expression right, MethodInfo? method)
static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, Expression arg0)
static ListInitExpression ListInit(NewExpression newExpression, IEnumerable< ElementInit > initializers)
static BinaryExpression MultiplyAssignChecked(Expression left, Expression right, MethodInfo? method)
static bool TryGetFuncType(Type[] typeArgs, [NotNullWhen(true)] out Type? funcType)
static UnaryExpression ConvertChecked(Expression expression, Type type, MethodInfo? method)
static NewArrayExpression NewArrayBounds(Type type, IEnumerable< Expression > bounds)
static void ValidateConstructor(ConstructorInfo constructor, string paramName)
static ElementInit ElementInit(MethodInfo addMethod, IEnumerable< Expression > arguments)
static BinaryExpression OrElse(Expression left, Expression right, MethodInfo? method)
static SwitchExpression Switch(Expression switchValue, Expression? defaultBody, params SwitchCase[]? cases)
static BinaryExpression OrAssign(Expression left, Expression right)
static UnaryExpression IsTrue(Expression expression, MethodInfo? method)
static DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, Expression arg0, Expression arg1, Expression arg2)
static BinaryExpression DivideAssign(Expression left, Expression right)
static void ValidateAnonymousTypeMember(ref MemberInfo member, out Type memberType, string paramName, int index)
static LabelTarget Label(string? name)
static DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, params Expression[] arguments)
static BinaryExpression LessThan(Expression left, Expression right, bool liftToNull, MethodInfo? method)
static RuntimeVariablesExpression RuntimeVariables(params ParameterExpression[] variables)
static bool IsNullComparison(Expression left, Expression right)
static BinaryExpression SubtractAssign(Expression left, Expression right, MethodInfo? method)
static MemberMemberBinding MemberBind(MethodInfo propertyAccessor, IEnumerable< MemberBinding > bindings)
static UnaryExpression IsFalse(Expression expression)
static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, IEnumerable< Expression >? arguments)
static IndexExpression Property(Expression? instance, PropertyInfo indexer, params Expression[]? arguments)
static BinaryExpression ArrayIndex(Expression array, Expression index)
static BinaryExpression LessThanOrEqual(Expression left, Expression right, bool liftToNull, MethodInfo? method)
static BinaryExpression AndAlso(Expression left, Expression right)
static MemberMemberBinding MemberBind(MemberInfo member, IEnumerable< MemberBinding > bindings)
static BinaryExpression DivideAssign(Expression left, Expression right, MethodInfo? method)
static void ValidateSwitchCaseType(Expression @case, bool customType, Type resultType, string parameterName)
static BinaryExpression Subtract(Expression left, Expression right, MethodInfo? method)
static GotoExpression MakeGoto(GotoExpressionKind kind, LabelTarget target, Expression? value, Type type)
static UnaryExpression UnaryPlus(Expression expression)
static BinaryExpression AndAssign(Expression left, Expression right, MethodInfo? method)
static SwitchExpression Switch(Type? type, Expression switchValue, Expression? defaultBody, MethodInfo? comparison, params SwitchCase[]? cases)
static bool IsNullConstant(Expression e)
static Expression< TDelegate > Lambda< TDelegate >(Expression body, params ParameterExpression[]? parameters)
static MethodCallExpression Call(Expression instance, MethodInfo method, Expression arg0)
static Type GetResultTypeOfShift(Type left, Type right)
static MethodCallExpression Call(Expression? instance, MethodInfo method)
static BinaryExpression GreaterThanOrEqual(Expression left, Expression right, bool liftToNull, MethodInfo? method)
static bool TryQuote(Type parameterType, ref Expression argument)
static BinaryExpression ReferenceNotEqual(Expression left, Expression right)
static LabelTarget Label(Type type)
static BlockExpression Block(IEnumerable< ParameterExpression >? variables, IEnumerable< Expression > expressions)
static LambdaExpression Lambda(Type delegateType, Expression body, params ParameterExpression[]? parameters)
static BinaryExpression MultiplyChecked(Expression left, Expression right)
static UnaryExpression NegateChecked(Expression expression)
static SymbolDocumentInfo SymbolDocument(string fileName, Guid language, Guid languageVendor, Guid documentType)
static PropertyInfo FindProperty([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties|DynamicallyAccessedMemberTypes.NonPublicProperties)] Type type, string propertyName, Expression[] arguments, BindingFlags flags)
static TryGetFuncActionArgsResult ValidateTryGetFuncActionArgs(Type[] typeArgs)
static MemberInitExpression MemberInit(NewExpression newExpression, params MemberBinding[] bindings)
static UnaryExpression Negate(Expression expression, MethodInfo? method)
static TryExpression TryCatch(Expression body, params CatchBlock[]? handlers)
static BinaryExpression And(Expression left, Expression right)
static ConstantExpression Constant(object? value, Type type)
static BinaryExpression Coalesce(Expression left, Expression right)
static BinaryExpression AddAssign(Expression left, Expression right, MethodInfo? method, LambdaExpression? conversion)
static BinaryExpression Power(Expression left, Expression right, MethodInfo? method)
static void ValidateIndexedProperty(Expression instance, PropertyInfo indexer, string paramName, ref ReadOnlyCollection< Expression > argList)
static UnaryExpression Convert(Expression expression, Type type, MethodInfo? method)
new TDelegate Compile(bool preferInterpretation)
static void ValidateStaticOrInstanceMethod(Expression instance, MethodInfo method)
static LambdaExpression Lambda(Type delegateType, Expression body, IEnumerable< ParameterExpression >? parameters)
static BinaryExpression LessThan(Expression left, Expression right)
static BinaryExpression OrAssign(Expression left, Expression right, MethodInfo? method)
static ParameterInfo[] GetParametersForValidation(MethodBase method, ExpressionType nodeKind)
static MethodCallExpression Call(MethodInfo method, Expression arg0)
static BinaryExpression MultiplyAssign(Expression left, Expression right, MethodInfo? method, LambdaExpression? conversion)
static IndexExpression MakeIndex(Expression instance, PropertyInfo? indexer, IEnumerable< Expression >? arguments)
static NewArrayExpression NewArrayInit(Type type, params Expression[] initializers)
static MethodCallExpression Call(MethodInfo method, IEnumerable< Expression >? arguments)
Expression< TDelegate > Update(Expression body, IEnumerable< ParameterExpression >? parameters)
static BinaryExpression Modulo(Expression left, Expression right)
static UnaryExpression OnesComplement(Expression expression, MethodInfo? method)
static BinaryExpression RightShiftAssign(Expression left, Expression right)
static DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, Expression arg0, Expression arg1, Expression arg2, Expression arg3)
static MemberListBinding ListBind(MemberInfo member, params ElementInit[] initializers)
static LambdaExpression Lambda(Expression body, string? name, IEnumerable< ParameterExpression >? parameters)
static UnaryExpression Throw(Expression? value, Type type)
static BinaryExpression Equal(Expression left, Expression right)
static TryExpression TryFinally(Expression body, Expression? @finally)
static IndexExpression ArrayAccess(Expression array, params Expression[]? indexes)
static InvocationExpression Invoke(Expression expression, params Expression[]? arguments)
static UnaryExpression Throw(Expression? value)
static UnaryExpression Rethrow(Type type)
static NewExpression New(ConstructorInfo constructor, IEnumerable< Expression >? arguments, IEnumerable< MemberInfo >? members)
static BinaryExpression RightShiftAssign(Expression left, Expression right, MethodInfo? method)
static GotoExpression Goto(LabelTarget target)
static GotoExpression Continue(LabelTarget target, Type type)
static BlockExpression Block(Expression arg0, Expression arg1, Expression arg2, Expression arg3, Expression arg4)
static BinaryExpression SubtractAssignChecked(Expression left, Expression right, MethodInfo? method)
static UnaryExpression PostIncrementAssign(Expression expression, MethodInfo? method)
override LambdaExpression Accept(StackSpiller spiller)
static LabelTarget Label(Type type, string? name)
static MethodInfo ApplyTypeArgs(MethodInfo m, Type[] typeArgs)
static SymbolDocumentInfo SymbolDocument(string fileName)
static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1, Expression arg2, Expression arg3)
static BinaryExpression AddAssign(Expression left, Expression right, MethodInfo? method)
static MemberExpression Property(Expression? expression, MethodInfo propertyAccessor)
static BinaryExpression Modulo(Expression left, Expression right, MethodInfo? method)
static bool CheckMethod(MethodInfo method, MethodInfo propertyMethod)
static ParameterExpression Variable(Type type)
static BinaryExpression ExclusiveOrAssign(Expression left, Expression right)
static BinaryExpression LessThanOrEqual(Expression left, Expression right)
static BinaryExpression MakeBinary(ExpressionType binaryType, Expression left, Expression right, bool liftToNull, MethodInfo? method)
static BinaryExpression AndAlso(Expression left, Expression right, MethodInfo? method)
static ConditionalWeakTable< Expression, ExtensionInfo > s_legacyCtorSupportTable
static MemberExpression Property(Expression expression, string propertyName)
static BlockExpression Block(Expression arg0, Expression arg1, Expression arg2, Expression arg3)
static void ValidateElementInitAddMethodInfo(MethodInfo addMethod, string paramName)
static UnaryExpression NegateChecked(Expression expression, MethodInfo? method)
static bool ParameterIsAssignable(ParameterInfo pi, Type argType)
static BlockExpression Block(Type type, IEnumerable< ParameterExpression >? variables, IEnumerable< Expression > expressions)
static UnaryExpression GetMethodBasedUnaryOperator(ExpressionType unaryType, Expression operand, MethodInfo method)
static UnaryExpression PostDecrementAssign(Expression expression, MethodInfo? method)
static MethodCallExpression Call(Expression? instance, MethodInfo method, Expression arg0, Expression arg1)
static InvocationExpression Invoke(Expression expression)
ReadOnlyCollection< Expression > Arguments
LightDelegateCreator CompileTop(LambdaExpression node)
ReadOnlyCollection< ParameterExpression > Parameters
ReadOnlyCollection< ElementInit > Initializers
static PropertyExpression Make(Expression expression, PropertyInfo property)
ReadOnlyCollection< MemberBinding > Bindings
ReadOnlyCollection< Expression > Expressions
static NewArrayExpression Make(ExpressionType nodeType, Type type, ReadOnlyCollection< Expression > expressions)
ReadOnlyCollection< MemberInfo >? Members
ReadOnlyCollection< Expression > Arguments
static ParameterExpression Make(Type type, string name, bool isByRef)
ReadOnlyCollection< ParameterExpression > Variables
ReadOnlyCollection< Expression > TestValues
Definition SwitchCase.cs:11
ReadOnlyCollection< SwitchCase > Cases
ReadOnlyCollection< CatchBlock > Handlers
static int CompareExchange(ref int location1, int value, int comparand)
bool IsValueType
Definition Type.cs:234