Show / Hide Table of Contents

Class CodeGenerator

Represents code generator.

Inheritance
Object
CodeGenerator
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: DotNext.Metaprogramming
Assembly: DotNext.Metaprogramming.dll
Syntax
public static class CodeGenerator

Methods

| Improve this Doc View Source

Assert(Expression, String)

Checks for a condition; if the condition is false, displays a message box that shows the call stack.

Declaration
[Conditional("DEBUG")]
public static void Assert(Expression test, string message = null)
Parameters
Type Name Description
Expression test

The conditional expression to evaluate. If the condition is true, the specified message is not sent and the message box is not displayed.

String message

The message to include into trace.

| Improve this Doc View Source

Assign(Expression, FieldInfo, Expression)

Adds instance field assignment.

Declaration
public static void Assign(Expression instance, FieldInfo instanceField, Expression value)
Parameters
Type Name Description
Expression instance

this argument.

FieldInfo instanceField

Instance field to be assigned.

Expression value

A new value of the field.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Assign(Expression, PropertyInfo, Expression)

Adds instance property assignment.

Declaration
public static void Assign(Expression instance, PropertyInfo instanceProperty, Expression value)
Parameters
Type Name Description
Expression instance

this argument.

PropertyInfo instanceProperty

Instance property to be assigned.

Expression value

A new value of the property.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Assign(IndexExpression, Expression)

Adds assignment operation to this scope.

Declaration
public static void Assign(IndexExpression indexer, Expression value)
Parameters
Type Name Description
IndexExpression indexer

The indexer property or array element to modify.

Expression value

The value to be assigned to the member or array element.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Assign(MemberExpression, Expression)

Adds assignment operation to this scope.

Declaration
public static void Assign(MemberExpression member, Expression value)
Parameters
Type Name Description
MemberExpression member

The field or property to modify.

Expression value

The value to be assigned to the member.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Assign(ParameterExpression, Expression)

Adds assignment operation to this scope.

Declaration
public static void Assign(ParameterExpression variable, Expression value)
Parameters
Type Name Description
ParameterExpression variable

The variable to modify.

Expression value

The value to be assigned to the variable.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Assign(FieldInfo, Expression)

Adds static field assignment.

Declaration
public static void Assign(FieldInfo staticField, Expression value)
Parameters
Type Name Description
FieldInfo staticField

Static field to be assigned.

Expression value

A new value of the field.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Assign(PropertyInfo, Expression)

Adds static property assignment.

Declaration
public static void Assign(PropertyInfo staticProperty, Expression value)
Parameters
Type Name Description
PropertyInfo staticProperty

Static property to be assigned.

Expression value

A new value of the property.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Assign(String, Expression)

Adds local variable assignment operation this scope.

Declaration
public static void Assign(string variableName, Expression value)
Parameters
Type Name Description
String variableName

The name of the declared local variable.

Expression value

The value to be assigned to the local variable.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

AsyncLambda<TDelegate>(Action<LambdaContext, ParameterExpression>)

Constructs multi-line async lambda function capturing the current lexical scope.

Declaration
public static Expression<TDelegate> AsyncLambda<TDelegate>(Action<LambdaContext, ParameterExpression> body)

    where TDelegate : Delegate
Parameters
Type Name Description
Action<LambdaContext, ParameterExpression> body

Lambda function builder.

Returns
Type Description
Expression<TDelegate>

Constructed lambda expression.

Type Parameters
Name Description
TDelegate

The delegate describing signature of lambda function.

See Also
AwaitExpression
AsyncResultExpression
Async methods
| Improve this Doc View Source

AsyncLambda<TDelegate>(Action<LambdaContext>)

Constructs multi-line async lambda function capturing the current lexical scope.

Declaration
public static Expression<TDelegate> AsyncLambda<TDelegate>(Action<LambdaContext> body)

    where TDelegate : Delegate
Parameters
Type Name Description
Action<LambdaContext> body

Lambda function builder.

Returns
Type Description
Expression<TDelegate>

Constructed lambda expression.

Type Parameters
Name Description
TDelegate

The delegate describing signature of lambda function.

See Also
AwaitExpression
AsyncResultExpression
Async methods
| Improve this Doc View Source

Await(Expression, Boolean)

Adds await operator.

Declaration
public static void Await(Expression asyncResult, bool configureAwait = false)
Parameters
Type Name Description
Expression asyncResult

The expression representing asynchronous computing process.

Boolean configureAwait

true to call ConfigureAwait(Boolean) with false argument.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

AwaitForEach(Expression, Action<MemberExpression, LoopContext>, Expression, Boolean)

Adds await foreach loop statement.

Declaration
public static void AwaitForEach(Expression collection, Action<MemberExpression, LoopContext> body, Expression cancellationToken = null, bool configureAwait = false)
Parameters
Type Name Description
Expression collection

The expression providing enumerable collection.

Action<MemberExpression, LoopContext> body

Loop body.

Expression cancellationToken

The expression of type CancellationToken.

Boolean configureAwait

true to call ConfigureAwait(Boolean) with false argument when awaiting MoveNextAsync() method.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

See Also
Async Streams
| Improve this Doc View Source

AwaitForEach(Expression, Action<MemberExpression>, Expression, Boolean)

Adds await foreach loop statement.

Declaration
public static void AwaitForEach(Expression collection, Action<MemberExpression> body, Expression cancellationToken = null, bool configureAwait = false)
Parameters
Type Name Description
Expression collection

The expression providing enumerable collection.

Action<MemberExpression> body

Loop body.

Expression cancellationToken

The expression of type CancellationToken.

