1

I'm writing a T4 Template to generate code from various classes in the project.

I'd like to get all classes, then process them according to a custom attribute, however I can't get a list of classes, nor can see what I'm getting through the local variables window, as it says I have to turn on native code debugging.

This is the code I currently have:

<#
    IServiceProvider serviceProvider = (IServiceProvider)this.Host;
    DTE dte = (DTE)serviceProvider.GetService(typeof(DTE));
    var item = dte.Solution.FindProjectItem(Host.TemplateFile);
    var project = item.ContainingProject;
    foreach(EnvDTE.CodeElement element in project.CodeModel.CodeElements)
    {
        if (element.Kind == EnvDTE.vsCMElement.vsCMElementClass)
        {
            var myClass = (EnvDTE.CodeClass)element;
            //doing things with myClass
        }
    }
#>

but the if condition is always false. How can I see those variables through debugging?

BgrWorker
  • 619
  • 5
  • 20
  • Open two instances of visual studio. Debug one with the other (via attaching the debugger). –  Jul 16 '15 at 14:02

0 Answers0