### Collection Initializers Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/csharp-testdata.txt Examples of collection and list initializers. ```csharp () => new List() { "abcd", "efgh" } ``` ```csharp () => new Wrapper() { { "ab", "cd" }, { "ef", "gh" } } ``` ```csharp () => new Wrapper() { { "ab", "cd" }, "ef" } ``` ```csharp () => new Node() { Children = { new Node(), new Node() } } ``` -------------------------------- ### Object Initialization Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/csharp-testdata.txt Examples of object instantiation and member initialization. ```csharp () => new Node() { Data = { Name = "abcd" } } ``` ```csharp () => new Random() ``` ```csharp () => new Foo("ijkl") ``` ```csharp () => new Foo("ijkl") { Bar = "abcd", Baz = "efgh" } ``` ```csharp () => new Foo() { Bar = "abcd" } ``` ```csharp () => new Foo() { Bar = "abcd", Baz = "efgh" } ``` -------------------------------- ### Array Operations Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/visualbasic-testdata.txt Examples of array indexing, length, and initialization. ```vbnet Function() arr(0) ``` ```vbnet Function() arr.Length ``` ```vbnet Function() arr(5, 6) ``` ```vbnet Function() New String(4)(,) {} ``` ```vbnet Function() arr(5) ``` ```vbnet Function() New String(4)() {} ``` ```vbnet Function() New Object()() { ({ "ab", "cd" }), ({ "ef", "gh" }) } ``` ```vbnet Function() { ({ "ab", "cd" }), ({ "ef", "gh" }) } ``` ```vbnet Function() New String(2, 1)() {} ``` ```vbnet Function() New String(1, 2) {} ``` ```vbnet Function() { "" } ``` ```vbnet Function() New Object() { "" } ``` ```vbnet Function() New String(4) {} ``` -------------------------------- ### Array Operations Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/csharp-testdata.txt Examples of array indexing, length, and initialization. ```csharp () => arr[0] ``` ```csharp () => arr.Length ``` ```csharp () => arr[5, 6] ``` ```csharp () => new string[5][,] ``` ```csharp () => arr[5] ``` ```csharp () => new string[5][] ``` ```csharp () => new object[][] { new[] { "ab", "cd" }, new[] { "ef", "gh" } } ``` ```csharp () => new string[][] { new[] { "ab", "cd" }, new[] { "ef", "gh" } } ``` ```csharp () => new string[3, 2][] ``` ```csharp () => new string[2, 3] ``` ```csharp () => new[] { "" } ``` ```csharp () => new object[] { "" } ``` ```csharp () => new string[5] ``` -------------------------------- ### Object and Collection Initialization Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/visualbasic-testdata.txt Examples of creating objects and collections with initializers. ```vbnet Function() New With { .Bar = "abcd", .Baz = "efgh" } ``` ```vbnet Function() New With { Bar, Baz } ``` ```vbnet Function() New List(Of String) From { "abcd", "efgh" } ``` ```vbnet Function() New Wrapper From { { "ab", "cd" }, { "ef", "gh" } } ``` ```vbnet Function() New Wrapper From { { "ab", "cd" }, "ef" } ``` ```vbnet Function() New Node With { .Children = From { New Node, New Node } } ``` ```vbnet Function() New Node With { .Data = With { .Name = "abcd" } } ``` ```vbnet Function() New Random ``` ```vbnet Function() New Foo("ijkl") ``` ```vbnet Function() New Foo("ijkl") With { .Bar = "abcd", .Baz = "efgh" } ``` ```vbnet Function() New Foo With { .Bar = "abcd" } ``` ```vbnet Function() New Foo With { .Bar = "abcd", .Baz = "efgh" } ``` -------------------------------- ### Collection Initializers Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/visualbasic-testdata.txt Examples of initializing collections with single or multiple elements. ```vb New List(Of String) From { "abcd", "efgh" } ``` ```vb New Wrapper From { { "ab", "cd" }, { "ef", "gh" } } ``` ```vb New Wrapper From { { "ab", "cd" }, "ef" } ``` -------------------------------- ### Method Invocations Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/csharp-testdata.txt Examples of calling instance, static, and extension methods. ```csharp () => lst.Count() ``` ```csharp () => lst.ExtensionMethod1Argument(1) ``` ```csharp () => lst.ExtensionMethod2Arguments(5, 17) ``` ```csharp () => s.ToString() ``` ```csharp () => s.CompareTo("") ``` ```csharp () => s.IndexOf('a', 2) ``` ```csharp () => del() ``` ```csharp () => del(5) ``` ```csharp (double x, double y) => Math.Pow(x, y) ``` ```csharp () => Dummy.DummyMethod() ``` ```csharp () => string.Intern("") ``` ```csharp () => string.Join(",", new[] { "a", "b" }) ``` -------------------------------- ### String Operations Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/factorymethods-testdata.txt Examples of string constants and concatenation operations. ```csharp Lambda( Constant("abcd") ) ``` ```csharp var s1 = Parameter( typeof(string), "s1" ); var s2 = Parameter( typeof(string), "s2" ); Lambda( Call( typeof(string).GetMethod("Concat", 0, new[] { typeof(string), typeof(string) }), s1, s2 ), s1, s2 ) ``` ```csharp var s1 = Parameter( typeof(string), "s1" ); var s2 = Parameter( typeof(string), "s2" ); Lambda( Call( typeof(string).GetMethod("Concat", 0, new[] { typeof(string), typeof(string) }), s1, s2 ), s1, s2 ) ``` ```csharp var s1 = Parameter( typeof(string), "s1" ); var s2 = Parameter( typeof(string), "s2" ); Lambda( Call( typeof(string).GetMethod("Concat", 0, new[] { typeof(string[]) }), NewArrayInit( typeof(string), s1, s2, s1, s2, s1, s2 ) ), s1, s2 ) ``` -------------------------------- ### Method Invocations and Members Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/visualbasic-testdata.txt Examples of calling methods and accessing members. ```vbnet Function() lst.Count ``` ```vbnet Function() lst.ExtensionMethod2Arguments(5, 17) ``` ```vbnet Function() s.Length ``` ```vbnet Function() s.ToString ``` ```vbnet Function() s.CompareTo("") ``` ```vbnet Function() s.IndexOf("a"C, 2) ``` ```vbnet Function() del() ``` ```vbnet Function() del(5) ``` ```vbnet Function() String.Empty ``` ```vbnet Sub() Dummy.DummyMethod ``` ```vbnet Function() String.Intern("") ``` ```vbnet Function() String.Join(",", { "a", "b" }) ``` -------------------------------- ### Collection Initializer Expressions Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/csharp-testdata.txt Examples of initializing collections with single or multiple elements. ```csharp new List() { "abcd", "efgh" } ``` ```csharp new Wrapper() { { "ab", "cd" }, { "ef", "gh" } } ``` ```csharp new Wrapper() { { "ab", "cd" }, "ef" } ``` -------------------------------- ### Array Creation Expressions Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/csharp-testdata.txt Examples of creating arrays and multidimensional arrays. ```csharp new[] { "abcd", 5, #Random } ``` ```csharp new string[5][,] ``` -------------------------------- ### Parameter Naming Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/csharp-testdata.txt Examples of unnamed and whitespace-containing parameter names. ```csharp (string $var0) => $var0 == $var0 ``` ```csharp (string $x_y) => $x_y ``` -------------------------------- ### Logical and Comparison Operations Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/visualbasic-testdata.txt Examples of logical and comparison operators. ```vbnet Function() b1 AndAlso b2 ``` ```vbnet Function() b1 And b2 ``` ```vbnet Function() b1 Xor b2 ``` ```vbnet Function() i = j ``` ```vbnet Function() i > j ``` ```vbnet Function() i >= j ``` ```vbnet Function() i < j ``` ```vbnet Function() i <= j ``` ```vbnet Function() Not b ``` ```vbnet Function() i <> j ``` ```vbnet Function() b1 OrElse b2 ``` ```vbnet Function() b1 Or b2 ``` -------------------------------- ### Named Type Initializers Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/csharp-testdata.txt Examples of object initialization syntax within expression trees. ```csharp new Foo() { Bar = "abcd" } ``` ```csharp new Foo() { Bar = "abcd", Baz = "efgh" } ``` -------------------------------- ### Label Expressions Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/csharp-testdata.txt Examples of label targets and label expressions. ```csharp ( int i, ( int j, true, target: true ) ) ``` ```csharp ( int i, ( int j, target: true ) ) ``` ```csharp target ``` -------------------------------- ### Dynamic and Array Operations Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/visualbasic-testdata.txt Examples of dynamic operations and array initialization with bounds. ```VB.NET x + y ``` ```VB.NET CInt(x) ``` ```VB.NET Not b1 ``` ```VB.NET Function() New String(bounds) {} ``` ```VB.NET Function() New String(bound1, bound2) {} ``` ```VB.NET Function() New String(bound)() {} ``` -------------------------------- ### Logical and Bitwise Operations Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/csharp-testdata.txt Examples of logical and bitwise operators. ```csharp () => b1 && b2 ``` ```csharp () => i & j ``` ```csharp () => b1 & b2 ``` ```csharp () => ~i ``` ```csharp () => i ^ j ``` ```csharp () => b1 ^ b2 ``` ```csharp () => !b ``` ```csharp () => i | j ``` ```csharp () => b1 || b2 ``` ```csharp () => b1 | b2 ``` ```csharp () => i << j ``` ```csharp () => i >> j ``` -------------------------------- ### SQL Mapping Example Source: https://github.com/zspitz/expressiontreetostring/wiki/Overview-of-.NET-expression-trees Demonstrates how LINQ queries are represented as expression trees to be translated into SQL. ```sql SELECT * FROM Persons WHERE Persons.LastName LIKE N'D%' ``` ```csharp IQueryable personSource = ... ; var qry = personQuery.Where(x => x.LastName.StartsWith("D"); ``` ```vb Dim personSource As IQueryable(Of Person) = ... Dim qry = personQuery.Where(Function(x) x.LastName.StartsWith("D)) ``` -------------------------------- ### Anonymous Types Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/csharp-testdata.txt Examples of creating anonymous types. ```csharp () => new { Bar = "abcd", Baz = "efgh" } ``` ```csharp () => new { Bar, Baz } ``` -------------------------------- ### Extension Methods Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/visualbasic-testdata.txt Examples of calling extension methods with varying arguments and conversions. ```VB.NET Function() lst.ExtensionMethod1Argument(1) ``` ```VB.NET Function() lst.ExtensionMethod1ArgumentEnumerable(1) ``` ```VB.NET Function() lst.ExtensionMethod2Arguments(5, 17) ``` ```VB.NET Function() lst.ExtensionMethod2ArgumentsEnumerable(5, 6) ``` ```C# Function() lst.ExtensionMethod1Argument(1) ``` ```Factory lstString.ExtensionMethod1Argument(1) ``` ```Factory lstString.ExtensionMethod2Arguments(5, 17) ``` ```VB.NET Function() lst.Count ``` -------------------------------- ### Miscellaneous Expressions Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/csharp-testdata.txt Other miscellaneous expression tree examples. ```csharp #Random ``` ```csharp ( string s2, true // variables -- double x, string s1 ) ``` ```csharp s1 + s2 ``` -------------------------------- ### Dynamic Operations Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/csharp-testdata.txt Examples of dynamic member access and method invocation. ```csharp obj["key"] ``` ```csharp obj["key", 1] ``` ```csharp obj.Data ``` ```csharp obj() ``` ```csharp obj("arg1", 15) ``` ```csharp obj.Method() ``` ```csharp obj.Method("arg1", 15) ``` -------------------------------- ### Member Access and Method Calls Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/factorymethods-testdata.txt Examples of accessing instance members and calling methods with various argument counts. ```C# var s = Parameter( typeof(string), "s" ); Lambda( MakeMemberAccess( s, typeof(string).GetProperty("Length") ) ) ``` ```C# var s = Parameter( typeof(string), "s" ); Lambda( Call( s, typeof(string).GetMethod("ToString", new Type[] { }) ) ) ``` ```C# var s = Parameter( typeof(string), "s" ); Lambda( Call( s, typeof(string).GetMethod("CompareTo", new[] { typeof(string) }), Constant("") ) ) ``` ```C# var s = Parameter( typeof(string), "s" ); Lambda( Call( s, typeof(string).GetMethod("IndexOf", new[] { typeof(char), typeof(int) }), Constant('a'), Constant(2) ) ) ``` -------------------------------- ### Conditional and Comparison Operators Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/csharp-testdata.txt Examples of conditional logic and comparison operators. ```csharp (int i) => i > 10 ? i : i + 10 ``` ```csharp () => i == j ``` ```csharp () => i > j ``` ```csharp () => i >= j ``` ```csharp () => i < j ``` ```csharp () => i <= j ``` ```csharp () => i != j ``` -------------------------------- ### Bitwise and Logical Operations Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/factorymethods-testdata.txt Examples of Or, OrElse, and logical Or operations on parameters. ```csharp var i = Parameter( typeof(int), "i" ); var j = Parameter( typeof(int), "j" ); Lambda( Or( i, j ) ) ``` ```csharp var b1 = Parameter( typeof(bool), "b1" ); var b2 = Parameter( typeof(bool), "b2" ); Lambda( OrElse( b1, b2 ) ) ``` ```csharp var b1 = Parameter( typeof(bool), "b1" ); var b2 = Parameter( typeof(bool), "b2" ); Lambda( Or( b1, b2 ) ) ``` -------------------------------- ### Invocation Expressions Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/factorymethods-testdata.txt Examples of invoking delegates with or without arguments. ```C# var del = Parameter( typeof(VB$AnonymousDelegate), "del" ); Lambda( Invoke( del ) ) ``` ```C# var del = Parameter( typeof(VB$AnonymousDelegate), "del" ); ``` -------------------------------- ### Arithmetic and Comparison Expressions Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/factorymethods-testdata.txt Examples of binary operations including division, equality, and bitwise/logical XOR. ```C# var x = Parameter( typeof(double), "x" ); var y = Parameter( typeof(double), "y" ); Lambda( Divide( x, y ) ) ``` ```C# var i = Parameter( typeof(int), "i" ); var j = Parameter( typeof(int), "j" ); Lambda( Equal( i, j ) ) ``` ```C# var i = Parameter( typeof(int), "i" ); var j = Parameter( typeof(int), "j" ); Lambda( ExclusiveOr( i, j ) ) ``` ```C# var b1 = Parameter( typeof(bool), "b1" ); var b2 = Parameter( typeof(bool), "b2" ); Lambda( ExclusiveOr( b1, b2 ) ) ``` ```C# var i = Parameter( typeof(int), "i" ); var j = Parameter( typeof(int), "j" ); Lambda( GreaterThan( i, j ) ) ``` ```C# var i = Parameter( typeof(int), "i" ); var j = Parameter( typeof(int), "j" ); Lambda( GreaterThanOrEqual( i, j ) ) ``` -------------------------------- ### CSCompiler Operations Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/visualbasic-testdata.txt Examples of compiler-related expression tree constructions. ```vb Function(s1 As String, s2 As String) s1 + s2 ``` ```vb Function() x - y ``` ```vb Function() True ``` ```vb Function(s1 As String, s2 As String) s1 + s2 ``` ```vb Sub(s1 As String, s2 As String) Console.WriteLine(s1 + s2) ``` ```vb Function() GetType(String) ``` ```vb Function() TryCast(o, String) ``` ```vb Function() TypeOf o Is String ``` ```vb Function() lst(3) ``` -------------------------------- ### Block Expressions Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/csharp-testdata.txt Examples of block expressions with varying variable counts. ```csharp ( int i, string s1, true, true ) ``` ```csharp ( true, true ) ``` ```csharp ( int i, true, true ) ``` -------------------------------- ### Type Check Expressions Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/factorymethods-testdata.txt Examples of TypeAs and TypeIs expressions. ```C# Lambda( TypeAs( o, typeof(string) ) ) ``` ```C# Lambda( TypeIs( Constant(""), typeof(string) ) ) ``` -------------------------------- ### Constant Expressions Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/factorymethods-testdata.txt Examples of creating constant expressions for null, reference types, and value types. ```C# Lambda( Constant(null) ) ``` ```C# Lambda( Constant(null, typeof(string) ) ) ``` ```C# Lambda( Constant(0) ) ``` -------------------------------- ### Indexers and Enum Comparisons Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/visualbasic-testdata.txt Examples of array/list indexing and enum comparisons in both VB and C#. ```VB.NET Function() lst(3) ``` ```VB.NET Function() x(5) ``` ```VB.NET Function() dow >= DayOfWeek.Tuesday ``` ```VB.NET Function() DayOfWeek.Tuesday <= dow ``` ```VB.NET Function() dow1 = dow2 ``` ```C# Function() dow >= DayOfWeek.Tuesday ``` ```C# Function() DayOfWeek.Tuesday <= dow ``` ```C# Function() dow1 = dow2 ``` -------------------------------- ### Switch Expressions Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/visualbasic-testdata.txt Examples of Select Case statements used in factory methods. ```VB.NET Select Case i Case 1 "One" Case 2 "Two" Case 3 "Three" Case Else "Default" End Select ``` ```VB.NET Select Case i Case 1 Nothing "One" Case 2 Nothing "Two" Case Else Nothing "Default" End Select ``` ```VB.NET Select Case i Case 1, 2 "OneTwo" Case 3, 4 "ThreeFour" Case Else "Default" End Select ``` -------------------------------- ### Arithmetic Operations Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/visualbasic-testdata.txt Examples of basic arithmetic and bitwise operations in Visual Basic lambdas. ```vbnet Function() x + y ``` ```vbnet Function() i And j ``` ```vbnet Function() i Or j ``` ```vbnet Function() i Xor j ``` ```vbnet Function() Not i ``` ```vbnet Function() x / y ``` ```vbnet Function() x Mod y ``` ```vbnet Function() x * y ``` ```vbnet Function() -i ``` ```vbnet Function(x As Double, y As Double) x ^ y ``` -------------------------------- ### Division Operations Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/factorymethods-testdata.txt Examples of division operations involving type conversions. ```csharp var x = Parameter( typeof(int), "x" ); var y = Parameter( typeof(int), "y" ); Lambda( Divide( Convert( x, typeof(double) ), Convert( y, typeof(double) ) ) ) ``` ```csharp var x = Parameter( typeof(double), "x" ); var y = Parameter( typeof(double), "y" ); Lambda( Divide( ConvertChecked( x, typeof(long), typeof(Convert).GetMethod("ToInt64", new[] { typeof(double) }) ), ConvertChecked( y, typeof(long), typeof(Convert).GetMethod("ToInt64", new[] { typeof(double) }) ) ) ) ``` ```csharp var x = Parameter( typeof(int), "x" ); var y = Parameter( typeof(int), "y" ); ``` -------------------------------- ### Indexer Expressions Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/factorymethods-testdata.txt Examples of property access via indexers for standard and custom types. ```C# var lst = Parameter( typeof(List), "lst" ); Lambda( Property( lst, typeof(List).GetProperty("Item"), Constant(3) ) ) ``` ```C# var x = Parameter( typeof(DummyWithDefault), "x" ); Lambda( Property( x, typeof(DummyWithDefault).GetProperty("Item"), Constant(5) ) ) ``` -------------------------------- ### Catch Block Expressions Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/csharp-testdata.txt Examples of catch blocks with various filters and types. ```csharp catch (Exception ex) { Console.WriteLine(true); Console.WriteLine(true); } ``` ```csharp catch (Exception ex) when (true) { Console.WriteLine(true); Console.WriteLine(true); } ``` ```csharp catch (InvalidCastException) { Console.WriteLine(true); Console.WriteLine(true); } ``` ```csharp catch (Exception ex) { Console.WriteLine(true); } ``` ```csharp catch (Exception ex) when (true) { Console.WriteLine(true); } ``` ```csharp catch (InvalidCastException) { Console.WriteLine(true); } ``` ```csharp catch (Exception ex) when ( true, true ) { Console.WriteLine(true); } ``` -------------------------------- ### Nested Lambdas and Char Equality Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/visualbasic-testdata.txt Examples of nested lambda expressions and character equality checks. ```C# Function() Function() Function() "" ``` ```VB.NET Function() Function() "" ``` ```C# Function() "abcd"(0) = "c"C ``` ```C# Function() "c"C = "abcd"(0) ``` -------------------------------- ### Arithmetic Operations Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/csharp-testdata.txt Examples of basic arithmetic operations within lambda expressions. ```csharp () => x + y ``` ```csharp () => x / y ``` ```csharp () => x % y ``` ```csharp () => x * y ``` ```csharp () => x - y ``` ```csharp () => -i ``` -------------------------------- ### Constructing an If-Else Block Source: https://github.com/zspitz/expressiontreetostring/wiki/BlockExpression-rendering-in-C Example of an if-else structure using standard C# syntax. ```csharp if (DateTime.Now.Hour < 18) { Console.WriteLine("Good day"); Console.WriteLine("Have a nice day"); } else { Console.WriteLine("Good night"); Console.WriteLine("Have a nice night"); } ``` -------------------------------- ### Represent a nested expression tree Source: https://github.com/zspitz/expressiontreetostring/wiki/Overview-of-.NET-expression-trees An example showing how expressions can be nested to form a tree structure. ```csharp (x + 17) * 5 |------| |-| inner expressions |------------| outer expression ``` -------------------------------- ### Represent a simple addition expression Source: https://github.com/zspitz/expressiontreetostring/wiki/Overview-of-.NET-expression-trees A basic example of a C# expression involving a parameter and a constant. ```csharp x + 17 ``` -------------------------------- ### String Concatenation and Operators Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/visualbasic-testdata.txt Examples of string concatenation and arithmetic operations in VB.NET. ```VB.NET Function() "abcd" ``` ```VB.NET Function(s1 As String, s2 As String) s1 + s2 ``` ```VB.NET Function(s1 As String, s2 As String) s1 + s2 + s1 + s2 + s1 + s2 ``` ```VB.NET Function() x - y ``` -------------------------------- ### Switch Case Expressions Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/visualbasic-testdata.txt Examples of Select Case statements with single or multiple values and default cases. ```Visual Basic Case 5, 6 Console.WriteLine(True) Console.WriteLine(True) ``` ```Visual Basic Case 5, 6 Console.WriteLine(True) ``` ```Visual Basic Case 5 Console.WriteLine(True) Console.WriteLine(True) ``` ```Visual Basic Case 5 Console.WriteLine(True) ``` ```Visual Basic Select Case i Case 4 Console.WriteLine(True) Case 5 Console.WriteLine(False) Case Else True True End Select ``` ```Visual Basic Select Case i Case 4 Console.WriteLine(True) Case 5 Console.WriteLine(False) Case Else CType(Nothing, Void) End Select ``` ```Visual Basic Select Case i Case 4 Console.WriteLine(True) Case 5 Console.WriteLine(False) End Select ``` ```Visual Basic Select Case Block i j End Block Case 4 Console.WriteLine(True) Case 5 Console.WriteLine(False) Case Else True True End Select ``` ```Visual Basic Select Case Block i j End Block Case 4 Console.WriteLine(True) Case 5 Console.WriteLine(False) End Select ``` -------------------------------- ### Required Generic Parameters Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/factorymethods-testdata.txt Example of a Lambda expression calling a method with generic parameters. ```csharp Lambda( Call( typeof(Dummy).GetMethod("DummyMethodWithGenerics") ) ) ``` -------------------------------- ### Object Creation and Initializers Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/visualbasic-testdata.txt Constructing objects with parameters and property initializers. ```Visual Basic New Random ``` ```Visual Basic New Foo("ijkl") ``` ```Visual Basic New Foo("ijkl") With { .Bar = "abcd", .Baz = "efgh" } ``` ```Visual Basic New Foo With { .Bar = "abcd" } ``` ```Visual Basic New Foo With { .Bar = "abcd", .Baz = "efgh" } ``` -------------------------------- ### Make Element Init Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/csharp-testdata.txt Creates element initialization expressions. ```csharp "abcd" ``` ```csharp { "abcd", "efgh" } ``` -------------------------------- ### Parameter Expressions Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/factorymethods-testdata.txt Demonstrates creating parameters with and without names. ```csharp var $var0 = Parameter( typeof(string) ); Lambda( MakeBinary(ExpressionType.Equal, $var0, $var0, false, typeof(string).GetMethod("op_Equality") ), $var0 ) ``` ```csharp var $x_y = Parameter( typeof(string), "x y" ); Lambda($x_y, $x_y) ``` -------------------------------- ### Render Extension Methods Source: https://github.com/zspitz/expressiontreetostring/blob/master/README.md Shows how extension methods are rendered as instance methods in the output. ```csharp Expression> expr = x => Enumerable.Range(1, x).Select(y => x * y).Count(); Console.WriteLine(expr.ToString("C#")); // prints: (int x) => Enumerable.Range(1, x).Select((int y) => x * y).Count() ``` -------------------------------- ### Extension Method Calls with Conversion Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/factorymethods-testdata.txt Shows how to call extension methods with parameter conversions. ```csharp var lst = Parameter( typeof(List), "lst" ); Lambda( Call( typeof(Dummy).GetMethod("ExtensionMethod1ArgumentEnumerable"), Convert( lst, typeof(IEnumerable) ), Constant(1) ) ) ``` ```csharp var lst = Parameter( typeof(List), "lst" ); Lambda( Call( typeof(Dummy).GetMethod("ExtensionMethod2ArgumentsEnumerable"), Convert( lst, typeof(IEnumerable) ), Constant(5), Constant(6) ) ) ``` -------------------------------- ### Make Goto Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/csharp-testdata.txt Creates goto expressions. ```csharp goto target ``` ```csharp goto target 5 ``` -------------------------------- ### Query database with supported methods Source: https://github.com/zspitz/expressiontreetostring/wiki/Why-can't-I-use-my-function-in-a-database-query A working LINQ query using StartsWith, which is supported by most database providers. ```vb Class MyDbContext Inherits DbContext Property Persons As DbSet(Of Person) Protected Overrides Sub OnConfiguring(optionsBuilder As DbContextOptionsBuilder) optionsBuilder.UseSqlite("DataSource=People.db") End Sub End Class Dim ctx = New MyDbContext Dim qry = From person In ctx.Person Where person.LastName.StartsWith("A") Select person For Each person In qry Dim output = $"LastName: {person.LastName}, FirstName: {person.FirstName}, DateOfBirth: {person.DateOfBirth}" Console.WriteLine(output) Next ``` -------------------------------- ### Create Member and List Bindings Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/factorymethods-testdata.txt Constructs bindings for member initialization and list collection initialization. ```csharp ListBind( typeof(Node).GetProperty("Children", BindingFlags.Instance | BindingFlags.NonPublic), ElementInit( typeof(ICollection).GetMethod("Add"), New( typeof(Node).GetConstructor(new Type[] { }) ) ), ElementInit( typeof(ICollection).GetMethod("Add"), New( typeof(Node).GetConstructor(new Type[] { }) ) ) ) ``` ```csharp Bind( typeof(DummyMember).GetProperty("Foo", BindingFlags.Instance | BindingFlags.NonPublic), Constant("abcd") ) ``` ```csharp MemberBind( typeof(Node).GetProperty("Data", BindingFlags.Instance | BindingFlags.NonPublic), Bind( typeof(NodeData).GetProperty("Name", BindingFlags.Instance | BindingFlags.NonPublic), Constant("abcd") ) ) ``` -------------------------------- ### Make Element Initialization with 2 Arguments Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/visualbasic-testdata.txt Creates an element initialization expression with two arguments. ```vb { "abcd", "efgh" } ``` -------------------------------- ### Make Return Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/csharp-testdata.txt Creates return expressions. ```csharp return target ``` ```csharp return target 5 ``` -------------------------------- ### Instance Method with 2 Arguments Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/visualbasic-testdata.txt Calls an instance method with two arguments. ```vb s.IndexOf("a"C, 2) ``` -------------------------------- ### Collection Initializers Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/csharp-testdata.txt Initializes collections with various element structures. ```csharp () => new List() { "abcd", "efgh" } ``` ```csharp () => new Wrapper() { { "ab", "cd" }, { "ef", "gh" } } ``` ```csharp () => new Wrapper() { { "ab", "cd" }, "ef" } ``` -------------------------------- ### Instance Method Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/csharp-testdata.txt Creates instance method invocation expressions with varying arguments. ```csharp s.ToString() ``` ```csharp s.CompareTo("") ``` ```csharp s.IndexOf('a', 2) ``` -------------------------------- ### Instance Method with 0 Arguments Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/visualbasic-testdata.txt Calls an instance method with no arguments. ```vb s.ToString ``` -------------------------------- ### Make Element Initialization Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/visualbasic-testdata.txt Creates an element initialization expression. ```vb "abcd" ``` -------------------------------- ### Boolean and Type Operations Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/visualbasic-testdata.txt Examples of boolean constants, type casting, and type checking. ```VB.NET Function() True ``` ```VB.NET Function() TryCast(o, String) ``` ```VB.NET Function() TypeOf "" Is String ``` -------------------------------- ### Compiling and invoking expression trees Source: https://github.com/zspitz/expressiontreetostring/wiki/Overview-of-.NET-expression-trees Shows how to convert an expression block into a compiled delegate and execute it. ```csharp Expression expr = Lambda(block); Action action = expr.Compile(); ``` ```csharp action.Invoke(); ``` -------------------------------- ### Make Debug Info Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/csharp-testdata.txt Creates debug information markers. ```csharp // Debug to source.txt -- L1C2 : L3C4 ``` -------------------------------- ### Collection Initializer Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/factorymethods-testdata.txt Initializes a List with two elements. ```csharp Lambda( ListInit( New( typeof(List).GetConstructor(new Type[] { }) ), ElementInit( typeof(List).GetMethod("Add"), Constant("abcd") ), ElementInit( typeof(List).GetMethod("Add"), Constant("efgh") ) ) ) ``` -------------------------------- ### Array Initialization and Bounds Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/factorymethods-testdata.txt Creates array initialization and bounds expressions. ```csharp Lambda( NewArrayInit( typeof(string), Constant("") ) ) ``` ```csharp Lambda( NewArrayInit( typeof(object), Convert( Constant(""), typeof(object) ) ) ) ``` ```csharp Lambda( NewArrayBounds( typeof(string), Constant(5) ) ) ``` -------------------------------- ### VBCompiler Like Operator Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/csharp-testdata.txt Demonstrates string and object comparison using the Like operator. ```csharp (string s1, string s2) => LikeOperator.LikeString(s1, s2, CompareMethod.Binary) ``` ```csharp (object o1, object o2) => LikeOperator.LikeObject(o1, o2, CompareMethod.Binary) ``` -------------------------------- ### Nested Block in Test Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/csharp-testdata.txt Examples of block structures used within conditional test expressions. ```csharp if ( true, true, true, true ) { true; } ``` ```csharp if ( true, ( string s1, true, true ), true ) { true; } ``` -------------------------------- ### Construct Label Targets Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/factorymethods-testdata.txt Creates label targets and empty labels. ```C# Label("") ``` ```C# Label("target") ``` -------------------------------- ### Collection Initializers Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/factorymethods-testdata.txt Constructs ListInit expressions with various element initializers. ```csharp ListInit( New( typeof(List).GetConstructor(new Type[] { }) ), ElementInit( typeof(List).GetMethod("Add"), Constant("abcd") ), ElementInit( typeof(List).GetMethod("Add"), Constant("efgh") ) ) ``` ```csharp ListInit( New( typeof(Wrapper).GetConstructor(new Type[] { }) ), ElementInit( typeof(Wrapper).GetMethod("Add", BindingFlags.Instance | BindingFlags.NonPublic), Constant("ab"), Constant("cd") ), ElementInit( typeof(Wrapper).GetMethod("Add", BindingFlags.Instance | BindingFlags.NonPublic), Constant("ef"), Constant("gh") ) ) ``` ```csharp ListInit( New( typeof(Wrapper).GetConstructor(new Type[] { }) ), ElementInit( typeof(Wrapper).GetMethod("Add", BindingFlags.Instance | BindingFlags.NonPublic), Constant("ab"), Constant("cd") ), ElementInit( typeof(List).GetMethod("Add"), Constant("ef") ) ) ``` -------------------------------- ### Invalid BlockExpression Usage Source: https://github.com/zspitz/expressiontreetostring/wiki/BlockExpression-rendering-in-C Example of a BlockExpression used in a test clause where it is not supported by standard C# syntax. ```text if ({ true; true; }) { Console.WriteLine(true); } ``` -------------------------------- ### Arrays and Tuples Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/visualbasic-testdata.txt Initialization of arrays and creation of tuples. ```Visual Basic { "" } ``` ```Visual Basic New Object() { "" } ``` ```Visual Basic New String(4) {} ``` ```Visual Basic Tuple.Create("abcd", 5) ``` ```Visual Basic ("abcd", 5) ``` -------------------------------- ### Construct Label with Value Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/factorymethods-testdata.txt Demonstrates the use of FactoryMethods.ConstructLabelWithValue to create a block containing parameters and a labeled constant. ```csharp var i = Parameter( typeof(int), "i" ); var j = Parameter( typeof(int), "j" ); Block(new[] { i }, Block(new[] { j }, Constant(true), Label( Label("target"), Constant(5) ), Constant(true) ) ) ``` -------------------------------- ### Retrieve Node Path Spans Source: https://github.com/zspitz/expressiontreetostring/blob/master/README.md Extracts the start and length of substrings corresponding to specific nodes in the expression tree. ```csharp var s = expr.ToString("C#", out var pathSpans); Console.WriteLine(s); // prints: (Person p) => p.DOB.DayOfWeek == DayOfWeek.Tuesday (int start, int length) = pathSpans["Body.Left.Operand"]; Console.WriteLine(s.Substring(start, length)); // prints: p.DOB.DayOfWeek ``` -------------------------------- ### Instance Indexer Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/csharp-testdata.txt Creates an instance indexer access expression. ```csharp lstString[0] ``` -------------------------------- ### Retrieve test objects Source: https://github.com/zspitz/expressiontreetostring/blob/master/TestObjects.VB/README.md Use the static Get method to retrieve a collection of expression tree objects. The returned array contains category, source, name, and the object itself. ```csharp // using ExpressionTreeTestObjects; (string category, string source, string name, object o)[] lst = Objects.Get(); ``` -------------------------------- ### Member Member Binding Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/factorymethods-testdata.txt Demonstrates nested member initialization and binding within an expression tree. ```csharp Lambda( MemberInit( New( typeof(Node).GetConstructor(new Type[] { }) ), MemberBind( typeof(Node).GetProperty("Data", BindingFlags.Instance | BindingFlags.NonPublic), Bind( typeof(NodeData).GetProperty("Name", BindingFlags.Instance | BindingFlags.NonPublic), Constant("abcd") ) ) ) ) ``` -------------------------------- ### VBCompiler Array Indexing Expressions Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/factorymethods-testdata.txt Demonstrates various array indexing and length operations. ```csharp var arr = Parameter( typeof(string[]), "arr" ); Lambda( ArrayIndex( arr, Constant(0) ) ) ``` ```csharp var arr = Parameter( typeof(string[]), "arr" ); Lambda( ArrayLength( arr ) ) ``` ```csharp var arr = Parameter( typeof(string[,]), "arr" ); Lambda( ArrayIndex( arr, Constant(5), Constant(6) ) ) ``` ```csharp var arr = Parameter( typeof(string[]), "arr" ); Lambda( ArrayIndex( arr, Constant(5) ) ) ``` -------------------------------- ### Register a custom renderer Source: https://github.com/zspitz/expressiontreetostring/wiki/Extensibility-and-plugin-mechanism Register a new renderer with a unique string key. ```csharp // using ExpressionTreeToString Renderers.Register( "DummyRenderer", (o, language, usePathSpans) => "Hello world!", null) ); ``` -------------------------------- ### Named Type Instantiation Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/csharp-testdata.txt Creating instances of classes with optional constructors and initializers. ```csharp () => new Random() ``` ```csharp () => new Foo("ijkl") ``` ```csharp () => new Foo("ijkl") { Bar = "abcd", Baz = "efgh" } ``` ```csharp () => new Foo() { Bar = "abcd" } ``` ```csharp () => new Foo() { Bar = "abcd", Baz = "efgh" } ``` -------------------------------- ### Equality and Comparison Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/csharp-testdata.txt Comparison operators for equality, inequality, and magnitude. ```csharp () => i == j ``` ```csharp () => i > j ``` ```csharp () => i >= j ``` ```csharp () => i < j ``` ```csharp () => i <= j ``` ```csharp () => i != j ``` -------------------------------- ### Make List Binding Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/csharp-testdata.txt Creates a list binding expression. ```csharp Children = { new Node(), new Node() } ``` -------------------------------- ### Mixed Collection Initializer Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/factorymethods-testdata.txt Initializes a collection using both custom wrapper and standard list methods. ```csharp Lambda( ListInit( New( typeof(Wrapper).GetConstructor(new Type[] { }) ), ElementInit( typeof(Wrapper).GetMethod("Add", BindingFlags.Instance | BindingFlags.NonPublic), Constant("ab"), Constant("cd") ), ElementInit( typeof(List).GetMethod("Add"), Constant("ef") ) ) ) ``` -------------------------------- ### Array Creation with Bounds Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/csharp-testdata.txt Creating single, multi-dimensional, and jagged arrays with dynamic bounds. ```csharp () => new string[bounds + 1] ``` ```csharp () => new string[bound1 + 1, bound2 + 1] ``` ```csharp () => new string[bound + 1][] ``` -------------------------------- ### Make List Binding Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/visualbasic-testdata.txt Creates a list binding expression. ```vb .Children = From { New Node, New Node } ``` -------------------------------- ### Specify Visual Basic language for factory method rendering Source: https://github.com/zspitz/expressiontreetostring/wiki/Home Demonstrates setting the language parameter to 'Visual Basic' when using the factory methods renderer. ```csharp Console.WriteLine(expr.ToString("Factory methods", "Visual Basic")); /* ' Imports System.Linq.Expressions.Expression Lambda( Call( MakeMemberAccess(p, GetType(Person).GetProperty("LastName") ), GetType(String).GetMethod("StartsWith", { GetType(String) }), Constant("A") ), Dim p = Parameter( GetType(Person), "p" ) ) */ ``` -------------------------------- ### Make Continue Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/csharp-testdata.txt Creates a continue expression. ```csharp continue target ``` -------------------------------- ### Instance Indexer Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/visualbasic-testdata.txt Accesses an instance indexer. ```vb lstString(0) ``` -------------------------------- ### Collection Initializer with Multiple Elements Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/factorymethods-testdata.txt Initializes a custom wrapper with multiple element initializers. ```csharp Lambda( ListInit( New( typeof(Wrapper).GetConstructor(new Type[] { }) ), ElementInit( typeof(Wrapper).GetMethod("Add", BindingFlags.Instance | BindingFlags.NonPublic), Constant("ab"), Constant("cd") ), ElementInit( typeof(Wrapper).GetMethod("Add", BindingFlags.Instance | BindingFlags.NonPublic), Constant("ef"), Constant("gh") ) ) ) ``` -------------------------------- ### Instance Member Access Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/csharp-testdata.txt Accessing properties and methods on an instance. ```csharp () => s.Length ``` ```csharp () => s.ToString() ``` ```csharp () => s.CompareTo("") ``` ```csharp () => s.IndexOf('a', 2) ``` -------------------------------- ### Make Goto With Value Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/visualbasic-testdata.txt Creates a goto expression with a value. ```vb Goto target 5 ``` -------------------------------- ### Create Element Initialization Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/factorymethods-testdata.txt Constructs element initialization expressions for collection initializers. ```csharp ElementInit( typeof(List).GetMethod("Add"), Constant("abcd") ) ``` ```csharp ElementInit( typeof(Wrapper).GetMethod("Add", BindingFlags.Instance | BindingFlags.NonPublic), Constant("abcd"), Constant("efgh") ) ``` -------------------------------- ### Instance Method with 1 Argument Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/visualbasic-testdata.txt Calls an instance method with one argument. ```vb s.CompareTo("") ``` -------------------------------- ### Construct Power Operations Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/factorymethods-testdata.txt Creates power and power assignment expressions. ```C# Power(x, y) ``` ```C# PowerAssign(x, y) ``` -------------------------------- ### Instance Method Call (0 Arguments) Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/factorymethods-testdata.txt Constructs a lambda expression calling the ToString method on a string parameter. ```csharp var s = Parameter( typeof(string), "s" ); Lambda( Call( s, typeof(object).GetMethod("ToString") ) ) ``` -------------------------------- ### Render Enum Comparisons Source: https://github.com/zspitz/expressiontreetostring/blob/master/README.md Shows how enum comparisons are rendered correctly without being converted to integer values. ```csharp var dow = DayOfWeek.Sunday; Expression> expr = () => DateTime.Today.DayOfWeek == dow; Console.WriteLine(expr.ToString("Textual tree", "C#")); // prints: /* Lambda (Func) · Body - Equal (bool) = false · Left - Convert (int) = 3 · Operand - MemberAccess (DayOfWeek) DayOfWeek = DayOfWeek.Wednesday · Expression - MemberAccess (DateTime) DateTime.Today = 30/09/2020 12:00:00 am · Right - Convert (int) = 0 · Operand - MemberAccess (DayOfWeek) dow = DayOfWeek.Sunday · Expression - Constant () = # */ Console.WriteLine(expr.ToString("C#")); // prints: () => DateTime.Today.DayOfWeek == dow ``` -------------------------------- ### Make Quoted Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/csharp-testdata.txt Creates quoted expression trees. ```csharp ( double x, () => Console.WriteLine(true) ) ``` ```csharp () => () => Console.WriteLine(true) ``` -------------------------------- ### Make Return Expression Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/visualbasic-testdata.txt Creates a return expression. ```vb Return target ``` -------------------------------- ### Instance Method Call (1 Argument) Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/factorymethods-testdata.txt Constructs a lambda expression calling CompareTo on a string parameter with one argument. ```csharp var s = Parameter( typeof(string), "s" ); Lambda( Call( s, typeof(string).GetMethod("CompareTo", new[] { typeof(string) }), Constant("") ) ) ``` -------------------------------- ### Extension Method with 0 Arguments Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/visualbasic-testdata.txt Calls an extension method with no arguments. ```vb lstString.Count ``` -------------------------------- ### Arithmetic and Logical Factory Methods Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/factorymethods-testdata.txt Constructs various arithmetic and logical expressions. ```csharp Add(x, y) ``` ```csharp AddAssign(i, j) ``` ```csharp AddAssignChecked(i, j) ``` ```csharp AddChecked(x, y) ``` ```csharp AndAlso(b1, b2) ``` ```csharp AndAssign(b1, b2) ``` -------------------------------- ### Compile and Execute Expression Trees Source: https://github.com/zspitz/expressiontreetostring/wiki/Overview-of-.NET-expression-trees Wraps an expression in a lambda and compiles it for dynamic execution at runtime. ```csharp var lambdaExpression = Lambda( expr, prm ); string iToString = lambdaExpression.Compile().DynamicInvoke(17) as string; // == "17" ``` -------------------------------- ### Render .NET ToString Source: https://github.com/zspitz/expressiontreetostring/wiki/Available-renderers Uses the standard .NET Expression.ToString() implementation. ```csharp Console.WriteLine(expr3.ToString("ToString")); /* p => True */ ``` -------------------------------- ### Empty Loop Source: https://github.com/zspitz/expressiontreetostring/blob/master/Tests/expectedResults/visualbasic-testdata.txt Creates an empty Do-Loop. ```vb Do True Loop ```