index > Visual Studio Team System - Domain-Specific Language Tools > Reference from one DSL metamodel to another

Reference from one DSL metamodel to another


Hi,

How can I reference from my metamodel to element from another metamodel? For example, SDM (is based on old version of DSL), you can inherit or reference on elements from imported metamodels, but they implements it inside SDM. Probably, in the current version of the DSL you have implemented this as DSL functionality? May be if all referenced metamodels are loaded to Store it solves some problem, but how does it works for Designer, for instance?

Evgeny Popov

Evgeny Popov

We need this functionality as well, but have been unable to find any built-in way of accomplishing it. We were able to work around it by writing two custom directive processors that load the models being referenced before the DslDirectiveProcessor runs against our model. The code for these directive processors has been released into the public domain, and is available from http://orm.sf.net/DslImportDirectiveProcessor.zip. To use it, just build the project in the zip file and then add lines similar to the following to each of the .tt files in the GeneratedCode directory:

<#@ Dsl processor="DslImportDirectiveProcessor" requires="fileName='..\ObjectModel\ORMCore.dsl'" provides="dslLibrary='ORMCoreDslLibrary'" #>
<#@ Dsl processor="DslDirectiveProcessor" requires="fileName='..\ShapeModel\ORMShape.dsl'" #>
<#@ Dsl processor="DslImportEndDirectiveProcessor" #>

The middle line should already be present in the file. Before it, add one DslImportDirectiveProcessor line for each model that you want to reference (each must have a unique value for dslLibrary). After it, add a single DslEndImportDirectiveProcessor line (only one, regardless of how many models you are referencing).

This should make the code generation work, although the DSL Designer still won't.

You may still have some issues with the generated code, in particular the ToolboxHelper, since it tries to create a new Store and load your DomainModel into it (without loading the models that are being referenced). We have a work-around for this as well, which we can provide if you need it.

Hopefully the DSL Tools team builds this functionality into the product in the next release, since it is pretty important for a lot of scenarios (we use it for, among other things, keeping our presentation / view separate from our model, as well as for a number of our extensibility mechanisms).

P.S. Sorry for the brevity of this response, but IE lost the original response I wrote, and unfortunately I don't have time to rewrite all of it. Feel free to let me know if I wasn't clear enough about any of this.




Kevin M. Owen
Kevin M. Owen
Thank you! This is clear enough. But how do you work with DSL Tool? I mean how do you edit DslDefinition.dsl file. Even if you open it as XML file I didn't find a way to inherit my domain class from external source. It is possible to specify externalMoniker for Domain Property but not for "Base" definition:

<BaseClass>

<DomainClassMoniker Name="ArtifcatSource" />

</BaseClass>

Evgeny

Evgeny Popov

You can refer to it using a regular DomainClassMoniker (or any other type of Moniker, as appropriate).

The code generation components don't see it as "external" to the model, since they aren't even aware that another model has been loaded. In other words, you work with the parts of the external model as if they were in your model.

If the things you want to refer to elements that have a different namespace, you can use the same syntax as is used in ExternalTypeMonikers. It is basically:

/System.Foo/Bar

Where "System.Foo" is the namespace and "Bar" is the element.




Kevin M. Owen
Kevin M. Owen
In the V1 release, we've amended the supplied directive processor to correctly span a transaction across multiple uses of itself in one text template. However, this won't make the dsldesigner itself any happier with the multiple files in this release I'm afraid, so you will be stuck with editing the XML.


Gareth Jones - Developer - DSL Tools & Software Factories Platform [MSFT]
GarethJ - MSFT
reply 5

You can use google to search for other answers

 

More Articles

Why must the ShapeField's value be associated with a domain prope...
A better name for a BlankLanguage
Prevent generated DSL code from producing FxCop warnings
The definition of Triangle and Rectangle shape in Domain Model.
How to wrap words of one single line to multiple lines that fit i...
Changing type of element using property pane
Error creating DSL setup project (empty definitions)
Unregister DSL file extension
Compartiment with multiple classes to be added
Localization
Welcome to Bokebb   New Update   Joins the collection  
 

New Articles

What to use instead of GetDisplayPropert…
How to create multiple diagrams associat…
Custom Geometry Shape
Including template content inside method…
filtering reference dropdowns in the pro…
Controlling and detecting what elements …
Atrributes with particular properties
DSL Setup project fails to compile
Adopt model manually
Prevent rules from firing during model d…
Come Join the World's Largest Software F…
Unregister DSL file extension
Toolbox (in the Dsl Designer) only shows…
'security error'
Codegen templates selected at build time

Hot Articles

November DSL toolkit: how to add command…
academic distribution of a DSL
What one-shot recipes would you add to D…
Shape Icon and Shape Tool Minor Bug
problem with connector
CompartmentShapes Walkthrough causes Ove…
Right mouse click on model results in a …
Migrating to May CTP: MissingManifestRes…
How to Limit Number of Connectors Betwee…
Label Editing (how to prevent)
Defining custom multiplicities
May CTP is available....
How to create multiple diagrams associat…
filtering reference dropdowns in the pro…
how can i get a reference to a modelelem…

Recommend Articles

Unable to Replace Old Files by New ones
T4 Text Template Editor for VS2005
Many models, one template.
IsSerializing property
What can be created with DSL?
Is DSL development a language driven dev…
How to make the connector text parallel …
How to fill custom properties dynamicall…
Load Data designed in another model file
November release Designers compile errors
How to find the parent of a relationship…
Relationship representation
Next CTP
How can i associate a textfield with a p…
Documentation for Microsoft.VisualStudio…