A new sample of why and how to extend the DslDesigner … but also a way of enabling the Modelbus in your DSL.
Along with our RTM version of the Visual Studio Visualization and Modeling SDK, we have posted a new sample on the Code Gallery site: DslDesigner extension for Modelbus authoring
How to build the modelbus tool?
- Download the DslDesigner extension for Modelbus authoring sample zip file from the code gallery
- Unblock the zip file
- Extract all the files.
- Load the solution, and build it
- Go to DslDesignerExtensionForModelBus\bin\Debug (or DslDesignerExtensionForModelBus\bin\Release if you built it in Release mode), and double-click on the VSIX file (Microsoft.VisualStudio.Modeling.Sdk.ModelBusAuthoringDslDesignerExtension.vsix) to install it as an extension.
- Restart VS.
How to use the modelbus tool?
Once you have installed the tool, open your DSL solution, open the DslDefinition.dsl, and right click:
- either on the design surface itself
- or on the root node in the Dsl explorer.
The context menu contains a command named “Enable ModelBus”.
Using it you’ll get the following dialog
If you check both check-boxes, this dialog will:
- Enable your DSL to consume the ModelBus (by referencing Microsoft.VisualStudio.Modeling.Sdk.Integration.10.dll, in the Dsl project, adding the ModelBusReference external type in the model, and adding a new Text template ModelBusReferencesSerialization.tt in the GeneratedCode folder)
- Add a new project in your solution containing a ModelBus adapter / adapter manager for your DSL, referencing it from the DslPackage, and updating the source.extension.tt file to take it into account.
Of course you can chose only one of these options if you want.
Once you have enabled your DSL to consume the Modelbus, you can add Domain properties of type ModelBusReference to your domain classes, and chose the “Edit ModelBusReference specific properties”.
Then, you get a dialog, enabling you to specify options to control the picker UI. for instance, if you want to propose to the user to only pick StateMachine model elements in .sm files, you can do the following.
You DslDefinition.dsl will be modified (incrementally) to add the necessary custom attributes to your reference DomainProperty, and when you rebuild (assuming you enabled T4-Msbuild, or otherwise transform all templates and rebuild), each Component Domain instance of your designer now has new property MyReference that can reference a state machine.
Why did we publish the tool as a sample?
We received in the past many questions, suggestions, requests, for new features, some of them being very specific. We therefore decided to enable the DslDesigner to be extensible and we wanted to show you that you can, if you wish, add yourself great features to the DslDesigner. That’s not that complex to do!
Along with the Release Candidate version of the VsVmSdk, we already proposed a simple extension to the DslDesigner sample from the Code gallery site. Also, in the MSDN library, there is a page describing https://msdn.microsoft.com/en-us/library/ff519533.aspx. Once you’ll have understood the basics of it, you’ll be able to look at the code for this new modelbus authoring tool, and understand how to integrate your features.
What next?
In my next posts, I’ll describe the architecture of this sample to help you dig into it, since it involves information about DslDesigner extensions, modelbus authoring, and visual studio integration (we add projects, files, modify other files). Also, you might have noticed that we are using here the fact that we enabled the DslDesigner to discover its MEF extensions (containing commands, validation, double-click and drag&drop gestures). The good new is that you can also, if you wish, enable your own designers to discover their extensions by MEF, and I’ll explain how to do this.
Meanwhile, we would appreciate very much your feedback. Do you find it useful to be able to extend the DSL Tools authoring tool? Do you have ideas of what you would like to add? Do you find it useful you enable your own designer to be extensible in a simple way using MEF?
Comments
Anonymous
April 15, 2010
help: how can i implement modelbus with vs.net 2008 dslAnonymous
April 15, 2010
Thanks for posting this, Jean-Marc. Will this allow building DSLs that integrate with the UML repository in 2010?Anonymous
January 19, 2012
How would one go about spawning this editor in a WPF-built DSL?