Mono.CSharp

Back in April, I read this post by Miguel de Icaza about the C# REPL (read-eval-print-loop) feature coming to MS.NET framework (previously it had only run on the Mono framework, for reasons detailed in the blog post). I was pretty excited. The feature looked really awesome when Miguel first blogged about it back in 2008 and I was pretty bummed that it was only available for Mono. 

I hadn’t had an opportunity to play with it as I had been pretty busy doing other stuff at work and really didn’t want to touch the application that I wanted to add it to because it’s pretty touchy for some reason. It’s a very multithreaded application with networking, database and a bunch of other stuff, so trying to touch it can cause rippling effects. It’s something I’ve really wanted to rewrite for a while anyway. I finally decided to implement a couple new features in the application and brave the problems that would come.
I implemented the features and it seemed like everything was working fine until the day before I went on vacation. Everything went to pot. Right down the drain. I patched up the app as best I could before I left and received some frantic pages from a colleague before I actually hit the road.
Once I got back from my vacation I set about to correct the application correctly. You know, actually implement mutual exclusion and so forth so that it wouldn’t die a horrible death every couple days. I switched some of the threadpool stuff over to the new TPL (Task Parallel) that was released in .NET 4.0 and that has had a great improvement in speed, but I still wanted a way to break in and debug stuff at runtime. Enter the Mono.CSharp library.
I wrote a very simple network interface that received commands from a raw connection, would evaluate them and then print back the results to the client machine. I still have a few kinks to work out, but all-in-all the solution is AWESOME. I can now remotely login and run commands to see what is happening internally in the application. I used some of the code from the example csharp.exe that Miguel released in order to have some pretty-printing and other similar features, but nothing real intense.
If you haven’t checked out the Mono.Csharp library, I highly recommend you do. It has some potential to be very powerful. MS has promised a similar feature for the next revision of C#, but you can have it now, and very easily by just using the Mono.CSharp library.
If you’d like more information about Mono, check out http://go-mono.com.

One thought on “Mono.CSharp

Comments are closed.