【发布时间】:2010-12-25 04:03:01
【问题描述】:
我正在开发一个 DSL 工具,对于这个工具,有一个自定义代码生成工具可以创建输出文件。目前,此工具是使用 DslPackage 上的 RegistrationAttribute 向 C# 注册的,代码如下:
class FileGenerationRegistrationAttribute : RegistrationAttribute
{
private const string CSharpGeneratorsGuid = "{fae04ec1-301f-11d3-bf4b-00c04f79efbc}";
private const string CSharpProjectGuid = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}";
public override void Register( RegistrationAttribute.RegistrationContext context )
{
// register custom generator
key = context.CreateKey( @"Generators\ " + CSharpGeneratorsGuid );
...
key.Close();
// register editor notification
key = context.CreateKey( @"Projects\ " + CSharpProjectGuid + @"\FileExtensions" );
...
key.Close();
}
}
这可行,但问题是,该工具生成的代码将是语言中立的(通过使用 CodeDOM)。它不需要项目是 C# 类型。所以我的问题是:为了让我的工具可用于任何类型的项目,我可以使用哪些 GUID 而不是演示的 CSharpGeneratorsGuid 和 CSharpProjectGuid? (如 VB、F#、IronPython 等)
【问题讨论】:
-
不幸的是,我自己的研究告诉我这是不可能的,所以我真的希望有人能提供比这更好的消息。
标签: visual-studio code-generation dsl customtool