Custom Macros for File Templates via expression or annotations? Possible?
I need a Custom Macro for File Templates for Controllers and Views like this:
public class $ControllerName$<$formclass$>:BaseController<$formclass$>{
public $ControllerName$($formclass$ parent):base(parent){
}
$END$
}
the class name is the filename (for example: Form1Controller.cs → Form1Controller)
BUT the generic type is the class name WITHOUT the suffix “Controller” (Form1)
There are no macros that provide a “remove suffix” from another parameter.
A solution could be an EXPRESSION MACRO:
$$ControllerName.Replace("Controller","")$$
Another solution is add Macros via solution files and annotations:
[MacroDefinitionClass]
public static class MyCustomMacros{
[Macro("RemoveControllerSuffix")]
public string RemoveControllerMacro(string value)=>value.Remove("Controller","");
}
Please sign in to leave a comment.