title: How to generate a simple class with T4?
body: <p>I'm working on a VSPackage that's supposed to generate simple classes from some data in a DB. I already have a static method <code>GetFieldInfo</code> that gets the data I need from the DB, and <code>GetFieldInfo</code> returns me a <code>List&lt;TableField&gt;</code> where <code>TableField</code> is a custom class that holds all the data I need.</p>
  
  <p>So far, my T4 template looks like this:</p>
  
  <pre><code>&lt;#@ template language="C#" #&gt;
  &lt;#@ assembly name="System.Core" #&gt;
  &lt;#@ import namespace="System" #&gt;
  &lt;#@ import namespace="System.Collections.Generic" #&gt;
  &lt;#@ import namespace="System.Linq" #&gt;
  &lt;#@ import namespace="System.Text" #&gt;
  &lt;#@ import namespace="System.Threading.Tasks" #&gt;
  &lt;#@ output extension=".cs" #&gt;
  &lt;#@ parameter name="namespace" type="System.String" #&gt;
  &lt;#@ parameter name="className" type="System.String" #&gt;
  &lt;#@ parameter name="fields" type="System.Collections.Generic.List&lt;TableField&gt;" #&gt;
  
  namespace &lt;#= this.namespace #&gt;
  {
      public class &lt;#= classname #&gt;
      {
          &lt;#
              foreach (TableField campo in fields)
              {
  
              }
          #&gt;
      }
  }
  </code></pre>
  
  <p>All this (the static method, the custom class and the template) are in different namespaces inside the same project. This project (let's call it "the helper project") is not the VSPackage project (it's added as a reference in the VSPackage one).</p>
  
  <p>My problem is, this template spits out 27 incomprehensible errors (Examples: <code>Class, delegate, enum, interface or struct expected</code> on line 2, column 9; <code>} expected</code> on line 7, column 9; <code>method must have a return value</code> on line 15, column 18) and frankly, I don't even know where to start checking. My gut tells me when there's many weird errors, it's usually because of a couple simple things that the dev forgot to add/configure, but so far I haven't found anything that can help me. And nowhere in Google have I found a tutorial/example to generate a class via T4.</p>
  
  <p>What do I want to generate? This:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  
  namespace [TARGET_PROJECT_NAMESPACE]
  {
      public class [TABLE_NAME]
      {
          public [FIELD_TYPE] [FIELD_NAME] { get; set; }
      }
  }
  </code></pre>
  
  <p>So, what am I doing wrong?</p>