Microsoft Developer Network >
Forums Home
>
Microsoft Visual Studio 2010 Beta 2 Forums
>
Visual Studio Extensibility Beta 2
>
Preprocessed Text Templates and DSLs in VS2010
Preprocessed Text Templates and DSLs in VS2010
- I created a preprocessed text template to generate code from a DSL model in VS2010 Beta 1. I noticed that the Initialize() method is loading the model using an absolute path in the generated code. Are there any plans to solve this issue, using either of the following alternatives?
- Exposing a ModelPath property in the generated class that can be defined before calling Initialize().
- Generating an overload to the Initialize method that takes the model path as an argument.
Thanks.
Answers
- Hi Filipe,The code that's creating this fragment in the Initialize method is the model directive processor and the absolute path is coming from the absolute path in the template itself.You can modify the generated directive processor to do something else either by overriding generated methods or by changing the template used to generate the directive processor.We don't have any plans to modify this in the general DSL code as we're not focused on PreProcessed templates other than as a mechanism to allow T4's to run inside arbitrary .Net applications.As you can only really use DSLs in applications that work with (or close to Visual Studio) this isn't a high priority for us.
Gareth Jones - Architect - DSL Tools & Visual Studio eXtensibility [MSFT]- Marked As Answer byEsther FanMSFT, OwnerMonday, October 26, 2009 11:01 PM
All Replies
- Hi Filipe,The code that's creating this fragment in the Initialize method is the model directive processor and the absolute path is coming from the absolute path in the template itself.You can modify the generated directive processor to do something else either by overriding generated methods or by changing the template used to generate the directive processor.We don't have any plans to modify this in the general DSL code as we're not focused on PreProcessed templates other than as a mechanism to allow T4's to run inside arbitrary .Net applications.As you can only really use DSLs in applications that work with (or close to Visual Studio) this isn't a high priority for us.
Gareth Jones - Architect - DSL Tools & Visual Studio eXtensibility [MSFT]- Marked As Answer byEsther FanMSFT, OwnerMonday, October 26, 2009 11:01 PM
- I worked around this issue by adding an overload to the Initialize method in a partial class, but I did that by copying the entire method code (see details here ).
What could work would be to add a public property that holds the template path, and generating the Initialize method like this:
if (string.IsNullOrEmpty( this.ModelPath ))
{
this .examplemodelValue = Company.Language1.Language1SerializationHelper.Instance.LoadModel(serializationResult, this .Store, this.ModelPath , null , null , null );
}
Then it would be possible to call the template like this:
DslTextTemplate t = new DslTextTemplate();
t.ModelPath = "C:\\Users\\MyUser\\Documents\\Visual Studio 10\\Projects\\Language1\\Language1\\Debugging \\Sample.mydsl1" ;
t.Initialize();
this .Write(t.TransformText());

