Skip to content

Compilation failure #139

Description

@chalcrow

I'm working on a project that uses T4MV, with the latest versions of the T4MVC and T4MVCExtensions nuget packages (v4.2.4)

When I rebuild the project in VS2022, I get an error for T4MVC.cs:

A namespace cannot directly contain members such as fields, methods or statements.

T4MVC.cs only contains ErrorGeneratingOutput

I'm getting error in controllers as follows. I think this is probably because T4MVC isn't compiling:

The name 'MVC' does not exist in the current context.

When I right click T4MVC.tt and choose 'Run custom tool', I see the following errors related to T4MVC.tt.hooks.t4:

Compiling transformation: Invalid token 'this' in class, record, struct, or interface member declaration
Compiling transformation: 'GeneratedTextTransformation.GeneratedTextTransformation()' must declare a body because it is not marked abstract, extern, or partial
Compiling transformation: Method must have a return type
Compiling transformation: Identifier expected

I'm looking for ideas in how to diagnose the issue, or what may be causing the issue. I don't believe it's a namespace conflict, as in this Q&A

If I right-click T4MVC.tt and select
Debug T4 template, I get other errors.

Here's my T4MVC.tt.settings.xml file:

<?xml version="1.0" encoding="utf-8"?>
<MvcSettings>
  <!--The namespace used by some of T4MVC's generated code-->
  <T4MVCNamespace>T4MVC</T4MVCNamespace>
  <!--The prefix used for things like MVC.Dinners.Name and MVC.Dinners.Delete(Model.DinnerID)-->
  <HelpersPrefix>MVC</HelpersPrefix>
  <!--Namespaces to be referenced by the generated code-->
  <ReferencedNamespaces>
    <!--<Namespace></Namespace>-->
  </ReferencedNamespaces>
  <!--The folder under the project that contains the areas-->
  <AreasFolder>Areas</AreasFolder>
  <!--You can list folders containing portable areas here-->
  <PortableAreas>
    <!--<Area></Area>-->
  </PortableAreas>
  <!--Name of folder in your project root that follows the FeatureFolder convention (controllers and views are placed within the same folder)-->
  <!--<FeatureFolderRootArea></FeatureFolderRootArea>-->
  <!--Names of areas which follow the FeatureFolder convention (controllers and views are placed within the same folder).
Use <Area>*</Area> if you only use Areas with FeatureFolders-->
  <FeatureFolderAreas>
    <!--<Area></Area>-->
  </FeatureFolderAreas>
  <!--Choose whether you want to include an 'Areas' token when referring to areas.
e.g. Assume the Area is called Blog and the Controller is Post:
- When false use MVC.Blog.Post.etc...
- When true use MVC.Areas.Blog.Post.etc...-->
  <IncludeAreasToken>False</IncludeAreasToken>
  <!--The folder under the project that contains the controllers-->
  <ControllersFolder>Controllers</ControllersFolder>
  <!--The folder under the project that contains the views-->
  <ViewsRootFolder>Views</ViewsRootFolder>
  <!--Views in DisplayTemplates and EditorTemplates folders shouldn't be fully qualifed
as it breaks the templated helper code-->
  <NonQualifiedViewFolders>
    <ViewFolder>DisplayTemplates</ViewFolder>
    <ViewFolder>EditorTemplates</ViewFolder>
  </NonQualifiedViewFolders>
  <!--If true, the T4MVC action result interface will be generated
If false, the namespace of the interface must be referenced in the 'ReferencedNamespaces' setting-->
  <GenerateActionResultInterface>True</GenerateActionResultInterface>
  <!--If true, [new] overrides will be created for async actions on AsyncControllers
This breaks the Go To Definition function for async actions.-->
  <SupportAsyncActions>False</SupportAsyncActions>
  <!--If true, use lower case tokens in routes for the area, controller and action names-->
  <UseLowercaseRoutes>False</UseLowercaseRoutes>
  <!--The namespace that the links are generated in (e.g. "Links", as in Links.Content.nerd_jpg)-->
  <LinksNamespace>Links</LinksNamespace>
  <!--The namespace that raw URLS used for bundles are generated-->
  <AssetsNamespace>Assets</AssetsNamespace>
  <!--If true, links to static files include a query string containing the file's last change time.
This way, when the static file changes, the link changes and guarantees that the client will re-request the resource.
e.g. when true, the link looks like: "/Content/nerd.jpg?2009-09-04T12:25:48"
See http://mvccontrib.codeplex.com/workitem/7163 for potential issues with this feature-->
  <AddTimestampToStaticLinks>False</AddTimestampToStaticLinks>
  <!--Folders containing static files for which links are generated (e.g. Links.Scripts.Map_js)-->
  <StaticFilesFolders>
    <FileFolder>Scripts</FileFolder>
    <FileFolder>Content</FileFolder>
  </StaticFilesFolders>
  <!--If true, static file helpers are generated for all view folders. See https://t4mvc.codeplex.com/discussions/445358-->
  <AddAllViewsFoldersToStaticFilesFolders>False</AddAllViewsFoldersToStaticFilesFolders>
  <!--Static files to exclude from the generated links-->
  <ExcludedStaticFileExtensions>
    <Extension>.cs</Extension>
    <Extension>.cshtml</Extension>
    <Extension>.aspx</Extension>
    <Extension>.ascx</Extension>
  </ExcludedStaticFileExtensions>
  <!--Files to exclude from the generated views-->
  <ExcludedViewExtensions>
    <Extension>.cs</Extension>
    <Extension>.master</Extension>
    <Extension>.js</Extension>
    <Extension>.css</Extension>
  </ExcludedViewExtensions>
  <!--When creating links with T4MVC, it can force them to HTTPS if the action method you are linking to requires Http.-->
  <AttributeIndicatingHttps>System.Web.Mvc.RequireHttpsAttribute</AttributeIndicatingHttps>
  <GenerateSecureLinksInDebugMode>False</GenerateSecureLinksInDebugMode>
  <!--Set this to false to omit the generation of parameters for action methods.-->
  <GenerateParamsForActionMethods>True</GenerateParamsForActionMethods>
  <!--Set this to true to omit the generation of parameters for action methods as constants.  Choose this or GenerateParamsForActionMethods.-->
  <GenerateParamsAsConstantsForActionMethods>False</GenerateParamsAsConstantsForActionMethods>
  <!--The suffix added to action method names for the property containing the parameters, for example ImportParams
for the Import action method.-->
  <ParamsPropertySuffix>Params</ParamsPropertySuffix>
  <!--create explicit HtmlHelpers for rendering partials-->
  <ExplicitHtmlHelpersForPartials>False</ExplicitHtmlHelpersForPartials>
  <ExplicitHtmlHelpersForPartialsFormat>Render{0}</ExplicitHtmlHelpersForPartialsFormat>
  <!--If true,the template output will be split into multiple files.-->
  <SplitIntoMultipleFiles>True</SplitIntoMultipleFiles>
</MvcSettings>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions