【发布时间】:2011-10-24 09:00:39
【问题描述】:
我正在尝试使用 VS2010 Professional , windows 7 调试以下 T4 模板文件。
但调试器没有突出显示文件中的正确行:“Texttemplate2.tt”
文件 1:文件 1.tt
<#@ template debug="true" hostspecific="true" language="C#" #>
<#@ include file="Texttemplate2.tt" #>
<#
System.Diagnostics.Debugger.Launch();
int a= 10;
Write("ASS");
GetProperty("User","UserName");
#>
文件:Texttemplate2.tt
<#@ template debug="true" hostspecific="true" language="C#" #>
<#@ assembly name="System.Xml" #>
<#@ import namespace="System.Xml" #>
<#@ import namespace="System.IO" #>
<#+
public void Load()
{
string doc=null;
if(doc == null)
{
string templateDirectory = Path.GetDirectoryName(Host.TemplateFile);
string absolutePath = Path.Combine(templateDirectory,"../../App_Data/EntityUI_MetaData_Appsettings.xml");
}
}
public string GetProperty(string Entity, string prop)
{
Load();
string node="none";
if (node != "0" )
{
if (node == Entity )
{
return node;
}
}
return null;
}
#>
让我详细解释一下这个问题。我已经创建了上面的两个T4模板文件。现在我想调试我的 T4 模板文件“File1.tt”代码(不是生成的代码)。我做了什么我启动了调试器
System.Diagnostics.Debugger.Launch();
并设置断点
int a= 10;
。现在按 F5 会导致我的断点被命中。
int a= 10;
它现在以黄色作为背景,黄色箭头作为左侧突出显示。之后按 F11 直到到达
GetProperty
当这个方法被调用时,你会注意到黄色箭头,表示当前正在执行的语句没有突出显示。
意思是,假设 Line:20 是下一个执行语句,调试器会在 texttemplatefile2.tt 中高亮 line:10
【问题讨论】:
标签: c# asp.net visual-studio-2010 t4