Boolean configureAwait

true to call ConfigureAwait(Boolean) with false argument when awaiting MoveNextAsync() method.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

See Also
Async Streams
| Improve this Doc View Source

AwaitUsing(Expression, Action, Boolean)

Adds await using statement.

Declaration
public static void AwaitUsing(Expression resource, Action body, bool configureAwait = false)
Parameters
Type Name Description
Expression resource

The expression representing disposable resource.

Action body

The body of the statement.

Boolean configureAwait

true to call ConfigureAwait(Boolean) with false argument when awaiting DisposeAsync() method.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

See Also
Using async disposable
| Improve this Doc View Source

AwaitUsing(Expression, Action<ParameterExpression>, Boolean)

Adds await using statement.

Declaration
public static void AwaitUsing(Expression resource, Action<ParameterExpression> body, bool configureAwait = false)
Parameters
Type Name Description
Expression resource

The expression representing disposable resource.

Action<ParameterExpression> body

The body of the statement.

Boolean configureAwait

true to call ConfigureAwait(Boolean) with false argument when awaiting DisposeAsync() method.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

See Also
Using async disposable
| Improve this Doc View Source

Break()

Stops execution of the entire loop.

Declaration
public static void Break()
Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Break(LoopContext)

Stops execution the specified loop.

Declaration
public static void Break(LoopContext loop)
Parameters
Type Name Description
LoopContext loop

The loop reference.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Breakpoint()

Installs breakpoint.

Declaration
[Conditional("DEBUG")]
public static void Breakpoint()
Remarks

This method installs breakpoint in DEBUG configuration.

| Improve this Doc View Source

Call(Expression, MethodInfo, IEnumerable<Expression>)

Adds instance method call statement.

Declaration
public static void Call(Expression instance, MethodInfo method, IEnumerable<Expression> arguments)
Parameters
Type Name Description
Expression instance

this argument.

MethodInfo method

The method to be called.

IEnumerable<Expression> arguments

Method call arguments.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Call(Expression, MethodInfo, Expression[])

Adds instance method call statement.

Declaration
public static void Call(Expression instance, MethodInfo method, params Expression[] arguments)
Parameters
Type Name Description
Expression instance

this argument.

MethodInfo method

The method to be called.

Expression[] arguments

Method call arguments.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Call(Expression, String, Expression[])

Adds instance method call statement.

Declaration
public static void Call(Expression instance, string methodName, params Expression[] arguments)
Parameters
Type Name Description
Expression instance

this argument.

String methodName

The method to be called.

Expression[] arguments

Method call arguments.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

CallStatic(MethodInfo, IEnumerable<Expression>)

Adds static method call statement.

Declaration
public static void CallStatic(MethodInfo method, IEnumerable<Expression> arguments)
Parameters
Type Name Description
MethodInfo method

The method to be called.

IEnumerable<Expression> arguments

Method call arguments.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

CallStatic(MethodInfo, Expression[])

Adds static method call statement.

Declaration
public static void CallStatic(MethodInfo method, params Expression[] arguments)
Parameters
Type Name Description
MethodInfo method

The method to be called.

Expression[] arguments

Method call arguments.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

CallStatic(Type, String, Expression[])

Adds static method call.

Declaration
public static void CallStatic(Type type, string methodName, params Expression[] arguments)
Parameters
Type Name Description
Type type

The type that declares static method.

String methodName

The name of the static method.

Expression[] arguments

The arguments to be passed into static method.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

CallStatic<T>(String, Expression[])

Constructs static method call.

Declaration
public static void CallStatic<T>(string methodName, params Expression[] arguments)
Parameters
Type Name Description
String methodName

The name of the static method.

Expression[] arguments

The arguments to be passed into static method.

Type Parameters
Name Description
T

The type that declares static method.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Case(MatchBuilder, MatchBuilder.Pattern, Action<ParameterExpression>)

Defines pattern matching.

Declaration
public static MatchBuilder Case(this MatchBuilder builder, MatchBuilder.Pattern pattern, Action<ParameterExpression> body)
Parameters
Type Name Description
MatchBuilder builder

Pattern matching builder.

MatchBuilder.Pattern pattern

The condition representing pattern.

Action<ParameterExpression> body

The action to be executed if object matches to the pattern.

Returns
Type Description
MatchBuilder

this builder.

| Improve this Doc View Source

Case(MatchBuilder, Object, Action<ParameterExpression>)

Defines pattern matching based on structural matching.

Declaration
public static MatchBuilder Case(this MatchBuilder builder, object structPattern, Action<ParameterExpression> body)
Parameters
Type Name Description
MatchBuilder builder

Pattern matching builder.

Object structPattern

The structure pattern represented by instance of anonymous type.

Action<ParameterExpression> body

The action to be executed if object matches to the pattern.

Returns
Type Description
MatchBuilder

this builder.

| Improve this Doc View Source

Case(MatchBuilder, String, Expression, Action<MemberExpression>)

Defines pattern matching based on structural matching.

Declaration
public static MatchBuilder Case(this MatchBuilder builder, string memberName, Expression memberValue, Action<MemberExpression> body)
Parameters
Type Name Description
MatchBuilder builder

Pattern matching builder.

String memberName

The name of the field or property.

Expression memberValue

The expected value of the field or property.

Action<MemberExpression> body

The action to be executed if object matches to the pattern.

Returns
Type Description
MatchBuilder

this builder.

| Improve this Doc View Source

Case(MatchBuilder, String, Expression, String, Expression, Action<MemberExpression, MemberExpression>)

Defines pattern matching based on structural matching.

