|
Project Information
|
Generates valid, readable C# from an Expression Tree, for example: @"() => new[] { 1.0, 2.01, 3.5 }.SequenceEqual(new[] { 1.0, 2.01, 3.5 })"
==
ExpressionToCode.ToCode(
() => new[] { 1.0, 2.01, 3.5 }.SequenceEqual(new[] { 1.0, 2.01, 3.5 })
)ExpressionToCode also provides a clone of Groovy's Power Assert which includes the code of the failing assertion's expression and the values of its subexpressions. This functionality is particularly useful in a unit testing framework such as NUnit or xUnit.NET. When you execute the following (invalid) assertion: PAssert.That(()=>Enumerable.Range(0,1000).ToDictionary(i=>"n"+i)["n3"].ToString() == (3.5).ToString()); The assertion fails with the following message: PAssert.That failed for:
Enumerable.Range(0, 1000).ToDictionary(i => "n" + (object)i)["n3"].ToString() == 3.5.ToString()
| | | | | |
| | | | | "3.5"
| | | | false
| | | "3"
| | 3
| {[n0, 0], [n1, 1], [n2, 2], [n3, 3], [n4, 4], [n5, 5], [n6, 6], [n7, 7], [n8, 8], [n9, 9], ...}
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ...}ExpressionToCode was inspired by Power Asssert.NET. It differs from PowerAssert.NET by support a larger portion of the lambda syntax; the aim is to generate valid C# for all expression trees created from lambda's. Currently supported:
Not yet implemented:
Requires .NET 3.5. If you have any questions, you can contact me at eamon at nerbonne dot org. See the documentation and download the library or checkout the source (license: Apache 2.0 or the MIT license, at your option)! |