Skip to content
String representation of expression trees and expression tree parts + debugging visualizer
Branch: master
Clone or download
Latest commit 01a145c Mar 24, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/ISSUE_TEMPLATE Update issue templates Mar 22, 2019
ExpressionToString.Tests Replace DOS EOL with Unix EOL, so tests will pass Mar 24, 2019
ExpressionToString Enable appveyor release Mar 14, 2019
_visualizerTests.VB Fixes #46; although without unit tests Mar 20, 2019
.gitignore Add .gitignore and .gitattributes. Dec 9, 2018
ExpressionToString.sln Fixes #46; although without unit tests Mar 20, 2019
LICENSE Create LICENSE Jan 2, 2019
language-switch.gif Updated README Mar 13, 2019
screenshot-01.png Updated README Mar 13, 2019
screenshot-csharp.jpg Updated README and screenshots Jan 21, 2019
screenshot-vb.jpg Updated README and screenshots Jan 21, 2019
sync-from-code.gif Updated README Mar 13, 2019
sync-from-source.gif Updated README Mar 13, 2019

Expression To String and Expression Tree Visualizer

This project provides the following:

  • NuGet Status Extension methods to create a C# or VB.NET code-like string representation, of expression trees or expression tree parts (.NET Standard library)
  • GitHub Release A debugging visualizer for expression trees / expression tree parts
    Note: Tested with VS 2017, which only supports custom visualizers in .NET Framework projects
    Installation: The visualizer DLL and the dependent DLL (MultiSelectTreeView.DLL), on the release page, should be placed in the appropriate folder, as described here. It may be necessary to unblock the DLLs.

String representations of expression trees

Expression<Func<bool>> expr = () => true;

// prints: () => true

Console.WriteLine(expr.ToString("Visual Basic"));
// prints: Function() True


  • Support for outputting C#- and VB.NET-style pseudocode (with more to come)

  • Extension methods are rendered as instance methods

    Expression<Func<int, int>> expr = x => Enumerable.Range(1, x).Select(y => x * y).Count();
    // prints: (int x) => Enumerable.Range(1, x).Select((int y) => x * y).Count()
  • Closed-over variables are rendered as simple identifiers (instead of member access on the hidden compiler-generated class)

    var i = 7;
    var j = 8;
    Expression<Func<int>> expr = () => i + j;
    // prints: () => i + j
  • Special handling of calls to String.Concat and String.Format

    var name = "World";
    Expression<Func<string>> expr = () => string.Format("Hello, {0}!", name);
    // prints: () => $"Hello, {name}!"

Note that support for the full range of types in System.Linq.Expressions is incomplete, but progressing.

Visual Studio debugger visualizer for expression trees


The UI consists of three parts:

  1. Tree view of the various parts of an expression tree

  2. Source code view, using the above ExpressionToString library

  3. End nodes -- nodes in the expression tree which are not composed of other expressions

    • Parameters
    • Closed-over variables
    • Constant expressions


  • Live switching between C# and VB.NET

    Language switch

  • Selection syncing when selecting from the tree:

    Selection sync from tree

    from source code:

    Selection sync from source code

    and from end nodes:

    Selection sync from end nodes


You can’t perform that action at this time.