Declaration
public static MatchBuilder Case(this MatchBuilder builder, string memberName1, Expression memberValue1, string memberName2, Expression memberValue2, Action<MemberExpression, MemberExpression> body)
Parameters
Type Name Description
MatchBuilder builder

Pattern matching builder.

String memberName1

The name of the first field or property.

Expression memberValue1

The expected value of the first field or property.

String memberName2

The name of the second field or property.

Expression memberValue2

The expected value of the second field or property.

Action<MemberExpression, MemberExpression> body

The action to be executed if object matches to the pattern.

Returns
Type Description
MatchBuilder

this builder.

| Improve this Doc View Source

Case(MatchBuilder, String, Expression, String, Expression, String, Expression, Action<MemberExpression, MemberExpression, MemberExpression>)

Defines pattern matching based on structural matching.

Declaration
public static MatchBuilder Case(this MatchBuilder builder, string memberName1, Expression memberValue1, string memberName2, Expression memberValue2, string memberName3, Expression memberValue3, Action<MemberExpression, MemberExpression, MemberExpression> body)
Parameters
Type Name Description
MatchBuilder builder

Pattern matching builder.

String memberName1

The name of the first field or property.

Expression memberValue1

The expected value of the first field or property.

String memberName2

The name of the second field or property.

Expression memberValue2

The expected value of the second field or property.

String memberName3

The name of the third field or property.

Expression memberValue3

The expected value of the third field or property.

Action<MemberExpression, MemberExpression, MemberExpression> body

The action to be executed if object matches to the pattern.

Returns
Type Description
MatchBuilder

this builder.

| Improve this Doc View Source

Case(MatchBuilder, Type, MatchBuilder.Pattern, Action<ParameterExpression>)

Defines pattern matching based on the expected type of value.

Declaration
public static MatchBuilder Case(this MatchBuilder builder, Type expectedType, MatchBuilder.Pattern pattern, Action<ParameterExpression> body)
Parameters
Type Name Description
MatchBuilder builder

Pattern matching builder.

Type expectedType

The expected type of the value.

MatchBuilder.Pattern pattern

Additional condition associated with the value.

Action<ParameterExpression> body

The action to be executed if object matches to the pattern.

Returns
Type Description
MatchBuilder

this builder.

| Improve this Doc View Source

Case(MatchBuilder, Type, Action<ParameterExpression>)

Defines pattern matching based on the expected type of value.

Declaration
public static MatchBuilder Case(this MatchBuilder builder, Type expectedType, Action<ParameterExpression> body)
Parameters
Type Name Description
MatchBuilder builder

Pattern matching builder.

Type expectedType

The expected type of the value.

Action<ParameterExpression> body

The action to be executed if object matches to the pattern.

Returns
Type Description
MatchBuilder

this builder.

| Improve this Doc View Source

Case(SwitchBuilder, IEnumerable<Expression>, Action)

Specifies a pattern to compare to the match expression and action to be executed if matching is successful.

Declaration
public static SwitchBuilder Case(this SwitchBuilder builder, IEnumerable<Expression> testValues, Action body)
Parameters
Type Name Description
SwitchBuilder builder

Selection builder.

IEnumerable<Expression> testValues

A list of test values.

Action body

The block code to be executed if input value is equal to one of test values.

Returns
Type Description
SwitchBuilder

Modified selection builder.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Case(SwitchBuilder, Expression, Action)

Specifies a pattern to compare to the match expression and action to be executed if matching is successful.

Declaration
public static SwitchBuilder Case(this SwitchBuilder builder, Expression test, Action body)
Parameters
Type Name Description
SwitchBuilder builder

Selection builder.

Expression test

Single test value.

Action body

The block code to be executed if input value is equal to one of test values.

Returns
Type Description
SwitchBuilder

Modified selection builder.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Case<T>(MatchBuilder, MatchBuilder.Pattern, Action<ParameterExpression>)

Defines pattern matching based on the expected type of value.

Declaration
public static MatchBuilder Case<T>(this MatchBuilder builder, MatchBuilder.Pattern pattern, Action<ParameterExpression> body)
Parameters
Type Name Description
MatchBuilder builder

Pattern matching builder.

MatchBuilder.Pattern pattern

Additional condition associated with the value.

Action<ParameterExpression> body

The action to be executed if object matches to the pattern.

Returns
Type Description
MatchBuilder

this builder.

Type Parameters
Name Description
T

The expected type of the value.

| Improve this Doc View Source

Case<T>(MatchBuilder, Action<ParameterExpression>)

Defines pattern matching based on the expected type of value.

Declaration
public static MatchBuilder Case<T>(this MatchBuilder builder, Action<ParameterExpression> body)
Parameters
Type Name Description
MatchBuilder builder

Pattern matching builder.

Action<ParameterExpression> body

The action to be executed if object matches to the pattern.

Returns
Type Description
MatchBuilder

this builder.

Type Parameters
Name Description
T

The expected type of the value.

| Improve this Doc View Source

Catch(TryBuilder, Action)

Constructs exception handling section that may capture any exception.

Declaration
public static TryBuilder Catch(this TryBuilder builder, Action handler)
Parameters
Type Name Description
TryBuilder builder

Structured exception handling builder.

Action handler

Exception handling block.

Returns
Type Description
TryBuilder

Structured exception handler.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Catch(TryBuilder, Type, TryBuilder.Filter, Action<ParameterExpression>)

Constructs exception handling section.

Declaration
public static TryBuilder Catch(this TryBuilder builder, Type exceptionType, TryBuilder.Filter filter, Action<ParameterExpression> handler)
Parameters
Type Name Description
TryBuilder builder

