title: Why don't LINQ and other features work in a T4 template?
body: <p>I've got a T4 template with a line like this:</p>
  
  <pre><code>Dim Variables = (From line in file.EnumerateLines() _
                  Let data = line.Split("|".ToCharArray())
                  Select new Variable With {.Name = data(0), .Type = data(1)}).ToList()
  </code></pre>
  
  <p><code>Variable</code> is defined elsewhere in the file, and <code>EnumerateLines</code> is defined in a utility library referenced by the template.  But I get tons of T4 compiler errors like <code>Close_parens expected</code> even though this is valid code that <strong>I cut and pasted from a VB code file in the IDE where it compiled just fine</strong>.  I'm referencing all needed libraries and importing namespaces, but it seems like T4 will only accept VB code from 8 years ago.  For example, this code is functionally identical, and compiles:</p>
  
  <pre><code>Dim Variables As New List(Of Variable)
  
  for each lineX As String in EnumerateLines(file)
      Dim data = lineX.Split("|".ToCharArray)
  
      Dim v as New Variable
      v.Name = data(0)
      v.Type = data(1)
  
      Variables.Add(v)
  next
  </code></pre>
  
  <p>How do I get T4 to understand LINQ, extension methods, initializers, and all the other stuff it doesn't seem to understand?</p>
  
  <p><strong>Update</strong>: 
  Just to clarify, I have the needed assemblies and namespaces imported:</p>
  
  <pre><code>&lt;#@ assembly name="System.Core" #&gt;
  &lt;#@ import namespace="System.Linq" #&gt;
  &lt;#@ import namespace="System.Text" #&gt;
  &lt;#@ import namespace="System.Collections.Generic" #&gt;
  &lt;#@ import namespace="Microsoft.VisualBasic" #&gt;
  </code></pre>