We’ve just published an updated set of samples for the DSL Tools. As well as updates to the previous examples, which show how to customize your DSL, there’s now a complete small end-to-end showing how a DSL can be used to generate the code of a project, and work as part of a larger solution.
The scenario in the end-to-end is in a team where they often have to design Windows wizards. The layout of the wizard pages is constant, with Next and Back buttons and so on; but the sequence of pages can change. So the team decide to create a Wizard Sequence Definition language. From the language, most of the code for the wizards is generated.
The developer assigned to author the language actually has two jobs: as well as creating the wizard sequence DSL itself, she has to create the generators that turn it into code. She begins by designing a typical wizard, and then gradually turns it into a template which reads the page sequence from a DSL instance. There are multiple code files in the wizard, so there is a complete project full code all generated from one DSL file.
When she is confident she has the language and the generated wizard project working, she packages it into a standard installer (MSI), with the help of the DSL Setup project. After her colleagues run the installer, they have a new project template available in theVisual Studio “new project” menu, which creates their own copy of the wizard project. They can now add a wizard to any application, and quickly generate the wizard code from a drawing of the page sequence.
The sample also makes good use of the new validation framework. Not all wizard sequences are valid – for example, you shouldn’t have pages that can’t be reached from the start page. The language author only has to create the code for the constraints themselves, and the validation framework applies them at the right times and manages the error list.