Note that there are some explanatory texts on larger screens.

plurals
  1. POT4 a namespace cannot directly contain membes such as fields or methods
    primarykey
    data
    text
    <p>Hi I am just starting out with T4 templates and I need to generate a javascript file based on the actions in my controller.</p> <p>I got the code all figured out forgetting the controllers and actions my only problem is that I am getting this error in the T4 template file and I do not understand it:</p> <blockquote> <p>Compiling transformation: A namespace cannot directly contain members such as fields or methods</p> </blockquote> <p>This is my code:</p> <pre><code>&lt;#@ template debug="false" hostspecific="false" language="C#" #&gt; &lt;#@ assembly name="System.Core" #&gt; &lt;#@ assembly name="$(TargetPath)" #&gt; &lt;#@ import namespace="System.Reflection" #&gt; &lt;#@ import namespace="System.Linq" #&gt; &lt;#@ import namespace="System.Text" #&gt; &lt;#@ import namespace="System.Collections.Generic" #&gt; &lt;#@ import namespace="eConnect.WebApi.Helpers.T4.ControllerDetails" #&gt; &lt;#@ import namespace="System.Web.Http;"#&gt; &lt;#@ output extension=".js" #&gt; define(['services/logger', 'services/jsonDataService', 'services/config', 'services/cachingService'], function (logger, jsonDataService, config, cache) { var dataService = { }; return dataService; }); &lt;# var controllers = ControllersInfo.GetControllers(); foreach(var controller in controllers) { Dictionary&lt;string, ParameterInfo[]&gt; actions = ControllersInfo.GetAllCustomActionsInController(controller, new HttpGetAttribute()); } #&gt; </code></pre> <p>There is also an external class that gets the controllers and actions but I do not think it's necesary for the current problem.</p> <p>What am I doing wrong?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload