ExpressionTreeTestObjects 1.0.23

.NET Core 3.1 .NET Standard 2.0 .NET Framework 4.5.2
dotnet add package ExpressionTreeTestObjects --version 1.0.23
NuGet\Install-Package ExpressionTreeTestObjects -Version 1.0.23
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ExpressionTreeTestObjects" Version="1.0.23" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ExpressionTreeTestObjects --version 1.0.23
#r "nuget: ExpressionTreeTestObjects, 1.0.23"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install ExpressionTreeTestObjects as a Cake Addin
#addin nuget:?package=ExpressionTreeTestObjects&version=1.0.23

// Install ExpressionTreeTestObjects as a Cake Tool
#tool nuget:?package=ExpressionTreeTestObjects&version=1.0.23

NuGet TestObjects Status

Expression trees (and related objects) can be generated in three ways:

  • Calling the factory methods at System.Linq.Expressions.Expression
  • In C#, assigning a lambda expression to an Expression<T> variable, parameter or property; the C# compiler generates an expression tree corresponding to the code of the lambda expression
  • The VB compiler also generates expression trees from VB lambda expressions assigned to Expression<T>.

As part of the development of ExpressionTreeToString, I needed a comprehensive set of expression trees to test the renderers against. This set of objects is available as a Nuget package.

Each expression object is a field with the TestObject attribute applied to it.

The objects are available by referencing the NuGet package, and calling the static Get method:

// using ExpressionTreeTestObjects;

(string category, string source, string name, object o)[] lst = Objects.Get();

where source is the type where the object is defined -- one of the following:

Source Description
Factory methods Factory methods
CSCompiler C# compiler
VBCompiler VB compiler

and category is one of these values:

  • Binary
  • Blocks
  • Conditionals
  • Constants
  • DebugInfos
  • Defaults
  • Dynamics
  • Gotos
  • Indexer
  • Invocation
  • Labels
  • Lambda
  • Literal
  • Loops
  • Member access (+ closed variables)
  • Member bindings
  • Method call
  • New array
  • Object creation and initialization
  • Quoted
  • Runtime variables
  • Switch, CatchBlock
  • Try, Catch, Finally
  • Type check
  • Unary

The static constructor automatically loads types in assemblies that start with ExpressionTreeTestObjects -- ExpressionTreeTestObjects.CSharp.dll, and ExpressionTreeTestObjects.VB.dll.

  1. Call the static LoadType method on the containing type:

     Objects.LoadType(typeof(MyCustomType));
    

    and it will add the object. The type name becomes the source, and the field name becomes the objectName.


The C# and VB compiler test expressions were added as I was working on the corresponding renderers. For the factory methods, I used reflection to build a list of all the methods and overloads at System.Linq.Expressions.Expression and created expressions by calling each one.

The result is pretty comprehensive, with one limitation: I didn't write test expressions for overloads which take an additional MethodInfo, like this one. This is being tracked at #20.

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net452 net46 net461 net462 net463 net47 net471 net472 net48 net481
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 3.1

    • No dependencies.
  • .NETFramework 4.5.2

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on ExpressionTreeTestObjects:

Repository Stars
zspitz/ExpressionTreeVisualizer
Debugging visualizer for expression trees
Version Downloads Last updated
1.0.23 222 12/23/2021
1.0.22 172 12/14/2021
1.0.21 388 6/6/2021
1.0.20 240 5/31/2021
1.0.19 329 1/16/2021
1.0.18 411 12/6/2020
1.0.17 385 12/5/2020
1.0.14 307 10/8/2020
1.0.13 354 9/23/2020
1.0.12 360 9/16/2020
1.0.11 324 9/14/2020
1.0.10 377 8/31/2020
1.0.9 306 8/24/2020
1.0.8 327 8/18/2020
1.0.7 323 8/5/2020
1.0.6 369 7/19/2020
1.0.5 2,864 7/19/2020
1.0.4 308 7/16/2020
1.0.3 441 6/27/2020
1.0.2 526 3/29/2020
1.0.1 468 12/18/2019
1.0.0 395 12/18/2019