2011-12-22 80 views
3

美好的一天!T4MVC 2.6.65和UseLowercaseRoutes =真正的錯誤

我使用的是最新的T4MVC從65年2月6日從的NuGet(自64年2月6日升級),我給自己定

// If true, use lower case tokens in routes for the area, controller and action names 
static bool UseLowercaseRoutes = true; 

而且我得到了錯誤:

The expression being assigned to '....' must be constant ...\T4MVC.cs  

這裏是生成的代碼觸發錯誤:

[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] 
    public class ActionNameConstants { 
     public const string Calc = ("Calc").ToLowerInvariant(); 
    } 

這是一個錯誤?

回答

2

對不起,以前的改變打破了它。我只是推出了T4MVC的新版本(2.6.66),它解決了這個問題。那麼,它更像是一種解決方法,因爲它在使用UseLowercaseRoutes時基本不會生成常量標記。但那會讓我們現在就去。

問題的根源在於C#不支持在常量字符串中使用.ToLowerInvariant()。理想情況下,它只是在編譯時評估,但它不是那麼聰明:)

+0

謝謝,大衛!你一如既往的快!我將等待下一個NuGet更新... – artvolk 2011-12-22 19:08:53

+0

現在它已經到來,所以你應該可以通過NuGet更新! – 2011-12-23 04:56:30

+0

謝謝,它現在可行! – artvolk 2011-12-23 11:07:06