Share via


Walkthrough: Creating a Domain-Specific Language Solution

This walkthrough teaches how to create a domain model, a designer, and an artifact generator to build a domain-specific language that is based on a family tree. Related walkthroughs teach how to customize the designer and add validation to it.

Prerequisites

Before you can start this walkthrough, you must complete these tasks:

Creating a Domain-Specific Language

Use the Domain-Specific Language Designer Wizard to create an initial domain-specific language for family trees.

To create a domain-specific language solution

  1. On the File menu, point to New, and then click Project.

    The New Project dialog box appears.

  2. Under Project types, expand the Other Project Types node, and click Extensibility.

  3. Under Templates, click Domain-Specific Language Designer.

    Important noteImportant Note:

    Do not click the Domain Specific Language Setup template.

  4. In the Name box, type FamilyTree as the name for the solution. Click OK.

    The Domain-Specific Language Designer Wizard appears.

  5. On the Select Domain-Specific Language Options page, select Minimal Language.

    When you select a solution template, the wizard displays a description. For more information about solution templates, see Choosing a Domain-Specific Language Solution Template.

  6. In the What do you want to name your domain-specific language box, the name that you specified for the solution (FamilyTree) appears by default. For this walkthrough, just leave it as is. Click Next.

    Note

    The name that you type must be a valid Visual C# identifier because the system uses it to generate code.

  7. On the Define New Model File Type page, in the What extension should model files use? box, type ftree. Click Next.

    You can select Unregister domain-specific language tools that currently handle this extension if you want to disassociate a file name extension from a previously created domain-specific language and register the file name extension with this new domain-specific language. Domain-specific languages that are currently registered to the file name extension appear in the list. By default, Unregister domain-specific language tools that currently handle this extension is selected. We recommend that you leave the option selected or specify a different file name extension so that you can avoid registration problems.

    The list under Other tools and applications registered to handle this extension shows conflicts with other file types on the local computer only. Also consider potential conflicts with registered file types on other computers, such as those of the language users.

    Note

    You can change the file name extension that is associated with the domain-specific language after you complete the wizard.

  8. On the Specify Product Details page, in the What is the name of the product that the new domain-specific language belongs to? box, type FamilyTree.

  9. In the What is the name of the company that the product belongs to? box, type Fabrikam or your company name.

    The names that you type on this page are automatically composed to create the namespace that is shown at the bottom of the page. The namespace should comply with the typical namespace rules.

  10. Verify that the namespace is valid, and then click Next.

  11. On the Select Strong Name Signing Method page, click Next to accept the default settings.

  12. On the Review Details of the Domain-Specific Language Solution page, review the settings that you have specified.

  13. If changes are required, click Previous to make corrections.

  14. When you are satisfied with the settings, click Finish.

    The wizard creates a solution named FamilyTree that is based on the Minimal Language solution template and the information that you supplied in the wizard. The solution has two projects, which are named Dsl and DslPackage.

    Note

    When you create a project, the wizard automatically generates default text templates. When you generate a text template, a message alerts you not to run text templates from untrusted sources. You can set this message not to appear again.

Next Steps

The solution that you create by following this walkthrough has the name and language file name extension that are required to define a minimal language.

In Walkthrough: Customizing the Domain-Specific Language Definition, you can continue to define the domain-specific language for a family tree. As you follow the steps, you can learn about how to use the domain model designer and the notation that is used to define domain-specific languages. As far as it is defined in this walkthrough, the domain-specific language will let inconsistencies occur, for example, setting the birth date of a child to a date before the birth date of a parent. Walkthrough: Adding Validation to a Domain Model shows how to add validation to check for this mistake and inform users about it. The validation identifies the problem by comparing birth dates.

See Also

Other Resources

Domain-Specific Language Tools Glossary

Change History

Date

History

Reason

July 2008

Rewrote and refactored project.

Content bug fix.