Click here to Skip to main content
15,888,065 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying to debug the following T4 template file using VS2010 professional , windows 7.

But debugger doesn't highlight the Correct line in the File : "Texttemplate2.tt"

File 1: File1.tt

XML
<#@ template debug="true" hostspecific="true" language="C#" #>

<#@ include file="Texttemplate2.tt"  #>

<#

System.Diagnostics.Debugger.Launch();



    int a= 10;

    Write("ASS");

    GetProperty("User","UserName");

#>

File : Texttemplate2.tt
XML
<#@ 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;
    }
 #>

Is anything wrong with my code or VS2010 debugger.

Revised :

I have read all the related links regarding T4 template.but my problem is different. Let me explain the question in detail.I have created the above two T4 template files. Now I want to debug my T4 template file "File1.tt" Code ( not the generated code). what I did I launched debugger with
System.Diagnostics.Debugger.Launch();
and set breakpoints in the at
int a= 10;
.pressing F5 now caused my breakpoint is to be hit.
int a= 10;
is now highlighted with YELLOW COLOR as BACKGOUND and YELLOW ARROW as in LEFT . press F11 thereafter until you reach
GetProperty
, there you will notice that YELLOW ARROW , means current executing statement is not highlighted.

Meant, supppose Line:20 is the next executing statement , the debugger highlights line:10 in texttemplatefile2.tt
Posted
Updated 23-Oct-11 18:22pm
v4

1 solution

Not sure what you mean... There is error on line X, but the error list says it's on line Y?
And without the error message it is hard to say what's wrong. Why not simply generate the code and see where your error is?
Anyway, perhaps one of these links can help you solve your problem.
Code Generation and T4 Text Templates[^]
Troubleshooting T4 Text Templates[^]
Common Error and Warnings while using Text Templates[^]
 
Share this answer
 
Comments
_Ashish 24-Oct-11 0:28am    
Thanks for the reply.The problem is different. I have updated my question. while debugging template file the yellow color highlight the line X when actually line Y is being executed when "getProperty" method is being executed.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900