Structured exception handling builder.

Type exceptionType

Expected exception.

TryBuilder.Filter filter

Additional filter to be applied to the caught exception.

Action<ParameterExpression> handler

Exception handling block.

Returns
Type Description
TryBuilder

Structured exception handler builder.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Catch(TryBuilder, Type, Action)

Constructs exception handling section.

Declaration
public static TryBuilder Catch(this TryBuilder builder, Type exceptionType, Action handler)
Parameters
Type Name Description
TryBuilder builder

Structured exception handling builder.

Type exceptionType

Expected exception.

Action handler

Exception handling block.

Returns
Type Description
TryBuilder

Structured exception handler.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Catch(TryBuilder, Type, Action<ParameterExpression>)

Constructs exception handling section.

Declaration
public static TryBuilder Catch(this TryBuilder builder, Type exceptionType, Action<ParameterExpression> handler)
Parameters
Type Name Description
TryBuilder builder

Structured exception handling builder.

Type exceptionType

Expected exception.

Action<ParameterExpression> handler

Exception handling block.

Returns
Type Description
TryBuilder

Structured exception handler.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Catch<TException>(TryBuilder, Action)

Constructs exception handling section.

Declaration
public static TryBuilder Catch<TException>(this TryBuilder builder, Action handler)

    where TException : Exception
Parameters
Type Name Description
TryBuilder builder

Structured exception handling builder.

Action handler

Exception handling block.

Returns
Type Description
TryBuilder

Structured exception handler.

Type Parameters
Name Description
TException

Expected exception.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Catch<TException>(TryBuilder, Action<ParameterExpression>)

Constructs exception handling section.

Declaration
public static TryBuilder Catch<TException>(this TryBuilder builder, Action<ParameterExpression> handler)

    where TException : Exception
Parameters
Type Name Description
TryBuilder builder

Structured exception handling builder.

Action<ParameterExpression> handler

Exception handling block.

Returns
Type Description
TryBuilder

Structured exception handler.

Type Parameters
Name Description
TException

Expected exception.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Continue()

Restarts execution of the entire loop.

Declaration
public static void Continue()
Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Continue(LoopContext)

Restarts execution of the loop.

Declaration
public static void Continue(LoopContext loop)
Parameters
Type Name Description
LoopContext loop

The loop reference.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

DebugMessage(Expression)

Writes line of the text into attached debugger.

Declaration
[Conditional("DEBUG")]
public static void DebugMessage(Expression value)
Parameters
Type Name Description
Expression value

The value to be written into attached debugger.

| Improve this Doc View Source

DeclareVariable(String, Expression)

Declares initialized local variable of automatically inferred type.

Declaration
public static ParameterExpression DeclareVariable(string name, Expression init)
Parameters
Type Name Description
String name

The name of the variable.

Expression init

Initialization expression.

Returns
Type Description
ParameterExpression

The expression representing local variable.

Remarks

The equivalent code is var i = expr;.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

DeclareVariable(Type, String)

Declares local variable in the current lexical scope.

Declaration
public static ParameterExpression DeclareVariable(Type variableType, string name)
Parameters
Type Name Description
Type variableType

The type of local variable.

String name

The name of local variable.

Returns
Type Description
ParameterExpression

The expression representing local variable.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

DeclareVariable<T>(String)

Declares local variable in the current lexical scope.

Declaration
public static ParameterExpression DeclareVariable<T>(string name)
Parameters
Type Name Description
String name

The name of local variable.

Returns
Type Description
ParameterExpression

The expression representing local variable.

Type Parameters
Name Description
T

The type of local variable.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Default(MatchBuilder, Action<ParameterExpression>)

Defines default behavior in case when all defined patterns are false positive.

Declaration
public static MatchBuilder Default(this MatchBuilder builder, Action<ParameterExpression> body)
Parameters
Type Name Description
MatchBuilder builder

Pattern matching builder.

Action<ParameterExpression> body

The body to be executed as default case.

Returns
Type Description
MatchBuilder

this builder.

| Improve this Doc View Source

Default(SwitchBuilder, Action)

Specifies the switch section to execute if the match expression doesn't match any other cases.

Declaration
public static SwitchBuilder Default(this SwitchBuilder builder, Action body)
Parameters
Type Name Description
SwitchBuilder builder

Selection builder.

Action body

The block code to be executed if input value is equal to one of test values.

Returns
Type Description
SwitchBuilder

Modified selection builder.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

DoWhile(Expression, Action)

Adds do{ } while(condition); loop statement.

Declaration
public static void DoWhile(Expression test, Action body)
Parameters
Type Name Description
Expression test

Loop continuation condition.

Action body

Loop body.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

See Also
do-while Statement
| Improve this Doc View Source

DoWhile(Expression, Action<LoopContext>)

Adds do{ } while(condition); loop statement.

Declaration
public static void DoWhile(Expression test, Action<LoopContext> body)
Parameters
Type Name Description
Expression test

Loop continuation condition.

Action<LoopContext> body

Loop body.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

See Also
do-while Statement
| Improve this Doc View Source

Else(ConditionalBuilder, Action)

Constructs negative branch of the conditional expression.

Declaration
public static ConditionalBuilder Else(this ConditionalBuilder builder, Action body)
Parameters
Type Name Description
ConditionalBuilder builder

Conditional statement builder.

Action body

Branch builder.

Returns
Type Description
ConditionalBuilder

Conditional expression builder.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Embed<TDelegate>(Expression<TDelegate>, Expression[])

Inserts expression tree as a statement.

