T4 Templates generate error when generating template classes

1,966 views
Skip to first unread message

Damien Rider

unread,
Dec 9, 2013, 8:04:25 PM12/9/13
to glass...@googlegroups.com
Hi,

I'm getting an error when I hit "Re-Generate Code for all items" on my TDS project I get the following error in my code file:

*********************************************
An error occured while generating code for item '/sitecore/templates'.
T4 Template: D:\Oakton\Thinkable\Source\Thinkable.TDS.Master\Code Generation Templates\GlassV3Item.tt
Errors:
 
Compiling transformation: Invalid token 'this' in classstruct, or interface member declaration
 
Compiling transformation: Method must have a return type
 
Compiling transformation: Type expected
 
*********************************************

The T4 templates from Hedgehog's Github work fine but when I grab the V3 templates they don't work for me.

Please help.

Thanks.

Damien Rider

unread,
Dec 10, 2013, 1:49:49 AM12/10/13
to glass...@googlegroups.com
Follow up, use the V3 templates from here, https://github.com/mikeedwards83/tds-codegen/tree/master/Sitecore.Master/Code%20Generation%20Templates

Thanks for the help Michael.

Chirag Patel

unread,
Aug 18, 2014, 5:11:07 PM8/18/14
to glass...@googlegroups.com
I am still getting the same issue after downloading the latest from the link provided. 

Here is what I see in the Output Windows:
ERROR : on line 0 column 0 of file c:\users\sitecore\documents\visual studio 2013\Projects\Glass\Master\Code Generation Templates\glassv3item.tt
Compiling transformation: Invalid token 'this' in class, struct, or interface member declaration

ERROR : on line 0 column 5 of file c:\users\sitecore\documents\visual studio 2013\Projects\Glass\Master\Code Generation Templates\glassv3item.tt
Compiling transformation: Method must have a return type

ERROR : on line 0 column 11 of file c:\users\sitecore\documents\visual studio 2013\Projects\Glass\Master\Code Generation Templates\glassv3item.tt
Compiling transformation: Type expected

Generating file c:\users\sitecore\documents\visual studio 2013\Projects\Glass\Data\Models.cs

The Generated code file has the following error:
ErrorGeneratingOutput
*********************************************
An error occured while generating code for item '/sitecore/templates'.
T4 Template: c:\users\sitecore\documents\visual studio 2013\Projects\Glass\Master\Code Generation Templates\glassv3item.tt
Errors:

Compiling transformation: Invalid token 'this' in class, struct, or interface member declaration

Compiling transformation: Method must have a return type

Compiling transformation: Type expected

*********************************************
ErrorGeneratingOutput

Is anyone have the same issue?  I've also tried using the T4 Templates from here: https://github.com/HedgehogDevelopment/tds-codegen/tree/master/Sitecore.Master/Code%20Generation%20Templates

Thanks,

Chirag

Chirag Patel

unread,
Aug 25, 2014, 5:13:18 PM8/25/14
to glass...@googlegroups.com
Has anyone been able to get around this issue?

Ryan Tuck

unread,
Sep 1, 2014, 12:58:57 AM9/1/14
to glass...@googlegroups.com
I managed to resolve the issue with the glassv3item.tt T4 Template.

Following from this post: http://siderite.blogspot.com/2010/06/t4-error-compiling-transformation.html, it appears that there are extraneous space characters in the T4 Template file. 

Open the file, Ctrl + A to select all text, and remove all extra space and newline characters. Try 'Re-Generate Code for all Items' after each edit, and eventually all errors in the Output window disappeared.

It looks as though this issue in the Template was caused by this commit in August: https://github.com/HedgehogDevelopment/tds-codegen/commit/f3beeb30cc8b9593b8b43c2ce91d496fd0f7d198


Hope that helps,
Ryan

Chirag Patel

unread,
Sep 2, 2014, 1:59:01 PM9/2/14
to glass...@googlegroups.com
Thanks Ryan,

That did the trick.  
Reply all
Reply to author
Forward
0 new messages