dotnet / Scaffolding

Code generators to speed up development.
MIT License
642 stars 229 forks source link

Multiple templates per projects #108

Open mmgafri opened 9 years ago

mmgafri commented 9 years ago

Hi the current scaffolding implementation restrict scaffolding to generators implementing ICodeGenerator which are controller and view

paths and folders are strongly typed in Microsoft.Framework.CodeGenerators.Mvc\Constants.cs

this implementation is sufficient when I only need a single template for controller and view however if i need multiple templates per project I will have to create a separate project to extend ICodeGenerator for new templates and reference them in my web project

the implementation in previous mvc was folder structure based for defining new templates in customization I used to add folders to Templates folder in my project and they would come up in scaffolding GUI to choose from

real world example when ever I launch new project I copy my templates folder which contain: templates\controller templates\MasterDetailController templates\MasterDetailPopUpController templates\SecurityController

and start scaffolding on the fly without any need for separate project for scaffolding tempalates

suggestion: add a new template called "custom" which require template folder name such as "MasterDetailPopUp" so I could run scaffolding command as follow

dnx . gen custom -m Person -dc MyCOntext -path MasterDetailPopUpController

at the end of template\MasterDetailPopUpController\ControllerWithContext.cshtml there should be a 5 scaffolding commands for related views of controller instead of strongly typed view names ( "Create", "Edit", "Details", "Delete", "List" ) within ControllerGenerator.cs example command AlsoScaffold("CreateView"); AlsoScaffold("EditView"); AlsoScaffold("DetailsView"); AlsoScaffold("DeleteView"); AlsoScaffold("ListView");

this approach will make scaffolding more convenience and a productive and eliminate the need for unnecessary projects for customized templating

barrytang commented 8 years ago

TFS Bug#232575

sayedihashimi commented 8 years ago

Hi @ddddddddeee22211, thanks a lot for taking the time to look into scaffolding and to post this issue. We don't have a great story for custom scaffolders today. We are focused on getting .NET Core scaffolding up to par with ASP.NET, and after that we will likely start looking more into areas like this.