mscorlib(4.0.0.0) API with additions
Expression.cs
1 using System.Collections;
4 using System.Dynamic.Utils;
6 using System.IO;
8 using System.Reflection;
10 using System.Text;
11 using System.Threading;
12 
14 {
16  [global::__DynamicallyInvokable]
17  public abstract class Expression
18  {
19  private delegate LambdaExpression LambdaFactory(Expression body, string name, bool tailCall, ReadOnlyCollection<ParameterExpression> parameters);
20 
21  private class ExtensionInfo
22  {
23  internal readonly ExpressionType NodeType;
24 
25  internal readonly Type Type;
26 
27  public ExtensionInfo(ExpressionType nodeType, Type type)
28  {
29  NodeType = nodeType;
30  Type = type;
31  }
32  }
33 
34  internal class BinaryExpressionProxy
35  {
36  private readonly BinaryExpression _node;
37 
38  public bool CanReduce => _node.CanReduce;
39 
40  public LambdaExpression Conversion => _node.Conversion;
41 
42  public string DebugView => _node.DebugView;
43 
44  public bool IsLifted => _node.IsLifted;
45 
46  public bool IsLiftedToNull => _node.IsLiftedToNull;
47 
48  public Expression Left => _node.Left;
49 
50  public MethodInfo Method => _node.Method;
51 
52  public ExpressionType NodeType => _node.NodeType;
53 
54  public Expression Right => _node.Right;
55 
56  public Type Type => _node.Type;
57 
58  public BinaryExpressionProxy(BinaryExpression node)
59  {
60  _node = node;
61  }
62  }
63 
64  internal class BlockExpressionProxy
65  {
66  private readonly BlockExpression _node;
67 
68  public bool CanReduce => _node.CanReduce;
69 
70  public string DebugView => _node.DebugView;
71 
72  public ReadOnlyCollection<Expression> Expressions => _node.Expressions;
73 
74  public ExpressionType NodeType => _node.NodeType;
75 
76  public Expression Result => _node.Result;
77 
78  public Type Type => _node.Type;
79 
80  public ReadOnlyCollection<ParameterExpression> Variables => _node.Variables;
81 
82  public BlockExpressionProxy(BlockExpression node)
83  {
84  _node = node;
85  }
86  }
87 
88  internal class CatchBlockProxy
89  {
90  private readonly CatchBlock _node;
91 
92  public Expression Body => _node.Body;
93 
94  public Expression Filter => _node.Filter;
95 
96  public Type Test => _node.Test;
97 
98  public ParameterExpression Variable => _node.Variable;
99 
100  public CatchBlockProxy(CatchBlock node)
101  {
102  _node = node;
103  }
104  }
105 
106  internal class ConditionalExpressionProxy
107  {
108  private readonly ConditionalExpression _node;
109 
110  public bool CanReduce => _node.CanReduce;
111 
112  public string DebugView => _node.DebugView;
113 
114  public Expression IfFalse => _node.IfFalse;
115 
116  public Expression IfTrue => _node.IfTrue;
117 
118  public ExpressionType NodeType => _node.NodeType;
119 
120  public Expression Test => _node.Test;
121 
122  public Type Type => _node.Type;
123 
124  public ConditionalExpressionProxy(ConditionalExpression node)
125  {
126  _node = node;
127  }
128  }
129 
130  internal class ConstantExpressionProxy
131  {
132  private readonly ConstantExpression _node;
133 
134  public bool CanReduce => _node.CanReduce;
135 
136  public string DebugView => _node.DebugView;
137 
138  public ExpressionType NodeType => _node.NodeType;
139 
140  public Type Type => _node.Type;
141 
142  public object Value => _node.Value;
143 
144  public ConstantExpressionProxy(ConstantExpression node)
145  {
146  _node = node;
147  }
148  }
149 
150  internal class DebugInfoExpressionProxy
151  {
152  private readonly DebugInfoExpression _node;
153 
154  public bool CanReduce => _node.CanReduce;
155 
156  public string DebugView => _node.DebugView;
157 
158  public SymbolDocumentInfo Document => _node.Document;
159 
160  public int EndColumn => _node.EndColumn;
161 
162  public int EndLine => _node.EndLine;
163 
164  public bool IsClear => _node.IsClear;
165 
166  public ExpressionType NodeType => _node.NodeType;
167 
168  public int StartColumn => _node.StartColumn;
169 
170  public int StartLine => _node.StartLine;
171 
172  public Type Type => _node.Type;
173 
174  public DebugInfoExpressionProxy(DebugInfoExpression node)
175  {
176  _node = node;
177  }
178  }
179 
180  internal class DefaultExpressionProxy
181  {
182  private readonly DefaultExpression _node;
183 
184  public bool CanReduce => _node.CanReduce;
185 
186  public string DebugView => _node.DebugView;
187 
188  public ExpressionType NodeType => _node.NodeType;
189 
190  public Type Type => _node.Type;
191 
192  public DefaultExpressionProxy(DefaultExpression node)
193  {
194  _node = node;
195  }
196  }
197 
198  internal class DynamicExpressionProxy
199  {
200  private readonly DynamicExpression _node;
201 
202  public ReadOnlyCollection<Expression> Arguments => _node.Arguments;
203 
204  public CallSiteBinder Binder => _node.Binder;
205 
206  public bool CanReduce => _node.CanReduce;
207 
208  public string DebugView => _node.DebugView;
209 
210  public Type DelegateType => _node.DelegateType;
211 
212  public ExpressionType NodeType => _node.NodeType;
213 
214  public Type Type => _node.Type;
215 
216  public DynamicExpressionProxy(DynamicExpression node)
217  {
218  _node = node;
219  }
220  }
221 
222  internal class GotoExpressionProxy
223  {
224  private readonly GotoExpression _node;
225 
226  public bool CanReduce => _node.CanReduce;
227 
228  public string DebugView => _node.DebugView;
229 
230  public GotoExpressionKind Kind => _node.Kind;
231 
232  public ExpressionType NodeType => _node.NodeType;
233 
234  public LabelTarget Target => _node.Target;
235 
236  public Type Type => _node.Type;
237 
238  public Expression Value => _node.Value;
239 
240  public GotoExpressionProxy(GotoExpression node)
241  {
242  _node = node;
243  }
244  }
245 
246  internal class IndexExpressionProxy
247  {
248  private readonly IndexExpression _node;
249 
250  public ReadOnlyCollection<Expression> Arguments => _node.Arguments;
251 
252  public bool CanReduce => _node.CanReduce;
253 
254  public string DebugView => _node.DebugView;
255 
256  public PropertyInfo Indexer => _node.Indexer;
257 
258  public ExpressionType NodeType => _node.NodeType;
259 
260  public Expression Object => _node.Object;
261 
262  public Type Type => _node.Type;
263 
264  public IndexExpressionProxy(IndexExpression node)
265  {
266  _node = node;
267  }
268  }
269 
270  internal class InvocationExpressionProxy
271  {
272  private readonly InvocationExpression _node;
273 
274  public ReadOnlyCollection<Expression> Arguments => _node.Arguments;
275 
276  public bool CanReduce => _node.CanReduce;
277 
278  public string DebugView => _node.DebugView;
279 
280  public Expression Expression => _node.Expression;
281 
282  public ExpressionType NodeType => _node.NodeType;
283 
284  public Type Type => _node.Type;
285 
286  public InvocationExpressionProxy(InvocationExpression node)
287  {
288  _node = node;
289  }
290  }
291 
292  internal class LabelExpressionProxy
293  {
294  private readonly LabelExpression _node;
295 
296  public bool CanReduce => _node.CanReduce;
297 
298  public string DebugView => _node.DebugView;
299 
300  public Expression DefaultValue => _node.DefaultValue;
301 
302  public ExpressionType NodeType => _node.NodeType;
303 
304  public LabelTarget Target => _node.Target;
305 
306  public Type Type => _node.Type;
307 
308  public LabelExpressionProxy(LabelExpression node)
309  {
310  _node = node;
311  }
312  }
313 
314  internal class LambdaExpressionProxy
315  {
316  private readonly LambdaExpression _node;
317 
318  public Expression Body => _node.Body;
319 
320  public bool CanReduce => _node.CanReduce;
321 
322  public string DebugView => _node.DebugView;
323 
324  public string Name => _node.Name;
325 
326  public ExpressionType NodeType => _node.NodeType;
327 
328  public ReadOnlyCollection<ParameterExpression> Parameters => _node.Parameters;
329 
330  public Type ReturnType => _node.ReturnType;
331 
332  public bool TailCall => _node.TailCall;
333 
334  public Type Type => _node.Type;
335 
336  public LambdaExpressionProxy(LambdaExpression node)
337  {
338  _node = node;
339  }
340  }
341 
342  internal class ListInitExpressionProxy
343  {
344  private readonly ListInitExpression _node;
345 
346  public bool CanReduce => _node.CanReduce;
347 
348  public string DebugView => _node.DebugView;
349 
350  public ReadOnlyCollection<ElementInit> Initializers => _node.Initializers;
351 
352  public NewExpression NewExpression => _node.NewExpression;
353 
354  public ExpressionType NodeType => _node.NodeType;
355 
356  public Type Type => _node.Type;
357 
358  public ListInitExpressionProxy(ListInitExpression node)
359  {
360  _node = node;
361  }
362  }
363 
364  internal class LoopExpressionProxy
365  {
366  private readonly LoopExpression _node;
367 
368  public Expression Body => _node.Body;
369 
370  public LabelTarget BreakLabel => _node.BreakLabel;
371 
372  public bool CanReduce => _node.CanReduce;
373 
374  public LabelTarget ContinueLabel => _node.ContinueLabel;
375 
376  public string DebugView => _node.DebugView;
377 
378  public ExpressionType NodeType => _node.NodeType;
379 
380  public Type Type => _node.Type;
381 
382  public LoopExpressionProxy(LoopExpression node)
383  {
384  _node = node;
385  }
386  }
387 
388  internal class MemberExpressionProxy
389  {
390  private readonly MemberExpression _node;
391 
392  public bool CanReduce => _node.CanReduce;
393 
394  public string DebugView => _node.DebugView;
395 
396  public Expression Expression => _node.Expression;
397 
398  public MemberInfo Member => _node.Member;
399 
400  public ExpressionType NodeType => _node.NodeType;
401 
402  public Type Type => _node.Type;
403 
404  public MemberExpressionProxy(MemberExpression node)
405  {
406  _node = node;
407  }
408  }
409 
410  internal class MemberInitExpressionProxy
411  {
412  private readonly MemberInitExpression _node;
413 
414  public ReadOnlyCollection<MemberBinding> Bindings => _node.Bindings;
415 
416  public bool CanReduce => _node.CanReduce;
417 
418  public string DebugView => _node.DebugView;
419 
420  public NewExpression NewExpression => _node.NewExpression;
421 
422  public ExpressionType NodeType => _node.NodeType;
423 
424  public Type Type => _node.Type;
425 
426  public MemberInitExpressionProxy(MemberInitExpression node)
427  {
428  _node = node;
429  }
430  }
431 
432  internal class MethodCallExpressionProxy
433  {
434  private readonly MethodCallExpression _node;
435 
436  public ReadOnlyCollection<Expression> Arguments => _node.Arguments;
437 
438  public bool CanReduce => _node.CanReduce;
439 
440  public string DebugView => _node.DebugView;
441 
442  public MethodInfo Method => _node.Method;
443 
444  public ExpressionType NodeType => _node.NodeType;
445 
446  public Expression Object => _node.Object;
447 
448  public Type Type => _node.Type;
449 
450  public MethodCallExpressionProxy(MethodCallExpression node)
451  {
452  _node = node;
453  }
454  }
455 
456  internal class NewArrayExpressionProxy
457  {
458  private readonly NewArrayExpression _node;
459 
460  public bool CanReduce => _node.CanReduce;
461 
462  public string DebugView => _node.DebugView;
463 
464  public ReadOnlyCollection<Expression> Expressions => _node.Expressions;
465 
466  public ExpressionType NodeType => _node.NodeType;
467 
468  public Type Type => _node.Type;
469 
470  public NewArrayExpressionProxy(NewArrayExpression node)
471  {
472  _node = node;
473  }
474  }
475 
476  internal class NewExpressionProxy
477  {
478  private readonly NewExpression _node;
479 
480  public ReadOnlyCollection<Expression> Arguments => _node.Arguments;
481 
482  public bool CanReduce => _node.CanReduce;
483 
484  public ConstructorInfo Constructor => _node.Constructor;
485 
486  public string DebugView => _node.DebugView;
487 
488  public ReadOnlyCollection<MemberInfo> Members => _node.Members;
489 
490  public ExpressionType NodeType => _node.NodeType;
491 
492  public Type Type => _node.Type;
493 
494  public NewExpressionProxy(NewExpression node)
495  {
496  _node = node;
497  }
498  }
499 
500  internal class ParameterExpressionProxy
501  {
502  private readonly ParameterExpression _node;
503 
504  public bool CanReduce => _node.CanReduce;
505 
506  public string DebugView => _node.DebugView;
507 
508  public bool IsByRef => _node.IsByRef;
509 
510  public string Name => _node.Name;
511 
512  public ExpressionType NodeType => _node.NodeType;
513 
514  public Type Type => _node.Type;
515 
516  public ParameterExpressionProxy(ParameterExpression node)
517  {
518  _node = node;
519  }
520  }
521 
522  internal class RuntimeVariablesExpressionProxy
523  {
524  private readonly RuntimeVariablesExpression _node;
525 
526  public bool CanReduce => _node.CanReduce;
527 
528  public string DebugView => _node.DebugView;
529 
530  public ExpressionType NodeType => _node.NodeType;
531 
532  public Type Type => _node.Type;
533 
534  public ReadOnlyCollection<ParameterExpression> Variables => _node.Variables;
535 
536  public RuntimeVariablesExpressionProxy(RuntimeVariablesExpression node)
537  {
538  _node = node;
539  }
540  }
541 
542  internal class SwitchCaseProxy
543  {
544  private readonly SwitchCase _node;
545 
546  public Expression Body => _node.Body;
547 
548  public ReadOnlyCollection<Expression> TestValues => _node.TestValues;
549 
550  public SwitchCaseProxy(SwitchCase node)
551  {
552  _node = node;
553  }
554  }
555 
556  internal class SwitchExpressionProxy
557  {
558  private readonly SwitchExpression _node;
559 
560  public bool CanReduce => _node.CanReduce;
561 
562  public ReadOnlyCollection<SwitchCase> Cases => _node.Cases;
563 
564  public MethodInfo Comparison => _node.Comparison;
565 
566  public string DebugView => _node.DebugView;
567 
568  public Expression DefaultBody => _node.DefaultBody;
569 
570  public ExpressionType NodeType => _node.NodeType;
571 
572  public Expression SwitchValue => _node.SwitchValue;
573 
574  public Type Type => _node.Type;
575 
576  public SwitchExpressionProxy(SwitchExpression node)
577  {
578  _node = node;
579  }
580  }
581 
582  internal class TryExpressionProxy
583  {
584  private readonly TryExpression _node;
585 
586  public Expression Body => _node.Body;
587 
588  public bool CanReduce => _node.CanReduce;
589 
590  public string DebugView => _node.DebugView;
591 
592  public Expression Fault => _node.Fault;
593 
594  public Expression Finally => _node.Finally;
595 
596  public ReadOnlyCollection<CatchBlock> Handlers => _node.Handlers;
597 
598  public ExpressionType NodeType => _node.NodeType;
599 
600  public Type Type => _node.Type;
601 
602  public TryExpressionProxy(TryExpression node)
603  {
604  _node = node;
605  }
606  }
607 
608  internal class TypeBinaryExpressionProxy
609  {
610  private readonly TypeBinaryExpression _node;
611 
612  public bool CanReduce => _node.CanReduce;
613 
614  public string DebugView => _node.DebugView;
615 
616  public Expression Expression => _node.Expression;
617 
618  public ExpressionType NodeType => _node.NodeType;
619 
620  public Type Type => _node.Type;
621 
622  public Type TypeOperand => _node.TypeOperand;
623 
624  public TypeBinaryExpressionProxy(TypeBinaryExpression node)
625  {
626  _node = node;
627  }
628  }
629 
630  internal class UnaryExpressionProxy
631  {
632  private readonly UnaryExpression _node;
633 
634  public bool CanReduce => _node.CanReduce;
635 
636  public string DebugView => _node.DebugView;
637 
638  public bool IsLifted => _node.IsLifted;
639 
640  public bool IsLiftedToNull => _node.IsLiftedToNull;
641 
642  public MethodInfo Method => _node.Method;
643 
644  public ExpressionType NodeType => _node.NodeType;
645 
646  public Expression Operand => _node.Operand;
647 
648  public Type Type => _node.Type;
649 
650  public UnaryExpressionProxy(UnaryExpression node)
651  {
652  _node = node;
653  }
654  }
655 
656  private static readonly CacheDict<Type, MethodInfo> _LambdaDelegateCache = new CacheDict<Type, MethodInfo>(40);
657 
658  private static volatile CacheDict<Type, LambdaFactory> _LambdaFactories;
659 
660  private static ConditionalWeakTable<Expression, ExtensionInfo> _legacyCtorSupportTable;
661 
664  [global::__DynamicallyInvokable]
665  public virtual ExpressionType NodeType
666  {
667  [global::__DynamicallyInvokable]
668  get
669  {
670  if (_legacyCtorSupportTable != null && _legacyCtorSupportTable.TryGetValue(this, out ExtensionInfo value))
671  {
672  return value.NodeType;
673  }
674  throw Error.ExtensionNodeMustOverrideProperty("Expression.NodeType");
675  }
676  }
677 
680  [global::__DynamicallyInvokable]
681  public virtual Type Type
682  {
683  [global::__DynamicallyInvokable]
684  get
685  {
686  if (_legacyCtorSupportTable != null && _legacyCtorSupportTable.TryGetValue(this, out ExtensionInfo value))
687  {
688  return value.Type;
689  }
690  throw Error.ExtensionNodeMustOverrideProperty("Expression.Type");
691  }
692  }
693 
696  [global::__DynamicallyInvokable]
697  public virtual bool CanReduce
698  {
699  [global::__DynamicallyInvokable]
700  get
701  {
702  return false;
703  }
704  }
705 
706  private string DebugView
707  {
708  get
709  {
710  using (StringWriter stringWriter = new StringWriter(CultureInfo.CurrentCulture))
711  {
712  DebugViewWriter.WriteTo(this, stringWriter);
713  return stringWriter.ToString();
714  }
715  }
716  }
717 
722  [global::__DynamicallyInvokable]
723  public static BinaryExpression Assign(Expression left, Expression right)
724  {
725  RequiresCanWrite(left, "left");
726  RequiresCanRead(right, "right");
727  TypeUtils.ValidateType(left.Type);
728  TypeUtils.ValidateType(right.Type);
729  if (!TypeUtils.AreReferenceAssignable(left.Type, right.Type))
730  {
731  throw Error.ExpressionTypeDoesNotMatchAssignment(right.Type, left.Type);
732  }
733  return new AssignBinaryExpression(left, right);
734  }
735 
736  private static BinaryExpression GetUserDefinedBinaryOperator(ExpressionType binaryType, string name, Expression left, Expression right, bool liftToNull)
737  {
738  MethodInfo userDefinedBinaryOperator = GetUserDefinedBinaryOperator(binaryType, left.Type, right.Type, name);
739  if (userDefinedBinaryOperator != null)
740  {
741  return new MethodBinaryExpression(binaryType, left, right, userDefinedBinaryOperator.ReturnType, userDefinedBinaryOperator);
742  }
743  if (left.Type.IsNullableType() && right.Type.IsNullableType())
744  {
745  Type nonNullableType = left.Type.GetNonNullableType();
746  Type nonNullableType2 = right.Type.GetNonNullableType();
747  userDefinedBinaryOperator = GetUserDefinedBinaryOperator(binaryType, nonNullableType, nonNullableType2, name);
748  if (userDefinedBinaryOperator != null && userDefinedBinaryOperator.ReturnType.IsValueType && !userDefinedBinaryOperator.ReturnType.IsNullableType())
749  {
750  if ((userDefinedBinaryOperator.ReturnType != typeof(bool)) | liftToNull)
751  {
752  return new MethodBinaryExpression(binaryType, left, right, TypeUtils.GetNullableType(userDefinedBinaryOperator.ReturnType), userDefinedBinaryOperator);
753  }
754  return new MethodBinaryExpression(binaryType, left, right, typeof(bool), userDefinedBinaryOperator);
755  }
756  }
757  return null;
758  }
759 
760  private static BinaryExpression GetMethodBasedBinaryOperator(ExpressionType binaryType, Expression left, Expression right, MethodInfo method, bool liftToNull)
761  {
762  ValidateOperator(method);
763  ParameterInfo[] parametersCached = method.GetParametersCached();
764  if (parametersCached.Length != 2)
765  {
766  throw Error.IncorrectNumberOfMethodCallArguments(method);
767  }
768  if (ParameterIsAssignable(parametersCached[0], left.Type) && ParameterIsAssignable(parametersCached[1], right.Type))
769  {
770  ValidateParamswithOperandsOrThrow(parametersCached[0].ParameterType, left.Type, binaryType, method.Name);
771  ValidateParamswithOperandsOrThrow(parametersCached[1].ParameterType, right.Type, binaryType, method.Name);
772  return new MethodBinaryExpression(binaryType, left, right, method.ReturnType, method);
773  }
774  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())
775  {
776  if ((method.ReturnType != typeof(bool)) | liftToNull)
777  {
778  return new MethodBinaryExpression(binaryType, left, right, TypeUtils.GetNullableType(method.ReturnType), method);
779  }
780  return new MethodBinaryExpression(binaryType, left, right, typeof(bool), method);
781  }
782  throw Error.OperandTypesDoNotMatchParameters(binaryType, method.Name);
783  }
784 
785  private static BinaryExpression GetMethodBasedAssignOperator(ExpressionType binaryType, Expression left, Expression right, MethodInfo method, LambdaExpression conversion, bool liftToNull)
786  {
787  BinaryExpression binaryExpression = GetMethodBasedBinaryOperator(binaryType, left, right, method, liftToNull);
788  if (conversion == null)
789  {
790  if (!TypeUtils.AreReferenceAssignable(left.Type, binaryExpression.Type))
791  {
792  throw Error.UserDefinedOpMustHaveValidReturnType(binaryType, binaryExpression.Method.Name);
793  }
794  }
795  else
796  {
797  ValidateOpAssignConversionLambda(conversion, binaryExpression.Left, binaryExpression.Method, binaryExpression.NodeType);
798  binaryExpression = new OpAssignMethodConversionBinaryExpression(binaryExpression.NodeType, binaryExpression.Left, binaryExpression.Right, binaryExpression.Left.Type, binaryExpression.Method, conversion);
799  }
800  return binaryExpression;
801  }
802 
803  private static BinaryExpression GetUserDefinedBinaryOperatorOrThrow(ExpressionType binaryType, string name, Expression left, Expression right, bool liftToNull)
804  {
805  BinaryExpression userDefinedBinaryOperator = GetUserDefinedBinaryOperator(binaryType, name, left, right, liftToNull);
806  if (userDefinedBinaryOperator != null)
807  {
808  ParameterInfo[] parametersCached = userDefinedBinaryOperator.Method.GetParametersCached();
809  ValidateParamswithOperandsOrThrow(parametersCached[0].ParameterType, left.Type, binaryType, name);
810  ValidateParamswithOperandsOrThrow(parametersCached[1].ParameterType, right.Type, binaryType, name);
811  return userDefinedBinaryOperator;
812  }
813  throw Error.BinaryOperatorNotDefined(binaryType, left.Type, right.Type);
814  }
815 
816  private static BinaryExpression GetUserDefinedAssignOperatorOrThrow(ExpressionType binaryType, string name, Expression left, Expression right, LambdaExpression conversion, bool liftToNull)
817  {
818  BinaryExpression binaryExpression = GetUserDefinedBinaryOperatorOrThrow(binaryType, name, left, right, liftToNull);
819  if (conversion == null)
820  {
821  if (!TypeUtils.AreReferenceAssignable(left.Type, binaryExpression.Type))
822  {
823  throw Error.UserDefinedOpMustHaveValidReturnType(binaryType, binaryExpression.Method.Name);
824  }
825  }
826  else
827  {
828  ValidateOpAssignConversionLambda(conversion, binaryExpression.Left, binaryExpression.Method, binaryExpression.NodeType);
829  binaryExpression = new OpAssignMethodConversionBinaryExpression(binaryExpression.NodeType, binaryExpression.Left, binaryExpression.Right, binaryExpression.Left.Type, binaryExpression.Method, conversion);
830  }
831  return binaryExpression;
832  }
833 
834  private static MethodInfo GetUserDefinedBinaryOperator(ExpressionType binaryType, Type leftType, Type rightType, string name)
835  {
836  Type[] types = new Type[2]
837  {
838  leftType,
839  rightType
840  };
841  Type nonNullableType = leftType.GetNonNullableType();
842  Type nonNullableType2 = rightType.GetNonNullableType();
843  BindingFlags bindingAttr = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
844  MethodInfo methodInfo = nonNullableType.GetMethodValidated(name, bindingAttr, null, types, null);
845  if (methodInfo == null && !TypeUtils.AreEquivalent(leftType, rightType))
846  {
847  methodInfo = nonNullableType2.GetMethodValidated(name, bindingAttr, null, types, null);
848  }
849  if (IsLiftingConditionalLogicalOperator(leftType, rightType, methodInfo, binaryType))
850  {
851  methodInfo = GetUserDefinedBinaryOperator(binaryType, nonNullableType, nonNullableType2, name);
852  }
853  return methodInfo;
854  }
855 
856  private static bool IsLiftingConditionalLogicalOperator(Type left, Type right, MethodInfo method, ExpressionType binaryType)
857  {
858  if (right.IsNullableType() && left.IsNullableType() && method == null)
859  {
860  if (binaryType != ExpressionType.AndAlso)
861  {
862  return binaryType == ExpressionType.OrElse;
863  }
864  return true;
865  }
866  return false;
867  }
868 
869  internal static bool ParameterIsAssignable(ParameterInfo pi, Type argType)
870  {
871  Type type = pi.ParameterType;
872  if (type.IsByRef)
873  {
874  type = type.GetElementType();
875  }
876  return TypeUtils.AreReferenceAssignable(type, argType);
877  }
878 
879  private static void ValidateParamswithOperandsOrThrow(Type paramType, Type operandType, ExpressionType exprType, string name)
880  {
881  if (paramType.IsNullableType() && !operandType.IsNullableType())
882  {
883  throw Error.OperandTypesDoNotMatchParameters(exprType, name);
884  }
885  }
886 
887  private static void ValidateOperator(MethodInfo method)
888  {
889  ValidateMethodInfo(method);
890  if (!method.IsStatic)
891  {
892  throw Error.UserDefinedOperatorMustBeStatic(method);
893  }
894  if (method.ReturnType == typeof(void))
895  {
896  throw Error.UserDefinedOperatorMustNotBeVoid(method);
897  }
898  }
899 
900  private static void ValidateMethodInfo(MethodInfo method)
901  {
902  if (method.IsGenericMethodDefinition)
903  {
904  throw Error.MethodIsGeneric(method);
905  }
906  if (method.ContainsGenericParameters)
907  {
908  throw Error.MethodContainsGenericParameters(method);
909  }
910  }
911 
912  private static bool IsNullComparison(Expression left, Expression right)
913  {
914  if (IsNullConstant(left) && !IsNullConstant(right) && right.Type.IsNullableType())
915  {
916  return true;
917  }
918  if (IsNullConstant(right) && !IsNullConstant(left) && left.Type.IsNullableType())
919  {
920  return true;
921  }
922  return false;
923  }
924 
925  private static bool IsNullConstant(Expression e)
926  {
927  ConstantExpression constantExpression = e as ConstantExpression;
928  if (constantExpression != null)
929  {
930  return constantExpression.Value == null;
931  }
932  return false;
933  }
934 
935  private static void ValidateUserDefinedConditionalLogicOperator(ExpressionType nodeType, Type left, Type right, MethodInfo method)
936  {
937  ValidateOperator(method);
938  ParameterInfo[] parametersCached = method.GetParametersCached();
939  if (parametersCached.Length != 2)
940  {
941  throw Error.IncorrectNumberOfMethodCallArguments(method);
942  }
943  if (!ParameterIsAssignable(parametersCached[0], left) && (!left.IsNullableType() || !ParameterIsAssignable(parametersCached[0], left.GetNonNullableType())))
944  {
945  throw Error.OperandTypesDoNotMatchParameters(nodeType, method.Name);
946  }
947  if (!ParameterIsAssignable(parametersCached[1], right) && (!right.IsNullableType() || !ParameterIsAssignable(parametersCached[1], right.GetNonNullableType())))
948  {
949  throw Error.OperandTypesDoNotMatchParameters(nodeType, method.Name);
950  }
951  if (parametersCached[0].ParameterType != parametersCached[1].ParameterType)
952  {
953  throw Error.UserDefinedOpMustHaveConsistentTypes(nodeType, method.Name);
954  }
955  if (method.ReturnType != parametersCached[0].ParameterType)
956  {
957  throw Error.UserDefinedOpMustHaveConsistentTypes(nodeType, method.Name);
958  }
959  if (IsValidLiftedConditionalLogicalOperator(left, right, parametersCached))
960  {
961  left = left.GetNonNullableType();
962  right = left.GetNonNullableType();
963  }
964  MethodInfo booleanOperator = TypeUtils.GetBooleanOperator(method.DeclaringType, "op_True");
965  MethodInfo booleanOperator2 = TypeUtils.GetBooleanOperator(method.DeclaringType, "op_False");
966  if (booleanOperator == null || booleanOperator.ReturnType != typeof(bool) || booleanOperator2 == null || booleanOperator2.ReturnType != typeof(bool))
967  {
968  throw Error.LogicalOperatorMustHaveBooleanOperators(nodeType, method.Name);
969  }
970  VerifyOpTrueFalse(nodeType, left, booleanOperator2);
971  VerifyOpTrueFalse(nodeType, left, booleanOperator);
972  }
973 
974  private static void VerifyOpTrueFalse(ExpressionType nodeType, Type left, MethodInfo opTrue)
975  {
976  ParameterInfo[] parametersCached = opTrue.GetParametersCached();
977  if (parametersCached.Length != 1)
978  {
979  throw Error.IncorrectNumberOfMethodCallArguments(opTrue);
980  }
981  if (!ParameterIsAssignable(parametersCached[0], left) && (!left.IsNullableType() || !ParameterIsAssignable(parametersCached[0], left.GetNonNullableType())))
982  {
983  throw Error.OperandTypesDoNotMatchParameters(nodeType, opTrue.Name);
984  }
985  }
986 
987  private static bool IsValidLiftedConditionalLogicalOperator(Type left, Type right, ParameterInfo[] pms)
988  {
989  if (TypeUtils.AreEquivalent(left, right) && right.IsNullableType())
990  {
991  return TypeUtils.AreEquivalent(pms[1].ParameterType, right.GetNonNullableType());
992  }
993  return false;
994  }
995 
1005  [global::__DynamicallyInvokable]
1006  public static BinaryExpression MakeBinary(ExpressionType binaryType, Expression left, Expression right)
1007  {
1008  return MakeBinary(binaryType, left, right, liftToNull: false, null, null);
1009  }
1010 
1023  [global::__DynamicallyInvokable]
1024  public static BinaryExpression MakeBinary(ExpressionType binaryType, Expression left, Expression right, bool liftToNull, MethodInfo method)
1025  {
1026  return MakeBinary(binaryType, left, right, liftToNull, method, null);
1027  }
1028 
1042  [global::__DynamicallyInvokable]
1043  public static BinaryExpression MakeBinary(ExpressionType binaryType, Expression left, Expression right, bool liftToNull, MethodInfo method, LambdaExpression conversion)
1044  {
1045  switch (binaryType)
1046  {
1047  case ExpressionType.Add:
1048  return Add(left, right, method);
1049  case ExpressionType.AddChecked:
1050  return AddChecked(left, right, method);
1051  case ExpressionType.Subtract:
1052  return Subtract(left, right, method);
1053  case ExpressionType.SubtractChecked:
1054  return SubtractChecked(left, right, method);
1055  case ExpressionType.Multiply:
1056  return Multiply(left, right, method);
1057  case ExpressionType.MultiplyChecked:
1058  return MultiplyChecked(left, right, method);
1059  case ExpressionType.Divide:
1060  return Divide(left, right, method);
1061  case ExpressionType.Modulo:
1062  return Modulo(left, right, method);
1063  case ExpressionType.Power:
1064  return Power(left, right, method);
1065  case ExpressionType.And:
1066  return And(left, right, method);
1067  case ExpressionType.AndAlso:
1068  return AndAlso(left, right, method);
1069  case ExpressionType.Or:
1070  return Or(left, right, method);
1071  case ExpressionType.OrElse:
1072  return OrElse(left, right, method);
1073  case ExpressionType.LessThan:
1074  return LessThan(left, right, liftToNull, method);
1075  case ExpressionType.LessThanOrEqual:
1076  return LessThanOrEqual(left, right, liftToNull, method);
1077  case ExpressionType.GreaterThan:
1078  return GreaterThan(left, right, liftToNull, method);
1079  case ExpressionType.GreaterThanOrEqual:
1080  return GreaterThanOrEqual(left, right, liftToNull, method);
1081  case ExpressionType.Equal:
1082  return Equal(left, right, liftToNull, method);
1083  case ExpressionType.NotEqual:
1084  return NotEqual(left, right, liftToNull, method);
1085  case ExpressionType.ExclusiveOr:
1086  return ExclusiveOr(left, right, method);
1087  case ExpressionType.Coalesce:
1088  return Coalesce(left, right, conversion);
1089  case ExpressionType.ArrayIndex:
1090  return ArrayIndex(left, right);
1091  case ExpressionType.RightShift:
1092  return RightShift(left, right, method);
1093  case ExpressionType.LeftShift:
1094  return LeftShift(left, right, method);
1095  case ExpressionType.Assign:
1096  return Assign(left, right);
1097  case ExpressionType.AddAssign:
1098  return AddAssign(left, right, method, conversion);
1099  case ExpressionType.AndAssign:
1100  return AndAssign(left, right, method, conversion);
1101  case ExpressionType.DivideAssign:
1102  return DivideAssign(left, right, method, conversion);
1103  case ExpressionType.ExclusiveOrAssign:
1104  return ExclusiveOrAssign(left, right, method, conversion);
1105  case ExpressionType.LeftShiftAssign:
1106  return LeftShiftAssign(left, right, method, conversion);
1107  case ExpressionType.ModuloAssign:
1108  return ModuloAssign(left, right, method, conversion);
1109  case ExpressionType.MultiplyAssign:
1110  return MultiplyAssign(left, right, method, conversion);
1111  case ExpressionType.OrAssign:
1112  return OrAssign(left, right, method, conversion);
1113  case ExpressionType.PowerAssign:
1114  return PowerAssign(left, right, method, conversion);
1115  case ExpressionType.RightShiftAssign:
1116  return RightShiftAssign(left, right, method, conversion);
1117  case ExpressionType.SubtractAssign:
1118  return SubtractAssign(left, right, method, conversion);
1119  case ExpressionType.AddAssignChecked:
1120  return AddAssignChecked(left, right, method, conversion);
1121  case ExpressionType.SubtractAssignChecked:
1122  return SubtractAssignChecked(left, right, method, conversion);
1123  case ExpressionType.MultiplyAssignChecked:
1124  return MultiplyAssignChecked(left, right, method, conversion);
1125  default:
1126  throw Error.UnhandledBinary(binaryType);
1127  }
1128  }
1129 
1137  [global::__DynamicallyInvokable]
1138  public static BinaryExpression Equal(Expression left, Expression right)
1139  {
1140  return Equal(left, right, liftToNull: false, null);
1141  }
1142 
1156  [global::__DynamicallyInvokable]
1157  public static BinaryExpression Equal(Expression left, Expression right, bool liftToNull, MethodInfo method)
1158  {
1159  RequiresCanRead(left, "left");
1160  RequiresCanRead(right, "right");
1161  if (method == null)
1162  {
1163  return GetEqualityComparisonOperator(ExpressionType.Equal, "op_Equality", left, right, liftToNull);
1164  }
1165  return GetMethodBasedBinaryOperator(ExpressionType.Equal, left, right, method, liftToNull);
1166  }
1167 
1172  [global::__DynamicallyInvokable]
1174  {
1175  RequiresCanRead(left, "left");
1176  RequiresCanRead(right, "right");
1177  if (TypeUtils.HasReferenceEquality(left.Type, right.Type))
1178  {
1179  return new LogicalBinaryExpression(ExpressionType.Equal, left, right);
1180  }
1181  throw Error.ReferenceEqualityNotDefined(left.Type, right.Type);
1182  }
1183 
1191  [global::__DynamicallyInvokable]
1192  public static BinaryExpression NotEqual(Expression left, Expression right)
1193  {
1194  return NotEqual(left, right, liftToNull: false, null);
1195  }
1196 
1210  [global::__DynamicallyInvokable]
1211  public static BinaryExpression NotEqual(Expression left, Expression right, bool liftToNull, MethodInfo method)
1212  {
1213  RequiresCanRead(left, "left");
1214  RequiresCanRead(right, "right");
1215  if (method == null)
1216  {
1217  return GetEqualityComparisonOperator(ExpressionType.NotEqual, "op_Inequality", left, right, liftToNull);
1218  }
1219  return GetMethodBasedBinaryOperator(ExpressionType.NotEqual, left, right, method, liftToNull);
1220  }
1221 
1226  [global::__DynamicallyInvokable]
1228  {
1229  RequiresCanRead(left, "left");
1230  RequiresCanRead(right, "right");
1231  if (TypeUtils.HasReferenceEquality(left.Type, right.Type))
1232  {
1233  return new LogicalBinaryExpression(ExpressionType.NotEqual, left, right);
1234  }
1235  throw Error.ReferenceEqualityNotDefined(left.Type, right.Type);
1236  }
1237 
1238  private static BinaryExpression GetEqualityComparisonOperator(ExpressionType binaryType, string opName, Expression left, Expression right, bool liftToNull)
1239  {
1240  if (left.Type == right.Type && (TypeUtils.IsNumeric(left.Type) || left.Type == typeof(object) || TypeUtils.IsBool(left.Type) || left.Type.GetNonNullableType().IsEnum))
1241  {
1242  if (left.Type.IsNullableType() && liftToNull)
1243  {
1244  return new SimpleBinaryExpression(binaryType, left, right, typeof(bool?));
1245  }
1246  return new LogicalBinaryExpression(binaryType, left, right);
1247  }
1248  BinaryExpression userDefinedBinaryOperator = GetUserDefinedBinaryOperator(binaryType, opName, left, right, liftToNull);
1249  if (userDefinedBinaryOperator != null)
1250  {
1251  return userDefinedBinaryOperator;
1252  }
1253  if (TypeUtils.HasBuiltInEqualityOperator(left.Type, right.Type) || IsNullComparison(left, right))
1254  {
1255  if (left.Type.IsNullableType() && liftToNull)
1256  {
1257  return new SimpleBinaryExpression(binaryType, left, right, typeof(bool?));
1258  }
1259  return new LogicalBinaryExpression(binaryType, left, right);
1260  }
1261  throw Error.BinaryOperatorNotDefined(binaryType, left.Type, right.Type);
1262  }
1263 
1271  [global::__DynamicallyInvokable]
1273  {
1274  return GreaterThan(left, right, liftToNull: false, null);
1275  }
1276 
1290  [global::__DynamicallyInvokable]
1291  public static BinaryExpression GreaterThan(Expression left, Expression right, bool liftToNull, MethodInfo method)
1292  {
1293  RequiresCanRead(left, "left");
1294  RequiresCanRead(right, "right");
1295  if (method == null)
1296  {
1297  return GetComparisonOperator(ExpressionType.GreaterThan, "op_GreaterThan", left, right, liftToNull);
1298  }
1299  return GetMethodBasedBinaryOperator(ExpressionType.GreaterThan, left, right, method, liftToNull);
1300  }
1301 
1309  [global::__DynamicallyInvokable]
1310  public static BinaryExpression LessThan(Expression left, Expression right)
1311  {
1312  return LessThan(left, right, liftToNull: false, null);
1313  }
1314 
1328  [global::__DynamicallyInvokable]
1329  public static BinaryExpression LessThan(Expression left, Expression right, bool liftToNull, MethodInfo method)
1330  {
1331  RequiresCanRead(left, "left");
1332  RequiresCanRead(right, "right");
1333  if (method == null)
1334  {
1335  return GetComparisonOperator(ExpressionType.LessThan, "op_LessThan", left, right, liftToNull);
1336  }
1337  return GetMethodBasedBinaryOperator(ExpressionType.LessThan, left, right, method, liftToNull);
1338  }
1339 
1347  [global::__DynamicallyInvokable]
1349  {
1350  return GreaterThanOrEqual(left, right, liftToNull: false, null);
1351  }
1352 
1366  [global::__DynamicallyInvokable]
1367  public static BinaryExpression GreaterThanOrEqual(Expression left, Expression right, bool liftToNull, MethodInfo method)
1368  {
1369  RequiresCanRead(left, "left");
1370  RequiresCanRead(right, "right");
1371  if (method == null)
1372  {
1373  return GetComparisonOperator(ExpressionType.GreaterThanOrEqual, "op_GreaterThanOrEqual", left, right, liftToNull);
1374  }
1375  return GetMethodBasedBinaryOperator(ExpressionType.GreaterThanOrEqual, left, right, method, liftToNull);
1376  }
1377 
1385  [global::__DynamicallyInvokable]
1387  {
1388  return LessThanOrEqual(left, right, liftToNull: false, null);
1389  }
1390 
1404  [global::__DynamicallyInvokable]
1405  public static BinaryExpression LessThanOrEqual(Expression left, Expression right, bool liftToNull, MethodInfo method)
1406  {
1407  RequiresCanRead(left, "left");
1408  RequiresCanRead(right, "right");
1409  if (method == null)
1410  {
1411  return GetComparisonOperator(ExpressionType.LessThanOrEqual, "op_LessThanOrEqual", left, right, liftToNull);
1412  }
1413  return GetMethodBasedBinaryOperator(ExpressionType.LessThanOrEqual, left, right, method, liftToNull);
1414  }
1415 
1416  private static BinaryExpression GetComparisonOperator(ExpressionType binaryType, string opName, Expression left, Expression right, bool liftToNull)
1417  {
1418  if (left.Type == right.Type && TypeUtils.IsNumeric(left.Type))
1419  {
1420  if (left.Type.IsNullableType() && liftToNull)
1421  {
1422  return new SimpleBinaryExpression(binaryType, left, right, typeof(bool?));
1423  }
1424  return new LogicalBinaryExpression(binaryType, left, right);
1425  }
1426  return GetUserDefinedBinaryOperatorOrThrow(binaryType, opName, left, right, liftToNull);
1427  }
1428 
1437  [global::__DynamicallyInvokable]
1438  public static BinaryExpression AndAlso(Expression left, Expression right)
1439  {
1440  return AndAlso(left, right, null);
1441  }
1442 
1455  [global::__DynamicallyInvokable]
1456  public static BinaryExpression AndAlso(Expression left, Expression right, MethodInfo method)
1457  {
1458  RequiresCanRead(left, "left");
1459  RequiresCanRead(right, "right");
1460  Type type;
1461  if (method == null)
1462  {
1463  if (left.Type == right.Type)
1464  {
1465  if (left.Type == typeof(bool))
1466  {
1467  return new LogicalBinaryExpression(ExpressionType.AndAlso, left, right);
1468  }
1469  if (left.Type == typeof(bool?))
1470  {
1471  return new SimpleBinaryExpression(ExpressionType.AndAlso, left, right, left.Type);
1472  }
1473  }
1474  method = GetUserDefinedBinaryOperator(ExpressionType.AndAlso, left.Type, right.Type, "op_BitwiseAnd");
1475  if (method != null)
1476  {
1477  ValidateUserDefinedConditionalLogicOperator(ExpressionType.AndAlso, left.Type, right.Type, method);
1478  type = ((left.Type.IsNullableType() && TypeUtils.AreEquivalent(method.ReturnType, left.Type.GetNonNullableType())) ? left.Type : method.ReturnType);
1479  return new MethodBinaryExpression(ExpressionType.AndAlso, left, right, type, method);
1480  }
1481  throw Error.BinaryOperatorNotDefined(ExpressionType.AndAlso, left.Type, right.Type);
1482  }
1483  ValidateUserDefinedConditionalLogicOperator(ExpressionType.AndAlso, left.Type, right.Type, method);
1484  type = ((left.Type.IsNullableType() && TypeUtils.AreEquivalent(method.ReturnType, left.Type.GetNonNullableType())) ? left.Type : method.ReturnType);
1485  return new MethodBinaryExpression(ExpressionType.AndAlso, left, right, type, method);
1486  }
1487 
1496  [global::__DynamicallyInvokable]
1497  public static BinaryExpression OrElse(Expression left, Expression right)
1498  {
1499  return OrElse(left, right, null);
1500  }
1501 
1514  [global::__DynamicallyInvokable]
1515  public static BinaryExpression OrElse(Expression left, Expression right, MethodInfo method)
1516  {
1517  RequiresCanRead(left, "left");
1518  RequiresCanRead(right, "right");
1519  Type type;
1520  if (method == null)
1521  {
1522  if (left.Type == right.Type)
1523  {
1524  if (left.Type == typeof(bool))
1525  {
1526  return new LogicalBinaryExpression(ExpressionType.OrElse, left, right);
1527  }
1528  if (left.Type == typeof(bool?))
1529  {
1530  return new SimpleBinaryExpression(ExpressionType.OrElse, left, right, left.Type);
1531  }
1532  }
1533  method = GetUserDefinedBinaryOperator(ExpressionType.OrElse, left.Type, right.Type, "op_BitwiseOr");
1534  if (method != null)
1535  {
1536  ValidateUserDefinedConditionalLogicOperator(ExpressionType.OrElse, left.Type, right.Type, method);
1537  type = ((left.Type.IsNullableType() && method.ReturnType == left.Type.GetNonNullableType()) ? left.Type : method.ReturnType);
1538  return new MethodBinaryExpression(ExpressionType.OrElse, left, right, type, method);
1539  }
1540  throw Error.BinaryOperatorNotDefined(ExpressionType.OrElse, left.Type, right.Type);
1541  }
1542  ValidateUserDefinedConditionalLogicOperator(ExpressionType.OrElse, left.Type, right.Type, method);
1543  type = ((left.Type.IsNullableType() && method.ReturnType == left.Type.GetNonNullableType()) ? left.Type : method.ReturnType);
1544  return new MethodBinaryExpression(ExpressionType.OrElse, left, right, type, method);
1545  }
1546 
1556  [global::__DynamicallyInvokable]
1557  public static BinaryExpression Coalesce(Expression left, Expression right)
1558  {
1559  return Coalesce(left, right, null);
1560  }
1561 
1573  [global::__DynamicallyInvokable]
1574  public static BinaryExpression Coalesce(Expression left, Expression right, LambdaExpression conversion)
1575  {
1576  RequiresCanRead(left, "left");
1577  RequiresCanRead(right, "right");
1578  if (conversion == null)
1579  {
1580  Type type = ValidateCoalesceArgTypes(left.Type, right.Type);
1581  return new SimpleBinaryExpression(ExpressionType.Coalesce, left, right, type);
1582  }
1583  if (left.Type.IsValueType && !left.Type.IsNullableType())
1584  {
1585  throw Error.CoalesceUsedOnNonNullType();
1586  }
1587  Type type2 = conversion.Type;
1588  MethodInfo method = type2.GetMethod("Invoke");
1589  if (method.ReturnType == typeof(void))
1590  {
1591  throw Error.UserDefinedOperatorMustNotBeVoid(conversion);
1592  }
1593  ParameterInfo[] parametersCached = method.GetParametersCached();
1594  if (parametersCached.Length != 1)
1595  {
1596  throw Error.IncorrectNumberOfMethodCallArguments(conversion);
1597  }
1598  if (!TypeUtils.AreEquivalent(method.ReturnType, right.Type))
1599  {
1600  throw Error.OperandTypesDoNotMatchParameters(ExpressionType.Coalesce, conversion.ToString());
1601  }
1602  if (!ParameterIsAssignable(parametersCached[0], left.Type.GetNonNullableType()) && !ParameterIsAssignable(parametersCached[0], left.Type))
1603  {
1604  throw Error.OperandTypesDoNotMatchParameters(ExpressionType.Coalesce, conversion.ToString());
1605  }
1606  return new CoalesceConversionBinaryExpression(left, right, conversion);
1607  }
1608 
1609  private static Type ValidateCoalesceArgTypes(Type left, Type right)
1610  {
1611  Type nonNullableType = left.GetNonNullableType();
1612  if (left.IsValueType && !left.IsNullableType())
1613  {
1614  throw Error.CoalesceUsedOnNonNullType();
1615  }
1616  if (left.IsNullableType() && TypeUtils.IsImplicitlyConvertible(right, nonNullableType))
1617  {
1618  return nonNullableType;
1619  }
1620  if (TypeUtils.IsImplicitlyConvertible(right, left))
1621  {
1622  return left;
1623  }
1624  if (TypeUtils.IsImplicitlyConvertible(nonNullableType, right))
1625  {
1626  return right;
1627  }
1628  throw Error.ArgumentTypesMustMatch();
1629  }
1630 
1638  [global::__DynamicallyInvokable]
1639  public static BinaryExpression Add(Expression left, Expression right)
1640  {
1641  return Add(left, right, null);
1642  }
1643 
1655  [global::__DynamicallyInvokable]
1656  public static BinaryExpression Add(Expression left, Expression right, MethodInfo method)
1657  {
1658  RequiresCanRead(left, "left");
1659  RequiresCanRead(right, "right");
1660  if (method == null)
1661  {
1662  if (left.Type == right.Type && TypeUtils.IsArithmetic(left.Type))
1663  {
1664  return new SimpleBinaryExpression(ExpressionType.Add, left, right, left.Type);
1665  }
1666  return GetUserDefinedBinaryOperatorOrThrow(ExpressionType.Add, "op_Addition", left, right, liftToNull: true);
1667  }
1668  return GetMethodBasedBinaryOperator(ExpressionType.Add, left, right, method, liftToNull: true);
1669  }
1670 
1675  [global::__DynamicallyInvokable]
1677  {
1678  return AddAssign(left, right, null, null);
1679  }
1680 
1686  [global::__DynamicallyInvokable]
1687  public static BinaryExpression AddAssign(Expression left, Expression right, MethodInfo method)
1688  {
1689  return AddAssign(left, right, method, null);
1690  }
1691 
1698  [global::__DynamicallyInvokable]
1699  public static BinaryExpression AddAssign(Expression left, Expression right, MethodInfo method, LambdaExpression conversion)
1700  {
1701  RequiresCanRead(left, "left");
1702  RequiresCanWrite(left, "left");
1703  RequiresCanRead(right, "right");
1704  if (method == null)
1705  {
1706  if (left.Type == right.Type && TypeUtils.IsArithmetic(left.Type))
1707  {
1708  if (conversion != null)
1709  {
1710  throw Error.ConversionIsNotSupportedForArithmeticTypes();
1711  }
1712  return new SimpleBinaryExpression(ExpressionType.AddAssign, left, right, left.Type);
1713  }
1714  return GetUserDefinedAssignOperatorOrThrow(ExpressionType.AddAssign, "op_Addition", left, right, conversion, liftToNull: true);
1715  }
1716  return GetMethodBasedAssignOperator(ExpressionType.AddAssign, left, right, method, conversion, liftToNull: true);
1717  }
1718 
1719  private static void ValidateOpAssignConversionLambda(LambdaExpression conversion, Expression left, MethodInfo method, ExpressionType nodeType)
1720  {
1721  Type type = conversion.Type;
1722  MethodInfo method2 = type.GetMethod("Invoke");
1723  ParameterInfo[] parametersCached = method2.GetParametersCached();
1724  if (parametersCached.Length != 1)
1725  {
1726  throw Error.IncorrectNumberOfMethodCallArguments(conversion);
1727  }
1728  if (!TypeUtils.AreEquivalent(method2.ReturnType, left.Type))
1729  {
1730  throw Error.OperandTypesDoNotMatchParameters(nodeType, conversion.ToString());
1731  }
1732  if (method != null && !TypeUtils.AreEquivalent(parametersCached[0].ParameterType, method.ReturnType))
1733  {
1734  throw Error.OverloadOperatorTypeDoesNotMatchConversionType(nodeType, conversion.ToString());
1735  }
1736  }
1737 
1742  [global::__DynamicallyInvokable]
1744  {
1745  return AddAssignChecked(left, right, null);
1746  }
1747 
1753  [global::__DynamicallyInvokable]
1755  {
1756  return AddAssignChecked(left, right, method, null);
1757  }
1758 
1765  [global::__DynamicallyInvokable]
1767  {
1768  RequiresCanRead(left, "left");
1769  RequiresCanWrite(left, "left");
1770  RequiresCanRead(right, "right");
1771  if (method == null)
1772  {
1773  if (left.Type == right.Type && TypeUtils.IsArithmetic(left.Type))
1774  {
1775  if (conversion != null)
1776  {
1777  throw Error.ConversionIsNotSupportedForArithmeticTypes();
1778  }
1779  return new SimpleBinaryExpression(ExpressionType.AddAssignChecked, left, right, left.Type);
1780  }
1781  return GetUserDefinedAssignOperatorOrThrow(ExpressionType.AddAssignChecked, "op_Addition", left, right, conversion, liftToNull: true);
1782  }
1783  return GetMethodBasedAssignOperator(ExpressionType.AddAssignChecked, left, right, method, conversion, liftToNull: true);
1784  }
1785 
1793  [global::__DynamicallyInvokable]
1795  {
1796  return AddChecked(left, right, null);
1797  }
1798 
1810  [global::__DynamicallyInvokable]
1811  public static BinaryExpression AddChecked(Expression left, Expression right, MethodInfo method)
1812  {
1813  RequiresCanRead(left, "left");
1814  RequiresCanRead(right, "right");
1815  if (method == null)
1816  {
1817  if (left.Type == right.Type && TypeUtils.IsArithmetic(left.Type))
1818  {
1819  return new SimpleBinaryExpression(ExpressionType.AddChecked, left, right, left.Type);
1820  }
1821  return GetUserDefinedBinaryOperatorOrThrow(ExpressionType.AddChecked, "op_Addition", left, right, liftToNull: false);
1822  }
1823  return GetMethodBasedBinaryOperator(ExpressionType.AddChecked, left, right, method, liftToNull: true);
1824  }
1825 
1833  [global::__DynamicallyInvokable]
1834  public static BinaryExpression Subtract(Expression left, Expression right)
1835  {
1836  return Subtract(left, right, null);
1837  }
1838 
1850  [global::__DynamicallyInvokable]
1851  public static BinaryExpression Subtract(Expression left, Expression right, MethodInfo method)
1852  {
1853  RequiresCanRead(left, "left");
1854  RequiresCanRead(right, "right");
1855  if (method == null)
1856  {
1857  if (left.Type == right.Type && TypeUtils.IsArithmetic(left.Type))
1858  {
1859  return new SimpleBinaryExpression(ExpressionType.Subtract, left, right, left.Type);
1860  }
1861  return GetUserDefinedBinaryOperatorOrThrow(ExpressionType.Subtract, "op_Subtraction", left, right, liftToNull: true);
1862  }
1863  return GetMethodBasedBinaryOperator(ExpressionType.Subtract, left, right, method, liftToNull: true);
1864  }
1865 
1870  [global::__DynamicallyInvokable]
1872  {
1873  return SubtractAssign(left, right, null, null);
1874  }
1875 
1881  [global::__DynamicallyInvokable]
1883  {
1884  return SubtractAssign(left, right, method, null);
1885  }
1886 
1893  [global::__DynamicallyInvokable]
1894  public static BinaryExpression SubtractAssign(Expression left, Expression right, MethodInfo method, LambdaExpression conversion)
1895  {
1896  RequiresCanRead(left, "left");
1897  RequiresCanWrite(left, "left");
1898  RequiresCanRead(right, "right");
1899  if (method == null)
1900  {
1901  if (left.Type == right.Type && TypeUtils.IsArithmetic(left.Type))
1902  {
1903  if (conversion != null)
1904  {
1905  throw Error.ConversionIsNotSupportedForArithmeticTypes();
1906  }
1907  return new SimpleBinaryExpression(ExpressionType.SubtractAssign, left, right, left.Type);
1908  }
1909  return GetUserDefinedAssignOperatorOrThrow(ExpressionType.SubtractAssign, "op_Subtraction", left, right, conversion, liftToNull: true);
1910  }
1911  return GetMethodBasedAssignOperator(ExpressionType.SubtractAssign, left, right, method, conversion, liftToNull: true);
1912  }
1913 
1918  [global::__DynamicallyInvokable]
1920  {
1921  return SubtractAssignChecked(left, right, null);
1922  }
1923 
1929  [global::__DynamicallyInvokable]
1931  {
1932  return SubtractAssignChecked(left, right, method, null);
1933  }
1934 
1941  [global::__DynamicallyInvokable]
1943  {
1944  RequiresCanRead(left, "left");
1945  RequiresCanWrite(left, "left");
1946  RequiresCanRead(right, "right");
1947  if (method == null)
1948  {
1949  if (left.Type == right.Type && TypeUtils.IsArithmetic(left.Type))
1950  {
1951  if (conversion != null)
1952  {
1953  throw Error.ConversionIsNotSupportedForArithmeticTypes();
1954  }
1955  return new SimpleBinaryExpression(ExpressionType.SubtractAssignChecked, left, right, left.Type);
1956  }
1957  return GetUserDefinedAssignOperatorOrThrow(ExpressionType.SubtractAssignChecked, "op_Subtraction", left, right, conversion, liftToNull: true);
1958  }
1959  return GetMethodBasedAssignOperator(ExpressionType.SubtractAssignChecked, left, right, method, conversion, liftToNull: true);
1960  }
1961 
1969  [global::__DynamicallyInvokable]
1971  {
1972  return SubtractChecked(left, right, null);
1973  }
1974 
1986  [global::__DynamicallyInvokable]
1988  {
1989  RequiresCanRead(left, "left");
1990  RequiresCanRead(right, "right");
1991  if (method == null)
1992  {
1993  if (left.Type == right.Type && TypeUtils.IsArithmetic(left.Type))
1994  {
1995  return new SimpleBinaryExpression(ExpressionType.SubtractChecked, left, right, left.Type);
1996  }
1997  return GetUserDefinedBinaryOperatorOrThrow(ExpressionType.SubtractChecked, "op_Subtraction", left, right, liftToNull: true);
1998  }
1999  return GetMethodBasedBinaryOperator(ExpressionType.SubtractChecked, left, right, method, liftToNull: true);
2000  }
2001 
2009  [global::__DynamicallyInvokable]
2010  public static BinaryExpression Divide(Expression left, Expression right)
2011  {
2012  return Divide(left, right, null);
2013  }
2014 
2026  [global::__DynamicallyInvokable]
2027  public static BinaryExpression Divide(Expression left, Expression right, MethodInfo method)
2028  {
2029  RequiresCanRead(left, "left");
2030  RequiresCanRead(right, "right");
2031  if (method == null)
2032  {
2033  if (left.Type == right.Type && TypeUtils.IsArithmetic(left.Type))
2034  {
2035  return new SimpleBinaryExpression(ExpressionType.Divide, left, right, left.Type);
2036  }
2037  return GetUserDefinedBinaryOperatorOrThrow(ExpressionType.Divide, "op_Division", left, right, liftToNull: true);
2038  }
2039  return GetMethodBasedBinaryOperator(ExpressionType.Divide, left, right, method, liftToNull: true);
2040  }
2041 
2046  [global::__DynamicallyInvokable]
2048  {
2049  return DivideAssign(left, right, null, null);
2050  }
2051 
2057  [global::__DynamicallyInvokable]
2058  public static BinaryExpression DivideAssign(Expression left, Expression right, MethodInfo method)
2059  {
2060  return DivideAssign(left, right, method, null);
2061  }
2062 
2069  [global::__DynamicallyInvokable]
2070  public static BinaryExpression DivideAssign(Expression left, Expression right, MethodInfo method, LambdaExpression conversion)
2071  {
2072  RequiresCanRead(left, "left");
2073  RequiresCanWrite(left, "left");
2074  RequiresCanRead(right, "right");
2075  if (method == null)
2076  {
2077  if (left.Type == right.Type && TypeUtils.IsArithmetic(left.Type))
2078  {
2079  if (conversion != null)
2080  {
2081  throw Error.ConversionIsNotSupportedForArithmeticTypes();
2082  }
2083  return new SimpleBinaryExpression(ExpressionType.DivideAssign, left, right, left.Type);
2084  }
2085  return GetUserDefinedAssignOperatorOrThrow(ExpressionType.DivideAssign, "op_Division", left, right, conversion, liftToNull: true);
2086  }
2087  return GetMethodBasedAssignOperator(ExpressionType.DivideAssign, left, right, method, conversion, liftToNull: true);
2088  }
2089 
2097  [global::__DynamicallyInvokable]
2098  public static BinaryExpression Modulo(Expression left, Expression right)
2099  {
2100  return Modulo(left, right, null);
2101  }
2102 
2114  [global::__DynamicallyInvokable]
2115  public static BinaryExpression Modulo(Expression left, Expression right, MethodInfo method)
2116  {
2117  RequiresCanRead(left, "left");
2118  RequiresCanRead(right, "right");
2119  if (method == null)
2120  {
2121  if (left.Type == right.Type && TypeUtils.IsArithmetic(left.Type))
2122  {
2123  return new SimpleBinaryExpression(ExpressionType.Modulo, left, right, left.Type);
2124  }
2125  return GetUserDefinedBinaryOperatorOrThrow(ExpressionType.Modulo, "op_Modulus", left, right, liftToNull: true);
2126  }
2127  return GetMethodBasedBinaryOperator(ExpressionType.Modulo, left, right, method, liftToNull: true);
2128  }
2129 
2134  [global::__DynamicallyInvokable]
2136  {
2137  return ModuloAssign(left, right, null, null);
2138  }
2139 
2145  [global::__DynamicallyInvokable]
2146  public static BinaryExpression ModuloAssign(Expression left, Expression right, MethodInfo method)
2147  {
2148  return ModuloAssign(left, right, method, null);
2149  }
2150 
2157  [global::__DynamicallyInvokable]
2158  public static BinaryExpression ModuloAssign(Expression left, Expression right, MethodInfo method, LambdaExpression conversion)
2159  {
2160  RequiresCanRead(left, "left");
2161  RequiresCanWrite(left, "left");
2162  RequiresCanRead(right, "right");
2163  if (method == null)
2164  {
2165  if (left.Type == right.Type && TypeUtils.IsArithmetic(left.Type))
2166  {
2167  if (conversion != null)
2168  {
2169  throw Error.ConversionIsNotSupportedForArithmeticTypes();
2170  }
2171  return new SimpleBinaryExpression(ExpressionType.ModuloAssign, left, right, left.Type);
2172  }
2173  return GetUserDefinedAssignOperatorOrThrow(ExpressionType.ModuloAssign, "op_Modulus", left, right, conversion, liftToNull: true);
2174  }
2175  return GetMethodBasedAssignOperator(ExpressionType.ModuloAssign, left, right, method, conversion, liftToNull: true);
2176  }
2177 
2185  [global::__DynamicallyInvokable]
2186  public static BinaryExpression Multiply(Expression left, Expression right)
2187  {
2188  return Multiply(left, right, null);
2189  }
2190 
2202  [global::__DynamicallyInvokable]
2203  public static BinaryExpression Multiply(Expression left, Expression right, MethodInfo method)
2204  {
2205  RequiresCanRead(left, "left");
2206  RequiresCanRead(right, "right");
2207  if (method == null)
2208  {
2209  if (left.Type == right.Type && TypeUtils.IsArithmetic(left.Type))
2210  {
2211  return new SimpleBinaryExpression(ExpressionType.Multiply, left, right, left.Type);
2212  }
2213  return GetUserDefinedBinaryOperatorOrThrow(ExpressionType.Multiply, "op_Multiply", left, right, liftToNull: true);
2214  }
2215  return GetMethodBasedBinaryOperator(ExpressionType.Multiply, left, right, method, liftToNull: true);
2216  }
2217 
2222  [global::__DynamicallyInvokable]
2224  {
2225  return MultiplyAssign(left, right, null, null);
2226  }
2227 
2233  [global::__DynamicallyInvokable]
2235  {
2236  return MultiplyAssign(left, right, method, null);
2237  }
2238 
2245  [global::__DynamicallyInvokable]
2246  public static BinaryExpression MultiplyAssign(Expression left, Expression right, MethodInfo method, LambdaExpression conversion)
2247  {
2248  RequiresCanRead(left, "left");
2249  RequiresCanWrite(left, "left");
2250  RequiresCanRead(right, "right");
2251  if (method == null)
2252  {
2253  if (left.Type == right.Type && TypeUtils.IsArithmetic(left.Type))
2254  {
2255  if (conversion != null)
2256  {
2257  throw Error.ConversionIsNotSupportedForArithmeticTypes();
2258  }
2259  return new SimpleBinaryExpression(ExpressionType.MultiplyAssign, left, right, left.Type);
2260  }
2261  return GetUserDefinedAssignOperatorOrThrow(ExpressionType.MultiplyAssign, "op_Multiply", left, right, conversion, liftToNull: true);
2262  }
2263  return GetMethodBasedAssignOperator(ExpressionType.MultiplyAssign, left, right, method, conversion, liftToNull: true);
2264  }
2265 
2270  [global::__DynamicallyInvokable]
2272  {
2273  return MultiplyAssignChecked(left, right, null);
2274  }
2275 
2281  [global::__DynamicallyInvokable]
2283  {
2284  return MultiplyAssignChecked(left, right, method, null);
2285  }
2286 
2293  [global::__DynamicallyInvokable]
2295  {
2296  RequiresCanRead(left, "left");
2297  RequiresCanWrite(left, "left");
2298  RequiresCanRead(right, "right");
2299  if (method == null)
2300  {
2301  if (left.Type == right.Type && TypeUtils.IsArithmetic(left.Type))
2302  {
2303  if (conversion != null)
2304  {
2305  throw Error.ConversionIsNotSupportedForArithmeticTypes();
2306  }
2307  return new SimpleBinaryExpression(ExpressionType.MultiplyAssignChecked, left, right, left.Type);
2308  }
2309  return GetUserDefinedAssignOperatorOrThrow(ExpressionType.MultiplyAssignChecked, "op_Multiply", left, right, conversion, liftToNull: true);
2310  }
2311  return GetMethodBasedAssignOperator(ExpressionType.MultiplyAssignChecked, left, right, method, conversion, liftToNull: true);
2312  }
2313 
2321  [global::__DynamicallyInvokable]
2323  {
2324  return MultiplyChecked(left, right, null);
2325  }
2326 
2338  [global::__DynamicallyInvokable]
2340  {
2341  RequiresCanRead(left, "left");
2342  RequiresCanRead(right, "right");
2343  if (method == null)
2344  {
2345  if (left.Type == right.Type && TypeUtils.IsArithmetic(left.Type))
2346  {
2347  return new SimpleBinaryExpression(ExpressionType.MultiplyChecked, left, right, left.Type);
2348  }
2349  return GetUserDefinedBinaryOperatorOrThrow(ExpressionType.MultiplyChecked, "op_Multiply", left, right, liftToNull: true);
2350  }
2351  return GetMethodBasedBinaryOperator(ExpressionType.MultiplyChecked, left, right, method, liftToNull: true);
2352  }
2353 
2354  private static bool IsSimpleShift(Type left, Type right)
2355  {
2356  if (TypeUtils.IsInteger(left))
2357  {
2358  return right.GetNonNullableType() == typeof(int);
2359  }
2360  return false;
2361  }
2362 
2363  private static Type GetResultTypeOfShift(Type left, Type right)
2364  {
2365  if (!left.IsNullableType() && right.IsNullableType())
2366  {
2367  return typeof(Nullable<>).MakeGenericType(left);
2368  }
2369  return left;
2370  }
2371 
2379  [global::__DynamicallyInvokable]
2381  {
2382  return LeftShift(left, right, null);
2383  }
2384 
2396  [global::__DynamicallyInvokable]
2397  public static BinaryExpression LeftShift(Expression left, Expression right, MethodInfo method)
2398  {
2399  RequiresCanRead(left, "left");
2400  RequiresCanRead(right, "right");
2401  if (method == null)
2402  {
2403  if (IsSimpleShift(left.Type, right.Type))
2404  {
2405  Type resultTypeOfShift = GetResultTypeOfShift(left.Type, right.Type);
2406  return new SimpleBinaryExpression(ExpressionType.LeftShift, left, right, resultTypeOfShift);
2407  }
2408  return GetUserDefinedBinaryOperatorOrThrow(ExpressionType.LeftShift, "op_LeftShift", left, right, liftToNull: true);
2409  }
2410  return GetMethodBasedBinaryOperator(ExpressionType.LeftShift, left, right, method, liftToNull: true);
2411  }
2412 
2417  [global::__DynamicallyInvokable]
2419  {
2420  return LeftShiftAssign(left, right, null, null);
2421  }
2422 
2428  [global::__DynamicallyInvokable]
2430  {
2431  return LeftShiftAssign(left, right, method, null);
2432  }
2433 
2440  [global::__DynamicallyInvokable]
2441  public static BinaryExpression LeftShiftAssign(Expression left, Expression right, MethodInfo method, LambdaExpression conversion)
2442  {
2443  RequiresCanRead(left, "left");
2444  RequiresCanWrite(left, "left");
2445  RequiresCanRead(right, "right");
2446  if (method == null)
2447  {
2448  if (IsSimpleShift(left.Type, right.Type))
2449  {
2450  if (conversion != null)
2451  {
2452  throw Error.ConversionIsNotSupportedForArithmeticTypes();
2453  }
2454  Type resultTypeOfShift = GetResultTypeOfShift(left.Type, right.Type);
2455  return new SimpleBinaryExpression(ExpressionType.LeftShiftAssign, left, right, resultTypeOfShift);
2456  }
2457  return GetUserDefinedAssignOperatorOrThrow(ExpressionType.LeftShiftAssign, "op_LeftShift", left, right, conversion, liftToNull: true);
2458  }
2459  return GetMethodBasedAssignOperator(ExpressionType.LeftShiftAssign, left, right, method, conversion, liftToNull: true);
2460  }
2461 
2469  [global::__DynamicallyInvokable]
2471  {
2472  return RightShift(left, right, null);
2473  }
2474 
2486  [global::__DynamicallyInvokable]
2487  public static BinaryExpression RightShift(Expression left, Expression right, MethodInfo method)
2488  {
2489  RequiresCanRead(left, "left");
2490  RequiresCanRead(right, "right");
2491  if (method == null)
2492  {
2493  if (IsSimpleShift(left.Type, right.Type))
2494  {
2495  Type resultTypeOfShift = GetResultTypeOfShift(left.Type, right.Type);
2496  return new SimpleBinaryExpression(ExpressionType.RightShift, left, right, resultTypeOfShift);
2497  }
2498  return GetUserDefinedBinaryOperatorOrThrow(ExpressionType.RightShift, "op_RightShift", left, right, liftToNull: true);
2499  }
2500  return GetMethodBasedBinaryOperator(ExpressionType.RightShift, left, right, method, liftToNull: true);
2501  }
2502 
2507  [global::__DynamicallyInvokable]
2509  {
2510  return RightShiftAssign(left, right, null, null);
2511  }
2512 
2518  [global::__DynamicallyInvokable]
2520  {
2521  return RightShiftAssign(left, right, method, null);
2522  }
2523 
2530  [global::__DynamicallyInvokable]
2532  {
2533  RequiresCanRead(left, "left");
2534  RequiresCanWrite(left, "left");
2535  RequiresCanRead(right, "right");
2536  if (method == null)
2537  {
2538  if (IsSimpleShift(left.Type, right.Type))
2539  {
2540  if (conversion != null)
2541  {
2542  throw Error.ConversionIsNotSupportedForArithmeticTypes();
2543  }
2544  Type resultTypeOfShift = GetResultTypeOfShift(left.Type, right.Type);
2545  return new SimpleBinaryExpression(ExpressionType.RightShiftAssign, left, right, resultTypeOfShift);
2546  }
2547  return GetUserDefinedAssignOperatorOrThrow(ExpressionType.RightShiftAssign, "op_RightShift", left, right, conversion, liftToNull: true);
2548  }
2549  return GetMethodBasedAssignOperator(ExpressionType.RightShiftAssign, left, right, method, conversion, liftToNull: true);
2550  }
2551 
2559  [global::__DynamicallyInvokable]
2560  public static BinaryExpression And(Expression left, Expression right)
2561  {
2562  return And(left, right, null);
2563  }
2564 
2576  [global::__DynamicallyInvokable]
2577  public static BinaryExpression And(Expression left, Expression right, MethodInfo method)
2578  {
2579  RequiresCanRead(left, "left");
2580  RequiresCanRead(right, "right");
2581  if (method == null)
2582  {
2583  if (left.Type == right.Type && TypeUtils.IsIntegerOrBool(left.Type))
2584  {
2585  return new SimpleBinaryExpression(ExpressionType.And, left, right, left.Type);
2586  }
2587  return GetUserDefinedBinaryOperatorOrThrow(ExpressionType.And, "op_BitwiseAnd", left, right, liftToNull: true);
2588  }
2589  return GetMethodBasedBinaryOperator(ExpressionType.And, left, right, method, liftToNull: true);
2590  }
2591 
2596  [global::__DynamicallyInvokable]
2598  {
2599  return AndAssign(left, right, null, null);
2600  }
2601 
2607  [global::__DynamicallyInvokable]
2608  public static BinaryExpression AndAssign(Expression left, Expression right, MethodInfo method)
2609  {
2610  return AndAssign(left, right, method, null);
2611  }
2612 
2619  [global::__DynamicallyInvokable]
2620  public static BinaryExpression AndAssign(Expression left, Expression right, MethodInfo method, LambdaExpression conversion)
2621  {
2622  RequiresCanRead(left, "left");
2623  RequiresCanWrite(left, "left");
2624  RequiresCanRead(right, "right");
2625  if (method == null)
2626  {
2627  if (left.Type == right.Type && TypeUtils.IsIntegerOrBool(left.Type))
2628  {
2629  if (conversion != null)
2630  {
2631  throw Error.ConversionIsNotSupportedForArithmeticTypes();
2632  }
2633  return new SimpleBinaryExpression(ExpressionType.AndAssign, left, right, left.Type);
2634  }
2635  return GetUserDefinedAssignOperatorOrThrow(ExpressionType.AndAssign, "op_BitwiseAnd", left, right, conversion, liftToNull: true);
2636  }
2637  return GetMethodBasedAssignOperator(ExpressionType.AndAssign, left, right, method, conversion, liftToNull: true);
2638  }
2639 
2647  [global::__DynamicallyInvokable]
2648  public static BinaryExpression Or(Expression left, Expression right)
2649  {
2650  return Or(left, right, null);
2651  }
2652 
2664  [global::__DynamicallyInvokable]
2665  public static BinaryExpression Or(Expression left, Expression right, MethodInfo method)
2666  {
2667  RequiresCanRead(left, "left");
2668  RequiresCanRead(right, "right");
2669  if (method == null)
2670  {
2671  if (left.Type == right.Type && TypeUtils.IsIntegerOrBool(left.Type))
2672  {
2673  return new SimpleBinaryExpression(ExpressionType.Or, left, right, left.Type);
2674  }
2675  return GetUserDefinedBinaryOperatorOrThrow(ExpressionType.Or, "op_BitwiseOr", left, right, liftToNull: true);
2676  }
2677  return GetMethodBasedBinaryOperator(ExpressionType.Or, left, right, method, liftToNull: true);
2678  }
2679 
2684  [global::__DynamicallyInvokable]
2685  public static BinaryExpression OrAssign(Expression left, Expression right)
2686  {
2687  return OrAssign(left, right, null, null);
2688  }
2689 
2695  [global::__DynamicallyInvokable]
2696  public static BinaryExpression OrAssign(Expression left, Expression right, MethodInfo method)
2697  {
2698  return OrAssign(left, right, method, null);
2699  }
2700 
2707  [global::__DynamicallyInvokable]
2708  public static BinaryExpression OrAssign(Expression left, Expression right, MethodInfo method, LambdaExpression conversion)
2709  {
2710  RequiresCanRead(left, "left");
2711  RequiresCanWrite(left, "left");
2712  RequiresCanRead(right, "right");
2713  if (method == null)
2714  {
2715  if (left.Type == right.Type && TypeUtils.IsIntegerOrBool(left.Type))
2716  {
2717  if (conversion != null)
2718  {
2719  throw Error.ConversionIsNotSupportedForArithmeticTypes();
2720  }
2721  return new SimpleBinaryExpression(ExpressionType.OrAssign, left, right, left.Type);
2722  }
2723  return GetUserDefinedAssignOperatorOrThrow(ExpressionType.OrAssign, "op_BitwiseOr", left, right, conversion, liftToNull: true);
2724  }
2725  return GetMethodBasedAssignOperator(ExpressionType.OrAssign, left, right, method, conversion, liftToNull: true);
2726  }
2727 
2735  [global::__DynamicallyInvokable]
2737  {
2738  return ExclusiveOr(left, right, null);
2739  }
2740 
2752  [global::__DynamicallyInvokable]
2753  public static BinaryExpression ExclusiveOr(Expression left, Expression right, MethodInfo method)
2754  {
2755  RequiresCanRead(left, "left");
2756  RequiresCanRead(right, "right");
2757  if (method == null)
2758  {
2759  if (left.Type == right.Type && TypeUtils.IsIntegerOrBool(left.Type))
2760  {
2761  return new SimpleBinaryExpression(ExpressionType.ExclusiveOr, left, right, left.Type);
2762  }
2763  return GetUserDefinedBinaryOperatorOrThrow(ExpressionType.ExclusiveOr, "op_ExclusiveOr", left, right, liftToNull: true);
2764  }
2765  return GetMethodBasedBinaryOperator(ExpressionType.ExclusiveOr, left, right, method, liftToNull: true);
2766  }
2767 
2772  [global::__DynamicallyInvokable]
2774  {
2775  return ExclusiveOrAssign(left, right, null, null);
2776  }
2777 
2783  [global::__DynamicallyInvokable]
2785  {
2786  return ExclusiveOrAssign(left, right, method, null);
2787  }
2788 
2795  [global::__DynamicallyInvokable]
2797  {
2798  RequiresCanRead(left, "left");
2799  RequiresCanWrite(left, "left");
2800  RequiresCanRead(right, "right");
2801  if (method == null)
2802  {
2803  if (left.Type == right.Type && TypeUtils.IsIntegerOrBool(left.Type))
2804  {
2805  if (conversion != null)
2806  {
2807  throw Error.ConversionIsNotSupportedForArithmeticTypes();
2808  }
2809  return new SimpleBinaryExpression(ExpressionType.ExclusiveOrAssign, left, right, left.Type);
2810  }
2811  return GetUserDefinedAssignOperatorOrThrow(ExpressionType.ExclusiveOrAssign, "op_ExclusiveOr", left, right, conversion, liftToNull: true);
2812  }
2813  return GetMethodBasedAssignOperator(ExpressionType.ExclusiveOrAssign, left, right, method, conversion, liftToNull: true);
2814  }
2815 
2824  [global::__DynamicallyInvokable]
2825  public static BinaryExpression Power(Expression left, Expression right)
2826  {
2827  return Power(left, right, null);
2828  }
2829 
2842  [global::__DynamicallyInvokable]
2843  public static BinaryExpression Power(Expression left, Expression right, MethodInfo method)
2844  {
2845  RequiresCanRead(left, "left");
2846  RequiresCanRead(right, "right");
2847  if (method == null)
2848  {
2849  Type typeFromHandle = typeof(Math);
2850  method = typeFromHandle.GetMethod("Pow", BindingFlags.Static | BindingFlags.Public);
2851  if (method == null)
2852  {
2853  throw Error.BinaryOperatorNotDefined(ExpressionType.Power, left.Type, right.Type);
2854  }
2855  }
2856  return GetMethodBasedBinaryOperator(ExpressionType.Power, left, right, method, liftToNull: true);
2857  }
2858 
2863  [global::__DynamicallyInvokable]
2865  {
2866  return PowerAssign(left, right, null, null);
2867  }
2868 
2874  [global::__DynamicallyInvokable]
2875  public static BinaryExpression PowerAssign(Expression left, Expression right, MethodInfo method)
2876  {
2877  return PowerAssign(left, right, method, null);
2878  }
2879 
2886  [global::__DynamicallyInvokable]
2887  public static BinaryExpression PowerAssign(Expression left, Expression right, MethodInfo method, LambdaExpression conversion)
2888  {
2889  RequiresCanRead(left, "left");
2890  RequiresCanWrite(left, "left");
2891  RequiresCanRead(right, "right");
2892  if (method == null)
2893  {
2894  Type typeFromHandle = typeof(Math);
2895  method = typeFromHandle.GetMethod("Pow", BindingFlags.Static | BindingFlags.Public);
2896  if (method == null)
2897  {
2898  throw Error.BinaryOperatorNotDefined(ExpressionType.PowerAssign, left.Type, right.Type);
2899  }
2900  }
2901  return GetMethodBasedAssignOperator(ExpressionType.PowerAssign, left, right, method, conversion, liftToNull: true);
2902  }
2903 
2914  [global::__DynamicallyInvokable]
2915  public static BinaryExpression ArrayIndex(Expression array, Expression index)
2916  {
2917  RequiresCanRead(array, "array");
2918  RequiresCanRead(index, "index");
2919  if (index.Type != typeof(int))
2920  {
2921  throw Error.ArgumentMustBeArrayIndexType();
2922  }
2923  Type type = array.Type;
2924  if (!type.IsArray)
2925  {
2926  throw Error.ArgumentMustBeArray();
2927  }
2928  if (type.GetArrayRank() != 1)
2929  {
2930  throw Error.IncorrectNumberOfIndexes();
2931  }
2932  return new SimpleBinaryExpression(ExpressionType.ArrayIndex, array, index, type.GetElementType());
2933  }
2934 
2939  [global::__DynamicallyInvokable]
2940  public static BlockExpression Block(Expression arg0, Expression arg1)
2941  {
2942  RequiresCanRead(arg0, "arg0");
2943  RequiresCanRead(arg1, "arg1");
2944  return new Block2(arg0, arg1);
2945  }
2946 
2952  [global::__DynamicallyInvokable]
2953  public static BlockExpression Block(Expression arg0, Expression arg1, Expression arg2)
2954  {
2955  RequiresCanRead(arg0, "arg0");
2956  RequiresCanRead(arg1, "arg1");
2957  RequiresCanRead(arg2, "arg2");
2958  return new Block3(arg0, arg1, arg2);
2959  }
2960 
2967  [global::__DynamicallyInvokable]
2968  public static BlockExpression Block(Expression arg0, Expression arg1, Expression arg2, Expression arg3)
2969  {
2970  RequiresCanRead(arg0, "arg0");
2971  RequiresCanRead(arg1, "arg1");
2972  RequiresCanRead(arg2, "arg2");
2973  RequiresCanRead(arg3, "arg3");
2974  return new Block4(arg0, arg1, arg2, arg3);
2975  }
2976 
2984  [global::__DynamicallyInvokable]
2985  public static BlockExpression Block(Expression arg0, Expression arg1, Expression arg2, Expression arg3, Expression arg4)
2986  {
2987  RequiresCanRead(arg0, "arg0");
2988  RequiresCanRead(arg1, "arg1");
2989  RequiresCanRead(arg2, "arg2");
2990  RequiresCanRead(arg3, "arg3");
2991  RequiresCanRead(arg4, "arg4");
2992  return new Block5(arg0, arg1, arg2, arg3, arg4);
2993  }
2994 
2998  [global::__DynamicallyInvokable]
2999  public static BlockExpression Block(params Expression[] expressions)
3000  {
3001  ContractUtils.RequiresNotNull(expressions, "expressions");
3002  switch (expressions.Length)
3003  {
3004  case 2:
3005  return Block(expressions[0], expressions[1]);
3006  case 3:
3007  return Block(expressions[0], expressions[1], expressions[2]);
3008  case 4:
3009  return Block(expressions[0], expressions[1], expressions[2], expressions[3]);
3010  case 5:
3011  return Block(expressions[0], expressions[1], expressions[2], expressions[3], expressions[4]);
3012  default:
3013  ContractUtils.RequiresNotEmpty(expressions, "expressions");
3014  RequiresCanRead(expressions, "expressions");
3015  return new BlockN(expressions.Copy());
3016  }
3017  }
3018 
3022  [global::__DynamicallyInvokable]
3023  public static BlockExpression Block(IEnumerable<Expression> expressions)
3024  {
3025  return Block(EmptyReadOnlyCollection<ParameterExpression>.Instance, expressions);
3026  }
3027 
3032  [global::__DynamicallyInvokable]
3033  public static BlockExpression Block(Type type, params Expression[] expressions)
3034  {
3035  ContractUtils.RequiresNotNull(expressions, "expressions");
3036  return Block(type, (IEnumerable<Expression>)expressions);
3037  }
3038 
3043  [global::__DynamicallyInvokable]
3044  public static BlockExpression Block(Type type, IEnumerable<Expression> expressions)
3045  {
3046  return Block(type, EmptyReadOnlyCollection<ParameterExpression>.Instance, expressions);
3047  }
3048 
3053  [global::__DynamicallyInvokable]
3054  public static BlockExpression Block(IEnumerable<ParameterExpression> variables, params Expression[] expressions)
3055  {
3056  return Block(variables, (IEnumerable<Expression>)expressions);
3057  }
3058 
3064  [global::__DynamicallyInvokable]
3065  public static BlockExpression Block(Type type, IEnumerable<ParameterExpression> variables, params Expression[] expressions)
3066  {
3067  return Block(type, variables, (IEnumerable<Expression>)expressions);
3068  }
3069 
3074  [global::__DynamicallyInvokable]
3076  {
3077  ContractUtils.RequiresNotNull(expressions, "expressions");
3078  ReadOnlyCollection<Expression> readOnlyCollection = expressions.ToReadOnly();
3079  ContractUtils.RequiresNotEmpty(readOnlyCollection, "expressions");
3080  RequiresCanRead(readOnlyCollection, "expressions");
3081  return Block(readOnlyCollection.Last().Type, variables, readOnlyCollection);
3082  }
3083 
3089  [global::__DynamicallyInvokable]
3091  {
3092  ContractUtils.RequiresNotNull(type, "type");
3093  ContractUtils.RequiresNotNull(expressions, "expressions");
3094  ReadOnlyCollection<Expression> readOnlyCollection = expressions.ToReadOnly();
3095  ReadOnlyCollection<ParameterExpression> readOnlyCollection2 = variables.ToReadOnly();
3096  ContractUtils.RequiresNotEmpty(readOnlyCollection, "expressions");
3097  RequiresCanRead(readOnlyCollection, "expressions");
3098  ValidateVariables(readOnlyCollection2, "variables");
3099  Expression expression = readOnlyCollection.Last();
3100  if (type != typeof(void) && !TypeUtils.AreReferenceAssignable(type, expression.Type))
3101  {
3102  throw Error.ArgumentTypesMustMatch();
3103  }
3104  if (!TypeUtils.AreEquivalent(type, expression.Type))
3105  {
3106  return new ScopeWithType(readOnlyCollection2, readOnlyCollection, type);
3107  }
3108  if (readOnlyCollection.Count == 1)
3109  {
3110  return new Scope1(readOnlyCollection2, readOnlyCollection[0]);
3111  }
3112  return new ScopeN(readOnlyCollection2, readOnlyCollection);
3113  }
3114 
3115  internal static void ValidateVariables(ReadOnlyCollection<ParameterExpression> varList, string collectionName)
3116  {
3117  if (varList.Count == 0)
3118  {
3119  return;
3120  }
3121  int count = varList.Count;
3122  Set<ParameterExpression> set = new Set<ParameterExpression>(count);
3123  int num = 0;
3124  ParameterExpression parameterExpression;
3125  while (true)
3126  {
3127  if (num < count)
3128  {
3129  parameterExpression = varList[num];
3130  if (parameterExpression == null)
3131  {
3132  throw new ArgumentNullException(string.Format(CultureInfo.CurrentCulture, "{0}[{1}]", new object[2]
3133  {
3134  collectionName,
3135  set.Count
3136  }));
3137  }
3138  if (parameterExpression.IsByRef)
3139  {
3140  throw Error.VariableMustNotBeByRef(parameterExpression, parameterExpression.Type);
3141  }
3142  if (set.Contains(parameterExpression))
3143  {
3144  break;
3145  }
3146  set.Add(parameterExpression);
3147  num++;
3148  continue;
3149  }
3150  return;
3151  }
3152  throw Error.DuplicateVariable(parameterExpression);
3153  }
3154 
3159  [global::__DynamicallyInvokable]
3160  public static CatchBlock Catch(Type type, Expression body)
3161  {
3162  return MakeCatchBlock(type, null, body, null);
3163  }
3164 
3169  [global::__DynamicallyInvokable]
3170  public static CatchBlock Catch(ParameterExpression variable, Expression body)
3171  {
3172  ContractUtils.RequiresNotNull(variable, "variable");
3173  return MakeCatchBlock(variable.Type, variable, body, null);
3174  }
3175 
3181  [global::__DynamicallyInvokable]
3182  public static CatchBlock Catch(Type type, Expression body, Expression filter)
3183  {
3184  return MakeCatchBlock(type, null, body, filter);
3185  }
3186 
3192  [global::__DynamicallyInvokable]
3193  public static CatchBlock Catch(ParameterExpression variable, Expression body, Expression filter)
3194  {
3195  ContractUtils.RequiresNotNull(variable, "variable");
3196  return MakeCatchBlock(variable.Type, variable, body, filter);
3197  }
3198 
3205  [global::__DynamicallyInvokable]
3206  public static CatchBlock MakeCatchBlock(Type type, ParameterExpression variable, Expression body, Expression filter)
3207  {
3208  ContractUtils.RequiresNotNull(type, "type");
3209  ContractUtils.Requires(variable == null || TypeUtils.AreEquivalent(variable.Type, type), "variable");
3210  if (variable != null && variable.IsByRef)
3211  {
3212  throw Error.VariableMustNotBeByRef(variable, variable.Type);
3213  }
3214  RequiresCanRead(body, "body");
3215  if (filter != null)
3216  {
3217  RequiresCanRead(filter, "filter");
3218  if (filter.Type != typeof(bool))
3219  {
3220  throw Error.ArgumentMustBeBoolean();
3221  }
3222  }
3223  return new CatchBlock(type, variable, body, filter);
3224  }
3225 
3236  [global::__DynamicallyInvokable]
3237  public static ConditionalExpression Condition(Expression test, Expression ifTrue, Expression ifFalse)
3238  {
3239  RequiresCanRead(test, "test");
3240  RequiresCanRead(ifTrue, "ifTrue");
3241  RequiresCanRead(ifFalse, "ifFalse");
3242  if (test.Type != typeof(bool))
3243  {
3244  throw Error.ArgumentMustBeBoolean();
3245  }
3246  if (!TypeUtils.AreEquivalent(ifTrue.Type, ifFalse.Type))
3247  {
3248  throw Error.ArgumentTypesMustMatch();
3249  }
3250  return ConditionalExpression.Make(test, ifTrue, ifFalse, ifTrue.Type);
3251  }
3252 
3259  [global::__DynamicallyInvokable]
3260  public static ConditionalExpression Condition(Expression test, Expression ifTrue, Expression ifFalse, Type type)
3261  {
3262  RequiresCanRead(test, "test");
3263  RequiresCanRead(ifTrue, "ifTrue");
3264  RequiresCanRead(ifFalse, "ifFalse");
3265  ContractUtils.RequiresNotNull(type, "type");
3266  if (test.Type != typeof(bool))
3267  {
3268  throw Error.ArgumentMustBeBoolean();
3269  }
3270  if (type != typeof(void) && (!TypeUtils.AreReferenceAssignable(type, ifTrue.Type) || !TypeUtils.AreReferenceAssignable(type, ifFalse.Type)))
3271  {
3272  throw Error.ArgumentTypesMustMatch();
3273  }
3274  return ConditionalExpression.Make(test, ifTrue, ifFalse, type);
3275  }
3276 
3281  [global::__DynamicallyInvokable]
3283  {
3284  return Condition(test, ifTrue, Empty(), typeof(void));
3285  }
3286 
3292  [global::__DynamicallyInvokable]
3293  public static ConditionalExpression IfThenElse(Expression test, Expression ifTrue, Expression ifFalse)
3294  {
3295  return Condition(test, ifTrue, ifFalse, typeof(void));
3296  }
3297 
3301  [global::__DynamicallyInvokable]
3302  public static ConstantExpression Constant(object value)
3303  {
3304  return ConstantExpression.Make(value, (value == null) ? typeof(object) : value.GetType());
3305  }
3306 
3315  [global::__DynamicallyInvokable]
3316  public static ConstantExpression Constant(object value, Type type)
3317  {
3318  ContractUtils.RequiresNotNull(type, "type");
3319  if (value == null && type.IsValueType && !type.IsNullableType())
3320  {
3321  throw Error.ArgumentTypesMustMatch();
3322  }
3323  if (value != null && !type.IsAssignableFrom(value.GetType()))
3324  {
3325  throw Error.ArgumentTypesMustMatch();
3326  }
3327  return ConstantExpression.Make(value, type);
3328  }
3329 
3337  [global::__DynamicallyInvokable]
3338  public static DebugInfoExpression DebugInfo(SymbolDocumentInfo document, int startLine, int startColumn, int endLine, int endColumn)
3339  {
3340  ContractUtils.RequiresNotNull(document, "document");
3341  if (startLine == 16707566 && startColumn == 0 && endLine == 16707566 && endColumn == 0)
3342  {
3343  return new ClearDebugInfoExpression(document);
3344  }
3345  ValidateSpan(startLine, startColumn, endLine, endColumn);
3346  return new SpanDebugInfoExpression(document, startLine, startColumn, endLine, endColumn);
3347  }
3348 
3352  [global::__DynamicallyInvokable]
3354  {
3355  ContractUtils.RequiresNotNull(document, "document");
3356  return new ClearDebugInfoExpression(document);
3357  }
3358 
3359  private static void ValidateSpan(int startLine, int startColumn, int endLine, int endColumn)
3360  {
3361  if (startLine < 1)
3362  {
3363  throw Error.OutOfRange("startLine", 1);
3364  }
3365  if (startColumn < 1)
3366  {
3367  throw Error.OutOfRange("startColumn", 1);
3368  }
3369  if (endLine < 1)
3370  {
3371  throw Error.OutOfRange("endLine", 1);
3372  }
3373  if (endColumn < 1)
3374  {
3375  throw Error.OutOfRange("endColumn", 1);
3376  }
3377  if (startLine > endLine)
3378  {
3379  throw Error.StartEndMustBeOrdered();
3380  }
3381  if (startLine == endLine && startColumn > endColumn)
3382  {
3383  throw Error.StartEndMustBeOrdered();
3384  }
3385  }
3386 
3389  [global::__DynamicallyInvokable]
3390  public static DefaultExpression Empty()
3391  {
3392  return new DefaultExpression(typeof(void));
3393  }
3394 
3398  [global::__DynamicallyInvokable]
3399  public static DefaultExpression Default(Type type)
3400  {
3401  if (type == typeof(void))
3402  {
3403  return Empty();
3404  }
3405  return new DefaultExpression(type);
3406  }
3407 
3413  [global::__DynamicallyInvokable]
3414  public static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, params Expression[] arguments)
3415  {
3416  return MakeDynamic(delegateType, binder, (IEnumerable<Expression>)arguments);
3417  }
3418 
3424  [global::__DynamicallyInvokable]
3425  public static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, IEnumerable<Expression> arguments)
3426  {
3427  ContractUtils.RequiresNotNull(delegateType, "delegateType");
3428  ContractUtils.RequiresNotNull(binder, "binder");
3429  if (!delegateType.IsSubclassOf(typeof(MulticastDelegate)))
3430  {
3431  throw Error.TypeMustBeDerivedFromSystemDelegate();
3432  }
3433  MethodInfo validMethodForDynamic = GetValidMethodForDynamic(delegateType);
3434  ReadOnlyCollection<Expression> arguments2 = arguments.ToReadOnly();
3435  ValidateArgumentTypes(validMethodForDynamic, ExpressionType.Dynamic, ref arguments2);
3436  return DynamicExpression.Make(validMethodForDynamic.GetReturnType(), delegateType, binder, arguments2);
3437  }
3438 
3444  [global::__DynamicallyInvokable]
3445  public static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, Expression arg0)
3446  {
3447  ContractUtils.RequiresNotNull(delegateType, "delegateType");
3448  ContractUtils.RequiresNotNull(binder, "binder");
3449  if (!delegateType.IsSubclassOf(typeof(MulticastDelegate)))
3450  {
3451  throw Error.TypeMustBeDerivedFromSystemDelegate();
3452  }
3453  MethodInfo validMethodForDynamic = GetValidMethodForDynamic(delegateType);
3454  ParameterInfo[] parametersCached = validMethodForDynamic.GetParametersCached();
3455  ValidateArgumentCount(validMethodForDynamic, ExpressionType.Dynamic, 2, parametersCached);
3456  ValidateDynamicArgument(arg0);
3457  ValidateOneArgument(validMethodForDynamic, ExpressionType.Dynamic, arg0, parametersCached[1]);
3458  return DynamicExpression.Make(validMethodForDynamic.GetReturnType(), delegateType, binder, arg0);
3459  }
3460 
3467  [global::__DynamicallyInvokable]
3468  public static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1)
3469  {
3470  ContractUtils.RequiresNotNull(delegateType, "delegateType");
3471  ContractUtils.RequiresNotNull(binder, "binder");
3472  if (!delegateType.IsSubclassOf(typeof(MulticastDelegate)))
3473  {
3474  throw Error.TypeMustBeDerivedFromSystemDelegate();
3475  }
3476  MethodInfo validMethodForDynamic = GetValidMethodForDynamic(delegateType);
3477  ParameterInfo[] parametersCached = validMethodForDynamic.GetParametersCached();
3478  ValidateArgumentCount(validMethodForDynamic, ExpressionType.Dynamic, 3, parametersCached);
3479  ValidateDynamicArgument(arg0);
3480  ValidateOneArgument(validMethodForDynamic, ExpressionType.Dynamic, arg0, parametersCached[1]);
3481  ValidateDynamicArgument(arg1);
3482  ValidateOneArgument(validMethodForDynamic, ExpressionType.Dynamic, arg1, parametersCached[2]);
3483  return DynamicExpression.Make(validMethodForDynamic.GetReturnType(), delegateType, binder, arg0, arg1);
3484  }
3485 
3493  [global::__DynamicallyInvokable]
3494  public static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1, Expression arg2)
3495  {
3496  ContractUtils.RequiresNotNull(delegateType, "delegateType");
3497  ContractUtils.RequiresNotNull(binder, "binder");
3498  if (!delegateType.IsSubclassOf(typeof(MulticastDelegate)))
3499  {
3500  throw Error.TypeMustBeDerivedFromSystemDelegate();
3501  }
3502  MethodInfo validMethodForDynamic = GetValidMethodForDynamic(delegateType);
3503  ParameterInfo[] parametersCached = validMethodForDynamic.GetParametersCached();
3504  ValidateArgumentCount(validMethodForDynamic, ExpressionType.Dynamic, 4, parametersCached);
3505  ValidateDynamicArgument(arg0);
3506  ValidateOneArgument(validMethodForDynamic, ExpressionType.Dynamic, arg0, parametersCached[1]);
3507  ValidateDynamicArgument(arg1);
3508  ValidateOneArgument(validMethodForDynamic, ExpressionType.Dynamic, arg1, parametersCached[2]);
3509  ValidateDynamicArgument(arg2);
3510  ValidateOneArgument(validMethodForDynamic, ExpressionType.Dynamic, arg2, parametersCached[3]);
3511  return DynamicExpression.Make(validMethodForDynamic.GetReturnType(), delegateType, binder, arg0, arg1, arg2);
3512  }
3513 
3522  [global::__DynamicallyInvokable]
3523  public static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1, Expression arg2, Expression arg3)
3524  {
3525  ContractUtils.RequiresNotNull(delegateType, "delegateType");
3526  ContractUtils.RequiresNotNull(binder, "binder");
3527  if (!delegateType.IsSubclassOf(typeof(MulticastDelegate)))
3528  {
3529  throw Error.TypeMustBeDerivedFromSystemDelegate();
3530  }
3531  MethodInfo validMethodForDynamic = GetValidMethodForDynamic(delegateType);
3532  ParameterInfo[] parametersCached = validMethodForDynamic.GetParametersCached();
3533  ValidateArgumentCount(validMethodForDynamic, ExpressionType.Dynamic, 5, parametersCached);
3534  ValidateDynamicArgument(arg0);
3535  ValidateOneArgument(validMethodForDynamic, ExpressionType.Dynamic, arg0, parametersCached[1]);
3536  ValidateDynamicArgument(arg1);
3537  ValidateOneArgument(validMethodForDynamic, ExpressionType.Dynamic, arg1, parametersCached[2]);
3538  ValidateDynamicArgument(arg2);
3539  ValidateOneArgument(validMethodForDynamic, ExpressionType.Dynamic, arg2, parametersCached[3]);
3540  ValidateDynamicArgument(arg3);
3541  ValidateOneArgument(validMethodForDynamic, ExpressionType.Dynamic, arg3, parametersCached[4]);
3542  return DynamicExpression.Make(validMethodForDynamic.GetReturnType(), delegateType, binder, arg0, arg1, arg2, arg3);
3543  }
3544 
3545  private static MethodInfo GetValidMethodForDynamic(Type delegateType)
3546  {
3547  MethodInfo method = delegateType.GetMethod("Invoke");
3548  ParameterInfo[] parametersCached = method.GetParametersCached();
3549  if (parametersCached.Length == 0 || parametersCached[0].ParameterType != typeof(CallSite))
3550  {
3551  throw Error.FirstArgumentMustBeCallSite();
3552  }
3553  return method;
3554  }
3555 
3561  [global::__DynamicallyInvokable]
3562  public static DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, params Expression[] arguments)
3563  {
3564  return Dynamic(binder, returnType, (IEnumerable<Expression>)arguments);
3565  }
3566 
3572  [global::__DynamicallyInvokable]
3573  public static DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, Expression arg0)
3574  {
3575  ContractUtils.RequiresNotNull(binder, "binder");
3576  ValidateDynamicArgument(arg0);
3577  DelegateHelpers.TypeInfo nextTypeInfo = DelegateHelpers.GetNextTypeInfo(returnType, DelegateHelpers.GetNextTypeInfo(arg0.Type, DelegateHelpers.NextTypeInfo(typeof(CallSite))));
3578  Type type = nextTypeInfo.DelegateType;
3579  if (type == null)
3580  {
3581  type = nextTypeInfo.MakeDelegateType(returnType, arg0);
3582  }
3583  return DynamicExpression.Make(returnType, type, binder, arg0);
3584  }
3585 
3592  [global::__DynamicallyInvokable]
3593  public static DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, Expression arg0, Expression arg1)
3594  {
3595  ContractUtils.RequiresNotNull(binder, "binder");
3596  ValidateDynamicArgument(arg0);
3597  ValidateDynamicArgument(arg1);
3598  DelegateHelpers.TypeInfo nextTypeInfo = DelegateHelpers.GetNextTypeInfo(returnType, DelegateHelpers.GetNextTypeInfo(arg1.Type, DelegateHelpers.GetNextTypeInfo(arg0.Type, DelegateHelpers.NextTypeInfo(typeof(CallSite)))));
3599  Type type = nextTypeInfo.DelegateType;
3600  if (type == null)
3601  {
3602  type = nextTypeInfo.MakeDelegateType(returnType, arg0, arg1);
3603  }
3604  return DynamicExpression.Make(returnType, type, binder, arg0, arg1);
3605  }
3606 
3614  [global::__DynamicallyInvokable]
3615  public static DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, Expression arg0, Expression arg1, Expression arg2)
3616  {
3617  ContractUtils.RequiresNotNull(binder, "binder");
3618  ValidateDynamicArgument(arg0);
3619  ValidateDynamicArgument(arg1);
3620  ValidateDynamicArgument(arg2);
3621  DelegateHelpers.TypeInfo nextTypeInfo = DelegateHelpers.GetNextTypeInfo(returnType, DelegateHelpers.GetNextTypeInfo(arg2.Type, DelegateHelpers.GetNextTypeInfo(arg1.Type, DelegateHelpers.GetNextTypeInfo(arg0.Type, DelegateHelpers.NextTypeInfo(typeof(CallSite))))));
3622  Type type = nextTypeInfo.DelegateType;
3623  if (type == null)
3624  {
3625  type = nextTypeInfo.MakeDelegateType(returnType, arg0, arg1, arg2);
3626  }
3627  return DynamicExpression.Make(returnType, type, binder, arg0, arg1, arg2);
3628  }
3629 
3638  [global::__DynamicallyInvokable]
3639  public static DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, Expression arg0, Expression arg1, Expression arg2, Expression arg3)
3640  {
3641  ContractUtils.RequiresNotNull(binder, "binder");
3642  ValidateDynamicArgument(arg0);
3643  ValidateDynamicArgument(arg1);
3644  ValidateDynamicArgument(arg2);
3645  ValidateDynamicArgument(arg3);
3646  DelegateHelpers.TypeInfo nextTypeInfo = DelegateHelpers.GetNextTypeInfo(returnType, DelegateHelpers.GetNextTypeInfo(arg3.Type, DelegateHelpers.GetNextTypeInfo(arg2.Type, DelegateHelpers.GetNextTypeInfo(arg1.Type, DelegateHelpers.GetNextTypeInfo(arg0.Type, DelegateHelpers.NextTypeInfo(typeof(CallSite)))))));
3647  Type type = nextTypeInfo.DelegateType;
3648  if (type == null)
3649  {
3650  type = nextTypeInfo.MakeDelegateType(returnType, arg0, arg1, arg2, arg3);
3651  }
3652  return DynamicExpression.Make(returnType, type, binder, arg0, arg1, arg2, arg3);
3653  }
3654 
3660  [global::__DynamicallyInvokable]
3661  public static DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, IEnumerable<Expression> arguments)
3662  {
3663  ContractUtils.RequiresNotNull(arguments, "arguments");
3664  ContractUtils.RequiresNotNull(returnType, "returnType");
3665  ReadOnlyCollection<Expression> readOnlyCollection = arguments.ToReadOnly();
3666  ContractUtils.RequiresNotEmpty(readOnlyCollection, "args");
3667  return MakeDynamic(binder, returnType, readOnlyCollection);
3668  }
3669 
3670  private static DynamicExpression MakeDynamic(CallSiteBinder binder, Type returnType, ReadOnlyCollection<Expression> args)
3671  {
3672  ContractUtils.RequiresNotNull(binder, "binder");
3673  for (int i = 0; i < args.Count; i++)
3674  {
3675  Expression arg = args[i];
3676  ValidateDynamicArgument(arg);
3677  }
3678  Type delegateType = DelegateHelpers.MakeCallSiteDelegate(args, returnType);
3679  switch (args.Count)
3680  {
3681  case 1:
3682  return DynamicExpression.Make(returnType, delegateType, binder, args[0]);
3683  case 2:
3684  return DynamicExpression.Make(returnType, delegateType, binder, args[0], args[1]);
3685  case 3:
3686  return DynamicExpression.Make(returnType, delegateType, binder, args[0], args[1], args[2]);
3687  case 4:
3688  return DynamicExpression.Make(returnType, delegateType, binder, args[0], args[1], args[2], args[3]);
3689  default:
3690  return DynamicExpression.Make(returnType, delegateType, binder, args);
3691  }
3692  }
3693 
3694  private static void ValidateDynamicArgument(Expression arg)
3695  {
3696  RequiresCanRead(arg, "arguments");
3697  Type type = arg.Type;
3698  ContractUtils.RequiresNotNull(type, "type");
3699  TypeUtils.ValidateType(type);
3700  if (type == typeof(void))
3701  {
3702  throw Error.ArgumentTypeCannotBeVoid();
3703  }
3704  }
3705 
3713  [global::__DynamicallyInvokable]
3714  public static ElementInit ElementInit(MethodInfo addMethod, params Expression[] arguments)
3715  {
3716  return ElementInit(addMethod, (IEnumerable<Expression>)arguments);
3717  }
3718 
3727  [global::__DynamicallyInvokable]
3728  public static ElementInit ElementInit(MethodInfo addMethod, IEnumerable<Expression> arguments)
3729  {
3730  ContractUtils.RequiresNotNull(addMethod, "addMethod");
3731  ContractUtils.RequiresNotNull(arguments, "arguments");
3732  ReadOnlyCollection<Expression> arguments2 = arguments.ToReadOnly();
3733  RequiresCanRead(arguments2, "arguments");
3734  ValidateElementInitAddMethodInfo(addMethod);
3735  ValidateArgumentTypes(addMethod, ExpressionType.Call, ref arguments2);
3736  return new ElementInit(addMethod, arguments2);
3737  }
3738 
3739  private static void ValidateElementInitAddMethodInfo(MethodInfo addMethod)
3740  {
3741  ValidateMethodInfo(addMethod);
3742  ParameterInfo[] parametersCached = addMethod.GetParametersCached();
3743  if (parametersCached.Length == 0)
3744  {
3745  throw Error.ElementInitializerMethodWithZeroArgs();
3746  }
3747  if (!addMethod.Name.Equals("Add", StringComparison.OrdinalIgnoreCase))
3748  {
3749  throw Error.ElementInitializerMethodNotAdd();
3750  }
3751  if (addMethod.IsStatic)
3752  {
3753  throw Error.ElementInitializerMethodStatic();
3754  }
3755  ParameterInfo[] array = parametersCached;
3756  int num = 0;
3757  ParameterInfo parameterInfo;
3758  while (true)
3759  {
3760  if (num < array.Length)
3761  {
3762  parameterInfo = array[num];
3763  if (parameterInfo.ParameterType.IsByRef)
3764  {
3765  break;
3766  }
3767  num++;
3768  continue;
3769  }
3770  return;
3771  }
3772  throw Error.ElementInitializerMethodNoRefOutParam(parameterInfo.Name, addMethod.Name);
3773  }
3774 
3778  [Obsolete("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.")]
3779  protected Expression(ExpressionType nodeType, Type type)
3780  {
3781  if (_legacyCtorSupportTable == null)
3782  {
3783  Interlocked.CompareExchange(ref _legacyCtorSupportTable, new ConditionalWeakTable<Expression, ExtensionInfo>(), null);
3784  }
3785  _legacyCtorSupportTable.Add(this, new ExtensionInfo(nodeType, type));
3786  }
3787 
3789  [global::__DynamicallyInvokable]
3790  protected Expression()
3791  {
3792  }
3793 
3796  [global::__DynamicallyInvokable]
3797  public virtual Expression Reduce()
3798  {
3799  if (CanReduce)
3800  {
3801  throw Error.ReducibleMustOverrideReduce();
3802  }
3803  return this;
3804  }
3805 
3809  [global::__DynamicallyInvokable]
3810  protected internal virtual Expression VisitChildren(ExpressionVisitor visitor)
3811  {
3812  if (!CanReduce)
3813  {
3814  throw Error.MustBeReducible();
3815  }
3816  return visitor.Visit(ReduceAndCheck());
3817  }
3818 
3822  [global::__DynamicallyInvokable]
3823  protected internal virtual Expression Accept(ExpressionVisitor visitor)
3824  {
3825  return visitor.VisitExtension(this);
3826  }
3827 
3830  [global::__DynamicallyInvokable]
3832  {
3833  if (!CanReduce)
3834  {
3835  throw Error.MustBeReducible();
3836  }
3837  Expression expression = Reduce();
3838  if (expression == null || expression == this)
3839  {
3840  throw Error.MustReduceToDifferent();
3841  }
3842  if (!TypeUtils.AreReferenceAssignable(Type, expression.Type))
3843  {
3844  throw Error.ReducedNotCompatible();
3845  }
3846  return expression;
3847  }
3848 
3851  [global::__DynamicallyInvokable]
3853  {
3854  Expression expression = this;
3855  while (expression.NodeType == ExpressionType.Extension)
3856  {
3857  expression = expression.ReduceAndCheck();
3858  }
3859  return expression;
3860  }
3861 
3864  [global::__DynamicallyInvokable]
3865  public override string ToString()
3866  {
3867  return ExpressionStringBuilder.ExpressionToString(this);
3868  }
3869 
3870  internal static ReadOnlyCollection<T> ReturnReadOnly<T>(ref IList<T> collection)
3871  {
3872  IList<T> list = collection;
3873  ReadOnlyCollection<T> readOnlyCollection = list as ReadOnlyCollection<T>;
3874  if (readOnlyCollection != null)
3875  {
3876  return readOnlyCollection;
3877  }
3878  Interlocked.CompareExchange(ref collection, list.ToReadOnly(), list);
3879  return (ReadOnlyCollection<T>)collection;
3880  }
3881 
3882  internal static ReadOnlyCollection<Expression> ReturnReadOnly(IArgumentProvider provider, ref object collection)
3883  {
3884  Expression expression = collection as Expression;
3885  if (expression != null)
3886  {
3887  Interlocked.CompareExchange(ref collection, new ReadOnlyCollection<Expression>(new ListArgumentProvider(provider, expression)), expression);
3888  }
3889  return (ReadOnlyCollection<Expression>)collection;
3890  }
3891 
3892  internal static T ReturnObject<T>(object collectionOrT) where T : class
3893  {
3894  T val = collectionOrT as T;
3895  if (val != null)
3896  {
3897  return val;
3898  }
3899  return ((ReadOnlyCollection<T>)collectionOrT)[0];
3900  }
3901 
3902  private static void RequiresCanRead(Expression expression, string paramName)
3903  {
3904  if (expression == null)
3905  {
3906  throw new ArgumentNullException(paramName);
3907  }
3908  switch (expression.NodeType)
3909  {
3910  case ExpressionType.Index:
3911  {
3912  IndexExpression indexExpression = (IndexExpression)expression;
3913  if (indexExpression.Indexer != null && !indexExpression.Indexer.CanRead)
3914  {
3915  throw new ArgumentException(Strings.ExpressionMustBeReadable, paramName);
3916  }
3917  break;
3918  }
3919  case ExpressionType.MemberAccess:
3920  {
3921  MemberExpression memberExpression = (MemberExpression)expression;
3922  MemberInfo member = memberExpression.Member;
3923  if (member.MemberType == MemberTypes.Property)
3924  {
3925  PropertyInfo propertyInfo = (PropertyInfo)member;
3926  if (!propertyInfo.CanRead)
3927  {
3928  throw new ArgumentException(Strings.ExpressionMustBeReadable, paramName);
3929  }
3930  }
3931  break;
3932  }
3933  }
3934  }
3935 
3936  private static void RequiresCanRead(IEnumerable<Expression> items, string paramName)
3937  {
3938  if (items == null)
3939  {
3940  return;
3941  }
3942  IList<Expression> list = items as IList<Expression>;
3943  if (list != null)
3944  {
3945  for (int i = 0; i < list.Count; i++)
3946  {
3947  RequiresCanRead(list[i], paramName);
3948  }
3949  }
3950  else
3951  {
3952  foreach (Expression item in items)
3953  {
3954  RequiresCanRead(item, paramName);
3955  }
3956  }
3957  }
3958 
3959  private static void RequiresCanWrite(Expression expression, string paramName)
3960  {
3961  if (expression == null)
3962  {
3963  throw new ArgumentNullException(paramName);
3964  }
3965  bool flag = false;
3966  switch (expression.NodeType)
3967  {
3968  case ExpressionType.Index:
3969  {
3970  IndexExpression indexExpression = (IndexExpression)expression;
3971  flag = (!(indexExpression.Indexer != null) || indexExpression.Indexer.CanWrite);
3972  break;
3973  }
3974  case ExpressionType.MemberAccess:
3975  {
3976  MemberExpression memberExpression = (MemberExpression)expression;
3977  switch (memberExpression.Member.MemberType)
3978  {
3979  case MemberTypes.Property:
3980  {
3981  PropertyInfo propertyInfo = (PropertyInfo)memberExpression.Member;
3982  flag = propertyInfo.CanWrite;
3983  break;
3984  }
3985  case MemberTypes.Field:
3986  {
3987  FieldInfo fieldInfo = (FieldInfo)memberExpression.Member;
3988  flag = (!fieldInfo.IsInitOnly && !fieldInfo.IsLiteral);
3989  break;
3990  }
3991  }
3992  break;
3993  }
3994  case ExpressionType.Parameter:
3995  flag = true;
3996  break;
3997  }
3998  if (!flag)
3999  {
4000  throw new ArgumentException(Strings.ExpressionMustBeWriteable, paramName);
4001  }
4002  }
4003 
4007  [global::__DynamicallyInvokable]
4008  public static GotoExpression Break(LabelTarget target)
4009  {
4010  return MakeGoto(GotoExpressionKind.Break, target, null, typeof(void));
4011  }
4012 
4017  [global::__DynamicallyInvokable]
4018  public static GotoExpression Break(LabelTarget target, Expression value)
4019  {
4020  return MakeGoto(GotoExpressionKind.Break, target, value, typeof(void));
4021  }
4022 
4027  [global::__DynamicallyInvokable]
4028  public static GotoExpression Break(LabelTarget target, Type type)
4029  {
4030  return MakeGoto(GotoExpressionKind.Break, target, null, type);
4031  }
4032 
4038  [global::__DynamicallyInvokable]
4039  public static GotoExpression Break(LabelTarget target, Expression value, Type type)
4040  {
4041  return MakeGoto(GotoExpressionKind.Break, target, value, type);
4042  }
4043 
4047  [global::__DynamicallyInvokable]
4048  public static GotoExpression Continue(LabelTarget target)
4049  {
4050  return MakeGoto(GotoExpressionKind.Continue, target, null, typeof(void));
4051  }
4052 
4057  [global::__DynamicallyInvokable]
4058  public static GotoExpression Continue(LabelTarget target, Type type)
4059  {
4060  return MakeGoto(GotoExpressionKind.Continue, target, null, type);
4061  }
4062 
4066  [global::__DynamicallyInvokable]
4067  public static GotoExpression Return(LabelTarget target)
4068  {
4069  return MakeGoto(GotoExpressionKind.Return, target, null, typeof(void));
4070  }
4071 
4076  [global::__DynamicallyInvokable]
4077  public static GotoExpression Return(LabelTarget target, Type type)
4078  {
4079  return MakeGoto(GotoExpressionKind.Return, target, null, type);
4080  }
4081 
4086  [global::__DynamicallyInvokable]
4087  public static GotoExpression Return(LabelTarget target, Expression value)
4088  {
4089  return MakeGoto(GotoExpressionKind.Return, target, value, typeof(void));
4090  }
4091 
4097  [global::__DynamicallyInvokable]
4098  public static GotoExpression Return(LabelTarget target, Expression value, Type type)
4099  {
4100  return MakeGoto(GotoExpressionKind.Return, target, value, type);
4101  }
4102 
4106  [global::__DynamicallyInvokable]
4107  public static GotoExpression Goto(LabelTarget target)
4108  {
4109  return MakeGoto(GotoExpressionKind.Goto, target, null, typeof(void));
4110  }
4111 
4116  [global::__DynamicallyInvokable]
4117  public static GotoExpression Goto(LabelTarget target, Type type)
4118  {
4119  return MakeGoto(GotoExpressionKind.Goto, target, null, type);
4120  }
4121 
4126  [global::__DynamicallyInvokable]
4127  public static GotoExpression Goto(LabelTarget target, Expression value)
4128  {
4129  return MakeGoto(GotoExpressionKind.Goto, target, value, typeof(void));
4130  }
4131 
4137  [global::__DynamicallyInvokable]
4138  public static GotoExpression Goto(LabelTarget target, Expression value, Type type)
4139  {
4140  return MakeGoto(GotoExpressionKind.Goto, target, value, type);
4141  }
4142 
4149  [global::__DynamicallyInvokable]
4150  public static GotoExpression MakeGoto(GotoExpressionKind kind, LabelTarget target, Expression value, Type type)
4151  {
4152  ValidateGoto(target, ref value, "target", "value");
4153  return new GotoExpression(kind, target, value, type);
4154  }
4155 
4156  private static void ValidateGoto(LabelTarget target, ref Expression value, string targetParameter, string valueParameter)
4157  {
4158  ContractUtils.RequiresNotNull(target, targetParameter);
4159  if (value == null)
4160  {
4161  if (target.Type != typeof(void))
4162  {
4163  throw Error.LabelMustBeVoidOrHaveExpression();
4164  }
4165  }
4166  else
4167  {
4168  ValidateGotoType(target.Type, ref value, valueParameter);
4169  }
4170  }
4171 
4172  private static void ValidateGotoType(Type expectedType, ref Expression value, string paramName)
4173  {
4174  RequiresCanRead(value, paramName);
4175  if (expectedType != typeof(void) && !TypeUtils.AreReferenceAssignable(expectedType, value.Type) && !TryQuote(expectedType, ref value))
4176  {
4177  throw Error.ExpressionTypeDoesNotMatchLabel(value.Type, expectedType);
4178  }
4179  }
4180 
4186  [global::__DynamicallyInvokable]
4187  public static IndexExpression MakeIndex(Expression instance, PropertyInfo indexer, IEnumerable<Expression> arguments)
4188  {
4189  if (indexer != null)
4190  {
4191  return Property(instance, indexer, arguments);
4192  }
4193  return ArrayAccess(instance, arguments);
4194  }
4195 
4200  [global::__DynamicallyInvokable]
4201  public static IndexExpression ArrayAccess(Expression array, params Expression[] indexes)
4202  {
4203  return ArrayAccess(array, (IEnumerable<Expression>)indexes);
4204  }
4205 
4210  [global::__DynamicallyInvokable]
4212  {
4213  RequiresCanRead(array, "array");
4214  Type type = array.Type;
4215  if (!type.IsArray)
4216  {
4217  throw Error.ArgumentMustBeArray();
4218  }
4219  ReadOnlyCollection<Expression> readOnlyCollection = indexes.ToReadOnly();
4220  if (type.GetArrayRank() != readOnlyCollection.Count)
4221  {
4222  throw Error.IncorrectNumberOfIndexes();
4223  }
4224  foreach (Expression item in readOnlyCollection)
4225  {
4226  RequiresCanRead(item, "indexes");
4227  if (item.Type != typeof(int))
4228  {
4229  throw Error.ArgumentMustBeArrayIndexType();
4230  }
4231  }
4232  return new IndexExpression(array, null, readOnlyCollection);
4233  }
4234 
4240  [global::__DynamicallyInvokable]
4241  public static IndexExpression Property(Expression instance, string propertyName, params Expression[] arguments)
4242  {
4243  RequiresCanRead(instance, "instance");
4244  ContractUtils.RequiresNotNull(propertyName, "indexerName");
4245  PropertyInfo indexer = FindInstanceProperty(instance.Type, propertyName, arguments);
4246  return Property(instance, indexer, arguments);
4247  }
4248 
4249  private static PropertyInfo FindInstanceProperty(Type type, string propertyName, Expression[] arguments)
4250  {
4251  BindingFlags flags = BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy;
4252  PropertyInfo propertyInfo = FindProperty(type, propertyName, arguments, flags);
4253  if (propertyInfo == null)
4254  {
4255  flags = (BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
4256  propertyInfo = FindProperty(type, propertyName, arguments, flags);
4257  }
4258  if (propertyInfo == null)
4259  {
4260  if (arguments == null || arguments.Length == 0)
4261  {
4262  throw Error.InstancePropertyWithoutParameterNotDefinedForType(propertyName, type);
4263  }
4264  throw Error.InstancePropertyWithSpecifiedParametersNotDefinedForType(propertyName, GetArgTypesString(arguments), type);
4265  }
4266  return propertyInfo;
4267  }
4268 
4269  private static string GetArgTypesString(Expression[] arguments)
4270  {
4271  StringBuilder stringBuilder = new StringBuilder();
4272  bool flag = true;
4273  stringBuilder.Append("(");
4274  foreach (Type item in from arg in arguments
4275  select arg.Type)
4276  {
4277  if (!flag)
4278  {
4279  stringBuilder.Append(", ");
4280  }
4281  stringBuilder.Append(item.Name);
4282  flag = false;
4283  }
4284  stringBuilder.Append(")");
4285  return stringBuilder.ToString();
4286  }
4287 
4288  private static PropertyInfo FindProperty(Type type, string propertyName, Expression[] arguments, BindingFlags flags)
4289  {
4290  MemberInfo[] array = type.FindMembers(MemberTypes.Property, flags, Type.FilterNameIgnoreCase, propertyName);
4291  if (array == null || array.Length == 0)
4292  {
4293  return null;
4294  }
4295  PropertyInfo[] properties = array.Map((MemberInfo t) => (PropertyInfo)t);
4296  PropertyInfo property;
4297  int num = FindBestProperty(properties, arguments, out property);
4298  if (num == 0)
4299  {
4300  return null;
4301  }
4302  if (num > 1)
4303  {
4304  throw Error.PropertyWithMoreThanOneMatch(propertyName, type);
4305  }
4306  return property;
4307  }
4308 
4309  private static int FindBestProperty(IEnumerable<PropertyInfo> properties, Expression[] args, out PropertyInfo property)
4310  {
4311  int num = 0;
4312  property = null;
4313  foreach (PropertyInfo property2 in properties)
4314  {
4315  if (property2 != null && IsCompatible(property2, args))
4316  {
4317  if (property == null)
4318  {
4319  property = property2;
4320  num = 1;
4321  }
4322  else
4323  {
4324  num++;
4325  }
4326  }
4327  }
4328  return num;
4329  }
4330 
4331  private static bool IsCompatible(PropertyInfo pi, Expression[] args)
4332  {
4333  MethodInfo methodInfo = pi.GetGetMethod(nonPublic: true);
4334  ParameterInfo[] array;
4335  if (methodInfo != null)
4336  {
4337  array = methodInfo.GetParametersCached();
4338  }
4339  else
4340  {
4341  methodInfo = pi.GetSetMethod(nonPublic: true);
4342  array = methodInfo.GetParametersCached().RemoveLast();
4343  }
4344  if (methodInfo == null)
4345  {
4346  return false;
4347  }
4348  if (args == null)
4349  {
4350  return array.Length == 0;
4351  }
4352  if (array.Length != args.Length)
4353  {
4354  return false;
4355  }
4356  for (int i = 0; i < args.Length; i++)
4357  {
4358  if (args[i] == null)
4359  {
4360  return false;
4361  }
4362  if (!TypeUtils.AreReferenceAssignable(array[i].ParameterType, args[i].Type))
4363  {
4364  return false;
4365  }
4366  }
4367  return true;
4368  }
4369 
4375  [global::__DynamicallyInvokable]
4376  public static IndexExpression Property(Expression instance, PropertyInfo indexer, params Expression[] arguments)
4377  {
4378  return Property(instance, indexer, (IEnumerable<Expression>)arguments);
4379  }
4380 
4386  [global::__DynamicallyInvokable]
4387  public static IndexExpression Property(Expression instance, PropertyInfo indexer, IEnumerable<Expression> arguments)
4388  {
4389  ReadOnlyCollection<Expression> argList = arguments.ToReadOnly();
4390  ValidateIndexedProperty(instance, indexer, ref argList);
4391  return new IndexExpression(instance, indexer, argList);
4392  }
4393 
4394  private static void ValidateIndexedProperty(Expression instance, PropertyInfo property, ref ReadOnlyCollection<Expression> argList)
4395  {
4396  ContractUtils.RequiresNotNull(property, "property");
4397  if (property.PropertyType.IsByRef)
4398  {
4399  throw Error.PropertyCannotHaveRefType();
4400  }
4401  if (property.PropertyType == typeof(void))
4402  {
4403  throw Error.PropertyTypeCannotBeVoid();
4404  }
4405  ParameterInfo[] array = null;
4406  MethodInfo getMethod = property.GetGetMethod(nonPublic: true);
4407  if (getMethod != null)
4408  {
4409  array = getMethod.GetParametersCached();
4410  ValidateAccessor(instance, getMethod, array, ref argList);
4411  }
4412  MethodInfo setMethod = property.GetSetMethod(nonPublic: true);
4413  if (setMethod != null)
4414  {
4415  ParameterInfo[] parametersCached = setMethod.GetParametersCached();
4416  if (parametersCached.Length == 0)
4417  {
4418  throw Error.SetterHasNoParams();
4419  }
4420  Type parameterType = parametersCached[parametersCached.Length - 1].ParameterType;
4421  if (parameterType.IsByRef)
4422  {
4423  throw Error.PropertyCannotHaveRefType();
4424  }
4425  if (setMethod.ReturnType != typeof(void))
4426  {
4427  throw Error.SetterMustBeVoid();
4428  }
4429  if (property.PropertyType != parameterType)
4430  {
4431  throw Error.PropertyTyepMustMatchSetter();
4432  }
4433  if (getMethod != null)
4434  {
4435  if (getMethod.IsStatic ^ setMethod.IsStatic)
4436  {
4437  throw Error.BothAccessorsMustBeStatic();
4438  }
4439  if (array.Length != parametersCached.Length - 1)
4440  {
4441  throw Error.IndexesOfSetGetMustMatch();
4442  }
4443  for (int i = 0; i < array.Length; i++)
4444  {
4445  if (array[i].ParameterType != parametersCached[i].ParameterType)
4446  {
4447  throw Error.IndexesOfSetGetMustMatch();
4448  }
4449  }
4450  }
4451  else
4452  {
4453  ValidateAccessor(instance, setMethod, parametersCached.RemoveLast(), ref argList);
4454  }
4455  }
4456  if (getMethod == null && setMethod == null)
4457  {
4458  throw Error.PropertyDoesNotHaveAccessor(property);
4459  }
4460  }
4461 
4462  private static void ValidateAccessor(Expression instance, MethodInfo method, ParameterInfo[] indexes, ref ReadOnlyCollection<Expression> arguments)
4463  {
4464  ContractUtils.RequiresNotNull(arguments, "arguments");
4465  ValidateMethodInfo(method);
4466  if ((method.CallingConvention & CallingConventions.VarArgs) != 0)
4467  {
4468  throw Error.AccessorsCannotHaveVarArgs();
4469  }
4470  if (method.IsStatic)
4471  {
4472  if (instance != null)
4473  {
4474  throw Error.OnlyStaticMethodsHaveNullInstance();
4475  }
4476  }
4477  else
4478  {
4479  if (instance == null)
4480  {
4481  throw Error.OnlyStaticMethodsHaveNullInstance();
4482  }
4483  RequiresCanRead(instance, "instance");
4484  ValidateCallInstanceType(instance.Type, method);
4485  }
4486  ValidateAccessorArgumentTypes(method, indexes, ref arguments);
4487  }
4488 
4489  private static void ValidateAccessorArgumentTypes(MethodInfo method, ParameterInfo[] indexes, ref ReadOnlyCollection<Expression> arguments)
4490  {
4491  if (indexes.Length != 0)
4492  {
4493  if (indexes.Length != arguments.Count)
4494  {
4495  throw Error.IncorrectNumberOfMethodCallArguments(method);
4496  }
4497  Expression[] array = null;
4498  int i = 0;
4499  for (int num = indexes.Length; i < num; i++)
4500  {
4501  Expression argument = arguments[i];
4502  ParameterInfo parameterInfo = indexes[i];
4503  RequiresCanRead(argument, "arguments");
4504  Type parameterType = parameterInfo.ParameterType;
4505  if (parameterType.IsByRef)
4506  {
4507  throw Error.AccessorsCannotHaveByRefArgs();
4508  }
4509  TypeUtils.ValidateType(parameterType);
4510  if (!TypeUtils.AreReferenceAssignable(parameterType, argument.Type) && !TryQuote(parameterType, ref argument))
4511  {
4512  throw Error.ExpressionTypeDoesNotMatchMethodParameter(argument.Type, parameterType, method);
4513  }
4514  if (array == null && argument != arguments[i])
4515  {
4516  array = new Expression[arguments.Count];
4517  for (int j = 0; j < i; j++)
4518  {
4519  array[j] = arguments[j];
4520  }
4521  }
4522  if (array != null)
4523  {
4524  array[i] = argument;
4525  }
4526  }
4527  if (array != null)
4528  {
4529  arguments = new TrueReadOnlyCollection<Expression>(array);
4530  }
4531  }
4532  else if (arguments.Count > 0)
4533  {
4534  throw Error.IncorrectNumberOfMethodCallArguments(method);
4535  }
4536  }
4537 
4548  [global::__DynamicallyInvokable]
4549  public static InvocationExpression Invoke(Expression expression, params Expression[] arguments)
4550  {
4551  return Invoke(expression, (IEnumerable<Expression>)arguments);
4552  }
4553 
4564  [global::__DynamicallyInvokable]
4565  public static InvocationExpression Invoke(Expression expression, IEnumerable<Expression> arguments)
4566  {
4567  RequiresCanRead(expression, "expression");
4568  ReadOnlyCollection<Expression> arguments2 = arguments.ToReadOnly();
4569  MethodInfo invokeMethod = GetInvokeMethod(expression);
4570  ValidateArgumentTypes(invokeMethod, ExpressionType.Invoke, ref arguments2);
4571  return new InvocationExpression(expression, arguments2, invokeMethod.ReturnType);
4572  }
4573 
4574  internal static MethodInfo GetInvokeMethod(Expression expression)
4575  {
4576  Type type = expression.Type;
4577  if (!expression.Type.IsSubclassOf(typeof(MulticastDelegate)))
4578  {
4579  Type type2 = TypeUtils.FindGenericType(typeof(Expression<>), expression.Type);
4580  if (type2 == null)
4581  {
4582  throw Error.ExpressionTypeNotInvocable(expression.Type);
4583  }
4584  type = type2.GetGenericArguments()[0];
4585  }
4586  return type.GetMethod("Invoke");
4587  }
4588 
4592  [global::__DynamicallyInvokable]
4593  public static LabelExpression Label(LabelTarget target)
4594  {
4595  return Label(target, null);
4596  }
4597 
4602  [global::__DynamicallyInvokable]
4603  public static LabelExpression Label(LabelTarget target, Expression defaultValue)
4604  {
4605  ValidateGoto(target, ref defaultValue, "label", "defaultValue");
4606  return new LabelExpression(target, defaultValue);
4607  }
4608 
4611  [global::__DynamicallyInvokable]
4612  public static LabelTarget Label()
4613  {
4614  return Label(typeof(void), null);
4615  }
4616 
4620  [global::__DynamicallyInvokable]
4621  public static LabelTarget Label(string name)
4622  {
4623  return Label(typeof(void), name);
4624  }
4625 
4629  [global::__DynamicallyInvokable]
4630  public static LabelTarget Label(Type type)
4631  {
4632  return Label(type, null);
4633  }
4634 
4639  [global::__DynamicallyInvokable]
4640  public static LabelTarget Label(Type type, string name)
4641  {
4642  ContractUtils.RequiresNotNull(type, "type");
4643  TypeUtils.ValidateType(type);
4644  return new LabelTarget(type, name);
4645  }
4646 
4647  internal static LambdaExpression CreateLambda(Type delegateType, Expression body, string name, bool tailCall, ReadOnlyCollection<ParameterExpression> parameters)
4648  {
4649  CacheDict<Type, LambdaFactory> cacheDict = _LambdaFactories;
4650  if (cacheDict == null)
4651  {
4652  cacheDict = (_LambdaFactories = new CacheDict<Type, LambdaFactory>(50));
4653  }
4654  MethodInfo methodInfo = null;
4655  if (!cacheDict.TryGetValue(delegateType, out LambdaFactory value))
4656  {
4657  methodInfo = typeof(Expression<>).MakeGenericType(delegateType).GetMethod("Create", BindingFlags.Static | BindingFlags.NonPublic);
4658  if (delegateType.CanCache())
4659  {
4660  value = (cacheDict[delegateType] = (LambdaFactory)Delegate.CreateDelegate(typeof(LambdaFactory), methodInfo));
4661  }
4662  }
4663  if (value != null)
4664  {
4665  return value(body, name, tailCall, parameters);
4666  }
4667  return (LambdaExpression)methodInfo.Invoke(null, new object[4]
4668  {
4669  body,
4670  name,
4671  tailCall,
4672  parameters
4673  });
4674  }
4675 
4687  [global::__DynamicallyInvokable]
4688  public static Expression<TDelegate> Lambda<TDelegate>(Expression body, params ParameterExpression[] parameters)
4689  {
4690  return Expression.Lambda<TDelegate>(body, tailCall: false, (IEnumerable<ParameterExpression>)parameters);
4691  }
4692 
4699  [global::__DynamicallyInvokable]
4700  public static Expression<TDelegate> Lambda<TDelegate>(Expression body, bool tailCall, params ParameterExpression[] parameters)
4701  {
4702  return Expression.Lambda<TDelegate>(body, tailCall, (IEnumerable<ParameterExpression>)parameters);
4703  }
4704 
4716  [global::__DynamicallyInvokable]
4717  public static Expression<TDelegate> Lambda<TDelegate>(Expression body, IEnumerable<ParameterExpression> parameters)
4718  {
4719  return Lambda<TDelegate>(body, null, tailCall: false, parameters);
4720  }
4721 
4728  [global::__DynamicallyInvokable]
4729  public static Expression<TDelegate> Lambda<TDelegate>(Expression body, bool tailCall, IEnumerable<ParameterExpression> parameters)
4730  {
4731  return Lambda<TDelegate>(body, null, tailCall, parameters);
4732  }
4733 
4740  [global::__DynamicallyInvokable]
4741  public static Expression<TDelegate> Lambda<TDelegate>(Expression body, string name, IEnumerable<ParameterExpression> parameters)
4742  {
4743  return Lambda<TDelegate>(body, name, tailCall: false, parameters);
4744  }
4745 
4753  [global::__DynamicallyInvokable]
4754  public static Expression<TDelegate> Lambda<TDelegate>(Expression body, string name, bool tailCall, IEnumerable<ParameterExpression> parameters)
4755  {
4756  ReadOnlyCollection<ParameterExpression> parameters2 = parameters.ToReadOnly();
4757  ValidateLambdaArgs(typeof(TDelegate), ref body, parameters2);
4758  return new Expression<TDelegate>(body, name, tailCall, parameters2);
4759  }
4760 
4769  [global::__DynamicallyInvokable]
4770  public static LambdaExpression Lambda(Expression body, params ParameterExpression[] parameters)
4771  {
4772  return Lambda(body, tailCall: false, (IEnumerable<ParameterExpression>)parameters);
4773  }
4774 
4780  [global::__DynamicallyInvokable]
4781  public static LambdaExpression Lambda(Expression body, bool tailCall, params ParameterExpression[] parameters)
4782  {
4783  return Lambda(body, tailCall, (IEnumerable<ParameterExpression>)parameters);
4784  }
4785 
4790  [global::__DynamicallyInvokable]
4792  {
4793  return Lambda(body, null, tailCall: false, parameters);
4794  }
4795 
4801  [global::__DynamicallyInvokable]
4802  public static LambdaExpression Lambda(Expression body, bool tailCall, IEnumerable<ParameterExpression> parameters)
4803  {
4804  return Lambda(body, null, tailCall, parameters);
4805  }
4806 
4818  [global::__DynamicallyInvokable]
4819  public static LambdaExpression Lambda(Type delegateType, Expression body, params ParameterExpression[] parameters)
4820  {
4821  return Lambda(delegateType, body, null, tailCall: false, parameters);
4822  }
4823 
4830  [global::__DynamicallyInvokable]
4831  public static LambdaExpression Lambda(Type delegateType, Expression body, bool tailCall, params ParameterExpression[] parameters)
4832  {
4833  return Lambda(delegateType, body, null, tailCall, parameters);
4834  }
4835 
4847  [global::__DynamicallyInvokable]
4848  public static LambdaExpression Lambda(Type delegateType, Expression body, IEnumerable<ParameterExpression> parameters)
4849  {
4850  return Lambda(delegateType, body, null, tailCall: false, parameters);
4851  }
4852 
4859  [global::__DynamicallyInvokable]
4860  public static LambdaExpression Lambda(Type delegateType, Expression body, bool tailCall, IEnumerable<ParameterExpression> parameters)
4861  {
4862  return Lambda(delegateType, body, null, tailCall, parameters);
4863  }
4864 
4870  [global::__DynamicallyInvokable]
4871  public static LambdaExpression Lambda(Expression body, string name, IEnumerable<ParameterExpression> parameters)
4872  {
4873  return Lambda(body, name, tailCall: false, parameters);
4874  }
4875 
4882  [global::__DynamicallyInvokable]
4883  public static LambdaExpression Lambda(Expression body, string name, bool tailCall, IEnumerable<ParameterExpression> parameters)
4884  {
4885  ContractUtils.RequiresNotNull(body, "body");
4886  ReadOnlyCollection<ParameterExpression> readOnlyCollection = parameters.ToReadOnly();
4887  int count = readOnlyCollection.Count;
4888  Type[] array = new Type[count + 1];
4889  if (count > 0)
4890  {
4891  Set<ParameterExpression> set = new Set<ParameterExpression>(readOnlyCollection.Count);
4892  for (int i = 0; i < count; i++)
4893  {
4894  ParameterExpression parameterExpression = readOnlyCollection[i];
4895  ContractUtils.RequiresNotNull(parameterExpression, "parameter");
4896  array[i] = (parameterExpression.IsByRef ? parameterExpression.Type.MakeByRefType() : parameterExpression.Type);
4897  if (set.Contains(parameterExpression))
4898  {
4899  throw Error.DuplicateVariable(parameterExpression);
4900  }
4901  set.Add(parameterExpression);
4902  }
4903  }
4904  array[count] = body.Type;
4905  Type delegateType = DelegateHelpers.MakeDelegateType(array);
4906  return CreateLambda(delegateType, body, name, tailCall, readOnlyCollection);
4907  }
4908 
4915  [global::__DynamicallyInvokable]
4916  public static LambdaExpression Lambda(Type delegateType, Expression body, string name, IEnumerable<ParameterExpression> parameters)
4917  {
4918  ReadOnlyCollection<ParameterExpression> parameters2 = parameters.ToReadOnly();
4919  ValidateLambdaArgs(delegateType, ref body, parameters2);
4920  return CreateLambda(delegateType, body, name, tailCall: false, parameters2);
4921  }
4922 
4930  [global::__DynamicallyInvokable]
4931  public static LambdaExpression Lambda(Type delegateType, Expression body, string name, bool tailCall, IEnumerable<ParameterExpression> parameters)
4932  {
4933  ReadOnlyCollection<ParameterExpression> parameters2 = parameters.ToReadOnly();
4934  ValidateLambdaArgs(delegateType, ref body, parameters2);
4935  return CreateLambda(delegateType, body, name, tailCall, parameters2);
4936  }
4937 
4938  private static void ValidateLambdaArgs(Type delegateType, ref Expression body, ReadOnlyCollection<ParameterExpression> parameters)
4939  {
4940  ContractUtils.RequiresNotNull(delegateType, "delegateType");
4941  RequiresCanRead(body, "body");
4942  if (!typeof(MulticastDelegate).IsAssignableFrom(delegateType) || delegateType == typeof(MulticastDelegate))
4943  {
4944  throw Error.LambdaTypeMustBeDerivedFromSystemDelegate();
4945  }
4946  CacheDict<Type, MethodInfo> lambdaDelegateCache = _LambdaDelegateCache;
4947  if (!lambdaDelegateCache.TryGetValue(delegateType, out MethodInfo value))
4948  {
4949  value = delegateType.GetMethod("Invoke");
4950  if (delegateType.CanCache())
4951  {
4952  lambdaDelegateCache[delegateType] = value;
4953  }
4954  }
4955  ParameterInfo[] parametersCached = value.GetParametersCached();
4956  if (parametersCached.Length != 0)
4957  {
4958  if (parametersCached.Length != parameters.Count)
4959  {
4960  throw Error.IncorrectNumberOfLambdaDeclarationParameters();
4961  }
4962  Set<ParameterExpression> set = new Set<ParameterExpression>(parametersCached.Length);
4963  int i = 0;
4964  for (int num = parametersCached.Length; i < num; i++)
4965  {
4966  ParameterExpression parameterExpression = parameters[i];
4967  ParameterInfo parameterInfo = parametersCached[i];
4968  RequiresCanRead(parameterExpression, "parameters");
4969  Type type = parameterInfo.ParameterType;
4970  if (parameterExpression.IsByRef)
4971  {
4972  if (!type.IsByRef)
4973  {
4974  throw Error.ParameterExpressionNotValidAsDelegate(parameterExpression.Type.MakeByRefType(), type);
4975  }
4976  type = type.GetElementType();
4977  }
4978  if (!TypeUtils.AreReferenceAssignable(parameterExpression.Type, type))
4979  {
4980  throw Error.ParameterExpressionNotValidAsDelegate(parameterExpression.Type, type);
4981  }
4982  if (set.Contains(parameterExpression))
4983  {
4984  throw Error.DuplicateVariable(parameterExpression);
4985  }
4986  set.Add(parameterExpression);
4987  }
4988  }
4989  else if (parameters.Count > 0)
4990  {
4991  throw Error.IncorrectNumberOfLambdaDeclarationParameters();
4992  }
4993  if (value.ReturnType != typeof(void) && !TypeUtils.AreReferenceAssignable(value.ReturnType, body.Type) && !TryQuote(value.ReturnType, ref body))
4994  {
4995  throw Error.ExpressionTypeDoesNotMatchReturn(body.Type, value.ReturnType);
4996  }
4997  }
4998 
4999  private static bool ValidateTryGetFuncActionArgs(Type[] typeArgs)
5000  {
5001  if (typeArgs == null)
5002  {
5003  throw new ArgumentNullException("typeArgs");
5004  }
5005  int i = 0;
5006  for (int num = typeArgs.Length; i < num; i++)
5007  {
5008  Type type = typeArgs[i];
5009  if (type == null)
5010  {
5011  throw new ArgumentNullException("typeArgs");
5012  }
5013  if (type.IsByRef)
5014  {
5015  return false;
5016  }
5017  }
5018  return true;
5019  }
5020 
5028  [global::__DynamicallyInvokable]
5029  public static Type GetFuncType(params Type[] typeArgs)
5030  {
5031  if (!ValidateTryGetFuncActionArgs(typeArgs))
5032  {
5033  throw Error.TypeMustNotBeByRef();
5034  }
5035  Type funcType = DelegateHelpers.GetFuncType(typeArgs);
5036  if (funcType == null)
5037  {
5038  throw Error.IncorrectNumberOfTypeArgsForFunc();
5039  }
5040  return funcType;
5041  }
5042 
5047  [global::__DynamicallyInvokable]
5048  public static bool TryGetFuncType(Type[] typeArgs, out Type funcType)
5049  {
5050  if (ValidateTryGetFuncActionArgs(typeArgs))
5051  {
5052  return (funcType = DelegateHelpers.GetFuncType(typeArgs)) != null;
5053  }
5054  funcType = null;
5055  return false;
5056  }
5057 
5065  [global::__DynamicallyInvokable]
5066  public static Type GetActionType(params Type[] typeArgs)
5067  {
5068  if (!ValidateTryGetFuncActionArgs(typeArgs))
5069  {
5070  throw Error.TypeMustNotBeByRef();
5071  }
5072  Type actionType = DelegateHelpers.GetActionType(typeArgs);
5073  if (actionType == null)
5074  {
5075  throw Error.IncorrectNumberOfTypeArgsForAction();
5076  }
5077  return actionType;
5078  }
5079 
5084  [global::__DynamicallyInvokable]
5085  public static bool TryGetActionType(Type[] typeArgs, out Type actionType)
5086  {
5087  if (ValidateTryGetFuncActionArgs(typeArgs))
5088  {
5089  return (actionType = DelegateHelpers.GetActionType(typeArgs)) != null;
5090  }
5091  actionType = null;
5092  return false;
5093  }
5094 
5098  [global::__DynamicallyInvokable]
5099  public static Type GetDelegateType(params Type[] typeArgs)
5100  {
5101  ContractUtils.RequiresNotEmpty(typeArgs, "typeArgs");
5102  ContractUtils.RequiresNotNullItems(typeArgs, "typeArgs");
5103  return DelegateHelpers.MakeDelegateType(typeArgs);
5104  }
5105 
5115  [global::__DynamicallyInvokable]
5116  public static ListInitExpression ListInit(NewExpression newExpression, params Expression[] initializers)
5117  {
5118  ContractUtils.RequiresNotNull(newExpression, "newExpression");
5119  ContractUtils.RequiresNotNull(initializers, "initializers");
5120  return ListInit(newExpression, (IEnumerable<Expression>)initializers);
5121  }
5122 
5132  [global::__DynamicallyInvokable]
5133  public static ListInitExpression ListInit(NewExpression newExpression, IEnumerable<Expression> initializers)
5134  {
5135  ContractUtils.RequiresNotNull(newExpression, "newExpression");
5136  ContractUtils.RequiresNotNull(initializers, "initializers");
5137  ReadOnlyCollection<Expression> readOnlyCollection = initializers.ToReadOnly();
5138  if (readOnlyCollection.Count == 0)
5139  {
5140  throw Error.ListInitializerWithZeroMembers();
5141  }
5142  MethodInfo addMethod = FindMethod(newExpression.Type, "Add", null, new Expression[1]
5143  {
5144  readOnlyCollection[0]
5145  }, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
5146  return ListInit(newExpression, addMethod, initializers);
5147  }
5148 
5162  [global::__DynamicallyInvokable]
5163  public static ListInitExpression ListInit(NewExpression newExpression, MethodInfo addMethod, params Expression[] initializers)
5164  {
5165  if (addMethod == null)
5166  {
5167  return ListInit(newExpression, (IEnumerable<Expression>)initializers);
5168  }
5169  ContractUtils.RequiresNotNull(newExpression, "newExpression");
5170  ContractUtils.RequiresNotNull(initializers, "initializers");
5171  return ListInit(newExpression, addMethod, (IEnumerable<Expression>)initializers);
5172  }
5173 
5187  [global::__DynamicallyInvokable]
5188  public static ListInitExpression ListInit(NewExpression newExpression, MethodInfo addMethod, IEnumerable<Expression> initializers)
5189  {
5190  if (addMethod == null)
5191  {
5192  return ListInit(newExpression, initializers);
5193  }
5194  ContractUtils.RequiresNotNull(newExpression, "newExpression");
5195  ContractUtils.RequiresNotNull(initializers, "initializers");
5196  ReadOnlyCollection<Expression> readOnlyCollection = initializers.ToReadOnly();
5197  if (readOnlyCollection.Count == 0)
5198  {
5199  throw Error.ListInitializerWithZeroMembers();
5200  }
5201  ElementInit[] array = new ElementInit[readOnlyCollection.Count];
5202  for (int i = 0; i < readOnlyCollection.Count; i++)
5203  {
5204  array[i] = ElementInit(addMethod, readOnlyCollection[i]);
5205  }
5206  return ListInit(newExpression, new TrueReadOnlyCollection<ElementInit>(array));
5207  }
5208 
5217  [global::__DynamicallyInvokable]
5218  public static ListInitExpression ListInit(NewExpression newExpression, params ElementInit[] initializers)
5219  {
5220  return ListInit(newExpression, (IEnumerable<ElementInit>)initializers);
5221  }
5222 
5231  [global::__DynamicallyInvokable]
5232  public static ListInitExpression ListInit(NewExpression newExpression, IEnumerable<ElementInit> initializers)
5233  {
5234  ContractUtils.RequiresNotNull(newExpression, "newExpression");
5235  ContractUtils.RequiresNotNull(initializers, "initializers");
5236  ReadOnlyCollection<ElementInit> readOnlyCollection = initializers.ToReadOnly();
5237  if (readOnlyCollection.Count == 0)
5238  {
5239  throw Error.ListInitializerWithZeroMembers();
5240  }
5241  ValidateListInitArgs(newExpression.Type, readOnlyCollection);
5242  return new ListInitExpression(newExpression, readOnlyCollection);
5243  }
5244 
5248  [global::__DynamicallyInvokable]
5249  public static LoopExpression Loop(Expression body)
5250  {
5251  return Loop(body, null);
5252  }
5253 
5258  [global::__DynamicallyInvokable]
5259  public static LoopExpression Loop(Expression body, LabelTarget @break)
5260  {
5261  return Loop(body, @break, null);
5262  }
5263 
5269  [global::__DynamicallyInvokable]
5270  public static LoopExpression Loop(Expression body, LabelTarget @break, LabelTarget @continue)
5271  {
5272  RequiresCanRead(body, "body");
5273  if (@continue != null && @continue.Type != typeof(void))
5274  {
5275  throw Error.LabelTypeMustBeVoid();
5276  }
5277  return new LoopExpression(body, @break, @continue);
5278  }
5279 
5289  [global::__DynamicallyInvokable]
5290  public static MemberAssignment Bind(MemberInfo member, Expression expression)
5291  {
5292  ContractUtils.RequiresNotNull(member, "member");
5293  RequiresCanRead(expression, "expression");
5294  ValidateSettableFieldOrPropertyMember(member, out Type memberType);
5295  if (!memberType.IsAssignableFrom(expression.Type))
5296  {
5297  throw Error.ArgumentTypesMustMatch();
5298  }
5299  return new MemberAssignment(member, expression);
5300  }
5301 
5311  [global::__DynamicallyInvokable]
5312  public static MemberAssignment Bind(MethodInfo propertyAccessor, Expression expression)
5313  {
5314  ContractUtils.RequiresNotNull(propertyAccessor, "propertyAccessor");
5315  ContractUtils.RequiresNotNull(expression, "expression");
5316  ValidateMethodInfo(propertyAccessor);
5317  return Bind(GetProperty(propertyAccessor), expression);
5318  }
5319 
5320  private static void ValidateSettableFieldOrPropertyMember(MemberInfo member, out Type memberType)
5321  {
5322  FieldInfo fieldInfo = member as FieldInfo;
5323  if (fieldInfo == null)
5324  {
5325  PropertyInfo propertyInfo = member as PropertyInfo;
5326  if (propertyInfo == null)
5327  {
5328  throw Error.ArgumentMustBeFieldInfoOrPropertInfo();
5329  }
5330  if (!propertyInfo.CanWrite)
5331  {
5332  throw Error.PropertyDoesNotHaveSetter(propertyInfo);
5333  }
5334  memberType = propertyInfo.PropertyType;
5335  }
5336  else
5337  {
5338  memberType = fieldInfo.FieldType;
5339  }
5340  }
5341 
5350  [global::__DynamicallyInvokable]
5351  public static MemberExpression Field(Expression expression, FieldInfo field)
5352  {
5353  ContractUtils.RequiresNotNull(field, "field");
5354  if (field.IsStatic)
5355  {
5356  if (expression != null)
5357  {
5358  throw new ArgumentException(Strings.OnlyStaticFieldsHaveNullInstance, "expression");
5359  }
5360  }
5361  else
5362  {
5363  if (expression == null)
5364  {
5365  throw new ArgumentException(Strings.OnlyStaticFieldsHaveNullInstance, "field");
5366  }
5367  RequiresCanRead(expression, "expression");
5368  if (!TypeUtils.AreReferenceAssignable(field.DeclaringType, expression.Type))
5369  {
5370  throw Error.FieldInfoNotDefinedForType(field.DeclaringType, field.Name, expression.Type);
5371  }
5372  }
5373  return MemberExpression.Make(expression, field);
5374  }
5375 
5383  [global::__DynamicallyInvokable]
5384  public static MemberExpression Field(Expression expression, string fieldName)
5385  {
5386  RequiresCanRead(expression, "expression");
5387  FieldInfo field = expression.Type.GetField(fieldName, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy);
5388  if (field == null)
5389  {
5390  field = expression.Type.GetField(fieldName, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
5391  }
5392  if (field == null)
5393  {
5394  throw Error.InstanceFieldNotDefinedForType(fieldName, expression.Type);
5395  }
5396  return Field(expression, field);
5397  }
5398 
5404  [global::__DynamicallyInvokable]
5405  public static MemberExpression Field(Expression expression, Type type, string fieldName)
5406  {
5407  ContractUtils.RequiresNotNull(type, "type");
5408  FieldInfo field = type.GetField(fieldName, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);
5409  if (field == null)
5410  {
5411  field = type.GetField(fieldName, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
5412  }
5413  if (field == null)
5414  {
5415  throw Error.FieldNotDefinedForType(fieldName, type);
5416  }
5417  return Field(expression, field);
5418  }
5419 
5427  [global::__DynamicallyInvokable]
5428  public static MemberExpression Property(Expression expression, string propertyName)
5429  {
5430  RequiresCanRead(expression, "expression");
5431  ContractUtils.RequiresNotNull(propertyName, "propertyName");
5432  PropertyInfo property = expression.Type.GetProperty(propertyName, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy);
5433  if (property == null)
5434  {
5435  property = expression.Type.GetProperty(propertyName, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
5436  }
5437  if (property == null)
5438  {
5439  throw Error.InstancePropertyNotDefinedForType(propertyName, expression.Type);
5440  }
5441  return Property(expression, property);
5442  }
5443 
5449  [global::__DynamicallyInvokable]
5450  public static MemberExpression Property(Expression expression, Type type, string propertyName)
5451  {
5452  ContractUtils.RequiresNotNull(type, "type");
5453  ContractUtils.RequiresNotNull(propertyName, "propertyName");
5454  PropertyInfo property = type.GetProperty(propertyName, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);
5455  if (property == null)
5456  {
5457  property = type.GetProperty(propertyName, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
5458  }
5459  if (property == null)
5460  {
5461  throw Error.PropertyNotDefinedForType(propertyName, type);
5462  }
5463  return Property(expression, property);
5464  }
5465 
5474  [global::__DynamicallyInvokable]
5475  public static MemberExpression Property(Expression expression, PropertyInfo property)
5476  {
5477  ContractUtils.RequiresNotNull(property, "property");
5478  MethodInfo methodInfo = property.GetGetMethod(nonPublic: true) ?? property.GetSetMethod(nonPublic: true);
5479  if (methodInfo == null)
5480  {
5481  throw Error.PropertyDoesNotHaveAccessor(property);
5482  }
5483  if (methodInfo.IsStatic)
5484  {
5485  if (expression != null)
5486  {
5487  throw new ArgumentException(Strings.OnlyStaticPropertiesHaveNullInstance, "expression");
5488  }
5489  }
5490  else
5491  {
5492  if (expression == null)
5493  {
5494  throw new ArgumentException(Strings.OnlyStaticPropertiesHaveNullInstance, "property");
5495  }
5496  RequiresCanRead(expression, "expression");
5497  if (!TypeUtils.IsValidInstanceType(property, expression.Type))
5498  {
5499  throw Error.PropertyNotDefinedForType(property, expression.Type);
5500  }
5501  }
5502  return MemberExpression.Make(expression, property);
5503  }
5504 
5513  [global::__DynamicallyInvokable]
5514  public static MemberExpression Property(Expression expression, MethodInfo propertyAccessor)
5515  {
5516  ContractUtils.RequiresNotNull(propertyAccessor, "propertyAccessor");
5517  ValidateMethodInfo(propertyAccessor);
5518  return Property(expression, GetProperty(propertyAccessor));
5519  }
5520 
5521  private static PropertyInfo GetProperty(MethodInfo mi)
5522  {
5523  Type declaringType = mi.DeclaringType;
5524  BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.NonPublic;
5525  bindingFlags = (BindingFlags)((int)bindingFlags | (mi.IsStatic ? 8 : 4));
5526  PropertyInfo[] properties = declaringType.GetProperties(bindingFlags);
5527  PropertyInfo[] array = properties;
5528  foreach (PropertyInfo propertyInfo in array)
5529  {
5530  if (propertyInfo.CanRead && CheckMethod(mi, propertyInfo.GetGetMethod(nonPublic: true)))
5531  {
5532  return propertyInfo;
5533  }
5534  if (propertyInfo.CanWrite && CheckMethod(mi, propertyInfo.GetSetMethod(nonPublic: true)))
5535  {
5536  return propertyInfo;
5537  }
5538  }
5539  throw Error.MethodNotPropertyAccessor(mi.DeclaringType, mi.Name);
5540  }
5541 
5542  private static bool CheckMethod(MethodInfo method, MethodInfo propertyMethod)
5543  {
5544  if (method == propertyMethod)
5545  {
5546  return true;
5547  }
5548  Type declaringType = method.DeclaringType;
5549  if (declaringType.IsInterface && method.Name == propertyMethod.Name && declaringType.GetMethod(method.Name) == propertyMethod)
5550  {
5551  return true;
5552  }
5553  return false;
5554  }
5555 
5563  [global::__DynamicallyInvokable]
5564  public static MemberExpression PropertyOrField(Expression expression, string propertyOrFieldName)
5565  {
5566  RequiresCanRead(expression, "expression");
5567  PropertyInfo property = expression.Type.GetProperty(propertyOrFieldName, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy);
5568  if (property != null)
5569  {
5570  return Property(expression, property);
5571  }
5572  FieldInfo field = expression.Type.GetField(propertyOrFieldName, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy);
5573  if (field != null)
5574  {
5575  return Field(expression, field);
5576  }
5577  property = expression.Type.GetProperty(propertyOrFieldName, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
5578  if (property != null)
5579  {
5580  return Property(expression, property);
5581  }
5582  field = expression.Type.GetField(propertyOrFieldName, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
5583  if (field != null)
5584  {
5585  return Field(expression, field);
5586  }
5587  throw Error.NotAMemberOfType(propertyOrFieldName, expression.Type);
5588  }
5589 
5598  [global::__DynamicallyInvokable]
5599  public static MemberExpression MakeMemberAccess(Expression expression, MemberInfo member)
5600  {
5601  ContractUtils.RequiresNotNull(member, "member");
5602  FieldInfo fieldInfo = member as FieldInfo;
5603  if (fieldInfo != null)
5604  {
5605  return Field(expression, fieldInfo);
5606  }
5607  PropertyInfo propertyInfo = member as PropertyInfo;
5608  if (propertyInfo != null)
5609  {
5610  return Property(expression, propertyInfo);
5611  }
5612  throw Error.MemberNotFieldOrProperty(member);
5613  }
5614 
5622  [global::__DynamicallyInvokable]
5623  public static MemberInitExpression MemberInit(NewExpression newExpression, params MemberBinding[] bindings)
5624  {
5625  return MemberInit(newExpression, (IEnumerable<MemberBinding>)bindings);
5626  }
5627 
5635  [global::__DynamicallyInvokable]
5637  {
5638  ContractUtils.RequiresNotNull(newExpression, "newExpression");
5639  ContractUtils.RequiresNotNull(bindings, "bindings");
5640  ReadOnlyCollection<MemberBinding> bindings2 = bindings.ToReadOnly();
5641  ValidateMemberInitArgs(newExpression.Type, bindings2);
5642  return new MemberInitExpression(newExpression, bindings2);
5643  }
5644 
5653  [global::__DynamicallyInvokable]
5654  public static MemberListBinding ListBind(MemberInfo member, params ElementInit[] initializers)
5655  {
5656  ContractUtils.RequiresNotNull(member, "member");
5657  ContractUtils.RequiresNotNull(initializers, "initializers");
5658  return ListBind(member, (IEnumerable<ElementInit>)initializers);
5659  }
5660 
5669  [global::__DynamicallyInvokable]
5671  {
5672  ContractUtils.RequiresNotNull(member, "member");
5673  ContractUtils.RequiresNotNull(initializers, "initializers");
5674  ValidateGettableFieldOrPropertyMember(member, out Type memberType);
5675  ReadOnlyCollection<ElementInit> initializers2 = initializers.ToReadOnly();
5676  ValidateListInitArgs(memberType, initializers2);
5677  return new MemberListBinding(member, initializers2);
5678  }
5679 
5688  [global::__DynamicallyInvokable]
5689  public static MemberListBinding ListBind(MethodInfo propertyAccessor, params ElementInit[] initializers)
5690  {
5691  ContractUtils.RequiresNotNull(propertyAccessor, "propertyAccessor");
5692  ContractUtils.RequiresNotNull(initializers, "initializers");
5693  return ListBind(propertyAccessor, (IEnumerable<ElementInit>)initializers);
5694  }
5695 
5704  [global::__DynamicallyInvokable]
5705  public static MemberListBinding ListBind(MethodInfo propertyAccessor, IEnumerable<ElementInit> initializers)
5706  {
5707  ContractUtils.RequiresNotNull(propertyAccessor, "propertyAccessor");
5708  ContractUtils.RequiresNotNull(initializers, "initializers");
5709  return ListBind(GetProperty(propertyAccessor), initializers);
5710  }
5711 
5712  private static void ValidateListInitArgs(Type listType, ReadOnlyCollection<ElementInit> initializers)
5713  {
5714  if (!typeof(IEnumerable).IsAssignableFrom(listType))
5715  {
5716  throw Error.TypeNotIEnumerable(listType);
5717  }
5718  int i = 0;
5719  for (int count = initializers.Count; i < count; i++)
5720  {
5721  ElementInit elementInit = initializers[i];
5722  ContractUtils.RequiresNotNull(elementInit, "initializers");
5723  ValidateCallInstanceType(listType, elementInit.AddMethod);
5724  }
5725  }
5726 
5735  [global::__DynamicallyInvokable]
5736  public static MemberMemberBinding MemberBind(MemberInfo member, params MemberBinding[] bindings)
5737  {
5738  ContractUtils.RequiresNotNull(member, "member");
5739  ContractUtils.RequiresNotNull(bindings, "bindings");
5740  return MemberBind(member, (IEnumerable<MemberBinding>)bindings);
5741  }
5742 
5751  [global::__DynamicallyInvokable]
5753  {
5754  ContractUtils.RequiresNotNull(member, "member");
5755  ContractUtils.RequiresNotNull(bindings, "bindings");
5756  ReadOnlyCollection<MemberBinding> bindings2 = bindings.ToReadOnly();
5757  ValidateGettableFieldOrPropertyMember(member, out Type memberType);
5758  ValidateMemberInitArgs(memberType, bindings2);
5759  return new MemberMemberBinding(member, bindings2);
5760  }
5761 
5770  [global::__DynamicallyInvokable]
5771  public static MemberMemberBinding MemberBind(MethodInfo propertyAccessor, params MemberBinding[] bindings)
5772  {
5773  ContractUtils.RequiresNotNull(propertyAccessor, "propertyAccessor");
5774  return MemberBind(GetProperty(propertyAccessor), bindings);
5775  }
5776 
5785  [global::__DynamicallyInvokable]
5786  public static MemberMemberBinding MemberBind(MethodInfo propertyAccessor, IEnumerable<MemberBinding> bindings)
5787  {
5788  ContractUtils.RequiresNotNull(propertyAccessor, "propertyAccessor");
5789  return MemberBind(GetProperty(propertyAccessor), bindings);
5790  }
5791 
5792  private static void ValidateGettableFieldOrPropertyMember(MemberInfo member, out Type memberType)
5793  {
5794  FieldInfo fieldInfo = member as FieldInfo;
5795  if (fieldInfo == null)
5796  {
5797  PropertyInfo propertyInfo = member as PropertyInfo;
5798  if (propertyInfo == null)
5799  {
5800  throw Error.ArgumentMustBeFieldInfoOrPropertInfo();
5801  }
5802  if (!propertyInfo.CanRead)
5803  {
5804  throw Error.PropertyDoesNotHaveGetter(propertyInfo);
5805  }
5806  memberType = propertyInfo.PropertyType;
5807  }
5808  else
5809  {
5810  memberType = fieldInfo.FieldType;
5811  }
5812  }
5813 
5814  private static void ValidateMemberInitArgs(Type type, ReadOnlyCollection<MemberBinding> bindings)
5815  {
5816  int num = 0;
5817  int count = bindings.Count;
5818  MemberBinding memberBinding;
5819  while (true)
5820  {
5821  if (num < count)
5822  {
5823  memberBinding = bindings[num];
5824  ContractUtils.RequiresNotNull(memberBinding, "bindings");
5825  if (!memberBinding.Member.DeclaringType.IsAssignableFrom(type))
5826  {
5827  break;
5828  }
5829  num++;
5830  continue;
5831  }
5832  return;
5833  }
5834  throw Error.NotAMemberOfType(memberBinding.Member.Name, type);
5835  }
5836 
5843  [global::__DynamicallyInvokable]
5844  public static MethodCallExpression Call(MethodInfo method, Expression arg0)
5845  {
5846  ContractUtils.RequiresNotNull(method, "method");
5847  ContractUtils.RequiresNotNull(arg0, "arg0");
5848  ParameterInfo[] array = ValidateMethodAndGetParameters(null, method);
5849  ValidateArgumentCount(method, ExpressionType.Call, 1, array);
5850  arg0 = ValidateOneArgument(method, ExpressionType.Call, arg0, array[0]);
5851  return new MethodCallExpression1(method, arg0);
5852  }
5853 
5861  [global::__DynamicallyInvokable]
5862  public static MethodCallExpression Call(MethodInfo method, Expression arg0, Expression arg1)
5863  {
5864  ContractUtils.RequiresNotNull(method, "method");
5865  ContractUtils.RequiresNotNull(arg0, "arg0");
5866  ContractUtils.RequiresNotNull(arg1, "arg1");
5867  ParameterInfo[] array = ValidateMethodAndGetParameters(null, method);
5868  ValidateArgumentCount(method, ExpressionType.Call, 2, array);
5869  arg0 = ValidateOneArgument(method, ExpressionType.Call, arg0, array[0]);
5870  arg1 = ValidateOneArgument(method, ExpressionType.Call, arg1, array[1]);
5871  return new MethodCallExpression2(method, arg0, arg1);
5872  }
5873 
5882  [global::__DynamicallyInvokable]
5883  public static MethodCallExpression Call(MethodInfo method, Expression arg0, Expression arg1, Expression arg2)
5884  {
5885  ContractUtils.RequiresNotNull(method, "method");
5886  ContractUtils.RequiresNotNull(arg0, "arg0");
5887  ContractUtils.RequiresNotNull(arg1, "arg1");
5888  ContractUtils.RequiresNotNull(arg2, "arg2");
5889  ParameterInfo[] array = ValidateMethodAndGetParameters(null, method);
5890  ValidateArgumentCount(method, ExpressionType.Call, 3, array);
5891  arg0 = ValidateOneArgument(method, ExpressionType.Call, arg0, array[0]);
5892  arg1 = ValidateOneArgument(method, ExpressionType.Call, arg1, array[1]);
5893  arg2 = ValidateOneArgument(method, ExpressionType.Call, arg2, array[2]);
5894  return new MethodCallExpression3(method, arg0, arg1, arg2);
5895  }
5896 
5906  [global::__DynamicallyInvokable]
5907  public static MethodCallExpression Call(MethodInfo method, Expression arg0, Expression arg1, Expression arg2, Expression arg3)
5908  {
5909  ContractUtils.RequiresNotNull(method, "method");
5910  ContractUtils.RequiresNotNull(arg0, "arg0");
5911  ContractUtils.RequiresNotNull(arg1, "arg1");
5912  ContractUtils.RequiresNotNull(arg2, "arg2");
5913  ContractUtils.RequiresNotNull(arg3, "arg3");
5914  ParameterInfo[] array = ValidateMethodAndGetParameters(null, method);
5915  ValidateArgumentCount(method, ExpressionType.Call, 4, array);
5916  arg0 = ValidateOneArgument(method, ExpressionType.Call, arg0, array[0]);
5917  arg1 = ValidateOneArgument(method, ExpressionType.Call, arg1, array[1]);
5918  arg2 = ValidateOneArgument(method, ExpressionType.Call, arg2, array[2]);
5919  arg3 = ValidateOneArgument(method, ExpressionType.Call, arg3, array[3]);
5920  return new MethodCallExpression4(method, arg0, arg1, arg2, arg3);
5921  }
5922 
5933  [global::__DynamicallyInvokable]
5934  public static MethodCallExpression Call(MethodInfo method, Expression arg0, Expression arg1, Expression arg2, Expression arg3, Expression arg4)
5935  {
5936  ContractUtils.RequiresNotNull(method, "method");
5937  ContractUtils.RequiresNotNull(arg0, "arg0");
5938  ContractUtils.RequiresNotNull(arg1, "arg1");
5939  ContractUtils.RequiresNotNull(arg2, "arg2");
5940  ContractUtils.RequiresNotNull(arg3, "arg3");
5941  ContractUtils.RequiresNotNull(arg4, "arg4");
5942  ParameterInfo[] array = ValidateMethodAndGetParameters(null, method);
5943  ValidateArgumentCount(method, ExpressionType.Call, 5, array);
5944  arg0 = ValidateOneArgument(method, ExpressionType.Call, arg0, array[0]);
5945  arg1 = ValidateOneArgument(method, ExpressionType.Call, arg1, array[1]);
5946  arg2 = ValidateOneArgument(method, ExpressionType.Call, arg2, array[2]);
5947  arg3 = ValidateOneArgument(method, ExpressionType.Call, arg3, array[3]);
5948  arg4 = ValidateOneArgument(method, ExpressionType.Call, arg4, array[4]);
5949  return new MethodCallExpression5(method, arg0, arg1, arg2, arg3, arg4);
5950  }
5951 
5959  [global::__DynamicallyInvokable]
5960  public static MethodCallExpression Call(MethodInfo method, params Expression[] arguments)
5961  {
5962  return Call(null, method, arguments);
5963  }
5964 
5969  [global::__DynamicallyInvokable]
5971  {
5972  return Call(null, method, arguments);
5973  }
5974 
5984  [global::__DynamicallyInvokable]
5985  public static MethodCallExpression Call(Expression instance, MethodInfo method)
5986  {
5987  return Call(instance, method, EmptyReadOnlyCollection<Expression>.Instance);
5988  }
5989 
6001  [global::__DynamicallyInvokable]
6002  public static MethodCallExpression Call(Expression instance, MethodInfo method, params Expression[] arguments)
6003  {
6004  return Call(instance, method, (IEnumerable<Expression>)arguments);
6005  }
6006 
6013  [global::__DynamicallyInvokable]
6014  public static MethodCallExpression Call(Expression instance, MethodInfo method, Expression arg0, Expression arg1)
6015  {
6016  ContractUtils.RequiresNotNull(method, "method");
6017  ContractUtils.RequiresNotNull(arg0, "arg0");
6018  ContractUtils.RequiresNotNull(arg1, "arg1");
6019  ParameterInfo[] array = ValidateMethodAndGetParameters(instance, method);
6020  ValidateArgumentCount(method, ExpressionType.Call, 2, array);
6021  arg0 = ValidateOneArgument(method, ExpressionType.Call, arg0, array[0]);
6022  arg1 = ValidateOneArgument(method, ExpressionType.Call, arg1, array[1]);
6023  if (instance != null)
6024  {
6025  return new InstanceMethodCallExpression2(method, instance, arg0, arg1);
6026  }
6027  return new MethodCallExpression2(method, arg0, arg1);
6028  }
6029 
6037  [global::__DynamicallyInvokable]
6038  public static MethodCallExpression Call(Expression instance, MethodInfo method, Expression arg0, Expression arg1, Expression arg2)
6039  {
6040  ContractUtils.RequiresNotNull(method, "method");
6041  ContractUtils.RequiresNotNull(arg0, "arg0");
6042  ContractUtils.RequiresNotNull(arg1, "arg1");
6043  ContractUtils.RequiresNotNull(arg2, "arg2");
6044  ParameterInfo[] array = ValidateMethodAndGetParameters(instance, method);
6045  ValidateArgumentCount(method, ExpressionType.Call, 3, array);
6046  arg0 = ValidateOneArgument(method, ExpressionType.Call, arg0, array[0]);
6047  arg1 = ValidateOneArgument(method, ExpressionType.Call, arg1, array[1]);
6048  arg2 = ValidateOneArgument(method, ExpressionType.Call, arg2, array[2]);
6049  if (instance != null)
6050  {
6051  return new InstanceMethodCallExpression3(method, instance, arg0, arg1, arg2);
6052  }
6053  return new MethodCallExpression3(method, arg0, arg1, arg2);
6054  }
6055 
6065  [global::__DynamicallyInvokable]
6066  public static MethodCallExpression Call(Expression instance, string methodName, Type[] typeArguments, params Expression[] arguments)
6067  {
6068  ContractUtils.RequiresNotNull(instance, "instance");
6069  ContractUtils.RequiresNotNull(methodName, "methodName");
6070  if (arguments == null)
6071  {
6072  arguments = new Expression[0];
6073  }
6074  BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy;
6075  return Call(instance, FindMethod(instance.Type, methodName, typeArguments, arguments, flags), arguments);
6076  }
6077 
6087  [global::__DynamicallyInvokable]
6088  public static MethodCallExpression Call(Type type, string methodName, Type[] typeArguments, params Expression[] arguments)
6089  {
6090  ContractUtils.RequiresNotNull(type, "type");
6091  ContractUtils.RequiresNotNull(methodName, "methodName");
6092  if (arguments == null)
6093  {
6094  arguments = new Expression[0];
6095  }
6096  BindingFlags flags = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy;
6097  return Call(null, FindMethod(type, methodName, typeArguments, arguments, flags), arguments);
6098  }
6099 
6110  [global::__DynamicallyInvokable]
6111  public static MethodCallExpression Call(Expression instance, MethodInfo method, IEnumerable<Expression> arguments)
6112  {
6113  ContractUtils.RequiresNotNull(method, "method");
6114  ReadOnlyCollection<Expression> arguments2 = arguments.ToReadOnly();
6115  ValidateMethodInfo(method);
6116  ValidateStaticOrInstanceMethod(instance, method);
6117  ValidateArgumentTypes(method, ExpressionType.Call, ref arguments2);
6118  if (instance == null)
6119  {
6120  return new MethodCallExpressionN(method, arguments2);
6121  }
6122  return new InstanceMethodCallExpressionN(method, instance, arguments2);
6123  }
6124 
6125  private static ParameterInfo[] ValidateMethodAndGetParameters(Expression instance, MethodInfo method)
6126  {
6127  ValidateMethodInfo(method);
6128  ValidateStaticOrInstanceMethod(instance, method);
6129  return GetParametersForValidation(method, ExpressionType.Call);
6130  }
6131 
6132  private static void ValidateStaticOrInstanceMethod(Expression instance, MethodInfo method)
6133  {
6134  if (method.IsStatic)
6135  {
6136  if (instance != null)
6137  {
6138  throw new ArgumentException(Strings.OnlyStaticMethodsHaveNullInstance, "instance");
6139  }
6140  return;
6141  }
6142  if (instance == null)
6143  {
6144  throw new ArgumentException(Strings.OnlyStaticMethodsHaveNullInstance, "method");
6145  }
6146  RequiresCanRead(instance, "instance");
6147  ValidateCallInstanceType(instance.Type, method);
6148  }
6149 
6150  private static void ValidateCallInstanceType(Type instanceType, MethodInfo method)
6151  {
6152  if (!TypeUtils.IsValidInstanceType(method, instanceType))
6153  {
6154  throw Error.InstanceAndMethodTypeMismatch(method, method.DeclaringType, instanceType);
6155  }
6156  }
6157 
6158  private static void ValidateArgumentTypes(MethodBase method, ExpressionType nodeKind, ref ReadOnlyCollection<Expression> arguments)
6159  {
6160  ParameterInfo[] parametersForValidation = GetParametersForValidation(method, nodeKind);
6161  ValidateArgumentCount(method, nodeKind, arguments.Count, parametersForValidation);
6162  Expression[] array = null;
6163  int i = 0;
6164  for (int num = parametersForValidation.Length; i < num; i++)
6165  {
6166  Expression arg = arguments[i];
6167  ParameterInfo pi = parametersForValidation[i];
6168  arg = ValidateOneArgument(method, nodeKind, arg, pi);
6169  if (array == null && arg != arguments[i])
6170  {
6171  array = new Expression[arguments.Count];
6172  for (int j = 0; j < i; j++)
6173  {
6174  array[j] = arguments[j];
6175  }
6176  }
6177  if (array != null)
6178  {
6179  array[i] = arg;
6180  }
6181  }
6182  if (array != null)
6183  {
6184  arguments = new TrueReadOnlyCollection<Expression>(array);
6185  }
6186  }
6187 
6188  private static ParameterInfo[] GetParametersForValidation(MethodBase method, ExpressionType nodeKind)
6189  {
6190  ParameterInfo[] array = method.GetParametersCached();
6191  if (nodeKind == ExpressionType.Dynamic)
6192  {
6193  array = array.RemoveFirst();
6194  }
6195  return array;
6196  }
6197 
6198  private static void ValidateArgumentCount(MethodBase method, ExpressionType nodeKind, int count, ParameterInfo[] pis)
6199  {
6200  if (pis.Length != count)
6201  {
6202  switch (nodeKind)
6203  {
6204  case ExpressionType.New:
6205  throw Error.IncorrectNumberOfConstructorArguments();
6206  case ExpressionType.Invoke:
6207  throw Error.IncorrectNumberOfLambdaArguments();
6208  case ExpressionType.Call:
6209  case ExpressionType.Dynamic:
6210  throw Error.IncorrectNumberOfMethodCallArguments(method);
6211  default:
6212  throw ContractUtils.Unreachable;
6213  }
6214  }
6215  }
6216 
6217  private static Expression ValidateOneArgument(MethodBase method, ExpressionType nodeKind, Expression arg, ParameterInfo pi)
6218  {
6219  RequiresCanRead(arg, "arguments");
6220  Type type = pi.ParameterType;
6221  if (type.IsByRef)
6222  {
6223  type = type.GetElementType();
6224  }
6225  TypeUtils.ValidateType(type);
6226  if (!TypeUtils.AreReferenceAssignable(type, arg.Type) && !TryQuote(type, ref arg))
6227  {
6228  switch (nodeKind)
6229  {
6230  case ExpressionType.New:
6231  throw Error.ExpressionTypeDoesNotMatchConstructorParameter(arg.Type, type);
6232  case ExpressionType.Invoke:
6233  throw Error.ExpressionTypeDoesNotMatchParameter(arg.Type, type);
6234  case ExpressionType.Call:
6235  case ExpressionType.Dynamic:
6236  throw Error.ExpressionTypeDoesNotMatchMethodParameter(arg.Type, type, method);
6237  default:
6238  throw ContractUtils.Unreachable;
6239  }
6240  }
6241  return arg;
6242  }
6243 
6244  private static bool TryQuote(Type parameterType, ref Expression argument)
6245  {
6246  Type typeFromHandle = typeof(LambdaExpression);
6247  if (TypeUtils.IsSameOrSubclass(typeFromHandle, parameterType) && parameterType.IsAssignableFrom(argument.GetType()))
6248  {
6249  argument = Quote(argument);
6250  return true;
6251  }
6252  return false;
6253  }
6254 
6255  private static MethodInfo FindMethod(Type type, string methodName, Type[] typeArgs, Expression[] args, BindingFlags flags)
6256  {
6257  MemberInfo[] array = type.FindMembers(MemberTypes.Method, flags, Type.FilterNameIgnoreCase, methodName);
6258  if (array == null || array.Length == 0)
6259  {
6260  throw Error.MethodDoesNotExistOnType(methodName, type);
6261  }
6262  MethodInfo[] methods = array.Map((MemberInfo t) => (MethodInfo)t);
6263  MethodInfo method;
6264  int num = FindBestMethod(methods, typeArgs, args, out method);
6265  if (num == 0)
6266  {
6267  if (typeArgs != null && typeArgs.Length != 0)
6268  {
6269  throw Error.GenericMethodWithArgsDoesNotExistOnType(methodName, type);
6270  }
6271  throw Error.MethodWithArgsDoesNotExistOnType(methodName, type);
6272  }
6273  if (num > 1)
6274  {
6275  throw Error.MethodWithMoreThanOneMatch(methodName, type);
6276  }
6277  return method;
6278  }
6279 
6280  private static int FindBestMethod(IEnumerable<MethodInfo> methods, Type[] typeArgs, Expression[] args, out MethodInfo method)
6281  {
6282  int num = 0;
6283  method = null;
6284  foreach (MethodInfo method2 in methods)
6285  {
6286  MethodInfo methodInfo = ApplyTypeArgs(method2, typeArgs);
6287  if (methodInfo != null && IsCompatible(methodInfo, args))
6288  {
6289  if (method == null || (!method.IsPublic && methodInfo.IsPublic))
6290  {
6291  method = methodInfo;
6292  num = 1;
6293  }
6294  else if (method.IsPublic == methodInfo.IsPublic)
6295  {
6296  num++;
6297  }
6298  }
6299  }
6300  return num;
6301  }
6302 
6303  private static bool IsCompatible(MethodBase m, Expression[] args)
6304  {
6305  ParameterInfo[] parametersCached = m.GetParametersCached();
6306  if (parametersCached.Length != args.Length)
6307  {
6308  return false;
6309  }
6310  for (int i = 0; i < args.Length; i++)
6311  {
6312  Expression expression = args[i];
6313  ContractUtils.RequiresNotNull(expression, "argument");
6314  Type type = expression.Type;
6315  Type type2 = parametersCached[i].ParameterType;
6316  if (type2.IsByRef)
6317  {
6318  type2 = type2.GetElementType();
6319  }
6320  if (!TypeUtils.AreReferenceAssignable(type2, type) && (!TypeUtils.IsSameOrSubclass(typeof(LambdaExpression), type2) || !type2.IsAssignableFrom(expression.GetType())))
6321  {
6322  return false;
6323  }
6324  }
6325  return true;
6326  }
6327 
6328  private static MethodInfo ApplyTypeArgs(MethodInfo m, Type[] typeArgs)
6329  {
6330  if (typeArgs == null || typeArgs.Length == 0)
6331  {
6333  {
6334  return m;
6335  }
6336  }
6337  else if (m.IsGenericMethodDefinition && m.GetGenericArguments().Length == typeArgs.Length)
6338  {
6339  return m.MakeGenericMethod(typeArgs);
6340  }
6341  return null;
6342  }
6343 
6352  [global::__DynamicallyInvokable]
6353  public static MethodCallExpression ArrayIndex(Expression array, params Expression[] indexes)
6354  {
6355  return ArrayIndex(array, (IEnumerable<Expression>)indexes);
6356  }
6357 
6366  [global::__DynamicallyInvokable]
6368  {
6369  RequiresCanRead(array, "array");
6370  ContractUtils.RequiresNotNull(indexes, "indexes");
6371  Type type = array.Type;
6372  if (!type.IsArray)
6373  {
6374  throw Error.ArgumentMustBeArray();
6375  }
6376  ReadOnlyCollection<Expression> readOnlyCollection = indexes.ToReadOnly();
6377  if (type.GetArrayRank() != readOnlyCollection.Count)
6378  {
6379  throw Error.IncorrectNumberOfIndexes();
6380  }
6381  foreach (Expression item in readOnlyCollection)
6382  {
6383  RequiresCanRead(item, "indexes");
6384  if (item.Type != typeof(int))
6385  {
6386  throw Error.ArgumentMustBeArrayIndexType();
6387  }
6388  }
6389  MethodInfo method = array.Type.GetMethod("Get", BindingFlags.Instance | BindingFlags.Public);
6390  return Call(array, method, readOnlyCollection);
6391  }
6392 
6400  [global::__DynamicallyInvokable]
6401  public static NewArrayExpression NewArrayInit(Type type, params Expression[] initializers)
6402  {
6403  return NewArrayInit(type, (IEnumerable<Expression>)initializers);
6404  }
6405 
6413  [global::__DynamicallyInvokable]
6415  {
6416  ContractUtils.RequiresNotNull(type, "type");
6417  ContractUtils.RequiresNotNull(initializers, "initializers");
6418  if (type.Equals(typeof(void)))
6419  {
6420  throw Error.ArgumentCannotBeOfTypeVoid();
6421  }
6422  ReadOnlyCollection<Expression> readOnlyCollection = initializers.ToReadOnly();
6423  Expression[] array = null;
6424  int i = 0;
6425  for (int count = readOnlyCollection.Count; i < count; i++)
6426  {
6427  Expression argument = readOnlyCollection[i];
6428  RequiresCanRead(argument, "initializers");
6429  if (!TypeUtils.AreReferenceAssignable(type, argument.Type))
6430  {
6431  if (!TryQuote(type, ref argument))
6432  {
6433  throw Error.ExpressionTypeCannotInitializeArrayType(argument.Type, type);
6434  }
6435  if (array == null)
6436  {
6437  array = new Expression[readOnlyCollection.Count];
6438  for (int j = 0; j < i; j++)
6439  {
6440  array[j] = readOnlyCollection[j];
6441  }
6442  }
6443  }
6444  if (array != null)
6445  {
6446  array[i] = argument;
6447  }
6448  }
6449  if (array != null)
6450  {
6451  readOnlyCollection = new TrueReadOnlyCollection<Expression>(array);
6452  }
6453  return NewArrayExpression.Make(ExpressionType.NewArrayInit, type.MakeArrayType(), readOnlyCollection);
6454  }
6455 
6463  [global::__DynamicallyInvokable]
6464  public static NewArrayExpression NewArrayBounds(Type type, params Expression[] bounds)
6465  {
6466  return NewArrayBounds(type, (IEnumerable<Expression>)bounds);
6467  }
6468 
6476  [global::__DynamicallyInvokable]
6478  {
6479  ContractUtils.RequiresNotNull(type, "type");
6480  ContractUtils.RequiresNotNull(bounds, "bounds");
6481  if (type.Equals(typeof(void)))
6482  {
6483  throw Error.ArgumentCannotBeOfTypeVoid();
6484  }
6485  ReadOnlyCollection<Expression> readOnlyCollection = bounds.ToReadOnly();
6486  int count = readOnlyCollection.Count;
6487  if (count <= 0)
6488  {
6489  throw Error.BoundsCannotBeLessThanOne();
6490  }
6491  for (int i = 0; i < count; i++)
6492  {
6493  Expression expression = readOnlyCollection[i];
6494  RequiresCanRead(expression, "bounds");
6495  if (!TypeUtils.IsInteger(expression.Type))
6496  {
6497  throw Error.ArgumentMustBeInteger();
6498  }
6499  }
6500  Type type2 = (count != 1) ? type.MakeArrayType(count) : type.MakeArrayType();
6501  return NewArrayExpression.Make(ExpressionType.NewArrayBounds, type2, bounds.ToReadOnly());
6502  }
6503 
6510  [global::__DynamicallyInvokable]
6511  public static NewExpression New(ConstructorInfo constructor)
6512  {
6513  return New(constructor, (IEnumerable<Expression>)null);
6514  }
6515 
6523  [global::__DynamicallyInvokable]
6524  public static NewExpression New(ConstructorInfo constructor, params Expression[] arguments)
6525  {
6526  return New(constructor, (IEnumerable<Expression>)arguments);
6527  }
6528 
6536  [global::__DynamicallyInvokable]
6537  public static NewExpression New(ConstructorInfo constructor, IEnumerable<Expression> arguments)
6538  {
6539  ContractUtils.RequiresNotNull(constructor, "constructor");
6540  ContractUtils.RequiresNotNull(constructor.DeclaringType, "constructor.DeclaringType");
6541  TypeUtils.ValidateType(constructor.DeclaringType);
6542  ReadOnlyCollection<Expression> arguments2 = arguments.ToReadOnly();
6543  ValidateArgumentTypes(constructor, ExpressionType.New, ref arguments2);
6544  return new NewExpression(constructor, arguments2, null);
6545  }
6546 
6555  [global::__DynamicallyInvokable]
6557  {
6558  ContractUtils.RequiresNotNull(constructor, "constructor");
6559  ReadOnlyCollection<MemberInfo> members2 = members.ToReadOnly();
6560  ReadOnlyCollection<Expression> arguments2 = arguments.ToReadOnly();
6561  ValidateNewArgs(constructor, ref arguments2, ref members2);
6562  return new NewExpression(constructor, arguments2, members2);
6563  }
6564 
6573  [global::__DynamicallyInvokable]
6574  public static NewExpression New(ConstructorInfo constructor, IEnumerable<Expression> arguments, params MemberInfo[] members)
6575  {
6576  return New(constructor, arguments, (IEnumerable<MemberInfo>)members);
6577  }
6578 
6585  [global::__DynamicallyInvokable]
6586  public static NewExpression New(Type type)
6587  {
6588  ContractUtils.RequiresNotNull(type, "type");
6589  if (type == typeof(void))
6590  {
6591  throw Error.ArgumentCannotBeOfTypeVoid();
6592  }
6593  ConstructorInfo constructorInfo = null;
6594  if (!type.IsValueType)
6595  {
6596  constructorInfo = type.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null);
6597  if (constructorInfo == null)
6598  {
6599  throw Error.TypeMissingDefaultConstructor(type);
6600  }
6601  return New(constructorInfo);
6602  }
6603  return new NewValueTypeExpression(type, EmptyReadOnlyCollection<Expression>.Instance, null);
6604  }
6605 
6606  private static void ValidateNewArgs(ConstructorInfo constructor, ref ReadOnlyCollection<Expression> arguments, ref ReadOnlyCollection<MemberInfo> members)
6607  {
6608  ParameterInfo[] parametersCached;
6609  if ((parametersCached = constructor.GetParametersCached()).Length != 0)
6610  {
6611  if (arguments.Count != parametersCached.Length)
6612  {
6613  throw Error.IncorrectNumberOfConstructorArguments();
6614  }
6615  if (arguments.Count != members.Count)
6616  {
6617  throw Error.IncorrectNumberOfArgumentsForMembers();
6618  }
6619  Expression[] array = null;
6620  MemberInfo[] array2 = null;
6621  int i = 0;
6622  for (int count = arguments.Count; i < count; i++)
6623  {
6624  Expression argument = arguments[i];
6625  RequiresCanRead(argument, "argument");
6626  MemberInfo member = members[i];
6627  ContractUtils.RequiresNotNull(member, "member");
6628  if (!TypeUtils.AreEquivalent(member.DeclaringType, constructor.DeclaringType))
6629  {
6630  throw Error.ArgumentMemberNotDeclOnType(member.Name, constructor.DeclaringType.Name);
6631  }
6632  ValidateAnonymousTypeMember(ref member, out Type memberType);
6633  if (!TypeUtils.AreReferenceAssignable(memberType, argument.Type) && !TryQuote(memberType, ref argument))
6634  {
6635  throw Error.ArgumentTypeDoesNotMatchMember(argument.Type, memberType);
6636  }
6637  ParameterInfo parameterInfo = parametersCached[i];
6638  Type type = parameterInfo.ParameterType;
6639  if (type.IsByRef)
6640  {
6641  type = type.GetElementType();
6642  }
6643  if (!TypeUtils.AreReferenceAssignable(type, argument.Type) && !TryQuote(type, ref argument))
6644  {
6645  throw Error.ExpressionTypeDoesNotMatchConstructorParameter(argument.Type, type);
6646  }
6647  if (array == null && argument != arguments[i])
6648  {
6649  array = new Expression[arguments.Count];
6650  for (int j = 0; j < i; j++)
6651  {
6652  array[j] = arguments[j];
6653  }
6654  }
6655  if (array != null)
6656  {
6657  array[i] = argument;
6658  }
6659  if (array2 == null && member != members[i])
6660  {
6661  array2 = new MemberInfo[members.Count];
6662  for (int k = 0; k < i; k++)
6663  {
6664  array2[k] = members[k];
6665  }
6666  }
6667  if (array2 != null)
6668  {
6669  array2[i] = member;
6670  }
6671  }
6672  if (array != null)
6673  {
6674  arguments = new TrueReadOnlyCollection<Expression>(array);
6675  }
6676  if (array2 != null)
6677  {
6678  members = new TrueReadOnlyCollection<MemberInfo>(array2);
6679  }
6680  }
6681  else
6682  {
6683  if (arguments != null && arguments.Count > 0)
6684  {
6685  throw Error.IncorrectNumberOfConstructorArguments();
6686  }
6687  if (members != null && members.Count > 0)
6688  {
6689  throw Error.IncorrectNumberOfMembersForGivenConstructor();
6690  }
6691  }
6692  }
6693 
6694  private static void ValidateAnonymousTypeMember(ref MemberInfo member, out Type memberType)
6695  {
6696  switch (member.MemberType)
6697  {
6698  case MemberTypes.Field:
6699  {
6700  FieldInfo fieldInfo = member as FieldInfo;
6701  if (fieldInfo.IsStatic)
6702  {
6703  throw Error.ArgumentMustBeInstanceMember();
6704  }
6705  memberType = fieldInfo.FieldType;
6706  break;
6707  }
6708  case MemberTypes.Property:
6709  {
6710  PropertyInfo propertyInfo = member as PropertyInfo;
6711  if (!propertyInfo.CanRead)
6712  {
6713  throw Error.PropertyDoesNotHaveGetter(propertyInfo);
6714  }
6715  if (propertyInfo.GetGetMethod().IsStatic)
6716  {
6717  throw Error.ArgumentMustBeInstanceMember();
6718  }
6719  memberType = propertyInfo.PropertyType;
6720  break;
6721  }
6722  case MemberTypes.Method:
6723  {
6724  MethodInfo methodInfo = member as MethodInfo;
6725  if (methodInfo.IsStatic)
6726  {
6727  throw Error.ArgumentMustBeInstanceMember();
6728  }
6729  memberType = ((PropertyInfo)(member = GetProperty(methodInfo))).PropertyType;
6730  break;
6731  }
6732  default:
6733  throw Error.ArgumentMustBeFieldInfoOrPropertInfoOrMethod();
6734  }
6735  }
6736 
6740  [global::__DynamicallyInvokable]
6741  public static ParameterExpression Parameter(Type type)
6742  {
6743  return Parameter(type, null);
6744  }
6745 
6749  [global::__DynamicallyInvokable]
6750  public static ParameterExpression Variable(Type type)
6751  {
6752  return Variable(type, null);
6753  }
6754 
6761  [global::__DynamicallyInvokable]
6762  public static ParameterExpression Parameter(Type type, string name)
6763  {
6764  ContractUtils.RequiresNotNull(type, "type");
6765  if (type == typeof(void))
6766  {
6767  throw Error.ArgumentCannotBeOfTypeVoid();
6768  }
6769  bool isByRef = type.IsByRef;
6770  if (isByRef)
6771  {
6772  type = type.GetElementType();
6773  }
6774  return ParameterExpression.Make(type, name, isByRef);
6775  }
6776 
6781  [global::__DynamicallyInvokable]
6782  public static ParameterExpression Variable(Type type, string name)
6783  {
6784  ContractUtils.RequiresNotNull(type, "type");
6785  if (type == typeof(void))
6786  {
6787  throw Error.ArgumentCannotBeOfTypeVoid();
6788  }
6789  if (type.IsByRef)
6790  {
6791  throw Error.TypeMustNotBeByRef();
6792  }
6793  return ParameterExpression.Make(type, name, isByRef: false);
6794  }
6795 
6799  [global::__DynamicallyInvokable]
6801  {
6803  }
6804 
6808  [global::__DynamicallyInvokable]
6810  {
6811  ContractUtils.RequiresNotNull(variables, "variables");
6812  ReadOnlyCollection<ParameterExpression> readOnlyCollection = variables.ToReadOnly();
6813  for (int i = 0; i < readOnlyCollection.Count; i++)
6814  {
6815  Expression expression = readOnlyCollection[i];
6816  if (expression == null)
6817  {
6818  throw new ArgumentNullException("variables[" + i + "]");
6819  }
6820  }
6821  return new RuntimeVariablesExpression(readOnlyCollection);
6822  }
6823 
6828  [global::__DynamicallyInvokable]
6829  public static SwitchCase SwitchCase(Expression body, params Expression[] testValues)
6830  {
6831  return SwitchCase(body, (IEnumerable<Expression>)testValues);
6832  }
6833 
6838  [global::__DynamicallyInvokable]
6840  {
6841  RequiresCanRead(body, "body");
6842  ReadOnlyCollection<Expression> readOnlyCollection = testValues.ToReadOnly();
6843  RequiresCanRead(readOnlyCollection, "testValues");
6844  ContractUtils.RequiresNotEmpty(readOnlyCollection, "testValues");
6845  return new SwitchCase(body, readOnlyCollection);
6846  }
6847 
6852  [global::__DynamicallyInvokable]
6853  public static SwitchExpression Switch(Expression switchValue, params SwitchCase[] cases)
6854  {
6855  return Switch(switchValue, (Expression)null, (MethodInfo)null, (IEnumerable<SwitchCase>)cases);
6856  }
6857 
6863  [global::__DynamicallyInvokable]
6864  public static SwitchExpression Switch(Expression switchValue, Expression defaultBody, params SwitchCase[] cases)
6865  {
6866  return Switch(switchValue, defaultBody, (MethodInfo)null, (IEnumerable<SwitchCase>)cases);
6867  }
6868 
6875  [global::__DynamicallyInvokable]
6876  public static SwitchExpression Switch(Expression switchValue, Expression defaultBody, MethodInfo comparison, params SwitchCase[] cases)
6877  {
6878  return Switch(switchValue, defaultBody, comparison, (IEnumerable<SwitchCase>)cases);
6879  }
6880 
6888  [global::__DynamicallyInvokable]
6889  public static SwitchExpression Switch(Type type, Expression switchValue, Expression defaultBody, MethodInfo comparison, params SwitchCase[] cases)
6890  {
6891  return Switch(type, switchValue, defaultBody, comparison, (IEnumerable<SwitchCase>)cases);
6892  }
6893 
6900  [global::__DynamicallyInvokable]
6901  public static SwitchExpression Switch(Expression switchValue, Expression defaultBody, MethodInfo comparison, IEnumerable<SwitchCase> cases)
6902  {
6903  return Switch(null, switchValue, defaultBody, comparison, cases);
6904  }
6905 
6913  [global::__DynamicallyInvokable]
6914  public static SwitchExpression Switch(Type type, Expression switchValue, Expression defaultBody, MethodInfo comparison, IEnumerable<SwitchCase> cases)
6915  {
6916  RequiresCanRead(switchValue, "switchValue");
6917  if (switchValue.Type == typeof(void))
6918  {
6919  throw Error.ArgumentCannotBeOfTypeVoid();
6920  }
6921  ReadOnlyCollection<SwitchCase> readOnlyCollection = cases.ToReadOnly();
6922  ContractUtils.RequiresNotEmpty(readOnlyCollection, "cases");
6923  ContractUtils.RequiresNotNullItems(readOnlyCollection, "cases");
6924  Type type2 = type ?? readOnlyCollection[0].Body.Type;
6925  bool customType = type != null;
6926  if (comparison != null)
6927  {
6928  ParameterInfo[] parametersCached = comparison.GetParametersCached();
6929  if (parametersCached.Length != 2)
6930  {
6931  throw Error.IncorrectNumberOfMethodCallArguments(comparison);
6932  }
6933  ParameterInfo parameterInfo = parametersCached[0];
6934  bool flag = false;
6935  if (!ParameterIsAssignable(parameterInfo, switchValue.Type))
6936  {
6937  flag = ParameterIsAssignable(parameterInfo, switchValue.Type.GetNonNullableType());
6938  if (!flag)
6939  {
6940  throw Error.SwitchValueTypeDoesNotMatchComparisonMethodParameter(switchValue.Type, parameterInfo.ParameterType);
6941  }
6942  }
6943  ParameterInfo parameterInfo2 = parametersCached[1];
6944  foreach (SwitchCase item in readOnlyCollection)
6945  {
6946  ContractUtils.RequiresNotNull(item, "cases");
6947  ValidateSwitchCaseType(item.Body, customType, type2, "cases");
6948  for (int i = 0; i < item.TestValues.Count; i++)
6949  {
6950  Type type3 = item.TestValues[i].Type;
6951  if (flag)
6952  {
6953  if (!type3.IsNullableType())
6954  {
6955  throw Error.TestValueTypeDoesNotMatchComparisonMethodParameter(type3, parameterInfo2.ParameterType);
6956  }
6957  type3 = type3.GetNonNullableType();
6958  }
6959  if (!ParameterIsAssignable(parameterInfo2, type3))
6960  {
6961  throw Error.TestValueTypeDoesNotMatchComparisonMethodParameter(type3, parameterInfo2.ParameterType);
6962  }
6963  }
6964  }
6965  }
6966  else
6967  {
6968  Expression expression = readOnlyCollection[0].TestValues[0];
6969  foreach (SwitchCase item2 in readOnlyCollection)
6970  {
6971  ContractUtils.RequiresNotNull(item2, "cases");
6972  ValidateSwitchCaseType(item2.Body, customType, type2, "cases");
6973  for (int j = 0; j < item2.TestValues.Count; j++)
6974  {
6975  if (!TypeUtils.AreEquivalent(expression.Type, item2.TestValues[j].Type))
6976  {
6977  throw new ArgumentException(Strings.AllTestValuesMustHaveSameType, "cases");
6978  }
6979  }
6980  }
6981  BinaryExpression binaryExpression = Equal(switchValue, expression, liftToNull: false, comparison);
6982  comparison = binaryExpression.Method;
6983  }
6984  if (defaultBody == null)
6985  {
6986  if (type2 != typeof(void))
6987  {
6988  throw Error.DefaultBodyMustBeSupplied();
6989  }
6990  }
6991  else
6992  {
6993  ValidateSwitchCaseType(defaultBody, customType, type2, "defaultBody");
6994  }
6995  if (comparison != null && comparison.ReturnType != typeof(bool))
6996  {
6997  throw Error.EqualityMustReturnBoolean(comparison);
6998  }
6999  return new SwitchExpression(type2, switchValue, defaultBody, comparison, readOnlyCollection);
7000  }
7001 
7002  private static void ValidateSwitchCaseType(Expression @case, bool customType, Type resultType, string parameterName)
7003  {
7004  if (customType)
7005  {
7006  if (resultType != typeof(void) && !TypeUtils.AreReferenceAssignable(resultType, @case.Type))
7007  {
7008  throw new ArgumentException(Strings.ArgumentTypesMustMatch, parameterName);
7009  }
7010  }
7011  else if (!TypeUtils.AreEquivalent(resultType, @case.Type))
7012  {
7013  throw new ArgumentException(Strings.AllCaseBodiesMustHaveSameType, parameterName);
7014  }
7015  }
7016 
7020  [global::__DynamicallyInvokable]
7021  public static SymbolDocumentInfo SymbolDocument(string fileName)
7022  {
7023  return new SymbolDocumentInfo(fileName);
7024  }
7025 
7030  [global::__DynamicallyInvokable]
7031  public static SymbolDocumentInfo SymbolDocument(string fileName, Guid language)
7032  {
7033  return new SymbolDocumentWithGuids(fileName, ref language);
7034  }
7035 
7041  [global::__DynamicallyInvokable]
7042  public static SymbolDocumentInfo SymbolDocument(string fileName, Guid language, Guid languageVendor)
7043  {
7044  return new SymbolDocumentWithGuids(fileName, ref language, ref languageVendor);
7045  }
7046 
7053  [global::__DynamicallyInvokable]
7054  public static SymbolDocumentInfo SymbolDocument(string fileName, Guid language, Guid languageVendor, Guid documentType)
7055  {
7056  return new SymbolDocumentWithGuids(fileName, ref language, ref languageVendor, ref documentType);
7057  }
7058 
7063  [global::__DynamicallyInvokable]
7064  public static TryExpression TryFault(Expression body, Expression fault)
7065  {
7066  return MakeTry(null, body, null, fault, null);
7067  }
7068 
7073  [global::__DynamicallyInvokable]
7074  public static TryExpression TryFinally(Expression body, Expression @finally)
7075  {
7076  return MakeTry(null, body, @finally, null, null);
7077  }
7078 
7083  [global::__DynamicallyInvokable]
7084  public static TryExpression TryCatch(Expression body, params CatchBlock[] handlers)
7085  {
7086  return MakeTry(null, body, null, null, handlers);
7087  }
7088 
7094  [global::__DynamicallyInvokable]
7095  public static TryExpression TryCatchFinally(Expression body, Expression @finally, params CatchBlock[] handlers)
7096  {
7097  return MakeTry(null, body, @finally, null, handlers);
7098  }
7099 
7107  [global::__DynamicallyInvokable]
7108  public static TryExpression MakeTry(Type type, Expression body, Expression @finally, Expression fault, IEnumerable<CatchBlock> handlers)
7109  {
7110  RequiresCanRead(body, "body");
7111  ReadOnlyCollection<CatchBlock> readOnlyCollection = handlers.ToReadOnly();
7112  ContractUtils.RequiresNotNullItems(readOnlyCollection, "handlers");
7113  ValidateTryAndCatchHaveSameType(type, body, readOnlyCollection);
7114  if (fault != null)
7115  {
7116  if (@finally != null || readOnlyCollection.Count > 0)
7117  {
7118  throw Error.FaultCannotHaveCatchOrFinally();
7119  }
7120  RequiresCanRead(fault, "fault");
7121  }
7122  else if (@finally != null)
7123  {
7124  RequiresCanRead(@finally, "finally");
7125  }
7126  else if (readOnlyCollection.Count == 0)
7127  {
7128  throw Error.TryMustHaveCatchFinallyOrFault();
7129  }
7130  return new TryExpression(type ?? body.Type, body, @finally, fault, readOnlyCollection);
7131  }
7132 
7133  private static void ValidateTryAndCatchHaveSameType(Type type, Expression tryBody, ReadOnlyCollection<CatchBlock> handlers)
7134  {
7135  if (type != null)
7136  {
7137  if (type != typeof(void))
7138  {
7139  if (!TypeUtils.AreReferenceAssignable(type, tryBody.Type))
7140  {
7141  throw Error.ArgumentTypesMustMatch();
7142  }
7143  foreach (CatchBlock handler in handlers)
7144  {
7145  if (!TypeUtils.AreReferenceAssignable(type, handler.Body.Type))
7146  {
7147  throw Error.ArgumentTypesMustMatch();
7148  }
7149  }
7150  }
7151  }
7152  else if (tryBody == null || tryBody.Type == typeof(void))
7153  {
7154  foreach (CatchBlock handler2 in handlers)
7155  {
7156  if (handler2.Body != null && handler2.Body.Type != typeof(void))
7157  {
7158  throw Error.BodyOfCatchMustHaveSameTypeAsBodyOfTry();
7159  }
7160  }
7161  }
7162  else
7163  {
7164  type = tryBody.Type;
7165  foreach (CatchBlock handler3 in handlers)
7166  {
7167  if (handler3.Body == null || !TypeUtils.AreEquivalent(handler3.Body.Type, type))
7168  {
7169  throw Error.BodyOfCatchMustHaveSameTypeAsBodyOfTry();
7170  }
7171  }
7172  }
7173  }
7174 
7181  [global::__DynamicallyInvokable]
7182  public static TypeBinaryExpression TypeIs(Expression expression, Type type)
7183  {
7184  RequiresCanRead(expression, "expression");
7185  ContractUtils.RequiresNotNull(type, "type");
7186  if (type.IsByRef)
7187  {
7188  throw Error.TypeMustNotBeByRef();
7189  }
7190  return new TypeBinaryExpression(expression, type, ExpressionType.TypeIs);
7191  }
7192 
7197  [global::__DynamicallyInvokable]
7198  public static TypeBinaryExpression TypeEqual(Expression expression, Type type)
7199  {
7200  RequiresCanRead(expression, "expression");
7201  ContractUtils.RequiresNotNull(type, "type");
7202  if (type.IsByRef)
7203  {
7204  throw Error.TypeMustNotBeByRef();
7205  }
7206  return new TypeBinaryExpression(expression, type, ExpressionType.TypeEqual);
7207  }
7208 
7218  [global::__DynamicallyInvokable]
7219  public static UnaryExpression MakeUnary(ExpressionType unaryType, Expression operand, Type type)
7220  {
7221  return MakeUnary(unaryType, operand, type, null);
7222  }
7223 
7234  [global::__DynamicallyInvokable]
7235  public static UnaryExpression MakeUnary(ExpressionType unaryType, Expression operand, Type type, MethodInfo method)
7236  {
7237  switch (unaryType)
7238  {
7239  case ExpressionType.Negate:
7240  return Negate(operand, method);
7241  case ExpressionType.NegateChecked:
7242  return NegateChecked(operand, method);
7243  case ExpressionType.Not:
7244  return Not(operand, method);
7245  case ExpressionType.IsFalse:
7246  return IsFalse(operand, method);
7247  case ExpressionType.IsTrue:
7248  return IsTrue(operand, method);
7249  case ExpressionType.OnesComplement:
7250  return OnesComplement(operand, method);
7251  case ExpressionType.ArrayLength:
7252  return ArrayLength(operand);
7253  case ExpressionType.Convert:
7254  return Convert(operand, type, method);
7255  case ExpressionType.ConvertChecked:
7256  return ConvertChecked(operand, type, method);
7257  case ExpressionType.Throw:
7258  return Throw(operand, type);
7259  case ExpressionType.TypeAs:
7260  return TypeAs(operand, type);
7261  case ExpressionType.Quote:
7262  return Quote(operand);
7263  case ExpressionType.UnaryPlus:
7264  return UnaryPlus(operand, method);
7265  case ExpressionType.Unbox:
7266  return Unbox(operand, type);
7267  case ExpressionType.Increment:
7268  return Increment(operand, method);
7269  case ExpressionType.Decrement:
7270  return Decrement(operand, method);
7271  case ExpressionType.PreIncrementAssign:
7272  return PreIncrementAssign(operand, method);
7273  case ExpressionType.PostIncrementAssign:
7274  return PostIncrementAssign(operand, method);
7275  case ExpressionType.PreDecrementAssign:
7276  return PreDecrementAssign(operand, method);
7277  case ExpressionType.PostDecrementAssign:
7278  return PostDecrementAssign(operand, method);
7279  default:
7280  throw Error.UnhandledUnary(unaryType);
7281  }
7282  }
7283 
7284  private static UnaryExpression GetUserDefinedUnaryOperatorOrThrow(ExpressionType unaryType, string name, Expression operand)
7285  {
7286  UnaryExpression userDefinedUnaryOperator = GetUserDefinedUnaryOperator(unaryType, name, operand);
7287  if (userDefinedUnaryOperator != null)
7288  {
7289  ValidateParamswithOperandsOrThrow(userDefinedUnaryOperator.Method.GetParametersCached()[0].ParameterType, operand.Type, unaryType, name);
7290  return userDefinedUnaryOperator;
7291  }
7292  throw Error.UnaryOperatorNotDefined(unaryType, operand.Type);
7293  }
7294 
7295  private static UnaryExpression GetUserDefinedUnaryOperator(ExpressionType unaryType, string name, Expression operand)
7296  {
7297  Type type = operand.Type;
7298  Type[] array = new Type[1]
7299  {
7300  type
7301  };
7302  Type nonNullableType = type.GetNonNullableType();
7303  BindingFlags bindingAttr = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
7304  MethodInfo methodValidated = nonNullableType.GetMethodValidated(name, bindingAttr, null, array, null);
7305  if (methodValidated != null)
7306  {
7307  return new UnaryExpression(unaryType, operand, methodValidated.ReturnType, methodValidated);
7308  }
7309  if (type.IsNullableType())
7310  {
7311  array[0] = nonNullableType;
7312  methodValidated = nonNullableType.GetMethodValidated(name, bindingAttr, null, array, null);
7313  if (methodValidated != null && methodValidated.ReturnType.IsValueType && !methodValidated.ReturnType.IsNullableType())
7314  {
7315  return new UnaryExpression(unaryType, operand, TypeUtils.GetNullableType(methodValidated.ReturnType), methodValidated);
7316  }
7317  }
7318  return null;
7319  }
7320 
7321  private static UnaryExpression GetMethodBasedUnaryOperator(ExpressionType unaryType, Expression operand, MethodInfo method)
7322  {
7323  ValidateOperator(method);
7324  ParameterInfo[] parametersCached = method.GetParametersCached();
7325  if (parametersCached.Length != 1)
7326  {
7327  throw Error.IncorrectNumberOfMethodCallArguments(method);
7328  }
7329  if (ParameterIsAssignable(parametersCached[0], operand.Type))
7330  {
7331  ValidateParamswithOperandsOrThrow(parametersCached[0].ParameterType, operand.Type, unaryType, method.Name);
7332  return new UnaryExpression(unaryType, operand, method.ReturnType, method);
7333  }
7334  if (operand.Type.IsNullableType() && ParameterIsAssignable(parametersCached[0], operand.Type.GetNonNullableType()) && method.ReturnType.IsValueType && !method.ReturnType.IsNullableType())
7335  {
7336  return new UnaryExpression(unaryType, operand, TypeUtils.GetNullableType(method.ReturnType), method);
7337  }
7338  throw Error.OperandTypesDoNotMatchParameters(unaryType, method.Name);
7339  }
7340 
7341  private static UnaryExpression GetUserDefinedCoercionOrThrow(ExpressionType coercionType, Expression expression, Type convertToType)
7342  {
7343  UnaryExpression userDefinedCoercion = GetUserDefinedCoercion(coercionType, expression, convertToType);
7344  if (userDefinedCoercion != null)
7345  {
7346  return userDefinedCoercion;
7347  }
7348  throw Error.CoercionOperatorNotDefined(expression.Type, convertToType);
7349  }
7350 
7351  private static UnaryExpression GetUserDefinedCoercion(ExpressionType coercionType, Expression expression, Type convertToType)
7352  {
7353  MethodInfo userDefinedCoercionMethod = TypeUtils.GetUserDefinedCoercionMethod(expression.Type, convertToType, implicitOnly: false);
7354  if (userDefinedCoercionMethod != null)
7355  {
7356  return new UnaryExpression(coercionType, expression, convertToType, userDefinedCoercionMethod);
7357  }
7358  return null;
7359  }
7360 
7361  private static UnaryExpression GetMethodBasedCoercionOperator(ExpressionType unaryType, Expression operand, Type convertToType, MethodInfo method)
7362  {
7363  ValidateOperator(method);
7364  ParameterInfo[] parametersCached = method.GetParametersCached();
7365  if (parametersCached.Length != 1)
7366  {
7367  throw Error.IncorrectNumberOfMethodCallArguments(method);
7368  }
7369  if (ParameterIsAssignable(parametersCached[0], operand.Type) && TypeUtils.AreEquivalent(method.ReturnType, convertToType))
7370  {
7371  return new UnaryExpression(unaryType, operand, method.ReturnType, method);
7372  }
7373  if ((operand.Type.IsNullableType() || convertToType.IsNullableType()) && ParameterIsAssignable(parametersCached[0], operand.Type.GetNonNullableType()) && TypeUtils.AreEquivalent(method.ReturnType, convertToType.GetNonNullableType()))
7374  {
7375  return new UnaryExpression(unaryType, operand, convertToType, method);
7376  }
7377  throw Error.OperandTypesDoNotMatchParameters(unaryType, method.Name);
7378  }
7379 
7386  [global::__DynamicallyInvokable]
7387  public static UnaryExpression Negate(Expression expression)
7388  {
7389  return Negate(expression, null);
7390  }
7391 
7403  [global::__DynamicallyInvokable]
7404  public static UnaryExpression Negate(Expression expression, MethodInfo method)
7405  {
7406  RequiresCanRead(expression, "expression");
7407  if (method == null)
7408  {
7409  if (TypeUtils.IsArithmetic(expression.Type) && !TypeUtils.IsUnsignedInt(expression.Type))
7410  {
7411  return new UnaryExpression(ExpressionType.Negate, expression, expression.Type, null);
7412  }
7413  return GetUserDefinedUnaryOperatorOrThrow(ExpressionType.Negate, "op_UnaryNegation", expression);
7414  }
7415  return GetMethodBasedUnaryOperator(ExpressionType.Negate, expression, method);
7416  }
7417 
7424  [global::__DynamicallyInvokable]
7425  public static UnaryExpression UnaryPlus(Expression expression)
7426  {
7427  return UnaryPlus(expression, null);
7428  }
7429 
7441  [global::__DynamicallyInvokable]
7442  public static UnaryExpression UnaryPlus(Expression expression, MethodInfo method)
7443  {
7444  RequiresCanRead(expression, "expression");
7445  if (method == null)
7446  {
7447  if (TypeUtils.IsArithmetic(expression.Type))
7448  {
7449  return new UnaryExpression(ExpressionType.UnaryPlus, expression, expression.Type, null);
7450  }
7451  return GetUserDefinedUnaryOperatorOrThrow(ExpressionType.UnaryPlus, "op_UnaryPlus", expression);
7452  }
7453  return GetMethodBasedUnaryOperator(ExpressionType.UnaryPlus, expression, method);
7454  }
7455 
7462  [global::__DynamicallyInvokable]
7463  public static UnaryExpression NegateChecked(Expression expression)
7464  {
7465  return NegateChecked(expression, null);
7466  }
7467 
7479  [global::__DynamicallyInvokable]
7480  public static UnaryExpression NegateChecked(Expression expression, MethodInfo method)
7481  {
7482  RequiresCanRead(expression, "expression");
7483  if (method == null)
7484  {
7485  if (TypeUtils.IsArithmetic(expression.Type) && !TypeUtils.IsUnsignedInt(expression.Type))
7486  {
7487  return new UnaryExpression(ExpressionType.NegateChecked, expression, expression.Type, null);
7488  }
7489  return GetUserDefinedUnaryOperatorOrThrow(ExpressionType.NegateChecked, "op_UnaryNegation", expression);
7490  }
7491  return GetMethodBasedUnaryOperator(ExpressionType.NegateChecked, expression, method);
7492  }
7493 
7500  [global::__DynamicallyInvokable]
7501  public static UnaryExpression Not(Expression expression)
7502  {
7503  return Not(expression, null);
7504  }
7505 
7517  [global::__DynamicallyInvokable]
7518  public static UnaryExpression Not(Expression expression, MethodInfo method)
7519  {
7520  RequiresCanRead(expression, "expression");
7521  if (method == null)
7522  {
7523  if (TypeUtils.IsIntegerOrBool(expression.Type))
7524  {
7525  return new UnaryExpression(ExpressionType.Not, expression, expression.Type, null);
7526  }
7527  UnaryExpression userDefinedUnaryOperator = GetUserDefinedUnaryOperator(ExpressionType.Not, "op_LogicalNot", expression);
7528  if (userDefinedUnaryOperator != null)
7529  {
7530  return userDefinedUnaryOperator;
7531  }
7532  return GetUserDefinedUnaryOperatorOrThrow(ExpressionType.Not, "op_OnesComplement", expression);
7533  }
7534  return GetMethodBasedUnaryOperator(ExpressionType.Not, expression, method);
7535  }
7536 
7540  [global::__DynamicallyInvokable]
7541  public static UnaryExpression IsFalse(Expression expression)
7542  {
7543  return IsFalse(expression, null);
7544  }
7545 
7550  [global::__DynamicallyInvokable]
7551  public static UnaryExpression IsFalse(Expression expression, MethodInfo method)
7552  {
7553  RequiresCanRead(expression, "expression");
7554  if (method == null)
7555  {
7556  if (TypeUtils.IsBool(expression.Type))
7557  {
7558  return new UnaryExpression(ExpressionType.IsFalse, expression, expression.Type, null);
7559  }
7560  return GetUserDefinedUnaryOperatorOrThrow(ExpressionType.IsFalse, "op_False", expression);
7561  }
7562  return GetMethodBasedUnaryOperator(ExpressionType.IsFalse, expression, method);
7563  }
7564 
7568  [global::__DynamicallyInvokable]
7569  public static UnaryExpression IsTrue(Expression expression)
7570  {
7571  return IsTrue(expression, null);
7572  }
7573 
7578  [global::__DynamicallyInvokable]
7579  public static UnaryExpression IsTrue(Expression expression, MethodInfo method)
7580  {
7581  RequiresCanRead(expression, "expression");
7582  if (method == null)
7583  {
7584  if (TypeUtils.IsBool(expression.Type))
7585  {
7586  return new UnaryExpression(ExpressionType.IsTrue, expression, expression.Type, null);
7587  }
7588  return GetUserDefinedUnaryOperatorOrThrow(ExpressionType.IsTrue, "op_True", expression);
7589  }
7590  return GetMethodBasedUnaryOperator(ExpressionType.IsTrue, expression, method);
7591  }
7592 
7596  [global::__DynamicallyInvokable]
7597  public static UnaryExpression OnesComplement(Expression expression)
7598  {
7599  return OnesComplement(expression, null);
7600  }
7601 
7606  [global::__DynamicallyInvokable]
7607  public static UnaryExpression OnesComplement(Expression expression, MethodInfo method)
7608  {
7609  RequiresCanRead(expression, "expression");
7610  if (method == null)
7611  {
7612  if (TypeUtils.IsInteger(expression.Type))
7613  {
7614  return new UnaryExpression(ExpressionType.OnesComplement, expression, expression.Type, null);
7615  }
7616  return GetUserDefinedUnaryOperatorOrThrow(ExpressionType.OnesComplement, "op_OnesComplement", expression);
7617  }
7618  return GetMethodBasedUnaryOperator(ExpressionType.OnesComplement, expression, method);
7619  }
7620 
7627  [global::__DynamicallyInvokable]
7628  public static UnaryExpression TypeAs(Expression expression, Type type)
7629  {
7630  RequiresCanRead(expression, "expression");
7631  ContractUtils.RequiresNotNull(type, "type");
7632  TypeUtils.ValidateType(type);
7633  if (type.IsValueType && !type.IsNullableType())
7634  {
7635  throw Error.IncorrectTypeForTypeAs(type);
7636  }
7637  return new UnaryExpression(ExpressionType.TypeAs, expression, type, null);
7638  }
7639 
7644  [global::__DynamicallyInvokable]
7645  public static UnaryExpression Unbox(Expression expression, Type type)
7646  {
7647  RequiresCanRead(expression, "expression");
7648  ContractUtils.RequiresNotNull(type, "type");
7649  if (!expression.Type.IsInterface && expression.Type != typeof(object))
7650  {
7651  throw Error.InvalidUnboxType();
7652  }
7653  if (!type.IsValueType)
7654  {
7655  throw Error.InvalidUnboxType();
7656  }
7657  TypeUtils.ValidateType(type);
7658  return new UnaryExpression(ExpressionType.Unbox, expression, type, null);
7659  }
7660 
7668  [global::__DynamicallyInvokable]
7669  public static UnaryExpression Convert(Expression expression, Type type)
7670  {
7671  return Convert(expression, type, null);
7672  }
7673 
7687  [global::__DynamicallyInvokable]
7688  public static UnaryExpression Convert(Expression expression, Type type, MethodInfo method)
7689  {
7690  RequiresCanRead(expression, "expression");
7691  ContractUtils.RequiresNotNull(type, "type");
7692  TypeUtils.ValidateType(type);
7693  if (method == null)
7694  {
7695  if (TypeUtils.HasIdentityPrimitiveOrNullableConversion(expression.Type, type) || TypeUtils.HasReferenceConversion(expression.Type, type))
7696  {
7697  return new UnaryExpression(ExpressionType.Convert, expression, type, null);
7698  }
7699  return GetUserDefinedCoercionOrThrow(ExpressionType.Convert, expression, type);
7700  }
7701  return GetMethodBasedCoercionOperator(ExpressionType.Convert, expression, type, method);
7702  }
7703 
7711  [global::__DynamicallyInvokable]
7712  public static UnaryExpression ConvertChecked(Expression expression, Type type)
7713  {
7714  return ConvertChecked(expression, type, null);
7715  }
7716 
7730  [global::__DynamicallyInvokable]
7731  public static UnaryExpression ConvertChecked(Expression expression, Type type, MethodInfo method)
7732  {
7733  RequiresCanRead(expression, "expression");
7734  ContractUtils.RequiresNotNull(type, "type");
7735  TypeUtils.ValidateType(type);
7736  if (method == null)
7737  {
7738  if (TypeUtils.HasIdentityPrimitiveOrNullableConversion(expression.Type, type))
7739  {
7740  return new UnaryExpression(ExpressionType.ConvertChecked, expression, type, null);
7741  }
7742  if (TypeUtils.HasReferenceConversion(expression.Type, type))
7743  {
7744  return new UnaryExpression(ExpressionType.Convert, expression, type, null);
7745  }
7746  return GetUserDefinedCoercionOrThrow(ExpressionType.ConvertChecked, expression, type);
7747  }
7748  return GetMethodBasedCoercionOperator(ExpressionType.ConvertChecked, expression, type, method);
7749  }
7750 
7758  [global::__DynamicallyInvokable]
7760  {
7761  ContractUtils.RequiresNotNull(array, "array");
7762  if (!array.Type.IsArray || !typeof(Array).IsAssignableFrom(array.Type))
7763  {
7764  throw Error.ArgumentMustBeArray();
7765  }
7766  if (array.Type.GetArrayRank() != 1)
7767  {
7768  throw Error.ArgumentMustBeSingleDimensionalArrayType();
7769  }
7770  return new UnaryExpression(ExpressionType.ArrayLength, array, typeof(int), null);
7771  }
7772 
7778  [global::__DynamicallyInvokable]
7779  public static UnaryExpression Quote(Expression expression)
7780  {
7781  RequiresCanRead(expression, "expression");
7782  if (!(expression is LambdaExpression))
7783  {
7784  throw Error.QuotedExpressionMustBeLambda();
7785  }
7786  return new UnaryExpression(ExpressionType.Quote, expression, expression.GetType(), null);
7787  }
7788 
7791  [global::__DynamicallyInvokable]
7792  public static UnaryExpression Rethrow()
7793  {
7794  return Throw(null);
7795  }
7796 
7800  [global::__DynamicallyInvokable]
7801  public static UnaryExpression Rethrow(Type type)
7802  {
7803  return Throw(null, type);
7804  }
7805 
7809  [global::__DynamicallyInvokable]
7810  public static UnaryExpression Throw(Expression value)
7811  {
7812  return Throw(value, typeof(void));
7813  }
7814 
7819  [global::__DynamicallyInvokable]
7820  public static UnaryExpression Throw(Expression value, Type type)
7821  {
7822  ContractUtils.RequiresNotNull(type, "type");
7823  TypeUtils.ValidateType(type);
7824  if (value != null)
7825  {
7826  RequiresCanRead(value, "value");
7827  if (value.Type.IsValueType)
7828  {
7829  throw Error.ArgumentMustNotHaveValueType();
7830  }
7831  }
7832  return new UnaryExpression(ExpressionType.Throw, value, type, null);
7833  }
7834 
7838  [global::__DynamicallyInvokable]
7839  public static UnaryExpression Increment(Expression expression)
7840  {
7841  return Increment(expression, null);
7842  }
7843 
7848  [global::__DynamicallyInvokable]
7849  public static UnaryExpression Increment(Expression expression, MethodInfo method)
7850  {
7851  RequiresCanRead(expression, "expression");
7852  if (method == null)
7853  {
7854  if (TypeUtils.IsArithmetic(expression.Type))
7855  {
7856  return new UnaryExpression(ExpressionType.Increment, expression, expression.Type, null);
7857  }
7858  return GetUserDefinedUnaryOperatorOrThrow(ExpressionType.Increment, "op_Increment", expression);
7859  }
7860  return GetMethodBasedUnaryOperator(ExpressionType.Increment, expression, method);
7861  }
7862 
7866  [global::__DynamicallyInvokable]
7867  public static UnaryExpression Decrement(Expression expression)
7868  {
7869  return Decrement(expression, null);
7870  }
7871 
7876  [global::__DynamicallyInvokable]
7877  public static UnaryExpression Decrement(Expression expression, MethodInfo method)
7878  {
7879  RequiresCanRead(expression, "expression");
7880  if (method == null)
7881  {
7882  if (TypeUtils.IsArithmetic(expression.Type))
7883  {
7884  return new UnaryExpression(ExpressionType.Decrement, expression, expression.Type, null);
7885  }
7886  return GetUserDefinedUnaryOperatorOrThrow(ExpressionType.Decrement, "op_Decrement", expression);
7887  }
7888  return GetMethodBasedUnaryOperator(ExpressionType.Decrement, expression, method);
7889  }
7890 
7894  [global::__DynamicallyInvokable]
7896  {
7897  return MakeOpAssignUnary(ExpressionType.PreIncrementAssign, expression, null);
7898  }
7899 
7904  [global::__DynamicallyInvokable]
7905  public static UnaryExpression PreIncrementAssign(Expression expression, MethodInfo method)
7906  {
7907  return MakeOpAssignUnary(ExpressionType.PreIncrementAssign, expression, method);
7908  }
7909 
7913  [global::__DynamicallyInvokable]
7915  {
7916  return MakeOpAssignUnary(ExpressionType.PreDecrementAssign, expression, null);
7917  }
7918 
7923  [global::__DynamicallyInvokable]
7924  public static UnaryExpression PreDecrementAssign(Expression expression, MethodInfo method)
7925  {
7926  return MakeOpAssignUnary(ExpressionType.PreDecrementAssign, expression, method);
7927  }
7928 
7932  [global::__DynamicallyInvokable]
7934  {
7935  return MakeOpAssignUnary(ExpressionType.PostIncrementAssign, expression, null);
7936  }
7937 
7942  [global::__DynamicallyInvokable]
7943  public static UnaryExpression PostIncrementAssign(Expression expression, MethodInfo method)
7944  {
7945  return MakeOpAssignUnary(ExpressionType.PostIncrementAssign, expression, method);
7946  }
7947 
7951  [global::__DynamicallyInvokable]
7953  {
7954  return MakeOpAssignUnary(ExpressionType.PostDecrementAssign, expression, null);
7955  }
7956 
7961  [global::__DynamicallyInvokable]
7962  public static UnaryExpression PostDecrementAssign(Expression expression, MethodInfo method)
7963  {
7964  return MakeOpAssignUnary(ExpressionType.PostDecrementAssign, expression, method);
7965  }
7966 
7967  private static UnaryExpression MakeOpAssignUnary(ExpressionType kind, Expression expression, MethodInfo method)
7968  {
7969  RequiresCanRead(expression, "expression");
7970  RequiresCanWrite(expression, "expression");
7971  UnaryExpression unaryExpression;
7972  if (method == null)
7973  {
7974  if (TypeUtils.IsArithmetic(expression.Type))
7975  {
7976  return new UnaryExpression(kind, expression, expression.Type, null);
7977  }
7978  string name = (kind != ExpressionType.PreIncrementAssign && kind != ExpressionType.PostIncrementAssign) ? "op_Decrement" : "op_Increment";
7979  unaryExpression = GetUserDefinedUnaryOperatorOrThrow(kind, name, expression);
7980  }
7981  else
7982  {
7983  unaryExpression = GetMethodBasedUnaryOperator(kind, expression, method);
7984  }
7985  if (!TypeUtils.AreReferenceAssignable(expression.Type, unaryExpression.Type))
7986  {
7987  throw Error.UserDefinedOpMustHaveValidReturnType(kind, method.Name);
7988  }
7989  return unaryExpression;
7990  }
7991  }
7994  [global::__DynamicallyInvokable]
7995  public sealed class Expression<TDelegate> : LambdaExpression
7996  {
7997  internal Expression(Expression body, string name, bool tailCall, ReadOnlyCollection<ParameterExpression> parameters)
7998  : base(typeof(TDelegate), name, body, tailCall, parameters)
7999  {
8000  }
8001 
8004  [global::__DynamicallyInvokable]
8005  public new TDelegate Compile()
8006  {
8007  return (TDelegate)(object)LambdaCompiler.Compile(this, null);
8008  }
8009 
8013  public new TDelegate Compile(DebugInfoGenerator debugInfoGenerator)
8014  {
8015  ContractUtils.RequiresNotNull(debugInfoGenerator, "debugInfoGenerator");
8016  return (TDelegate)(object)LambdaCompiler.Compile(this, debugInfoGenerator);
8017  }
8018 
8023  public new TDelegate Compile(bool preferInterpretation)
8024  {
8025  return Compile();
8026  }
8027 
8032  [global::__DynamicallyInvokable]
8034  {
8035  if (body == base.Body && parameters == base.Parameters)
8036  {
8037  return this;
8038  }
8039  return Expression.Lambda<TDelegate>(body, base.Name, base.TailCall, parameters);
8040  }
8041 
8042  protected internal override Expression Accept(ExpressionVisitor visitor)
8043  {
8044  return visitor.VisitLambda(this);
8045  }
8046 
8047  internal override LambdaExpression Accept(StackSpiller spiller)
8048  {
8049  return spiller.Rewrite(this);
8050  }
8051 
8052  internal static LambdaExpression Create(Expression body, string name, bool tailCall, ReadOnlyCollection<ParameterExpression> parameters)
8053  {
8054  return new Expression<TDelegate>(body, name, tailCall, parameters);
8055  }
8056  }
8057 }
Obtains information about the attributes of a member and provides access to member metadata.
Definition: MemberInfo.cs:14
sealed override Type Type
Gets the static type of the expression that this T:System.Linq.Expressions.Expression represents.
Represents an expression that has a constant value.
static BinaryExpression SubtractAssign(Expression left, Expression right, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a subtraction assignment operati...
Definition: Expression.cs:1882
static BinaryExpression LeftShift(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a bitwise left-shift operation.
Definition: Expression.cs:2380
static BinaryExpression Coalesce(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a coalescing operation.
Definition: Expression.cs:1557
Discovers the attributes of a parameter and provides access to parameter metadata.
static Type GetDelegateType(params Type[] typeArgs)
Gets a P:System.Linq.Expressions.Expression.Type object that represents a generic System....
Definition: Expression.cs:5099
abstract FieldInfo GetField(string name, BindingFlags bindingAttr)
Searches for the specified field, using the specified binding constraints.
static IndexExpression MakeIndex(Expression instance, PropertyInfo indexer, IEnumerable< Expression > arguments)
Creates an T:System.Linq.Expressions.IndexExpression that represents accessing an indexed property in...
Definition: Expression.cs:4187
static BinaryExpression ArrayIndex(Expression array, Expression index)
Creates a T:System.Linq.Expressions.BinaryExpression that represents applying an array index operator...
Definition: Expression.cs:2915
static BinaryExpression MultiplyAssignChecked(Expression left, Expression right, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a multiplication assignment oper...
Definition: Expression.cs:2282
static MethodCallExpression Call(Type type, string methodName, Type[] typeArguments, params Expression[] arguments)
Creates a T:System.Linq.Expressions.MethodCallExpression that represents a call to a static (Shared i...
Definition: Expression.cs:6088
static ListInitExpression ListInit(NewExpression newExpression, params ElementInit[] initializers)
Creates a T:System.Linq.Expressions.ListInitExpression that uses specified T:System....
Definition: Expression.cs:5218
A bitwise or logical OR operation, such as (a | b) in C# or (a Or b) in Visual Basic.
static SwitchExpression Switch(Expression switchValue, Expression defaultBody, MethodInfo comparison, IEnumerable< SwitchCase > cases)
Creates a T:System.Linq.Expressions.SwitchExpression that represents a switch statement that has a de...
Definition: Expression.cs:6901
static UnaryExpression Increment(Expression expression, MethodInfo method)
Creates a T:System.Linq.Expressions.UnaryExpression that represents the incrementing of the expressio...
Definition: Expression.cs:7849
A unary prefix decrement, such as (–a). The object a should be modified in place.
static UnaryExpression ArrayLength(Expression array)
Creates a T:System.Linq.Expressions.UnaryExpression that represents an expression for obtaining the l...
Definition: Expression.cs:7759
static LabelTarget Label()
Creates a T:System.Linq.Expressions.LabelTarget representing a label with void type and no name.
Definition: Expression.cs:4612
static BinaryExpression Modulo(Expression left, Expression right, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression that represents an arithmetic remainder operatio...
Definition: Expression.cs:2115
static ParameterExpression Variable(Type type)
Creates a T:System.Linq.Expressions.ParameterExpression node that can be used to identify a parameter...
Definition: Expression.cs:6750
bool IsLiteral
Gets a value indicating whether the value is written at compile time and cannot be changed.
Definition: FieldInfo.cs:157
Emits or clears a sequence point for debug information. This allows the debugger to highlight the cor...
static MethodCallExpression Call(MethodInfo method, Expression arg0, Expression arg1)
Creates a T:System.Linq.Expressions.MethodCallExpression that represents a call to a static method th...
Definition: Expression.cs:5862
static BinaryExpression GreaterThan(Expression left, Expression right, bool liftToNull, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a "greater than" numeric compari...
Definition: Expression.cs:1291
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
static BinaryExpression DivideAssign(Expression left, Expression right, MethodInfo method, LambdaExpression conversion)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a division assignment operation ...
Definition: Expression.cs:2070
static BinaryExpression LeftShiftAssign(Expression left, Expression right, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a bitwise left-shift assignment ...
Definition: Expression.cs:2429
static BinaryExpression NotEqual(Expression left, Expression right, bool liftToNull, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression that represents an inequality comparison.
Definition: Expression.cs:1211
An addition compound assignment operation, such as (a += b), with overflow checking,...
An operation that creates a new T:System.Collections.IEnumerable object and initializes it from a lis...
A short-circuiting conditional OR operation, such as (a || b) in C# or (a OrElse b) in Visual Basic.
static LambdaExpression Lambda(Type delegateType, Expression body, params ParameterExpression[] parameters)
Creates a T:System.Linq.Expressions.LambdaExpression by first constructing a delegate type....
Definition: Expression.cs:4819
A multiplication compound assignment operation, such as (a *= b), that has overflow checking,...
static BlockExpression Block(IEnumerable< ParameterExpression > variables, params Expression[] expressions)
Creates a T:System.Linq.Expressions.BlockExpression that contains the given variables and expressions...
Definition: Expression.cs:3054
static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, IEnumerable< Expression > arguments)
Creates a T:System.Linq.Expressions.DynamicExpression that represents a dynamic operation bound by th...
Definition: Expression.cs:3425
static BinaryExpression Equal(Expression left, Expression right, bool liftToNull, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression that represents an equality comparison....
Definition: Expression.cs:1157
override Type Type
Gets the static type of the expression that this T:System.Linq.Expressions.Expression represents.
A conditional AND operation that evaluates the second operand only if the first operand evaluates to ...
bool IsStatic
Gets a value indicating whether the field is static.
Definition: FieldInfo.cs:131
An explicit reference or boxing conversion in which null is supplied if the conversion fails,...
abstract Type FieldType
Gets the type of this field object.
Definition: FieldInfo.cs:34
Represents an infinite loop. It can be exited with "break".
static BinaryExpression MultiplyAssign(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a multiplication assignment oper...
Definition: Expression.cs:2223
static ListInitExpression ListInit(NewExpression newExpression, MethodInfo addMethod, params Expression[] initializers)
Creates a T:System.Linq.Expressions.ListInitExpression that uses a specified method to add elements t...
Definition: Expression.cs:5163
An division compound assignment operation, such as (a /= b), for numeric operands.
void Add(TKey key, TValue value)
Adds a key to the table.
static UnaryExpression PreIncrementAssign(Expression expression, MethodInfo method)
Creates a T:System.Linq.Expressions.UnaryExpression that increments the expression by 1 and assigns t...
Definition: Expression.cs:7905
abstract Type GetElementType()
When overridden in a derived class, returns the T:System.Type of the object encompassed or referred t...
static MethodCallExpression Call(MethodInfo method, params Expression[] arguments)
Creates a T:System.Linq.Expressions.MethodCallExpression that represents a call to a static (Shared i...
Definition: Expression.cs:5960
static MethodCallExpression Call(Expression instance, MethodInfo method, Expression arg0, Expression arg1, Expression arg2)
Creates a T:System.Linq.Expressions.MethodCallExpression that represents a call to a method that take...
Definition: Expression.cs:6038
static CatchBlock Catch(ParameterExpression variable, Expression body, Expression filter)
Creates a T:System.Linq.Expressions.CatchBlock representing a catch statement with an T:System....
Definition: Expression.cs:3193
A subtraction compound assignment operation, such as (a -= b), that has overflow checking,...
Represents accessing a field or property.
static BinaryExpression Modulo(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents an arithmetic remainder operatio...
Definition: Expression.cs:2098
static UnaryExpression Convert(Expression expression, Type type)
Creates a T:System.Linq.Expressions.UnaryExpression that represents a type conversion operation.
Definition: Expression.cs:7669
override bool Equals(object o)
Determines if the underlying system type of the current T:System.Type object is the same as the under...
Definition: Type.cs:2824
abstract Type DeclaringType
Gets the class that declares this member.
Definition: MemberInfo.cs:36
static BinaryExpression GreaterThanOrEqual(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a "greater than or equal" numeri...
Definition: Expression.cs:1348
unsafe override string ToString()
Converts the value of this instance to a T:System.String.
static MemberInitExpression MemberInit(NewExpression newExpression, IEnumerable< MemberBinding > bindings)
Represents an expression that creates a new object and initializes a property of the object.
Definition: Expression.cs:5636
static GotoExpression Return(LabelTarget target, Expression value, Type type)
Creates a T:System.Linq.Expressions.GotoExpression representing a return statement with the specified...
Definition: Expression.cs:4098
abstract MethodInfo GetGetMethod(bool nonPublic)
When overridden in a derived class, returns the public or non-public get accessor for this property.
static LambdaExpression Lambda(Expression body, bool tailCall, IEnumerable< ParameterExpression > parameters)
Creates a LambdaExpression by first constructing a delegate type.
Definition: Expression.cs:4802
static BinaryExpression OrAssign(Expression left, Expression right, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a bitwise OR assignment operatio...
Definition: Expression.cs:2696
Stores information necessary to emit debugging symbol information for a source file,...
A unary decrement operation, such as (a - 1) in C# and Visual Basic. The object a should not be modif...
static BinaryExpression RightShiftAssign(Expression left, Expression right, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a bitwise right-shift assignment...
Definition: Expression.cs:2519
A list of run-time variables. For more information, see T:System.Linq.Expressions....
Discovers the attributes of a method and provides access to method metadata.
Definition: MethodInfo.cs:13
Type Type
The type of value that is passed when jumping to the label (or T:System.Void if no value should be pa...
Definition: LabelTarget.cs:27
Implements a T:System.IO.TextWriter for writing information to a string. The information is stored in...
Definition: StringWriter.cs:13
static DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, Expression arg0, Expression arg1)
Creates a T:System.Linq.Expressions.DynamicExpression that represents a dynamic operation bound by th...
Definition: Expression.cs:3593
Represents a constructor call.
static UnaryExpression Negate(Expression expression)
Creates a T:System.Linq.Expressions.UnaryExpression that represents an arithmetic negation operation.
Definition: Expression.cs:7387
StringComparison
Specifies the culture, case, and sort rules to be used by certain overloads of the M:System....
static BinaryExpression SubtractAssignChecked(Expression left, Expression right, MethodInfo method, LambdaExpression conversion)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a subtraction assignment operati...
Definition: Expression.cs:1942
static BinaryExpression RightShiftAssign(Expression left, Expression right, MethodInfo method, LambdaExpression conversion)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a bitwise right-shift assignment...
Definition: Expression.cs:2531
Represents creating a new array and possibly initializing the elements of the new array.
static DefaultExpression Empty()
Creates an empty expression that has T:System.Void type.
Definition: Expression.cs:3390
A bitwise or logical AND compound assignment operation, such as (a &= b) in C#.
static BinaryExpression AddChecked(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents an arithmetic addition operation...
Definition: Expression.cs:1794
virtual internal Expression VisitChildren(ExpressionVisitor visitor)
Reduces the node and then calls the visitor delegate on the reduced expression. The method throws an ...
Definition: Expression.cs:3810
Represents calling a constructor and initializing one or more members of the new object.
static UnaryExpression IsTrue(Expression expression, MethodInfo method)
Returns whether the expression evaluates to true.
Definition: Expression.cs:7579
static MethodCallExpression Call(Expression instance, MethodInfo method, params Expression[] arguments)
Creates a T:System.Linq.Expressions.MethodCallExpression that represents a call to a method that take...
Definition: Expression.cs:6002
virtual bool ContainsGenericParameters
Gets a value indicating whether the generic method contains unassigned generic type parameters.
Definition: MethodBase.cs:90
static BlockExpression Block(Type type, IEnumerable< ParameterExpression > variables, params Expression[] expressions)
Creates a T:System.Linq.Expressions.BlockExpression that contains the given variables and expressions...
Definition: Expression.cs:3065
static BinaryExpression PowerAssign(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents raising an expression to a power...
Definition: Expression.cs:2864
Expression()
Constructs a new instance of T:System.Linq.Expressions.Expression.
Definition: Expression.cs:3790
static MemberExpression Property(Expression expression, Type type, string propertyName)
Creates a T:System.Linq.Expressions.MemberExpression accessing a property.
Definition: Expression.cs:5450
static BinaryExpression LeftShift(Expression left, Expression right, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a bitwise left-shift operation.
Definition: Expression.cs:2397
A unary postfix increment, such as (a++). The object a should be modified in place.
static UnaryExpression PostDecrementAssign(Expression expression)
Creates a T:System.Linq.Expressions.UnaryExpression that represents the assignment of the expression ...
Definition: Expression.cs:7952
Discovers the attributes of a class constructor and provides access to constructor metadata.
static ConditionalExpression IfThenElse(Expression test, Expression ifTrue, Expression ifFalse)
Creates a T:System.Linq.Expressions.ConditionalExpression that represents a conditional block with if...
Definition: Expression.cs:3293
Represents a multicast delegate; that is, a delegate that can have more than one element in its invoc...
static BinaryExpression NotEqual(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents an inequality comparison.
Definition: Expression.cs:1192
static BinaryExpression PowerAssign(Expression left, Expression right, MethodInfo method, LambdaExpression conversion)
Creates a T:System.Linq.Expressions.BinaryExpression that represents raising an expression to a power...
Definition: Expression.cs:2887
static TryExpression TryFinally(Expression body, Expression @finally)
Creates a T:System.Linq.Expressions.TryExpression representing a try block with a finally block and n...
Definition: Expression.cs:7074
Supports all classes in the .NET Framework class hierarchy and provides low-level services to derived...
Definition: Object.cs:18
static GotoExpression Goto(LabelTarget target, Expression value, Type type)
Creates a T:System.Linq.Expressions.GotoExpression representing a "go to" statement with the specifie...
Definition: Expression.cs:4138
static LambdaExpression Lambda(Type delegateType, Expression body, bool tailCall, IEnumerable< ParameterExpression > parameters)
Creates a LambdaExpression by first constructing a delegate type.
Definition: Expression.cs:4860
Discovers the attributes of a field and provides access to field metadata.
Definition: FieldInfo.cs:15
Represents a block that contains a sequence of expressions where variables can be defined.
abstract PropertyInfo [] GetProperties(BindingFlags bindingAttr)
When overridden in a derived class, searches for the properties of the current T:System....
static MemberInitExpression MemberInit(NewExpression newExpression, params MemberBinding[] bindings)
Creates a T:System.Linq.Expressions.MemberInitExpression.
Definition: Expression.cs:5623
A unary prefix increment, such as (++a). The object a should be modified in place.
BindingFlags
Specifies flags that control binding and the way in which the search for members and types is conduct...
Definition: BindingFlags.cs:10
static GotoExpression Goto(LabelTarget target, Expression value)
Creates a T:System.Linq.Expressions.GotoExpression representing a "go to" statement....
Definition: Expression.cs:4127
static BinaryExpression LessThanOrEqual(Expression left, Expression right, bool liftToNull, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a "less than or equal" numeric c...
Definition: Expression.cs:1405
Definition: __Canon.cs:3
static BinaryExpression AddAssignChecked(Expression left, Expression right, MethodInfo method, LambdaExpression conversion)
Creates a T:System.Linq.Expressions.BinaryExpression that represents an addition assignment operation...
Definition: Expression.cs:1766
static LambdaExpression Lambda(Type delegateType, Expression body, string name, IEnumerable< ParameterExpression > parameters)
Creates a LambdaExpression by first constructing a delegate type.
Definition: Expression.cs:4916
virtual Type ReturnType
Gets the return type of this method.
Definition: MethodInfo.cs:23
static BinaryExpression OrElse(Expression left, Expression right, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a conditional OR operation that ...
Definition: Expression.cs:1515
static UnaryExpression Negate(Expression expression, MethodInfo method)
Creates a T:System.Linq.Expressions.UnaryExpression that represents an arithmetic negation operation.
Definition: Expression.cs:7404
static MethodCallExpression Call(MethodInfo method, IEnumerable< Expression > arguments)
Creates a T:System.Linq.Expressions.MethodCallExpression that represents a call to a static (Shared i...
Definition: Expression.cs:5970
static BinaryExpression Power(Expression left, Expression right, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression that represents raising a number to a power.
Definition: Expression.cs:2843
virtual MethodInfo MakeGenericMethod(params Type[] typeArguments)
Substitutes the elements of an array of types for the type parameters of the current generic method d...
Definition: MethodInfo.cs:134
static MemberExpression Property(Expression expression, string propertyName)
Creates a T:System.Linq.Expressions.MemberExpression that represents accessing a property.
Definition: Expression.cs:5428
static BinaryExpression Subtract(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents an arithmetic subtraction operat...
Definition: Expression.cs:1834
static BinaryExpression Coalesce(Expression left, Expression right, LambdaExpression conversion)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a coalescing operation,...
Definition: Expression.cs:1574
virtual internal Expression Accept(ExpressionVisitor visitor)
Dispatches to the specific visit method for this node type. For example, T:System....
Definition: Expression.cs:3823
static ConditionalExpression IfThen(Expression test, Expression ifTrue)
Creates a T:System.Linq.Expressions.ConditionalExpression that represents a conditional block with an...
Definition: Expression.cs:3282
static UnaryExpression IsFalse(Expression expression)
Returns whether the expression evaluates to false.
Definition: Expression.cs:7541
An arithmetic remainder compound assignment operation, such as (a %= b) in C#.
bool IsInitOnly
Gets a value indicating whether the field can only be set in the body of the constructor.
Definition: FieldInfo.cs:144
static GotoExpression Break(LabelTarget target, Expression value)
Creates a T:System.Linq.Expressions.GotoExpression representing a break statement....
Definition: Expression.cs:4018
Represents initializing the elements of a collection member of a newly created object.
Represents a label, which can be put in any T:System.Linq.Expressions.Expression context....
A "greater than or equal to" comparison, such as (a >= b).
Represents an expression that applies a delegate or lambda expression to a list of argument expressio...
A dynamic call site base class. This type is used as a parameter type to the dynamic site targets.
Definition: CallSite.cs:13
An unbox value type operation, such as unbox and unbox.any instructions in MSIL.
An arithmetic subtraction operation, such as (a - b), that has overflow checking, for numeric operand...
static BlockExpression Block(Type type, params Expression[] expressions)
Creates a T:System.Linq.Expressions.BlockExpression that contains the given expressions,...
Definition: Expression.cs:3033
A multiplication compound assignment operation, such as (a *= b), without overflow checking,...
A reference to a parameter or variable that is defined in the context of the expression....
int Count
Gets the number of elements contained in the T:System.Collections.ObjectModel.ReadOnlyCollection`1 in...
static SwitchExpression Switch(Expression switchValue, Expression defaultBody, params SwitchCase[] cases)
Creates a T:System.Linq.Expressions.SwitchExpression that represents a switch statement that has a de...
Definition: Expression.cs:6864
static LabelExpression Label(LabelTarget target, Expression defaultValue)
Creates a T:System.Linq.Expressions.LabelExpression representing a label with the given default value...
Definition: Expression.cs:4603
static InvocationExpression Invoke(Expression expression, IEnumerable< Expression > arguments)
Creates an T:System.Linq.Expressions.InvocationExpression that applies a delegate or lambda expressio...
Definition: Expression.cs:4565
static UnaryExpression PostIncrementAssign(Expression expression)
Creates a T:System.Linq.Expressions.UnaryExpression that represents the assignment of the expression ...
Definition: Expression.cs:7933
Generates debug information for lambda expressions in an expression tree.
static LambdaExpression Lambda(Expression body, IEnumerable< ParameterExpression > parameters)
Creates a LambdaExpression by first constructing a delegate type.
Definition: Expression.cs:4791
static BinaryExpression MultiplyChecked(Expression left, Expression right, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression that represents an arithmetic multiplication ope...
Definition: Expression.cs:2339
ConstructorInfo GetConstructor(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
Searches for a constructor whose parameters match the specified argument types and modifiers,...
Definition: Type.cs:1378
static UnaryExpression Decrement(Expression expression, MethodInfo method)
Creates a T:System.Linq.Expressions.UnaryExpression that represents the decrementing of the expressio...
Definition: Expression.cs:7877
static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1, Expression arg2, Expression arg3)
Creates a T:System.Linq.Expressions.DynamicExpression that represents a dynamic operation bound by th...
Definition: Expression.cs:3523
static BinaryExpression Subtract(Expression left, Expression right, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression that represents an arithmetic subtraction operat...
Definition: Expression.cs:1851
static UnaryExpression Not(Expression expression)
Creates a T:System.Linq.Expressions.UnaryExpression that represents a bitwise complement operation.
Definition: Expression.cs:7501
Represents a value type that can be assigned null.
Definition: Nullable.cs:12
A mathematical operation that raises a number to a power, such as (a ^ b) in Visual Basic.
static BinaryExpression LessThan(Expression left, Expression right, bool liftToNull, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a "less than" numeric comparison...
Definition: Expression.cs:1329
static NewExpression New(ConstructorInfo constructor, IEnumerable< Expression > arguments, params MemberInfo[] members)
Creates a T:System.Linq.Expressions.NewExpression that represents calling the specified constructor w...
Definition: Expression.cs:6574
static ListInitExpression ListInit(NewExpression newExpression, MethodInfo addMethod, IEnumerable< Expression > initializers)
Creates a T:System.Linq.Expressions.ListInitExpression that uses a specified method to add elements t...
Definition: Expression.cs:5188
A loop, such as for or while.
Used to represent the target of a T:System.Linq.Expressions.GotoExpression.
Definition: LabelTarget.cs:5
static BinaryExpression ModuloAssign(Expression left, Expression right, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a remainder assignment operation...
Definition: Expression.cs:2146
static GotoExpression Return(LabelTarget target)
Creates a T:System.Linq.Expressions.GotoExpression representing a return statement.
Definition: Expression.cs:4067
static BinaryExpression Multiply(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents an arithmetic multiplication ope...
Definition: Expression.cs:2186
static BinaryExpression RightShiftAssign(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a bitwise right-shift assignment...
Definition: Expression.cs:2508
static LambdaExpression Lambda(Type delegateType, Expression body, string name, bool tailCall, IEnumerable< ParameterExpression > parameters)
Creates a LambdaExpression by first constructing a delegate type.
Definition: Expression.cs:4931
A method call, such as in the obj.sampleMethod() expression.
Expression ReduceExtensions()
Reduces the expression to a known node type (that is not an Extension node) or just returns the expre...
Definition: Expression.cs:3852
static DebugInfoExpression ClearDebugInfo(SymbolDocumentInfo document)
Creates a T:System.Linq.Expressions.DebugInfoExpression for clearing a sequence point.
Definition: Expression.cs:3353
static BinaryExpression AddAssign(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents an addition assignment operation...
Definition: Expression.cs:1676
static LambdaExpression Lambda(Expression body, params ParameterExpression[] parameters)
Creates a T:System.Linq.Expressions.LambdaExpression by first constructing a delegate type.
Definition: Expression.cs:4770
sealed override Type Type
Gets the static type of the expression that this T:System.Linq.Expressions.Expression represents.
static ElementInit ElementInit(MethodInfo addMethod, params Expression[] arguments)
Creates an T:System.Linq.Expressions.ElementInit, given an array of values as the second argument.
Definition: Expression.cs:3714
A bitwise left-shift operation, such as (a << b).
static BinaryExpression LessThan(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a "less than" numeric comparison...
Definition: Expression.cs:1310
static UnaryExpression OnesComplement(Expression expression, MethodInfo method)
Returns the expression representing the ones complement.
Definition: Expression.cs:7607
static BinaryExpression MultiplyAssignChecked(Expression left, Expression right, MethodInfo method, LambdaExpression conversion)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a multiplication assignment oper...
Definition: Expression.cs:2294
An indexing operation in a one-dimensional array, such as array[index] in C# or array(index) in Visua...
bool IsStatic
Gets a value indicating whether the method is static.
Definition: MethodBase.cs:227
static BinaryExpression ExclusiveOr(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a bitwise XOR operation,...
Definition: Expression.cs:2736
static BlockExpression Block(Expression arg0, Expression arg1, Expression arg2)
Creates a T:System.Linq.Expressions.BlockExpression that contains three expressions and has no variab...
Definition: Expression.cs:2953
A ones complement operation, such as (~a) in C#.
static BinaryExpression MultiplyChecked(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents an arithmetic multiplication ope...
Definition: Expression.cs:2322
An arithmetic negation operation, such as (-a), that has overflow checking. The object a should not b...
PropertyInfo GetProperty(string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers)
Searches for the specified property whose parameters match the specified argument types and modifiers...
Definition: Type.cs:1827
static MethodCallExpression Call(MethodInfo method, Expression arg0)
Creates a T:System.Linq.Expressions.MethodCallExpression that represents a call to a static (Shared i...
Definition: Expression.cs:5844
A compound assignment operation that raises a number to a power, such as (a ^= b) in Visual Basic.
static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, Expression arg0)
Creates a T:System.Linq.Expressions.DynamicExpression that represents a dynamic operation bound by th...
Definition: Expression.cs:3445
A bitwise or logical AND operation, such as (a & b) in C# and (a And b) in Visual Basic.
static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1)
Creates a T:System.Linq.Expressions.DynamicExpression that represents a dynamic operation bound by th...
Definition: Expression.cs:3468
static UnaryExpression Rethrow(Type type)
Creates a T:System.Linq.Expressions.UnaryExpression that represents a rethrowing of an exception with...
Definition: Expression.cs:7801
virtual bool IsSubclassOf(Type c)
Determines whether the current T:System.Type derives from the specified T:System.Type.
Definition: Type.cs:2664
virtual int GetArrayRank()
Gets the number of dimensions in an array.
Definition: Type.cs:1359
static MemberMemberBinding MemberBind(MethodInfo propertyAccessor, params MemberBinding[] bindings)
Creates a T:System.Linq.Expressions.MemberMemberBinding that represents the recursive initialization ...
Definition: Expression.cs:5771
static MethodCallExpression ArrayIndex(Expression array, IEnumerable< Expression > indexes)
Creates a T:System.Linq.Expressions.MethodCallExpression that represents applying an array index oper...
Definition: Expression.cs:6367
static SymbolDocumentInfo SymbolDocument(string fileName, Guid language, Guid languageVendor, Guid documentType)
Creates an instance of T:System.Linq.Expressions.SymbolDocumentInfo.
Definition: Expression.cs:7054
static Type GetActionType(params Type[] typeArgs)
Creates a T:System.Type object that represents a generic System.Action delegate type that has specifi...
Definition: Expression.cs:5066
An inequality comparison, such as (a != b) in C# or (a <> b) in Visual Basic.
bool IsByRef
Indicates that this ParameterExpression is to be treated as a ByRef parameter.
static BinaryExpression OrAssign(Expression left, Expression right, MethodInfo method, LambdaExpression conversion)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a bitwise OR assignment operatio...
Definition: Expression.cs:2708
static MethodCallExpression Call(MethodInfo method, Expression arg0, Expression arg1, Expression arg2)
Creates a T:System.Linq.Expressions.MethodCallExpression that represents a call to a static method th...
Definition: Expression.cs:5883
static SymbolDocumentInfo SymbolDocument(string fileName, Guid language, Guid languageVendor)
Creates an instance of T:System.Linq.Expressions.SymbolDocumentInfo.
Definition: Expression.cs:7042
static BinaryExpression DivideAssign(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a division assignment operation ...
Definition: Expression.cs:2047
A bitwise right-shift compound assignment operation, such as (a >>= b).
static CatchBlock Catch(Type type, Expression body)
Creates a T:System.Linq.Expressions.CatchBlock representing a catch statement.
Definition: Expression.cs:3160
static UnaryExpression PreDecrementAssign(Expression expression)
Creates a T:System.Linq.Expressions.UnaryExpression that decrements the expression by 1 and assigns t...
Definition: Expression.cs:7914
static UnaryExpression Throw(Expression value, Type type)
Creates a T:System.Linq.Expressions.UnaryExpression that represents a throwing of an exception with a...
Definition: Expression.cs:7820
virtual internal Expression VisitExtension(Expression node)
Visits the children of the extension expression.
static ParameterExpression Variable(Type type, string name)
Creates a T:System.Linq.Expressions.ParameterExpression node that can be used to identify a parameter...
Definition: Expression.cs:6782
static GotoExpression Return(LabelTarget target, Expression value)
Creates a T:System.Linq.Expressions.GotoExpression representing a return statement....
Definition: Expression.cs:4087
static UnaryExpression NegateChecked(Expression expression)
Creates a T:System.Linq.Expressions.UnaryExpression that represents an arithmetic negation operation ...
Definition: Expression.cs:7463
static BinaryExpression Add(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents an arithmetic addition operation...
Definition: Expression.cs:1639
static BinaryExpression SubtractAssign(Expression left, Expression right, MethodInfo method, LambdaExpression conversion)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a subtraction assignment operati...
Definition: Expression.cs:1894
virtual Type [] GetGenericArguments()
Returns an array of T:System.Type objects that represent the type arguments of a closed generic type ...
Definition: Type.cs:2433
override string ToString()
Returns a textual representation of the T:System.Linq.Expressions.Expression.
Definition: Expression.cs:3865
static BinaryExpression Power(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents raising a number to a power.
Definition: Expression.cs:2825
static UnaryExpression UnaryPlus(Expression expression, MethodInfo method)
Creates a T:System.Linq.Expressions.UnaryExpression that represents a unary plus operation.
Definition: Expression.cs:7442
static UnaryExpression TypeAs(Expression expression, Type type)
Creates a T:System.Linq.Expressions.UnaryExpression that represents an explicit reference or boxing c...
Definition: Expression.cs:7628
static MemberExpression PropertyOrField(Expression expression, string propertyOrFieldName)
Creates a T:System.Linq.Expressions.MemberExpression that represents accessing a property or field.
Definition: Expression.cs:5564
A bitwise right-shift operation, such as (a >> b).
static ElementInit ElementInit(MethodInfo addMethod, IEnumerable< Expression > arguments)
Creates an T:System.Linq.Expressions.ElementInit, given an T:System.Collections.Generic....
Definition: Expression.cs:3728
An arithmetic remainder operation, such as (a % b) in C# or (a Mod b) in Visual Basic.
CallingConventions
Defines the valid calling conventions for a method.
static DebugInfoExpression DebugInfo(SymbolDocumentInfo document, int startLine, int startColumn, int endLine, int endColumn)
Creates a T:System.Linq.Expressions.DebugInfoExpression with the specified span.
Definition: Expression.cs:3338
static BinaryExpression PowerAssign(Expression left, Expression right, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression that represents raising an expression to a power...
Definition: Expression.cs:2875
new TDelegate Compile(DebugInfoGenerator debugInfoGenerator)
Produces a delegate that represents the lambda expression.
Definition: Expression.cs:8013
Attribute can be applied to a constructor.
static BinaryExpression MultiplyAssign(Expression left, Expression right, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a multiplication assignment oper...
Definition: Expression.cs:2234
Provides the base class from which the classes that represent bindings that are used to initialize me...
Definition: MemberBinding.cs:7
static UnaryExpression Not(Expression expression, MethodInfo method)
Creates a T:System.Linq.Expressions.UnaryExpression that represents a bitwise complement operation....
Definition: Expression.cs:7518
Represents a globally unique identifier (GUID).To browse the .NET Framework source code for this type...
Definition: Guid.cs:14
static BinaryExpression And(Expression left, Expression right, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a bitwise AND operation....
Definition: Expression.cs:2577
bool IsArray
Gets a value that indicates whether the type is an array.
Definition: Type.cs:551
static LambdaExpression Lambda(Type delegateType, Expression body, IEnumerable< ParameterExpression > parameters)
Creates a T:System.Linq.Expressions.LambdaExpression by first constructing a delegate type....
Definition: Expression.cs:4848
Provides the base class from which the classes that represent expression tree nodes are derived....
Definition: Expression.cs:17
static CatchBlock Catch(ParameterExpression variable, Expression body)
Creates a T:System.Linq.Expressions.CatchBlock representing a catch statement with a reference to the...
Definition: Expression.cs:3170
static SwitchCase SwitchCase(Expression body, params Expression[] testValues)
Creates a T:System.Linq.Expressions.SwitchCase for use in a T:System.Linq.Expressions....
Definition: Expression.cs:6829
A subtraction compound assignment operation, such as (a -= b), without overflow checking,...
static bool TryGetActionType(Type[] typeArgs, out Type actionType)
Creates a P:System.Linq.Expressions.Expression.Type object that represents a generic System....
Definition: Expression.cs:5085
virtual bool CanReduce
Indicates that the node can be reduced to a simpler node. If this returns true, Reduce() can be calle...
Definition: Expression.cs:698
static BinaryExpression AndAssign(Expression left, Expression right, MethodInfo method, LambdaExpression conversion)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a bitwise AND assignment operati...
Definition: Expression.cs:2620
static LoopExpression Loop(Expression body, LabelTarget @break, LabelTarget @continue)
Creates a T:System.Linq.Expressions.LoopExpression with the given body.
Definition: Expression.cs:5270
An addition operation, such as (a + b), with overflow checking, for numeric operands.
StringBuilder Append(char value, int repeatCount)
Appends a specified number of copies of the string representation of a Unicode character to this inst...
static BinaryExpression AddChecked(Expression left, Expression right, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression that represents an arithmetic addition operation...
Definition: Expression.cs:1811
static UnaryExpression Quote(Expression expression)
Creates a T:System.Linq.Expressions.UnaryExpression that represents an expression that has a constant...
Definition: Expression.cs:7779
override string ToString()
Returns a string containing the characters written to the current StringWriter so far.
Represents an unconditional jump. This includes return statements, break and continue statements,...
static BinaryExpression SubtractAssign(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a subtraction assignment operati...
Definition: Expression.cs:1871
static ListInitExpression ListInit(NewExpression newExpression, params Expression[] initializers)
Creates a T:System.Linq.Expressions.ListInitExpression that uses a method named "Add" to add elements...
Definition: Expression.cs:5116
An expression that provides runtime read/write permission for variables.
A cast or conversion operation, such as (SampleType)obj in C::or CType(obj, SampleType) in Visual Bas...
An multiplication operation, such as (a * b), that has overflow checking, for numeric operands.
MethodInfo Method
Gets the implementing method for the binary operation.
static MemberAssignment Bind(MethodInfo propertyAccessor, Expression expression)
Creates a T:System.Linq.Expressions.MemberAssignment that represents the initialization of a member b...
Definition: Expression.cs:5312
static readonly Type [] EmptyTypes
Represents an empty array of type T:System.Type. This field is read-only.
Definition: Type.cs:38
static SymbolDocumentInfo SymbolDocument(string fileName, Guid language)
Creates an instance of T:System.Linq.Expressions.SymbolDocumentInfo.
Definition: Expression.cs:7031
static UnaryExpression OnesComplement(Expression expression)
Returns the expression representing the ones complement.
Definition: Expression.cs:7597
static BinaryExpression And(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a bitwise AND operation.
Definition: Expression.cs:2560
static UnaryExpression MakeUnary(ExpressionType unaryType, Expression operand, Type type)
Creates a T:System.Linq.Expressions.UnaryExpression, given an operand, by calling the appropriate fac...
Definition: Expression.cs:7219
static MemberMemberBinding MemberBind(MemberInfo member, params MemberBinding[] bindings)
Creates a T:System.Linq.Expressions.MemberMemberBinding that represents the recursive initialization ...
Definition: Expression.cs:5736
static BinaryExpression Add(Expression left, Expression right, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression that represents an arithmetic addition operation...
Definition: Expression.cs:1656
static TryExpression TryCatch(Expression body, params CatchBlock[] handlers)
Creates a T:System.Linq.Expressions.TryExpression representing a try block with any number of catch s...
Definition: Expression.cs:7084
static SwitchExpression Switch(Expression switchValue, params SwitchCase[] cases)
Creates a T:System.Linq.Expressions.SwitchExpression that represents a switch statement without a def...
Definition: Expression.cs:6853
static LambdaExpression Lambda(Expression body, string name, bool tailCall, IEnumerable< ParameterExpression > parameters)
Creates a LambdaExpression by first constructing a delegate type.
Definition: Expression.cs:4883
Expression(ExpressionType nodeType, Type type)
Initializes a new instance of the T:System.Linq.Expressions.Expression class.
Definition: Expression.cs:3779
static BinaryExpression MakeBinary(ExpressionType binaryType, Expression left, Expression right, bool liftToNull, MethodInfo method, LambdaExpression conversion)
Creates a T:System.Linq.Expressions.BinaryExpression, given the left operand, right operand,...
Definition: Expression.cs:1043
static int CompareExchange(ref int location1, int value, int comparand)
Compares two 32-bit signed integers for equality and, if they are equal, replaces the first value.
static BlockExpression Block(IEnumerable< Expression > expressions)
Creates a T:System.Linq.Expressions.BlockExpression that contains the given expressions and has no va...
Definition: Expression.cs:3023
virtual bool IsGenericMethodDefinition
Gets a value indicating whether the method is a generic method definition.
Definition: MethodBase.cs:77
Represents initializing members of a member of a newly created object.
static MemberMemberBinding MemberBind(MethodInfo propertyAccessor, IEnumerable< MemberBinding > bindings)
Creates a T:System.Linq.Expressions.MemberMemberBinding that represents the recursive initialization ...
Definition: Expression.cs:5786
Enables compilers to dynamically attach object fields to managed objects.
static BlockExpression Block(Expression arg0, Expression arg1, Expression arg2, Expression arg3)
Creates a T:System.Linq.Expressions.BlockExpression that contains four expressions and has no variabl...
Definition: Expression.cs:2968
static SwitchExpression Switch(Expression switchValue, Expression defaultBody, MethodInfo comparison, params SwitchCase[] cases)
Creates a T:System.Linq.Expressions.SwitchExpression that represents a switch statement that has a de...
Definition: Expression.cs:6876
An operation that creates a new array, in which the bounds for each dimension are specified,...
static BinaryExpression GreaterThanOrEqual(Expression left, Expression right, bool liftToNull, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a "greater than or equal" numeri...
Definition: Expression.cs:1367
static ConditionalExpression Condition(Expression test, Expression ifTrue, Expression ifFalse, Type type)
Creates a T:System.Linq.Expressions.ConditionalExpression that represents a conditional statement.
Definition: Expression.cs:3260
static readonly MemberFilter FilterNameIgnoreCase
Represents the case-insensitive member filter used on names. This field is read-only.
Definition: Type.cs:27
Represents an initializer for a single element of an T:System.Collections.IEnumerable collection.
Definition: ElementInit.cs:9
static BlockExpression Block(Type type, IEnumerable< ParameterExpression > variables, IEnumerable< Expression > expressions)
Creates a T:System.Linq.Expressions.BlockExpression that contains the given variables and expressions...
Definition: Expression.cs:3090
static DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, IEnumerable< Expression > arguments)
Creates a T:System.Linq.Expressions.DynamicExpression that represents a dynamic operation bound by th...
Definition: Expression.cs:3661
static BinaryExpression AndAlso(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a conditional AND operation that...
Definition: Expression.cs:1438
static BinaryExpression OrAssign(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a bitwise OR assignment operatio...
Definition: Expression.cs:2685
static BinaryExpression GreaterThan(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a "greater than" numeric compari...
Definition: Expression.cs:1272
virtual Type MakeArrayType()
Returns a T:System.Type object representing a one-dimensional array of the current type,...
Definition: Type.cs:1073
static BinaryExpression Multiply(Expression left, Expression right, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression that represents an arithmetic multiplication ope...
Definition: Expression.cs:2203
An arithmetic negation operation, such as (-a). The object a should not be modified in place.
static UnaryExpression MakeUnary(ExpressionType unaryType, Expression operand, Type type, MethodInfo method)
Creates a T:System.Linq.Expressions.UnaryExpression, given an operand and implementing method,...
Definition: Expression.cs:7235
A bitwise or logical XOR operation, such as (a ^ b) in C# or (a Xor b) in Visual Basic.
static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, Expression arg0, Expression arg1, Expression arg2)
Creates a T:System.Linq.Expressions.DynamicExpression that represents a dynamic operation bound by th...
Definition: Expression.cs:3494
Expression< TDelegate > Update(Expression body, IEnumerable< ParameterExpression > parameters)
Creates a new expression that is like this one, but using the supplied children. If all of the childr...
Definition: Expression.cs:8033
static BinaryExpression RightShift(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a bitwise right-shift operation.
Definition: Expression.cs:2470
A "less than or equal to" comparison, such as (a <= b).
static BlockExpression Block(Expression arg0, Expression arg1)
Creates a T:System.Linq.Expressions.BlockExpression that contains two expressions and has no variable...
Definition: Expression.cs:2940
A bitwise complement or logical negation operation. In C#, it is equivalent to (~a) for integral type...
static UnaryExpression PostDecrementAssign(Expression expression, MethodInfo method)
Creates a T:System.Linq.Expressions.UnaryExpression that represents the assignment of the expression ...
Definition: Expression.cs:7962
static bool TryGetFuncType(Type[] typeArgs, out Type funcType)
Creates a P:System.Linq.Expressions.Expression.Type object that represents a generic System....
Definition: Expression.cs:5048
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition: Array.cs:17
static UnaryExpression Rethrow()
Creates a T:System.Linq.Expressions.UnaryExpression that represents a rethrowing of an exception.
Definition: Expression.cs:7792
Represents a delegate, which is a data structure that refers to a static method or to a class instanc...
Definition: Delegate.cs:15
static LoopExpression Loop(Expression body, LabelTarget @break)
Creates a T:System.Linq.Expressions.LoopExpression with the given body and break target.
Definition: Expression.cs:5259
Represents type declarations: class types, interface types, array types, value types,...
Definition: Type.cs:18
static BinaryExpression AddAssignChecked(Expression left, Expression right, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression that represents an addition assignment operation...
Definition: Expression.cs:1754
Represents a constructor call that has a collection initializer.
static BinaryExpression MultiplyAssign(Expression left, Expression right, MethodInfo method, LambdaExpression conversion)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a multiplication assignment oper...
Definition: Expression.cs:2246
static UnaryExpression IsTrue(Expression expression)
Returns whether the expression evaluates to true.
Definition: Expression.cs:7569
static LambdaExpression Lambda(Type delegateType, Expression body, bool tailCall, params ParameterExpression[] parameters)
Creates a LambdaExpression by first constructing a delegate type.
Definition: Expression.cs:4831
A "less than" comparison, such as (a < b).
static NewExpression New(ConstructorInfo constructor)
Creates a T:System.Linq.Expressions.NewExpression that represents calling the specified constructor t...
Definition: Expression.cs:6511
static GotoExpression Break(LabelTarget target, Type type)
Creates a T:System.Linq.Expressions.GotoExpression representing a break statement with the specified ...
Definition: Expression.cs:4028
Provides information about methods and constructors.
Definition: MethodBase.cs:19
bool IsPublic
Gets a value indicating whether this is a public method.
Definition: MethodBase.cs:149
Type DeclaringType
Provides COM objects with version-independent access to the P:System.Reflection.MemberInfo....
Definition: _MethodInfo.cs:31
GotoExpressionKind Kind
The kind of the "go to" expression. Serves information purposes only.
static BinaryExpression MultiplyAssignChecked(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a multiplication assignment oper...
Definition: Expression.cs:2271
Attribute can be applied to a method.
static SwitchCase SwitchCase(Expression body, IEnumerable< Expression > testValues)
Creates a T:System.Linq.Expressions.SwitchCase object to be used in a T:System.Linq....
Definition: Expression.cs:6839
static MethodCallExpression Call(Expression instance, string methodName, Type[] typeArguments, params Expression[] arguments)
Creates a T:System.Linq.Expressions.MethodCallExpression that represents a call to a method by callin...
Definition: Expression.cs:6066
virtual Type MakeGenericType(params Type[] typeArguments)
Substitutes the elements of an array of types for the type parameters of the current generic type def...
Definition: Type.cs:2398
static NewExpression New(ConstructorInfo constructor, params Expression[] arguments)
Creates a T:System.Linq.Expressions.NewExpression that represents calling the specified constructor w...
Definition: Expression.cs:6524
static SwitchExpression Switch(Type type, Expression switchValue, Expression defaultBody, MethodInfo comparison, params SwitchCase[] cases)
Creates a T:System.Linq.Expressions.SwitchExpression that represents a switch statement that has a de...
Definition: Expression.cs:6889
static NewExpression New(Type type)
Creates a T:System.Linq.Expressions.NewExpression that represents calling the parameterless construct...
Definition: Expression.cs:6586
An addition compound assignment operation, such as (a += b), without overflow checking,...
static RuntimeVariablesExpression RuntimeVariables(IEnumerable< ParameterExpression > variables)
Creates an instance of T:System.Linq.Expressions.RuntimeVariablesExpression.
Definition: Expression.cs:6809
static LoopExpression Loop(Expression body)
Creates a T:System.Linq.Expressions.LoopExpression with the given body.
Definition: Expression.cs:5249
Represents a control expression that handles multiple selections by passing control to T:System....
static MemberExpression Field(Expression expression, string fieldName)
Creates a T:System.Linq.Expressions.MemberExpression that represents accessing a field given the name...
Definition: Expression.cs:5384
abstract string Name
Gets the name of the current member.
Definition: MemberInfo.cs:27
abstract MethodInfo GetSetMethod(bool nonPublic)
When overridden in a derived class, returns the set accessor for this property.
Represents a named parameter expression.
An operation that throws an exception, such as throw new Exception().
new TDelegate Compile()
Compiles the lambda expression described by the expression tree into executable code and produces a d...
Definition: Expression.cs:8005
static BinaryExpression AndAssign(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a bitwise AND assignment operati...
Definition: Expression.cs:2597
static BinaryExpression Or(Expression left, Expression right, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a bitwise OR operation.
Definition: Expression.cs:2665
abstract Type PropertyType
Gets the type of this property.
Definition: PropertyInfo.cs:25
Represents assignment operation for a field or property of an object.
bool IsValueType
Gets a value indicating whether the T:System.Type is a value type.
Definition: Type.cs:445
virtual CallingConventions CallingConvention
Gets a value indicating the calling conventions for this method.
Definition: MethodBase.cs:64
Object()
Initializes a new instance of the T:System.Object class.
Definition: Object.cs:24
A node that represents a null coalescing operation, such as (a ?? b) in C# or If(a,...
static SwitchExpression Switch(Type type, Expression switchValue, Expression defaultBody, MethodInfo comparison, IEnumerable< SwitchCase > cases)
Creates a T:System.Linq.Expressions.SwitchExpression that represents a switch statement that has a de...
Definition: Expression.cs:6914
static UnaryExpression Throw(Expression value)
Creates a T:System.Linq.Expressions.UnaryExpression that represents a throwing of an exception.
Definition: Expression.cs:7810
static ParameterExpression Parameter(Type type, string name)
Creates a T:System.Linq.Expressions.ParameterExpression node that can be used to identify a parameter...
Definition: Expression.cs:6762
virtual Expression Visit(Expression node)
Dispatches the expression to one of the more specialized visit methods in this class.
A lambda expression, such as a => a + a in C# or Function(a) a + a in Visual Basic.
ExpressionType
Describes the node types for the nodes of an expression tree.
Selects a member from a list of candidates, and performs type conversion from actual argument type to...
Definition: Binder.cs:10
MethodInfo GetMethod(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
Searches for the specified method whose parameters match the specified argument types and modifiers,...
Definition: Type.cs:1488
static UnaryExpression Unbox(Expression expression, Type type)
Creates a T:System.Linq.Expressions.UnaryExpression that represents an explicit unboxing.
Definition: Expression.cs:7645
static GotoExpression Break(LabelTarget target, Expression value, Type type)
Creates a T:System.Linq.Expressions.GotoExpression representing a break statement with the specified ...
Definition: Expression.cs:4039
override Type [] GetGenericArguments()
Returns an array of T:System.Type objects that represent the type arguments of a generic method or th...
Definition: MethodInfo.cs:109
Represents a mutable string of characters. This class cannot be inherited.To browse the ....
static MemberExpression Property(Expression expression, PropertyInfo property)
Creates a T:System.Linq.Expressions.MemberExpression that represents accessing a property.
Definition: Expression.cs:5475
static MemberExpression Field(Expression expression, FieldInfo field)
Creates a T:System.Linq.Expressions.MemberExpression that represents accessing a field.
Definition: Expression.cs:5351
static MethodCallExpression Call(Expression instance, MethodInfo method)
Creates a T:System.Linq.Expressions.MethodCallExpression that represents a call to a method that take...
Definition: Expression.cs:5985
Discovers the attributes of a property and provides access to property metadata.
Definition: PropertyInfo.cs:15
static GotoExpression Goto(LabelTarget target, Type type)
Creates a T:System.Linq.Expressions.GotoExpression representing a "go to" statement with the specifie...
Definition: Expression.cs:4117
static RuntimeVariablesExpression RuntimeVariables(params ParameterExpression[] variables)
Creates an instance of T:System.Linq.Expressions.RuntimeVariablesExpression.
Definition: Expression.cs:6800
static ListInitExpression ListInit(NewExpression newExpression, IEnumerable< ElementInit > initializers)
Creates a T:System.Linq.Expressions.ListInitExpression that uses specified T:System....
Definition: Expression.cs:5232
static BlockExpression Block(params Expression[] expressions)
Creates a T:System.Linq.Expressions.BlockExpression that contains the given expressions and has no va...
Definition: Expression.cs:2999
Type DeclaringType
Provides COM objects with version-independent access to the P:System.Reflection.MemberInfo....
static IndexExpression Property(Expression instance, string propertyName, params Expression[] arguments)
Creates an T:System.Linq.Expressions.IndexExpression representing the access to an indexed property.
Definition: Expression.cs:4241
A unary plus operation, such as (+a). The result of a predefined unary plus operation is the value of...
static UnaryExpression Convert(Expression expression, Type type, MethodInfo method)
Creates a T:System.Linq.Expressions.UnaryExpression that represents a conversion operation for which ...
Definition: Expression.cs:7688
static CultureInfo CurrentCulture
Gets or sets the T:System.Globalization.CultureInfo object that represents the culture used by the cu...
Definition: CultureInfo.cs:120
static BinaryExpression SubtractChecked(Expression left, Expression right, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression that represents an arithmetic subtraction operat...
Definition: Expression.cs:1987
static DynamicExpression MakeDynamic(Type delegateType, CallSiteBinder binder, params Expression[] arguments)
Creates a T:System.Linq.Expressions.DynamicExpression that represents a dynamic operation bound by th...
Definition: Expression.cs:3414
static TypeBinaryExpression TypeEqual(Expression expression, Type type)
Creates a T:System.Linq.Expressions.TypeBinaryExpression that compares run-time type identity.
Definition: Expression.cs:7198
Represents one case of a T:System.Linq.Expressions.SwitchExpression.
Definition: SwitchCase.cs:10
static GotoExpression Continue(LabelTarget target)
Creates a T:System.Linq.Expressions.GotoExpression representing a continue statement.
Definition: Expression.cs:4048
The exception that is thrown when one of the arguments provided to a method is not valid.
An addition operation, such as a + b, without overflow checking, for numeric operands.
static BinaryExpression RightShift(Expression left, Expression right, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a bitwise right-shift operation.
Definition: Expression.cs:2487
static TypeBinaryExpression TypeIs(Expression expression, Type type)
Creates a T:System.Linq.Expressions.TypeBinaryExpression.
Definition: Expression.cs:7182
Represents an operation between an expression and a type.
static CatchBlock Catch(Type type, Expression body, Expression filter)
Creates a T:System.Linq.Expressions.CatchBlock representing a catch statement with an T:System....
Definition: Expression.cs:3182
static GotoExpression Goto(LabelTarget target)
Creates a T:System.Linq.Expressions.GotoExpression representing a "go to" statement.
Definition: Expression.cs:4107
static BinaryExpression OrElse(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a conditional OR operation that ...
Definition: Expression.cs:1497
static UnaryExpression ConvertChecked(Expression expression, Type type)
Creates a T:System.Linq.Expressions.UnaryExpression that represents a conversion operation that throw...
Definition: Expression.cs:7712
static BinaryExpression Assign(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents an assignment operation.
Definition: Expression.cs:723
static SymbolDocumentInfo SymbolDocument(string fileName)
Creates an instance of T:System.Linq.Expressions.SymbolDocumentInfo.
Definition: Expression.cs:7021
Represents a try/catch/finally/fault block.
virtual Expression Reduce()
Reduces this node to a simpler expression. If CanReduce returns true, this should return a valid expr...
Definition: Expression.cs:3797
An operation that invokes a delegate or lambda expression, such as sampleDelegate....
static UnaryExpression NegateChecked(Expression expression, MethodInfo method)
Creates a T:System.Linq.Expressions.UnaryExpression that represents an arithmetic negation operation ...
Definition: Expression.cs:7480
static IndexExpression ArrayAccess(Expression array, IEnumerable< Expression > indexes)
Creates an T:System.Linq.Expressions.IndexExpression to access a multidimensional array.
Definition: Expression.cs:4211
override Type Type
Gets the static type of the expression that this T:System.Linq.Expressions.Expression represents.
static NewArrayExpression NewArrayInit(Type type, IEnumerable< Expression > initializers)
Creates a T:System.Linq.Expressions.NewArrayExpression that represents creating a one-dimensional arr...
Definition: Expression.cs:6414
static LabelTarget Label(Type type)
Creates a T:System.Linq.Expressions.LabelTarget representing a label with the given type.
Definition: Expression.cs:4630
A unary increment operation, such as (a + 1) in C# and Visual Basic. The object a should not be modif...
static BinaryExpression LeftShiftAssign(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a bitwise left-shift assignment ...
Definition: Expression.cs:2418
static MethodCallExpression Call(MethodInfo method, Expression arg0, Expression arg1, Expression arg2, Expression arg3, Expression arg4)
Creates a T:System.Linq.Expressions.MethodCallExpression that represents a call to a static method th...
Definition: Expression.cs:5934
static LambdaExpression Lambda(Expression body, string name, IEnumerable< ParameterExpression > parameters)
Creates a LambdaExpression by first constructing a delegate type.
Definition: Expression.cs:4871
static DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, Expression arg0, Expression arg1, Expression arg2)
Creates a T:System.Linq.Expressions.DynamicExpression that represents a dynamic operation bound by th...
Definition: Expression.cs:3615
sealed override ExpressionType NodeType
Returns the node type of this expression. Extension nodes should return F:System.Linq....
A switch operation, such as switch in C# or Select Case in Visual Basic.
static UnaryExpression IsFalse(Expression expression, MethodInfo method)
Returns whether the expression evaluates to false.
Definition: Expression.cs:7551
A division operation, such as (a / b), for numeric operands.
Represents the default value of a type or an empty expression.
static GotoExpression Continue(LabelTarget target, Type type)
Creates a T:System.Linq.Expressions.GotoExpression representing a continue statement with the specifi...
Definition: Expression.cs:4058
Class responsible for runtime binding of the dynamic operations on the dynamic call site.
static BinaryExpression ReferenceEqual(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a reference equality comparison.
Definition: Expression.cs:1173
MethodInfo Method
Gets the implementing method for the unary operation.
static LabelExpression Label(LabelTarget target)
Creates a T:System.Linq.Expressions.LabelExpression representing a label without a default value.
Definition: Expression.cs:4593
A node that represents an equality comparison, such as (a == b) in C# or (a = b) in Visual Basic.
static BinaryExpression Divide(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents an arithmetic division operation...
Definition: Expression.cs:2010
Represents a dynamic operation.
static GotoExpression Break(LabelTarget target)
Creates a T:System.Linq.Expressions.GotoExpression representing a break statement.
Definition: Expression.cs:4008
static NewExpression New(ConstructorInfo constructor, IEnumerable< Expression > arguments, IEnumerable< MemberInfo > members)
Creates a T:System.Linq.Expressions.NewExpression that represents calling the specified constructor w...
Definition: Expression.cs:6556
static BinaryExpression AddAssign(Expression left, Expression right, MethodInfo method, LambdaExpression conversion)
Creates a T:System.Linq.Expressions.BinaryExpression that represents an addition assignment operation...
Definition: Expression.cs:1699
A "greater than" comparison, such as (a > b).
static UnaryExpression PostIncrementAssign(Expression expression, MethodInfo method)
Creates a T:System.Linq.Expressions.UnaryExpression that represents the assignment of the expression ...
Definition: Expression.cs:7943
static MemberExpression Field(Expression expression, Type type, string fieldName)
Creates a T:System.Linq.Expressions.MemberExpression that represents accessing a field.
Definition: Expression.cs:5405
sealed override ExpressionType NodeType
Returns the node type of this Expression. Extension nodes should return F:System.Linq....
static ConstantExpression Constant(object value)
Creates a T:System.Linq.Expressions.ConstantExpression that has the P:System.Linq....
Definition: Expression.cs:3302
A bitwise or logical OR compound assignment, such as (a |= b) in C#.
An operation that creates a new one-dimensional array and initializes it from a list of elements,...
static UnaryExpression ConvertChecked(Expression expression, Type type, MethodInfo method)
Creates a T:System.Linq.Expressions.UnaryExpression that represents a conversion operation that throw...
Definition: Expression.cs:7731
Expression ReduceAndCheck()
Reduces this node to a simpler expression. If CanReduce returns true, this should return a valid expr...
Definition: Expression.cs:3831
static CatchBlock MakeCatchBlock(Type type, ParameterExpression variable, Expression body, Expression filter)
Creates a T:System.Linq.Expressions.CatchBlock representing a catch statement with the specified elem...
Definition: Expression.cs:3206
static BinaryExpression SubtractChecked(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents an arithmetic subtraction operat...
Definition: Expression.cs:1970
A binding that represents recursively initializing members of a member.
override bool CanReduce
Gets a value that indicates whether the expression tree node can be reduced.
static MethodCallExpression Call(MethodInfo method, Expression arg0, Expression arg1, Expression arg2, Expression arg3)
Creates a T:System.Linq.Expressions.MethodCallExpression that represents a call to a static method th...
Definition: Expression.cs:5907
static BlockExpression Block(Type type, IEnumerable< Expression > expressions)
Creates a T:System.Linq.Expressions.BlockExpression that contains the given expressions,...
Definition: Expression.cs:3044
static MemberListBinding ListBind(MethodInfo propertyAccessor, params ElementInit[] initializers)
Creates a T:System.Linq.Expressions.MemberListBinding object based on a specified property accessor m...
Definition: Expression.cs:5689
A unary postfix decrement, such as (a–). The object a should be modified in place.
static TryExpression TryCatchFinally(Expression body, Expression @finally, params CatchBlock[] handlers)
Creates a T:System.Linq.Expressions.TryExpression representing a try block with any number of catch s...
Definition: Expression.cs:7095
A multiplication operation, such as (a * b), without overflow checking, for numeric operands.
static BinaryExpression MakeBinary(ExpressionType binaryType, Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression, given the left and right operands,...
Definition: Expression.cs:1006
An operation that obtains the length of a one-dimensional array, such as array.Length.
A bitwise or logical XOR compound assignment operation, such as (a ^= b) in C#.
Represents indexing a property or array.
static BinaryExpression AddAssign(Expression left, Expression right, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression that represents an addition assignment operation...
Definition: Expression.cs:1687
static Type GetFuncType(params Type[] typeArgs)
Creates a P:System.Linq.Expressions.Expression.Type object that represents a generic System....
Definition: Expression.cs:5029
Represents an expression that has a unary operator.
static MemberListBinding ListBind(MemberInfo member, params ElementInit[] initializers)
Creates a T:System.Linq.Expressions.MemberListBinding where the member is a field or property.
Definition: Expression.cs:5654
Describes a lambda expression. This captures a block of code that is similar to a ....
static LambdaExpression Lambda(Expression body, bool tailCall, params ParameterExpression[] parameters)
Creates a LambdaExpression by first constructing a delegate type.
Definition: Expression.cs:4781
static BinaryExpression ExclusiveOr(Expression left, Expression right, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a bitwise XOR operation,...
Definition: Expression.cs:2753
static MemberExpression MakeMemberAccess(Expression expression, MemberInfo member)
Creates a T:System.Linq.Expressions.MemberExpression that represents accessing either a field or a pr...
Definition: Expression.cs:5599
new TDelegate Compile(bool preferInterpretation)
Compiles the lambda expression described by the expression tree into interpreted or compiled code and...
Definition: Expression.cs:8023
static ConditionalExpression Condition(Expression test, Expression ifTrue, Expression ifFalse)
Creates a T:System.Linq.Expressions.ConditionalExpression that represents a conditional statement.
Definition: Expression.cs:3237
virtual Type ParameterType
Gets the Type of this parameter.
static MethodCallExpression ArrayIndex(Expression array, params Expression[] indexes)
Creates a T:System.Linq.Expressions.MethodCallExpression that represents applying an array index oper...
Definition: Expression.cs:6353
Represents a catch statement in a try block.
Definition: CatchBlock.cs:8
static BinaryExpression Equal(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents an equality comparison.
Definition: Expression.cs:1138
static NewArrayExpression NewArrayBounds(Type type, IEnumerable< Expression > bounds)
Creates a T:System.Linq.Expressions.NewArrayExpression that represents creating an array that has a s...
Definition: Expression.cs:6477
static MethodCallExpression Call(Expression instance, MethodInfo method, IEnumerable< Expression > arguments)
Creates a T:System.Linq.Expressions.MethodCallExpression that represents a call to a method that take...
Definition: Expression.cs:6111
Expression Body
Gets the body of this case.
Definition: SwitchCase.cs:32
A cast or conversion operation, such as (SampleType)obj in C::or CType(obj, SampleType) in Visual Bas...
static BinaryExpression Divide(Expression left, Expression right, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression that represents an arithmetic division operation...
Definition: Expression.cs:2027
static NewExpression New(ConstructorInfo constructor, IEnumerable< Expression > arguments)
Creates a T:System.Linq.Expressions.NewExpression that represents calling the specified constructor w...
Definition: Expression.cs:6537
static DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, Expression arg0)
Creates a T:System.Linq.Expressions.DynamicExpression that represents a dynamic operation bound by th...
Definition: Expression.cs:3573
static NewArrayExpression NewArrayBounds(Type type, params Expression[] bounds)
Creates a T:System.Linq.Expressions.NewArrayExpression that represents creating an array that has a s...
Definition: Expression.cs:6464
Represents an expression that has a binary operator.
abstract MemberTypes MemberType
When overridden in a derived class, gets a T:System.Reflection.MemberTypes value indicating the type ...
Definition: MemberInfo.cs:19
Specifies that instance members are to be included in the search.
static NewArrayExpression NewArrayInit(Type type, params Expression[] initializers)
Creates a T:System.Linq.Expressions.NewArrayExpression that represents creating a one-dimensional arr...
Definition: Expression.cs:6401
static BinaryExpression LessThanOrEqual(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a " less than or equal" numeric ...
Definition: Expression.cs:1386
GotoExpressionKind
Specifies what kind of jump this T:System.Linq.Expressions.GotoExpression represents.
Represents a call to either static or an instance method.
Represents an expression that has a conditional operator.
string Name
Provides COM objects with version-independent access to the P:System.Reflection.MemberInfo....
Definition: _MethodInfo.cs:24
static TryExpression MakeTry(Type type, Expression body, Expression @finally, Expression fault, IEnumerable< CatchBlock > handlers)
Creates a T:System.Linq.Expressions.TryExpression representing a try block with the specified element...
Definition: Expression.cs:7108
static BinaryExpression ModuloAssign(Expression left, Expression right, MethodInfo method, LambdaExpression conversion)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a remainder assignment operation...
Definition: Expression.cs:2158
static BinaryExpression DivideAssign(Expression left, Expression right, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a division assignment operation ...
Definition: Expression.cs:2058
abstract bool CanWrite
Gets a value indicating whether the property can be written to.
Definition: PropertyInfo.cs:54
static IndexExpression Property(Expression instance, PropertyInfo indexer, IEnumerable< Expression > arguments)
Creates an T:System.Linq.Expressions.IndexExpression representing the access to an indexed property.
Definition: Expression.cs:4387
static BinaryExpression ExclusiveOrAssign(Expression left, Expression right, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a bitwise XOR assignment operati...
Definition: Expression.cs:2784
Provides constants and static methods for trigonometric, logarithmic, and other common mathematical f...
Definition: Math.cs:10
Provides information about a specific culture (called a locale for unmanaged code development)....
Definition: CultureInfo.cs:16
static TryExpression TryFault(Expression body, Expression fault)
Creates a T:System.Linq.Expressions.TryExpression representing a try block with a fault block and no ...
Definition: Expression.cs:7064
static ListInitExpression ListInit(NewExpression newExpression, IEnumerable< Expression > initializers)
Creates a T:System.Linq.Expressions.ListInitExpression that uses a method named "Add" to add elements...
Definition: Expression.cs:5133
static BlockExpression Block(IEnumerable< ParameterExpression > variables, IEnumerable< Expression > expressions)
Creates a T:System.Linq.Expressions.BlockExpression that contains the given variables and expressions...
Definition: Expression.cs:3075
static BinaryExpression LeftShiftAssign(Expression left, Expression right, MethodInfo method, LambdaExpression conversion)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a bitwise left-shift assignment ...
Definition: Expression.cs:2441
static BinaryExpression MakeBinary(ExpressionType binaryType, Expression left, Expression right, bool liftToNull, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression, given the left operand, right operand and imple...
Definition: Expression.cs:1024
bool IsByRef
Gets a value indicating whether the T:System.Type is passed by reference.
Definition: Type.cs:664
A subtraction operation, such as (a - b), without overflow checking, for numeric operands.
static MemberListBinding ListBind(MemberInfo member, IEnumerable< ElementInit > initializers)
Creates a T:System.Linq.Expressions.MemberListBinding where the member is a field or property.
Definition: Expression.cs:5670
MemberTypes
Marks each type of member that is defined as a derived class of T:System.Reflection....
Definition: MemberTypes.cs:9
static MemberAssignment Bind(MemberInfo member, Expression expression)
Creates a T:System.Linq.Expressions.MemberAssignment that represents the initialization of a field or...
Definition: Expression.cs:5290
sealed override ExpressionType NodeType
Returns the node type of this Expression. Extension nodes should return F:System.Linq....
static BinaryExpression SubtractAssignChecked(Expression left, Expression right, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a subtraction assignment operati...
Definition: Expression.cs:1930
static UnaryExpression Decrement(Expression expression)
Creates a T:System.Linq.Expressions.UnaryExpression that represents the decrementing of the expressio...
Definition: Expression.cs:7867
static DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, params Expression[] arguments)
Creates a T:System.Linq.Expressions.DynamicExpression that represents a dynamic operation bound by th...
Definition: Expression.cs:3562
An operation that creates a new object and initializes one or more of its members,...
static IndexExpression ArrayAccess(Expression array, params Expression[] indexes)
Creates an T:System.Linq.Expressions.IndexExpression to access an array.
Definition: Expression.cs:4201
static BinaryExpression ModuloAssign(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a remainder assignment operation...
Definition: Expression.cs:2135
An operation that calls a constructor to create a new object, such as new SampleType().
static BinaryExpression AndAlso(Expression left, Expression right, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a conditional AND operation that...
Definition: Expression.cs:1456
static BlockExpression Block(Expression arg0, Expression arg1, Expression arg2, Expression arg3, Expression arg4)
Creates a T:System.Linq.Expressions.BlockExpression that contains five expressions and has no variabl...
Definition: Expression.cs:2985
virtual Type MakeByRefType()
Returns a T:System.Type object that represents the current type when passed as a ref parameter (ByRef...
Definition: Type.cs:1063
static IndexExpression Property(Expression instance, PropertyInfo indexer, params Expression[] arguments)
Creates an T:System.Linq.Expressions.IndexExpression representing the access to an indexed property.
Definition: Expression.cs:4376
Provides atomic operations for variables that are shared by multiple threads.
Definition: Interlocked.cs:10
virtual Type Type
Gets the static type of the expression that this T:System.Linq.Expressions.Expression represents.
Definition: Expression.cs:682
virtual string Name
Gets the name of the parameter.
static MemberListBinding ListBind(MethodInfo propertyAccessor, IEnumerable< ElementInit > initializers)
Creates a T:System.Linq.Expressions.MemberListBinding based on a specified property accessor method.
Definition: Expression.cs:5705
override bool CanReduce
Gets a value that indicates whether the expression tree node can be reduced.
static GotoExpression Return(LabelTarget target, Type type)
Creates a T:System.Linq.Expressions.GotoExpression representing a return statement with the specified...
Definition: Expression.cs:4077
static BinaryExpression AndAssign(Expression left, Expression right, MethodInfo method)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a bitwise AND assignment operati...
Definition: Expression.cs:2608
static ConstantExpression Constant(object value, Type type)
Creates a T:System.Linq.Expressions.ConstantExpression that has the P:System.Linq....
Definition: Expression.cs:3316
static GotoExpression MakeGoto(GotoExpressionKind kind, LabelTarget target, Expression value, Type type)
Creates a T:System.Linq.Expressions.GotoExpression representing a jump of the specified T:System....
Definition: Expression.cs:4150
abstract bool CanRead
Gets a value indicating whether the property can be read.
Definition: PropertyInfo.cs:44
virtual bool IsAssignableFrom(Type c)
Determines whether an instance of a specified type can be assigned to an instance of the current type...
Definition: Type.cs:2707
Represents a visitor or rewriter for expression trees.
bool TryGetValue(TKey key, out TValue value)
Gets the value of the specified key.
static UnaryExpression PreDecrementAssign(Expression expression, MethodInfo method)
Creates a T:System.Linq.Expressions.UnaryExpression that decrements the expression by 1 and assigns t...
Definition: Expression.cs:7924
static BinaryExpression AddAssignChecked(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents an addition assignment operation...
Definition: Expression.cs:1743
static Delegate CreateDelegate(Type type, object target, string method)
Creates a delegate of the specified type that represents the specified instance method to invoke on t...
Definition: Delegate.cs:368
An assignment operation, such as (a = b).
override bool CanReduce
Gets a value that indicates whether the expression tree node can be reduced.
static DefaultExpression Default(Type type)
Creates a T:System.Linq.Expressions.DefaultExpression that has the P:System.Linq.Expressions....
Definition: Expression.cs:3399
static InvocationExpression Invoke(Expression expression, params Expression[] arguments)
Creates an T:System.Linq.Expressions.InvocationExpression that applies a delegate or lambda expressio...
Definition: Expression.cs:4549
static DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, Expression arg0, Expression arg1, Expression arg2, Expression arg3)
Creates a T:System.Linq.Expressions.DynamicExpression that represents a dynamic operation bound by th...
Definition: Expression.cs:3639
static LabelTarget Label(Type type, string name)
Creates a T:System.Linq.Expressions.LabelTarget representing a label with the given type and name.
Definition: Expression.cs:4640
An expression that has a constant value of type T:System.Linq.Expressions.Expression....
A bitwise left-shift compound assignment, such as (a <<= b).
static ParameterExpression Parameter(Type type)
Creates a T:System.Linq.Expressions.ParameterExpression node that can be used to identify a parameter...
Definition: Expression.cs:6741
static MethodCallExpression Call(Expression instance, MethodInfo method, Expression arg0, Expression arg1)
Creates a T:System.Linq.Expressions.MethodCallExpression that represents a call to a method that take...
Definition: Expression.cs:6014
static UnaryExpression UnaryPlus(Expression expression)
Creates a T:System.Linq.Expressions.UnaryExpression that represents a unary plus operation.
Definition: Expression.cs:7425
static BinaryExpression ExclusiveOrAssign(Expression left, Expression right, MethodInfo method, LambdaExpression conversion)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a bitwise XOR assignment operati...
Definition: Expression.cs:2796
static BinaryExpression SubtractAssignChecked(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a subtraction assignment operati...
Definition: Expression.cs:1919
ReadOnlyCollection< Expression > TestValues
Gets the values of this case. This case is selected for execution when the P:System....
Definition: SwitchCase.cs:20
static UnaryExpression Increment(Expression expression)
Creates a T:System.Linq.Expressions.UnaryExpression that represents the incrementing of the expressio...
Definition: Expression.cs:7839
static BinaryExpression ReferenceNotEqual(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a reference inequality compariso...
Definition: Expression.cs:1227
static UnaryExpression PreIncrementAssign(Expression expression)
Creates a T:System.Linq.Expressions.UnaryExpression that increments the expression by 1 and assigns t...
Definition: Expression.cs:7895
static BinaryExpression Or(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a bitwise OR operation.
Definition: Expression.cs:2648
static MemberExpression Property(Expression expression, MethodInfo propertyAccessor)
Creates a T:System.Linq.Expressions.MemberExpression that represents accessing a property by using a ...
Definition: Expression.cs:5514
static LabelTarget Label(string name)
Creates a T:System.Linq.Expressions.LabelTarget representing a label with void type and the given nam...
Definition: Expression.cs:4621
static MemberMemberBinding MemberBind(MemberInfo member, IEnumerable< MemberBinding > bindings)
Creates a T:System.Linq.Expressions.MemberMemberBinding that represents the recursive initialization ...
Definition: Expression.cs:5752
static BinaryExpression ExclusiveOrAssign(Expression left, Expression right)
Creates a T:System.Linq.Expressions.BinaryExpression that represents a bitwise XOR assignment operati...
Definition: Expression.cs:2773