Declaration
public static void Embed<TDelegate>(Expression<TDelegate> lambda, params Expression[] arguments)

    where TDelegate : MulticastDelegate
Parameters
Type Name Description
Expression<TDelegate> lambda

The expression to be inserted as statement.

Expression[] arguments

The arguments used to replace lambda parameters.

Type Parameters
Name Description
TDelegate

The type of the delegate describing lambda call site.

| Improve this Doc View Source

Fault(TryBuilder, Action)

Constructs block of code which will be executed in case of any exception.

Declaration
public static TryBuilder Fault(this TryBuilder builder, Action fault)
Parameters
Type Name Description
TryBuilder builder

Structured exception handling builder.

Action fault

Fault handling block.

Returns
Type Description
TryBuilder

this builder.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Finally(TryBuilder, Action)

Constructs block of code run when control leaves a try statement.

Declaration
public static TryBuilder Finally(this TryBuilder builder, Action body)
Parameters
Type Name Description
TryBuilder builder

Structured exception handling builder.

Action body

The block of code to be executed.

Returns
Type Description
TryBuilder

this builder.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

For(Expression, ForExpression.LoopBuilder.Condition, Action<ParameterExpression>, Action<ParameterExpression, LoopContext>)

Adds for loop statement.

Declaration
public static void For(Expression initializer, ForExpression.LoopBuilder.Condition condition, Action<ParameterExpression> iteration, Action<ParameterExpression, LoopContext> body)
Parameters
Type Name Description
Expression initializer

Loop variable initialization expression.

ForExpression.LoopBuilder.Condition condition

Loop continuation condition.

Action<ParameterExpression> iteration

Iteration statements.

Action<ParameterExpression, LoopContext> body

Loop body.

Remarks

This builder constructs the statement equivalent to for(var i = initializer; condition; iter){ body; }.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

See Also
for Statement
| Improve this Doc View Source

For(Expression, ForExpression.LoopBuilder.Condition, Action<ParameterExpression>, Action<ParameterExpression>)

Adds for loop statement.

Declaration
public static void For(Expression initializer, ForExpression.LoopBuilder.Condition condition, Action<ParameterExpression> iteration, Action<ParameterExpression> body)
Parameters
Type Name Description
Expression initializer

Loop variable initialization expression.

ForExpression.LoopBuilder.Condition condition

Loop continuation condition.

Action<ParameterExpression> iteration

Iteration statements.

Action<ParameterExpression> body

Loop body.

Remarks

This builder constructs the statement equivalent to for(var i = initializer; condition; iter){ body; }.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

See Also
for Statement
| Improve this Doc View Source

ForEach(Expression, Action<MemberExpression, LoopContext>)

Adds foreach loop statement.

Declaration
public static void ForEach(Expression collection, Action<MemberExpression, LoopContext> body)
Parameters
Type Name Description
Expression collection

The expression providing enumerable collection.

Action<MemberExpression, LoopContext> body

Loop body.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

See Also
foreach Statement
| Improve this Doc View Source

ForEach(Expression, Action<MemberExpression>)

Adds foreach loop statement.

Declaration
public static void ForEach(Expression collection, Action<MemberExpression> body)
Parameters
Type Name Description
Expression collection

The expression providing enumerable collection.

Action<MemberExpression> body

Loop body.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

See Also
foreach Statement
| Improve this Doc View Source

Goto(LabelTarget)

Adds unconditional control transfer statement to this scope.

Declaration
public static void Goto(LabelTarget target)
Parameters
Type Name Description
LabelTarget target

The label reference.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Goto(LabelTarget, Expression)

Adds unconditional control transfer statement to this scope.

Declaration
public static void Goto(LabelTarget target, Expression value)
Parameters
Type Name Description
LabelTarget target

The label reference.

Expression value

The value to be associated with the control transfer.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

If(Expression)

Adds if-then-else statement to this scope.

Declaration
public static ConditionalBuilder If(Expression test)
Parameters
Type Name Description
Expression test

Test expression.

Returns
Type Description
ConditionalBuilder

Conditional statement builder.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

IfThen(Expression, Action)

Adds if-then statement to this scope.

Declaration
public static void IfThen(Expression test, Action ifTrue)
Parameters
Type Name Description
Expression test

Test expression.

Action ifTrue

Positive branch builder.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

IfThenElse(Expression, Action, Action)

Adds if-then-else statement to this scope.

Declaration
public static void IfThenElse(Expression test, Action ifTrue, Action ifFalse)
Parameters
Type Name Description
Expression test

Test expression.

Action ifTrue

Positive branch builder.

Action ifFalse

Negative branch builder.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

InPlaceValue<T>(T)

Adds constant as in-place statement.

Declaration
public static void InPlaceValue<T>(T value)
Parameters
Type Name Description
T value

The value to be placed as statement.

Type Parameters
Name Description
T

The type of the constant.

| Improve this Doc View Source

Invoke(Expression, IEnumerable<Expression>)

Adds invocation statement.

Declaration
public static void Invoke(Expression delegate, IEnumerable<Expression> arguments)
Parameters
Type Name Description
Expression delegate

The expression providing delegate to be invoked.

IEnumerable<Expression> arguments

Delegate invocation arguments.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Invoke(Expression, Expression[])

Adds invocation statement.

Declaration
public static void Invoke(Expression delegate, params Expression[] arguments)
Parameters
Type Name Description
Expression delegate

The expression providing delegate to be invoked.

Expression[] arguments

Delegate invocation arguments.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Label()

Declares label in the current scope.

Declaration
public static LabelTarget Label()
Returns
Type Description
LabelTarget

