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 |