One of the things that proved to be move complicated than it should have been when we were developing the DSLs for the Service Factory: Modeling Edition was renaming DSL model elements.
This sounds easy; open the DSL designer, rename the element and then transform all templates to regenerate the code. Unfortunately this doesn’t update any of the custom code you may have written because the DSL designer doesn’t inform Visual Studio of the change. Worse still Visual Studio’s code model is now unable to help you finish the renaming because the code is incorrect.
The trick is to use the Visual Studio refactoring tools to change the code before you change the DSL. This will change both the custom code and the generated code but not the DSL model. Once you’ve done this then go back and change the DSL model using the designer.
- Rename the model element class using the VS refactoring tools.
- Update any related property names on other model element classes that refer to renamed element (see below).
- Open the DSL designer and rename the model element.
- Transform all templates to regenerate the code.
- Rebuild the solution to check everything is consistent.
Note that the DSL designer may do additional renaming. For example if I have a model element Foo that has a relationship with another element Bar then Bar will have a property Bar.Foo. When I rename Foo to NewFoo the DSL designer will also rename the property to Bar.NewFoo. You need to anticipate this when you rename the code prior (step 2) to changing the DSL model.