G4mvc 1.0.0-preview.1.22282.6

This is a prerelease version of G4mvc.
There is a newer version of this package available.
See the version list below for details.
dotnet add package G4mvc --version 1.0.0-preview.1.22282.6
                    
NuGet\Install-Package G4mvc -Version 1.0.0-preview.1.22282.6
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="G4mvc" Version="1.0.0-preview.1.22282.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="G4mvc" Version="1.0.0-preview.1.22282.6" />
                    
Directory.Packages.props
<PackageReference Include="G4mvc" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add G4mvc --version 1.0.0-preview.1.22282.6
                    
#r "nuget: G4mvc, 1.0.0-preview.1.22282.6"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package G4mvc@1.0.0-preview.1.22282.6
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=G4mvc&version=1.0.0-preview.1.22282.6&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=G4mvc&version=1.0.0-preview.1.22282.6&prerelease
                    
Install as a Cake Tool

G4mvc

G4mvc is a source generator for ASP.NET Core MVC apps that creates strongly typed helpers that eliminate the use of literal strings in many places.

It is a re-implementation of R4MVC using a C# Source Generator.

Installation

Install the G4mvc and G4mvc.Generator NuGet packages.

To enable the use of the tag helpers for anchor and form tags, add the @addTagHelper *, G4mvc.TagHelpers directive either in the view, or in the _ViewImports.cshtml to enable them globally.

If you want to use the IUrlHelper and IHtmlHelper Extension methods, add a using directive for G4mvc.Extensions either in the view, or in the _ViewImports.cshtml to enable them globally.

It might be necessary to restart Visual Studio for these changes to take affect.

Use

Source Generation

In order for the code generation to work, the controller class has to derive from the Microsoft.AspNetCore.Mvc.Controller class. Abstract classes will also be ignored. All Methods for which a routing helper should be generated, have to return Microsoft.AspNetCore.Mvc.IActionResult, Microsoft.AspNetCore.Mvc.Infrastructure.IConvertToActionResult or an implementation of either of these interfaces. For asyncronous controller actions, the task has to return one of these.

Examples: public IActionResult Edit(EditViewModel viewModel) public JsonResult Edit(EditViewModel viewModel) public Task<IActionResult> Edit(EditViewModel viewModel) public Task<JsonResult> Edit(EditViewModel viewModel) public IConvertToActionResult Edit(EditViewModel viewModel) public ActionResult<IEnumerable<string>> Edit(EditViewModel viewModel)

Something like public IEnumerable<string> Edit(EditViewModel viewModel) would be ignored.

Extensions

The G4mvc package provides a number of extension methods that can make using the generated route helpers a bit easier. You do however not have to rely on these because the G4mvcRouteValues class derives from the standard Microsoft.AspNetCore.Routing.RouteValueDictionary, so you can use any of the methods provided by ASP.net Core, that have an object routeValues parameter. An example would be the HtmlHelper.RouteLink Method. The provided extension methods are just wrappers for these methods.

Tag Helpers

G4mvc provides a TagHelper that can be used on anchor as well as form tags.

<a g4-action="MVC.Home.Index()">Home</a>

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on G4mvc:

Package Downloads
G4mvc.Generator

A source generator for ASP.NET Core MVC apps that creates strongly typed helpers that eliminate the use of literal strings for routing

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
6.0.0-beta.supportforrazorp... 114 6/25/2025
6.0.0-beta.supportforrazorp... 110 6/25/2025
6.0.0-beta.supportforrazorp... 109 6/25/2025
6.0.0-beta.supportforrazorp... 124 6/23/2025
5.0.4 44 8/4/2025
5.0.4-preview.104 55 7/11/2025
5.0.4-beta.issuewithusinggm... 43 7/11/2025
5.0.4-beta.issuewithusinggm... 47 7/11/2025
5.0.4-beta.issuewithusinggm... 115 7/8/2025
5.0.4-beta.issuewithgconten... 52 7/11/2025
5.0.4-beta.issuewithgconten... 46 7/11/2025
5.0.3 158 7/8/2025
5.0.3-preview.94 71 7/5/2025
5.0.3-beta.issuewithusinggm... 117 7/8/2025
5.0.3-beta.generatelinksonr... 107 7/6/2025
5.0.3-beta.generatelinksonr... 42 7/5/2025
5.0.3-beta.generatelinksonr... 46 7/5/2025
5.0.3-beta.generatelinksonr... 42 7/5/2025
5.0.3-beta.generatelinksonr... 47 7/5/2025
5.0.3-beta.generatedviewfil... 75 7/4/2025
5.0.2 211 3/17/2025
5.0.1-preview.76 127 3/16/2025
5.0.1-preview.70 131 3/13/2025
5.0.1-beta.removeoldslnfile.69 124 3/13/2025
5.0.1-beta.removenetstandar... 123 3/16/2025
5.0.1-beta.removenetstandar... 128 3/13/2025
5.0.0 155 11/14/2024
5.0.0-beta.slntoslnx.55 70 11/9/2024
5.0.0-beta.preview.59 56 11/14/2024
5.0.0-beta.net.61 55 11/14/2024
5.0.0-beta.net.58 70 11/10/2024
5.0.0-beta.net.57 61 11/10/2024
4.1.2 174 8/8/2024
4.1.2-beta.slntoslnx.52 64 11/9/2024
4.1.2-beta.readmeismissingn... 63 8/8/2024
4.1.2-beta.net.54 67 11/9/2024
4.1.1 177 5/23/2024
4.1.1-linkgenerationforsubf... 80 5/23/2024
4.1.1-linkgenerationforsubf... 70 5/23/2024
4.1.1-beta.readmeismissingn... 66 7/2/2024
4.1.1-beta.preview.45 66 6/12/2024
4.1.0 179 5/5/2024
4.1.0-preview.19 39 5/2/2024
4.1.0-preview.18 36 5/2/2024
4.1.0-preview.17 32 5/2/2024
4.1.0-preview.11 92 2/5/2024
4.1.0-preview.10 85 2/2/2024
4.1.0-missingcommasindocume... 70 5/8/2024
4.1.0-linksgenerationimprov... 78 5/5/2024
4.1.0-linksgenerationimprov... 76 5/5/2024
4.1.0-linkgenerationforsubf... 71 5/23/2024
4.1.0-10-links-generation-i... 74 5/5/2024
4.1.0-10-links-generation-i... 74 5/4/2024
4.1.0-10-links-generation-i... 73 5/4/2024
4.1.0-10-links-generation-i... 38 5/2/2024
4.1.0-10-links-generation-i... 42 5/2/2024
4.1.0-10-links-generation-i... 36 5/2/2024
4.1.0-10-links-generation-i... 70 4/19/2024
4.1.0-10-links-generation-i... 72 4/19/2024
4.0.0 274 1/4/2024
4.0.0-preview.12 73 3/20/2024
4.0.0-preview.9 67 2/2/2024
4.0.0-preview.8 72 2/2/2024
3.0.0 2,076 9/25/2023
3.0.0-preview.21 89 1/4/2024
3.0.0-preview.3 91 1/4/2024
3.0.0-preview.2 84 1/4/2024
3.0.0-preview.1.23285.2 88 10/12/2023
3.0.0-preview.1.23285.1 85 10/12/2023
3.0.0-preview.1.23230.3 99 8/18/2023
2.3.0 290 7/16/2023
2.2.1-preview.1.23197.3 115 7/16/2023
2.2.1-preview.1.23197.2 111 7/16/2023
2.2.1-preview.1.23197.1 113 7/16/2023
2.2.1-preview.1.23195.4 117 7/14/2023
2.2.1-preview.1.23195.3 115 7/14/2023
2.2.1-preview.1.23195.2 110 7/14/2023
2.2.1-preview.1.23195.1 115 7/14/2023
2.2.0 273 7/11/2023
2.1.2-preview.1.23192.1 111 7/11/2023
2.1.1 278 6/18/2023
2.1.1-preview.1.23169.3 106 6/18/2023
2.1.1-preview.1.23169.2 105 6/18/2023
2.1.1-preview.1.23169.1 108 6/18/2023
2.1.1-preview.1.23166.10 112 6/15/2023
2.1.1-preview.1.23166.9 112 6/15/2023
2.1.1-preview.1.23166.8 108 6/15/2023
2.1.1-preview.1.23166.7 108 6/15/2023
2.1.1-preview.1.23166.5 115 6/15/2023
2.1.0 1,046 6/1/2023
2.0.0 281 5/13/2023
1.1.2 765 3/5/2023
1.1.1 496 2/25/2023
1.1.0 489 2/9/2023
1.0.5 624 1/2/2023
1.0.4 653 11/21/2022
1.0.3 708 11/21/2022 1.0.3 is deprecated because it has critical bugs.
1.0.2 666 11/21/2022 1.0.2 is deprecated because it has critical bugs.
1.0.1 649 11/17/2022
1.0.0 817 10/9/2022
1.0.0-preview.1.22282.6 144 10/9/2022
1.0.0-preview.1.22253.6 207 9/10/2022
1.0.0-preview.1.22243.5 172 8/31/2022