none
T4 template how to add comment for T4 logic

    Question

  • Hi,

    Is there an option for adding comment for logic in T4 template. the comment is not for the generated code, so should not be in generated file. Comment is for new member understanding the logic of T4 template


    singhhome

    Tuesday, March 28, 2017 9:21 PM

Answers

  • Hi singhhome,

    Thanks for posting here.

    >>>Is there an option for adding comment for logic in T4 template?

    Do you want to add comment in T4 template for new member understanding the logic of T4 template?

    If yes, you can use below code to achieve that:

    <#
        // My Comment
    #>

    If I did not understand the correct words, please correct me for free, and describe your problem in more detail. Thanks.



    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Wednesday, March 29, 2017 7:31 AM

All replies

  • Hi singhhome,

    Thanks for posting here.

    >>>Is there an option for adding comment for logic in T4 template?

    Do you want to add comment in T4 template for new member understanding the logic of T4 template?

    If yes, you can use below code to achieve that:

    <#
        // My Comment
    #>

    If I did not understand the correct words, please correct me for free, and describe your problem in more detail. Thanks.



    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Wednesday, March 29, 2017 7:31 AM
  • You have an option to use one of two languages to code the logic. See the "template" directive and "language" parameter.

    You also have a code block - <# ... #> - where you put your logic of producing output. Code inside the block is a regular code on selected language - you can put your comments as usual.

    In addition...

    Needs of puting a comments into template code looks for me as template complexity problem. May be will be better to cut a huge template to a logical parts and implement a call of subtemplate.

    Tuesday, April 11, 2017 1:44 PM