Yesterday, I talked about the September CTP of the Domain Specific Language Tools. Over the next several days, I’m going to walk through an example of using the tools. I’ll try to throw in some tips and tricks along the way. If you follow along, by the end of the series you should have a better understanding of how the tools work. You may even be motivated to create your own DSLs.
In this first installment, I’ll cover downloading, installing, and running the tools.
The DSL tools can be downloaded from here. They require Visual Studio 2005 Beta 2. (See my previous post for a more detailed discussion of this topic.) They also require the Visual Studio SDK, which can be downloaded from here. You have to register before you can download the SDK, but the process is automated. So, a few minutes after you fill out the form, your account information should be e-mailed to you.
After you have installed everything, you will notice a new application on your start menu entitled “Visual Studio 2005 Experimental”. You don’t ever run this copy of Visual Studio directly. (You’ll see below how it is invoked.) You still run Visual Studo 2005 from Start -> Microsoft Visual Studio 2005 Beta 2.
Now you can build your first application. Create a new project in VS. For project type, select Other Projects -> Extensibility -> Domain Specific Language Designer. This starts a wizard. Instead of having you start from a blank screen, the wizard lets you select one of 6 pre-defined domain specific languages. The idea is that one of the pre-defined languages will be close to the one that you want to build and that it is easier to modify an existing one than start from scratch. For the initial project select “minimal language”. Press Next, then press Finish. Once the wizard has completed, open DomainModel.dsldm.
It turns out that the DSL designer is, itself, a DSL. So, the process you use to build your DSL, will be the same process users of your DSL will use to build their application. Basically, you have to first generate your code, and then build the solution. So, press the “Transform All Templates” button. It is next to the “Show All Files” button in the Solution Explorer. This takes what you see in the designer and uses it to generate code files. Next, rebuild the solution. Finally, select run without debugging.
A new copy of VS 2005 is started. This is actually the experimental version mentioned above. You are now seeing what a developer using your DSL would see. Open up “Sample.xyz”. Drag some additional lines and boxes into the designer. When you are done, press the “Transform All Templates Button”. Instead of creating a code file (we’ll do that in a future installment), this creates Language1Report.ReportTemplate/Language1Report.htm. View this file in your browser and see that it correctly describes your Sample.xyz file.
Next time, we will start building a new domain specific language. If you can’t wait, the DSL Tools come with four detailed walkthroughs for you to try out.