I saw a system that used partial classes and partial methods to regenerate code without affecting user code. "Rules engine" if you are completely formed from the Visio status diagram. This is basically a bad mans workflow, but very easy to modify. The Viso diagram was exported to XML, which was read using powershell and T4 to generate classes.
The above example is for external DSL. I.E. external to the programming language in which the application runs. Alternatively, you can create an internal DSL that is implemented and used in a programming language.
This and the previous article on Code-Magazine 's DSLS article are pretty good.
In the link above, Neal Ford shows you how to create an internal DSL in C # using a free interface.
One thing he hasn't mentioned yet is that you can put this [EditorBrowsable (EditorBrowsableState.Never)] attribute in your methods so that they don't appear in intellisense. This means that you can hide methods other than the DSL (if you want) class from the DSL user, which makes the free API more understandable.
You can see that this video is currently recording Daniel Cazzulino ’s free interface about writing an IoC container with TDD
Regarding external DSLs, you also have the Oslo option (CTP for now) , which is powerful enough to allow you to create external DSLs that can be executed directly, and not to use code generation, which concludes that this is not a very big part of DSL at all.
Jonathan parker
source share