Monday, March 8, 2010

RxSandbox V1

[RxSandbox downlaod has been upgraded to the newest version of Rx (Build 1.0.2677.0 08/27/2010).] download

[RxSandbox downlaod has been upgraded to the newest version of Rx (Build 1.0.2617.0 07/15/2010).] download(Changes: solution converted to VS2010, Net 4.0; 56 operators, grouping operators on the tree control; zoom)

[RxSandbox downlaod has been upgraded to the newest version of Rx (Build 1.0.2441.0 04/14/2010).] download

[RxSandbox downlaod has been upgraded to the newest version of Rx (Build 1.0.2350.0 03/15/2010).] download

I am really happy to announce that the new version of RxSandbox has been just released. Last timeI have been writing about the concept and the main ideas behind the project. That was just a small prototype, the proof of concept. This release is much more mature, the user can test more standard Rx operators and the API has been changed a little bit, however the concept stated the same.

These are the main new features:

Marble diagrams

New powerful API

Extensibility mechanism

Description of Rx the operators taken from Rx documentation

Lets start from the the end-user which is not necessary interested in writing any code. He just wants to experiment with Rx operators, check how they behave in specific scenarios. When we start RxSandbox application we will see the list of standard operators on the left hand side. Lets assume that we don’t know how Merge operator works. After double click on the Merge node the new tab will be displayed. We can find the short description of Merge operator taken from documentation provided by Rx installer, we can also find the code sample that can be tested interactively trough UI. Each input argument is presented as a simple automatically generated UI with one textbox where we can write input value, tree buttons and the history of the source. The output of the expression can be presented in two ways: by a simple list displaying the results (“Output” tab) or the marble diagrams drawn live during testing (‘Marble diagram – Live” tab). There is also one tab called “Marble diagram - Definition” showing the operator definition.

Now lets see what the developer can do with RxSandbox. The most important class in Rx API is the ExpressionDefinition. It holds all necessary information describing tested expression such as name, description and sample code.

When we look inside RxSandbox project we will see that the definitions of all standard operators are very similar, for example the Merge operator is defined like this:

This is all we need to write. Other things like operator’s name, description and the text of expression can be inferred from the Linq expression. Of course all these information can be set manually using appropriate Create method overload and ExpressionSettings class. All .Net types are supported as observable type, not only the System.String type like in this example. The only requirement is there must exist a TypeConverter for that type. Later in this post I’ll how implement TypeConverter for custom type and how to create ExpressionDefinition without using Linq expression but using the whole method with many statements. The second very important class in RxSandbox API is an ExpressionInstance class which is very useful in scenarios where we want to use some RxSandbox functionalities directly from code without any UI experience (for example during writing Unit Tests or recording marble diagram).

As we can see single marble diagram have a very simple Xml representation and diagrams for all standard operators from RxSandbox are stored in Diagrams.xml file (this file path can be changed in the configuration files).

Short description added to all standard operators extracted from Rx documentation Xml file is a next new feature of current release. Of course not all tested reactive expression are related to one particular operator so the description can be set manually (ExpressionSettings.Description property). When we want write a very complicated Linq expression or the expression is passed as delegate type to the ExpressionDefinition.Create method and we also want to provide description from particular Rx operator at the same time, we can do it indicating operator thought MethodInfo type (ExpressionSettings.Operator property).

The last but not least new feature is the extensibility mechanism. When we want to write our custom reactive expression without changing anything inside RxSadbox project we can do it by implementing IExpressionProvider interface directly or by inheriting from an abstract class ExpressionAttributeBasedProvider and setting our assembly name in the configuration file (ExtensionsAssembly element). During startup process RxSandbox loads that assembly, analyzes it and finds all expression providers. Few weeks ago I have been writing about Incremental Find implemented using Rx, lets see how such a query can tested via RxSandbox.

13 comments:

Probably the problem is that RxSandbox.exe cannot load Rx dlls. Please download once again binaries, you should see all necessary dlls next to the RxSandbox.exe file or install the newest version of Rx.

Just downloaded Post015 RxSandbox V1.zip again and got the same problem.

Here are the list of files in the bin folderDiagrams.xmlRxSandbox.exeRxSandbox.exe.configRxSandbox.pdbRxSandbox.vshost.exeRxSandbox.vshost.exe.configSystem.CoreEx.dllSystem.CoreEx.xmlSystem.Interactive.dllSystem.Interactive.xmlSystem.Observable.dllSystem.Reactive.dllSystem.Reactive.xmlSystem.Threading.dll

A few of suggestions:1. Have an option to make the balls in the diagram a bit larger and put the text inside them rather than the tooltip, that way you can understand how a method works in one glance without moving the mouse to read all the tooltips.

2. Turn the input textbox into an editable combobox, with the combobox menu option "Current Time". If "Current Time" is selected then clicking on OnNext should use the current time "mm:ss.millisec" format. This will help understanding of time-based operations. Another option is to just add an option to view the results on a time scale.

Great tool, looks very promising. I came across it when I was looking at creating a template for authoring marble diagrams (not necessarily with code), but I decided to play around with the source a bit anyway, since it was so neat.

Long story short, I created a StringExpressionProvider implementation that uses Roslyn to compile text snippets into expressions that can then be displayed on the marble diagram. That parts works oh so beautifully, but I'm having a bit of a snag in the WPF rendering code, specifically with the Series. Are you accepting patch submissions for this project? I'd love to share!

I wasn't able to get the ui to show the static diagram, but that wasnt really the full focus. I blogged about the changes that I made here - your code is extensible enough that a single page's worth of code is enough to get started. Something worth examining as a rendering option I think would be using a chart of some kind, or perhaps just refactoring the way marbles are being created and drawn - instead of a grid, perhaps a canvas for positioning? The margin between two marbles is some constant factor of the time interval between events.