How to output namespace in T4 templates?

前端 未结 6 816
無奈伤痛
無奈伤痛 2020-12-25 11:21

I have a T4 template for a class set up with TextTemplatingFileGenerator Custom Tool in Visual Studio:

<#@ template language=\"C#v3.5\" hostspecific=\"Tru         


        
6条回答
  •  Happy的楠姐
    2020-12-25 11:34

    Damien Guard includes some code in a blog posting which retrieves the Custom Tool Namespace for a given file:

    public override String GetCustomToolNamespace(string fileName)
    {
        return dte.Solution.FindProjectItem(fileName).Properties.Item("CustomToolNamespace").Value.ToString();
    }
    

提交回复
热议问题