R4MVC is a Roslyn code generator for ASP.NET MVC Core apps that creates strongly typed helpers that eliminate the use of literal strings in many places.
It is a re-implementation of T4MVC for ASP.NET Core projects.
Instead of
@Html.ActionLink("Dinner Details", "Details", "Dinners", new { id = Model.DinnerID }, null)
R4MVC lets you write
@Html.ActionLink("Dinner Details", MVC.Dinners.Details(Model.DinnerID))
When you're using tag helpers, instead of
<a asp-action="Details" asp-controller="Dinners" asp-route-id="@Model.DinnerID">Dinner Details</a>
you can write
<a mvc-action="MVC.Dinners.Details(Model.DinnerID)">Dinner Details</a>
and that's just the beginning!
R4MVC runs in Visual Studio 2017, and supports ASP.NET Core MVC 1 (v2 support in progress)
To use it, simply install the R4Mvc and R4Mvc.Tools package using NuGet. It will add the necessary tooling to your project, which will be invoked on install. You will instantly see a number of files get created in your project.
Unlike T4MVC, R4MVC isn't based on a T4 template, so triggering the generation code is slightly different. Currently, you would need to open the Package Manager Console (Tools Menu -> NuGet Package Manager -> Package Manager Console) and running the following PowerShell command:
> Generate-R4MVC
- Install R4MVC in your MVC app using NuGet
- Learn: visit the Documentation page
- Discuss: Discuss it on GitHub
- Contribute
- History & release notes: change history