CodeLab. Experiment on your code.

Run fast lightweight tests, check your code, explore legacy code.

Getting Started

To install the extension, just double-click on the .VSIX file. It'll ask you which Visual Studio editions you'd like to install it into - it currently only works with VS 2012.

Once you've got the plugin installed, a new window can be added to your Visual Studio environment.

To view the CodeLab window, on the menu bar click View -> Other Windows -> CodeLab.

You can dock this window anywhere, but it helps to have it visible next to your code. We like to keep it under the solution explorer.

Accessing the CodeLab window via View -> Other Windows -> CodeLab

Setting up experiments

To set up a quick experiment based on the code in the current editor, just click Add New in the CodeLab window. You can then enter an expression using C# syntax. Any valid C# expression can be used.

Each experiment is given a number, but you can edit this to name the expression and make it easier to reuse results. Once you've entered your expression it will be evaluated and the result shown. If the result is a complex object you can click the plus button to view members.

There are buttons next to each experiment which let you re-run it normally, or run it in debug mode, allowing you to set breakpoints and debug your code without running the whole solution.

You can also get rid of any old experiments with the delete button, or temporarily disable them with the checkbox.

Experiments in comments

Experiments can also be embedded as comments in a C# source file.

// Here's how we create an instance of a class:
//    CL: $Fib = new Fib()
// We can use the new instance to calculate the Fibonacci sequence 
//    CL: $Fib.Calculate(10)

These experiments will appear and be evaluated in the CodeLab window every time you load up a new source file in the editor.


Experiments can also be used to create mini-tests. You can apply the ==> and !=> operators to the end of your experiment expression and give the expected result. When these are evaluated, CodeLab provides a green or red bar to indicate whether the result is as expected or not.

Example Solution

There is an example solution, based on a simple Fibonacci series generator included in the CodeLab zip file. This shows you how to write quick experiments and lightweight tests using CodeLab.