I usually have a companion class library project for all the code for my MVC web project. The class library has extension methods, action filters, initialization code, etc.
I've been wanting to also move my controllers there, but haven't been able to because of T4MVC. Specifically, the class library project cannot reference the T4MVC code-gen output, as it resides in the web project. I also cannot move T4MVC.tt to the class
library project as it then finds no views.
If I were to come up with a solution, it would likely be to introduce configurable base paths for source and view/static files, allowing either of those to be located in a project different from the .tt file.
I'm not sure if this would work for the source files too, but at the very least I would like to be able to have stuff like IT4MVCActionResult emitted elsewhere, so that one can define services or other logic that consume them. For instance, I recently added
a mail-sending service that included a bunch of links, and would have liked to pass these in as action results. Because of the T4MVC code location I had to pre-format these to URLs before passing them on to the service layer.
Please let me know if you've run into the same problem or have an opinion about the suggested fix.
I'd also appreciate a heads-up on whether the suggested solution is something that might get merged into T4MVC itself, assuming that it is purely opt-in and configurable.