Thursday, September 17, 2009

LINQPad as a .Net Snippet Code IDE

InI Posted a very simple question about "a ? b : c" expression to Stackoverflow last night. I was at Cafe with my friend discussing a case of this expression: if b and c are different types. Since we did not have Visual Studio available to test my codes out. I posted the question to Stackoverflow. Within minutes, we got several answers to confirm my guess: a Cast can be used before either one to make them the same type. The question is indeed a very simple one. However, this lead to a new discovery, at least for me, of a great IDE tool, only one EXE with 2MB size, for .Net C# snippet codes.

The tool is called as LINQPad. Its user interface is very simple. On the top are menus and tool bars. The left panel is for Database connection or database structure list. The right panel is composed of top and bottom parts: code IDE and result view. This tool supports C# & VB expression, statements, programs, and SQL. It is very easy to use. However, it is very buggy. This morning I give it a try. After I added a reference to my library and added several my namespace lists. I could not to get a simple Console out work in a new tab when I tried to show it to my work colleges. I had to restart the application and removed references and namespaces to get it back to work.

All the codes can be saved an xml file. Within the xml file, all the references, namespaces, and code snips are saved there. It is really cool. No wonder a user who answered my question recommended me to try this tool. I guess he knew I had no VIsual Studio available. We actually had a Mac computer.

The project is not an open source project. It is a closed project. The standard version is free and an advanced version with auto-completion feature is for sale. After I give it a thought for this back engine, I guess that application is not hard to create. I would use the .Net CodeCom namespace as .Net compiler engine to create a dynamic project with a template for a snippet as plug in codes, just as I posted in my previous blogs. The dynamic project could be a simple console application> if it compiles OK, then run it through Process class. The process is hidden and all the outputs can be redirected as output back to the application. The application interface parts can be done with MEF framework so that each view parts can be plugged with various UIs to support IDE code editor (such as supporting syntax color schemas for various languages), result view (grid or table layout) and other views.

With this structure, LinPad should be an open source project so that talent developers can make it much better and extendable. One person's dedication is great, but with Web world available, great resources from the world should be utilized.