我可以在Dsl中使用预处理模板生成代码吗? [英] Can I use preprocessed templates for code generation in my Dsl?

查看:56
本文介绍了我可以在Dsl中使用预处理模板生成代码吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我在visual studio 2010中开发了一个dsl。我想使用预处理的t4模板来生成代码以提高性能。我已将所有.tt文件的CustomTool更改为TextTemplatingFilePreprocessor。当我运行自定义工具时,我得到
得到以下错误:



处理名为'Blueprint'的指令时抛出异常。转换不会运行。抛出以下异常:Microsoft.VisualStudio.TextTemplating.DirectiveProcessorException:无法为指令'Blueprint'解析requires参数
'FileName'的值。在Microsoft.VisualStudio.TextTemplating.RequiresProvidesDirectiveProcessor.ProcessDirective(String directiveName,IDictionary 2
参数)。 TextTemplating.Engine.ProcessCustomDirectives(ITextTemplatingEngineHost主机,TemplateProcessingSession会话,List
1 directivesToBeProcessed)




这就行了:

  <#@    蓝图  processor   =  " BlueprintDirectiveProcessor"  需要  =  " fileName"    #>   



自定义指令是否与预处理模板兼容,还是另一个问题?

解决方案

DirectiveProcessers在"正常"和预处理模板中工作。


指令处理器是否需要一个名为"FileName"的参数,例如<#@ Blueprint processor =" ..." FileName =" myfile.xxx"#>


问候,


Duncan


I have developed a dsl in visual studio 2010. I would like to use preprocessed t4 templates for code generation to improve the performance. I've changed the CustomTool for all the .tt files to TextTemplatingFilePreprocessor. When I run the custom tool I get get the following error:

An Exception was thrown while processing a directive named 'Blueprint'. The transformation will not be run. The following Exception was thrown: Microsoft.VisualStudio.TextTemplating.DirectiveProcessorException: Unable to resolve a value for the requires parameter 'FileName' for directive 'Blueprint'. at Microsoft.VisualStudio.TextTemplating.RequiresProvidesDirectiveProcessor.ProcessDirective(String directiveName, IDictionary2 arguments) at Microsoft.VisualStudio.TextTemplating.Engine.ProcessCustomDirectives(ITextTemplatingEngineHost host, TemplateProcessingSession session, List1 directivesToBeProcessed)

this is on the line:

<#@ Blueprint processor="BlueprintDirectiveProcessor" requires="fileName" #>

Are custom directives compatible with preprocessed templates or is this another problem?

解决方案

DirectiveProcessers work in both "normal" and pre-processed templates.

Is the directive processer expecting a parameter called "FileName" e.g. <#@ Blueprint processor="..." FileName="myfile.xxx" #>

Regards,

Duncan


这篇关于我可以在Dsl中使用预处理模板生成代码吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