【问题标题】:T4MVC Bug In generated code (Identifier expected)生成代码中的 T4MVC 错误(需要标识符)
【发布时间】:2016-06-26 10:01:14
【问题描述】:

我刚刚在一个新项目中安装了 T4MVC,但出现以下错误:
(我在之前的项目中使用过 T4MVC,从来没有遇到过这个问题)

CS1001: Identifier expected

错误来自这个生成的代码(在文件 T4MVC.cs 中):

[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
internal partial class T4MVC_System_Web_Mvc_FileResult : System.Web.Mvc.FileResult, IT4MVCActionResult
{
    public T4MVC_System_Web_Mvc_FileResult(string area, string controller, string action, string protocol = null): base(" ")
    {
        this.InitMVCT4Result(area, controller, action, protocol);
    }

    protected override void WriteFile(System.Web.HttpResponseBase ) { }

    public string Controller { get; set; }
    public string Action { get; set; }
    public string Protocol { get; set; }
    public RouteValueDictionary RouteValueDictionary { get; set; }
}

方法WriteFile 缺少System.Web.HttpResponseBase 参数的标识符。
有人有同样的问题吗? 有可用的修复程序吗?

【问题讨论】:

  • github.com/T4MVC/T4MVC 是报告问题的更好地方。但请包括重现步骤。
  • @DavidEbbo 好吧,重复步骤只是安装 T4MVC usig NugetPackage Manager 并运行 T4 模板。我正在使用 VS 2015,其中包含两种类型的控制器(MVC 和 WebApi)
  • 我会按照建议报告问题
  • 显然,并非所有解决方案都会发生这种情况,因此您的解决方案有很多特定的东西会触发这种情况。这就是我所说的再现。
  • 哦,等等,我知道问题所在。答案来了:)

标签: t4mvc


【解决方案1】:

这是一个已知的 VS 问题,已在 VS 补丁中修复。只需从https://msdn.microsoft.com/en-US/library/mt634751(VS.140).aspx 安装,它就会处理它。

另见https://github.com/T4MVC/T4MVC/issues/67

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-31
    • 1970-01-01
    • 1970-01-01
    • 2016-11-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多