Declared label.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Label(LabelTarget)

Adds label landing site to this scope.

Declaration
public static void Label(LabelTarget target)
Parameters
Type Name Description
LabelTarget target

The label target.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Label(Type, String)

Declares label of the specified type.

Declaration
public static LabelTarget Label(Type type, string name = null)
Parameters
Type Name Description
Type type

The type of landing site.

String name

The optional name of the label.

Returns
Type Description
LabelTarget

Declared label.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Label<T>(String)

Declares label of the specified type.

Declaration
public static LabelTarget Label<T>(string name = null)
Parameters
Type Name Description
String name

The optional name of the label.

Returns
Type Description
LabelTarget

Declared label.

Type Parameters
Name Description
T

The type of landing site.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Lambda<TDelegate>(Action<LambdaContext, ParameterExpression>)

Constructs multi-line lambda function capturing the current lexical scope.

Declaration
public static Expression<TDelegate> Lambda<TDelegate>(Action<LambdaContext, ParameterExpression> body)

    where TDelegate : Delegate
Parameters
Type Name Description
Action<LambdaContext, ParameterExpression> body

Lambda function builder.

Returns
Type Description
Expression<TDelegate>

Constructed lambda expression.

Type Parameters
Name Description
TDelegate

The delegate describing signature of lambda function.

| Improve this Doc View Source

Lambda<TDelegate>(Action<LambdaContext>)

Constructs multi-line lambda function capturing the current lexical scope.

Declaration
public static Expression<TDelegate> Lambda<TDelegate>(Action<LambdaContext> body)

    where TDelegate : Delegate
Parameters
Type Name Description
Action<LambdaContext> body

Lambda function builder.

Returns
Type Description
Expression<TDelegate>

Constructed lambda expression.

Type Parameters
Name Description
TDelegate

The delegate describing signature of lambda function.

| Improve this Doc View Source

Lambda<TDelegate>(Boolean, Action<LambdaContext, ParameterExpression>)

Constructs multi-line lambda function capturing the current lexical scope.

Declaration
public static Expression<TDelegate> Lambda<TDelegate>(bool tailCall, Action<LambdaContext, ParameterExpression> body)

    where TDelegate : Delegate
Parameters
Type Name Description
Boolean tailCall

true if the lambda expression will be compiled with the tail call optimization, otherwise false.

Action<LambdaContext, ParameterExpression> body

Lambda function builder.

Returns
Type Description
Expression<TDelegate>

Constructed lambda expression.

Type Parameters
Name Description
TDelegate

The delegate describing signature of lambda function.

| Improve this Doc View Source

Lambda<TDelegate>(Boolean, Action<LambdaContext>)

Constructs multi-line lambda function capturing the current lexical scope.

Declaration
public static Expression<TDelegate> Lambda<TDelegate>(bool tailCall, Action<LambdaContext> body)

    where TDelegate : Delegate
Parameters
Type Name Description
Boolean tailCall

true if the lambda expression will be compiled with the tail call optimization, otherwise false.

Action<LambdaContext> body

Lambda function builder.

Returns
Type Description
Expression<TDelegate>

Constructed lambda expression.

Type Parameters
Name Description
TDelegate

The delegate describing signature of lambda function.

| Improve this Doc View Source

Lambda<TDelegate>(Boolean, Func<LambdaContext, Expression>)

Constructs single-line lambda function capturing the current lexical scope.

Declaration
public static Expression<TDelegate> Lambda<TDelegate>(bool tailCall, Func<LambdaContext, Expression> body)

    where TDelegate : Delegate
Parameters
Type Name Description
Boolean tailCall

true if the lambda expression will be compiled with the tail call optimization, otherwise false.

Func<LambdaContext, Expression> body

Lambda function builder.

Returns
Type Description
Expression<TDelegate>

Constructed lambda expression.

Type Parameters
Name Description
TDelegate

The delegate describing signature of lambda function.

| Improve this Doc View Source

Lambda<TDelegate>(Func<LambdaContext, Expression>)

Constructs single-line lambda function capturing the current lexical scope.

Declaration
public static Expression<TDelegate> Lambda<TDelegate>(Func<LambdaContext, Expression> body)

    where TDelegate : Delegate
Parameters
Type Name Description
Func<LambdaContext, Expression> body

Lambda function builder.

Returns
Type Description
Expression<TDelegate>

Constructed lambda expression.

Type Parameters
Name Description
TDelegate

The delegate describing signature of lambda function.

| Improve this Doc View Source

Lock(Expression, Action)

Adds lock statement.

Declaration
public static void Lock(Expression syncRoot, Action body)
Parameters
Type Name Description
Expression syncRoot

The object to be locked during execution of the compound statement.

Action body

Synchronized scope of code.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

See Also
lock Statement
| Improve this Doc View Source

Lock(Expression, Action<ParameterExpression>)

Adds lock statement.

Declaration
public static void Lock(Expression syncRoot, Action<ParameterExpression> body)
Parameters
Type Name Description
Expression syncRoot

The object to be locked during execution of the compound statement.

Action<ParameterExpression> body

Synchronized scope of code.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

See Also
lock Statement
| Improve this Doc View Source

Loop(Action)

Adds generic loop statement.

Declaration
public static void Loop(Action body)
Parameters
Type Name Description
Action body

Loop body.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Loop(Action<LoopContext>)

Adds generic loop statement.

Declaration
public static void Loop(Action<LoopContext> body)
Parameters
Type Name Description
Action<LoopContext> body

Loop body.

Remarks

This loop is equivalent to while(true){ }.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Match(Expression)

Adds pattern match statement.

Declaration
public static MatchBuilder Match(Expression value)
Parameters
Type Name Description
Expression value

The value to be matched with patterns.

Returns
Type Description
MatchBuilder

Pattern matcher.

| Improve this Doc View Source

Nop()

Adds no-operation instruction to this scope.

Declaration
public static void Nop()
Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

NullCoalescingAssignment(IndexExpression, Expression)

Adds an expression that represents null-coalescing assignment of array element of indexer property.

Declaration
public static void NullCoalescingAssignment(IndexExpression indexer, Expression right)
Parameters
Type Name Description
IndexExpression indexer

The indexer property or array element to be assigned.

Expression right

The value to assign to indexer if it is null.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

ArgumentException

right is not assignable to indexer.

| Improve this Doc View Source

NullCoalescingAssignment(MemberExpression, Expression)

Adds an expression that represents null-coalescing assignment of property of field.

Declaration
public static void NullCoalescingAssignment(MemberExpression member, Expression right)
Parameters
Type Name Description
MemberExpression member

The member to be assigned.

Expression right

The value to assign to member if it is null.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

ArgumentException

right is not assignable to member.

| Improve this Doc View Source

NullCoalescingAssignment(ParameterExpression, Expression)

Adds an expression that represents null-coalescing assignment of local variable.

Declaration
public static void NullCoalescingAssignment(ParameterExpression variable, Expression right)
Parameters
Type Name Description
ParameterExpression variable

The variable to be assigned.

Expression right

The value to assigned to variable if it is null.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

ArgumentException

right is not assignable to variable.

| Improve this Doc View Source

NullSafeCall(Expression, MethodInfo, IEnumerable<Expression>)

Adds instance method call statement which is not invoked if instance is null.

Declaration
public static void NullSafeCall(Expression instance, MethodInfo method, IEnumerable<Expression> arguments)
Parameters
Type Name Description
Expression instance

this argument.

MethodInfo method

The method to be called.

IEnumerable<Expression> arguments

Method call arguments.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

NullSafeCall(Expression, MethodInfo, Expression[])

Adds instance method call statement which is not invoked if instance is null.

Declaration
public static void NullSafeCall(Expression instance, MethodInfo method, params Expression[] arguments)
Parameters
Type Name Description
Expression instance

this argument.

MethodInfo method

The method to be called.

Expression[] arguments

Method call arguments.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

NullSafeCall(Expression, String, Expression[])

Adds instance method call statement which is not invoked if instance is null.

Declaration
public static void NullSafeCall(Expression instance, string methodName, params Expression[] arguments)
Parameters
Type Name Description
Expression instance

this argument.

String methodName

The method to be called.

Expression[] arguments

Method call arguments.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

NullSafeInvoke(Expression, IEnumerable<Expression>)

Adds invocation statement which is not invoked if delegate is null.

Declaration
public static void NullSafeInvoke(Expression delegate, IEnumerable<Expression> arguments)
Parameters
Type Name Description
Expression delegate

The expression providing delegate to be invoked.

IEnumerable<Expression> arguments

Delegate invocation arguments.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

NullSafeInvoke(Expression, Expression[])

Adds invocation statement which is not invoked if delegate is null.

Declaration
public static void NullSafeInvoke(Expression delegate, params Expression[] arguments)
Parameters
Type Name Description
Expression delegate

The expression providing delegate to be invoked.

Expression[] arguments

Delegate invocation arguments.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

PostDecrementAssign(IndexExpression)

Adds an expression that represents the assignment of given field or property followed by a subsequent decrement by 1 of the original member.

Declaration
public static void PostDecrementAssign(IndexExpression member)
Parameters
Type Name Description
IndexExpression member

The member to be modified.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

PostDecrementAssign(MemberExpression)

Adds an expression that represents the assignment of given field or property followed by a subsequent decrement by 1 of the original member.

Declaration
public static void PostDecrementAssign(MemberExpression member)
Parameters
Type Name Description
MemberExpression member

The member to be modified.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

PostDecrementAssign(ParameterExpression)

Adds an expression that represents the assignment of given variable followed by a subsequent decrement by 1 of the original variable.

Declaration
public static void PostDecrementAssign(ParameterExpression variable)
Parameters
Type Name Description
ParameterExpression variable

The variable to be modified.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

PostIncrementAssign(IndexExpression)

Adds an expression that represents the assignment of given field or property followed by a subsequent increment by 1 of the original member.

Declaration
public static void PostIncrementAssign(IndexExpression member)
Parameters
Type Name Description
IndexExpression member

The member to be modified.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

PostIncrementAssign(MemberExpression)

Adds an expression that represents the assignment of given field or property followed by a subsequent increment by 1 of the original member.

Declaration
public static void PostIncrementAssign(MemberExpression member)
Parameters
Type Name Description
MemberExpression member

The member to be modified.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

PostIncrementAssign(ParameterExpression)

Adds an expression that represents the assignment of given variable followed by a subsequent increment by 1 of the original variable.

Declaration
public static void PostIncrementAssign(ParameterExpression variable)
Parameters
Type Name Description
ParameterExpression variable

The variable to be modified.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

PreDecrementAssign(IndexExpression)

Adds an expression that decrements given field or property by 1 and assigns the result back to the member.

Declaration
public static void PreDecrementAssign(IndexExpression member)
Parameters
Type Name Description
IndexExpression member

The member to be modified.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

PreDecrementAssign(MemberExpression)

Adds an expression that decrements given field or property by 1 and assigns the result back to the member.

Declaration
public static void PreDecrementAssign(MemberExpression member)
Parameters
Type Name Description
MemberExpression member

The member to be modified.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

PreDecrementAssign(ParameterExpression)

Adds an expression that decrements given variable by 1 and assigns the result back to the variable.

Declaration
public static void PreDecrementAssign(ParameterExpression variable)
Parameters
Type Name Description
ParameterExpression variable

The variable to be modified.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

PreIncrementAssign(IndexExpression)

Adds an expression that increments given field or property by 1 and assigns the result back to the member.

Declaration
public static void PreIncrementAssign(IndexExpression member)
Parameters
Type Name Description
IndexExpression member

The member to be modified.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

PreIncrementAssign(MemberExpression)

Adds an expression that increments given field or property by 1 and assigns the result back to the member.

Declaration
public static void PreIncrementAssign(MemberExpression member)
Parameters
Type Name Description
MemberExpression member

The member to be modified.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

PreIncrementAssign(ParameterExpression)

Adds an expression that increments given variable by 1 and assigns the result back to the variable.

Declaration
public static void PreIncrementAssign(ParameterExpression variable)
Parameters
Type Name Description
ParameterExpression variable

The variable to be modified.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Rethrow()

Adds re-throw statement.

Declaration
public static void Rethrow()
Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of catch clause.

| Improve this Doc View Source

Return(Expression)

Adds return instruction to return from underlying lambda function having non-Void return type.

Declaration
public static void Return(Expression result = null)
Parameters
Type Name Description
Expression result

Optional value to be returned from the lambda function.

Exceptions
Type Condition
InvalidOperationException

This method is not called from within body of lambda function.

| Improve this Doc View Source

Switch(Expression)

Adds selection expression.

Declaration
public static SwitchBuilder Switch(Expression value)
Parameters
Type Name Description
Expression value

The value to be handled by the selection expression.

Returns
Type Description
SwitchBuilder

A new instance of selection expression builder.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

See Also
switch Statement
| Improve this Doc View Source

Then(ConditionalBuilder, Action)

Constructs positive branch of the conditional expression.

Declaration
public static ConditionalBuilder Then(this ConditionalBuilder builder, Action body)
Parameters
Type Name Description
ConditionalBuilder builder

Conditional statement builder.

Action body

Branch builder.

Returns
Type Description
ConditionalBuilder

Conditional expression builder.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Throw(Expression)

Adds throw statement to the compound statement.

Declaration
public static void Throw(Expression exception)
Parameters
Type Name Description
Expression exception

The exception to be thrown.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Throw<TException>()

Adds throw statement to the compound statement.

Declaration
public static void Throw<TException>()

    where TException : Exception, new()
Type Parameters
Name Description
TException

The exception to be thrown.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Improve this Doc View Source

Try(Action)

Adds structured exception handling statement.

Declaration
public static TryBuilder Try(Action scope)
Parameters
Type Name Description
Action scope

try block builder.

Returns
Type Description
TryBuilder

Structured exception handling builder.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

See Also
try-catch-finally Statement
| Improve this Doc View Source

Try(Expression)

Adds structured exception handling statement.

Declaration
public static TryBuilder Try(Expression body)
Parameters
Type Name Description
Expression body

try block.

Returns
Type Description
TryBuilder

Structured exception handling builder.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

See Also
try-catch-finally Statement
| Improve this Doc View Source

Using(Expression, Action)

Adds using statement.

Declaration
public static void Using(Expression resource, Action body)
Parameters
Type Name Description
Expression resource

The expression representing disposable resource.

Action body

The body of the statement.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

See Also
using Statement
| Improve this Doc View Source

Using(Expression, Action<ParameterExpression>)

Adds using statement.

Declaration
public static void Using(Expression resource, Action<ParameterExpression> body)
Parameters
Type Name Description
Expression resource

The expression representing disposable resource.

Action<ParameterExpression> body

The body of the statement.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

See Also
using Statement
| Improve this Doc View Source

Variable(String)

Obtains local variable declared in the current or outer lexical scope.

Declaration
public static ParameterExpression Variable(string name)
Parameters
Type Name Description
String name

The name of the local variable.

Returns
Type Description
ParameterExpression

Declared local variable; or null, if there is no declared local variable with the given name.

| Improve this Doc View Source

While(Expression, Action)

Adds while loop statement.

Declaration
public static void While(Expression test, Action body)
Parameters
Type Name Description
Expression test

Loop continuation condition.

Action body

Loop body.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

See Also
while Statement
| Improve this Doc View Source

While(Expression, Action<LoopContext>)

Adds while loop statement.

Declaration
public static void While(Expression test, Action<LoopContext> body)
Parameters
Type Name Description
Expression test

Loop continuation condition.

Action<LoopContext> body

Loop body.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

See Also
while Statement
| Improve this Doc View Source

With(Expression, Action<ParameterExpression>)

Adds compound statement hat repeatedly refer to a single object or structure so that the statements can use a simplified syntax when accessing members of the object or structure.

Declaration
public static void With(Expression expression, Action<ParameterExpression> body)
Parameters
Type Name Description
Expression expression

The implicitly referenced object.

Action<ParameterExpression> body

The statement body.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

See Also
With..End Statement
| Improve this Doc View Source

WriteError(Expression)

Writes line of the text into Error.

Declaration
public static void WriteError(Expression value)
Parameters
Type Name Description
Expression value

The value to be written into stderr.

| Improve this Doc View Source

WriteLine(Expression)

Writes line of the text into Out.

Declaration
public static void WriteLine(Expression value)
Parameters
Type Name Description
Expression value

The value to be written into stdout.

  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX