0

I was trying to use the TemplateFileManager TT Include file (referenced from this article, and available in Tangible's template gallery) so that I could output multiple files from 1 T4 template, but I keep getting an error inside the default code. For some reason, this method returns null, and I cannot debug it easily enough to know why.

public static string GetProjectItemFullPath(EnvDTE.ProjectItem item)
{
    return item.Properties.Item("FullPath").Value.ToString();
}

Anybody know why? I did download the latest version (2.1) from their template download tool. My usage was very straightforward; I was trying to write out 2 CSV files. I have this declared:

<#@ output extension=".csv" #>
<#@ include file="TemplateFileManager.ttinclude" #>

At the top I create the TemplateManager:

var manager = TemplateFileManager.Create(this);

and when I want to split, I have this:

manager.StartNewFile("Documentation.Features.csv");

And at the end:

manager.Process();

I can debug through to know that the issue is with CleanupTemplatePlaceholders routine:

var dirtyHelperTemplates = VSHelper.GetAllSolutionItems(this.dte)
        .Where(p => delta.Contains(VSHelper.GetProjectItemFullPath(p)));

In this collection is an instance where something is null... (Object reference error).

Brian Mains
  • 50,520
  • 35
  • 148
  • 257
  • Attach another instance to debug it. Or simply rewrite it to throw when a null is first detected so you can figure out what's null (Value, I'd bet). Sounds like a bug on their part, no matter what. They'll need more details on *how* you are using it in order to repro. –  Jul 18 '18 at 16:42
  • Every time I try to use the immediate window, it is locking up (or taking a REALLY REALLY long time to come back with anything), so I gave up on that effort. V2.1 has been around for a really long time, which is why I thought someone would have experienced this... But I couldn't find any resolutions. I updated my example above. I wonder if it may because I'm outputting CSV? – Brian Mains Jul 18 '18 at 18:54

0 Answers0