This is a migrated thread and some comments may be shown as answers.

Debugging Custom T4 Templates

1 Answer 78 Views
Data Access Free Edition
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jimmy
Top achievements
Rank 1
Jimmy asked on 12 Nov 2013, 03:41 PM

I've created a custom T4 template (copied and modified the FluentModel.tt) and I'm having mixed results while debugging the template.  I've added the following line to the template file just before this.RunCodeGeneration():

System.Diagnostics.Debugger.Launch();

Sometimes this works, other times the template executes and exits without any errors or the VS prompt to debug.

I'm using VS 2012 with the latest install of OpenAccess Free Edition, VS project a Console App writing out the typical Hello World message.

1 Answer, 1 is accepted

Sort by
0
Dimitar Tachev
Telerik team
answered on 15 Nov 2013, 02:27 PM
Hi Jimmy,

 
In general having the debugger attached just before the RunCodeGeneration method call should be enough to debug the code generation template. For more details about this process I suggest you take a look at this blog post.

Regarding the inconstant behavior of the template execution that you have described - I was not able to reproduce this behavior both using our Fluent Library and the RLINQ file with Fluent Mapping which is a deprecated approach because our Fluent API is designed to be a code only approach providing auto-generated code only one time at the beginning.

Please bear in mind that if you use an RLINQ file with Fluent mapping the FluentModel.tt code generation template will not be used because the RLINQ files are using the DefaultTemplateCS.tt one while only the one-time code generation of our Fluent Library is using the FluentModel.tt for its code generation.

If you still experience the same behavior after considering the above-mentioned information could you please provide us with more details about the Fluent approach that you use (Fluent Library or RLINQ file with Fluent mapping)?

Also if you need advice or assistance with the modifications could you please provide us with more details about the goals that you need to achieve which will help us suggest you the recommended approaches and practices?

I am looking forward to your feedback.
 

Regards,
Dimitar Tachev
Telerik
OpenAccess ORM Q3 2013 simplifies your model operations even further providing you with greater flexibility. Check out the list of new features shipped with our latest release!
Tags
Data Access Free Edition
Asked by
Jimmy
Top achievements
Rank 1
Answers by
Dimitar Tachev
Telerik team
Share this question
or