Why are there no constant lines in the T4MVC generated code? My guess would be to copy constant compile-time values ββ...
But adding constants to the generated code would allow using the created T4MVC attributes in the attributes.
I am thinking of something like this:
Paste @line 400:
public const String ControllerNameCONST = @"<#=controller.ClassName #>";
Paste @line 445:
[<#= GeneratedCode #>, DebuggerNonUserCode] public static class ActionNamesCONST { <#foreach (var method in controller.ActionMethodsWithUniqueNames) { #> <# if (UseLowercaseRoutes) { #> public const string <#=method.ActionName #> = (<#=method.ActionNameValueExpression #>).ToLowerInvariant(); <# } else { #> public const string <#=method.ActionName #> = <#=method.ActionNameValueExpression #>; <# } } #> }
So, someone can use it like this:
[SomeAttribute(HomeController.ControllerNameCONST)] //instead of [SomeAttribute("Home")] //or [SomeAttribute(HomeController.ActionNamesCONST.SomeAction)] //instead of [SomeAttribute("SomeAction")]
Edit: use it as an autocomplete attribute for the model, so you can specify a βtargetβ controller and action on the model. Although it can rework the autocomplete attribute to take the ActionResult parameter as a parameter instead of the controller + action name ...
source share