Theseus 0.6.0

dotnet add package Theseus --version 0.6.0
                    
NuGet\Install-Package Theseus -Version 0.6.0
                    
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="Theseus" Version="0.6.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Theseus" Version="0.6.0" />
                    
Directory.Packages.props
<PackageReference Include="Theseus" />
                    
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 Theseus --version 0.6.0
                    
#r "nuget: Theseus, 0.6.0"
                    
#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 Theseus@0.6.0
                    
#: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=Theseus&version=0.6.0
                    
Install as a Cake Addin
#tool nuget:?package=Theseus&version=0.6.0
                    
Install as a Cake Tool

Theseus

IUrlHelper extensions to point at a controller method to generate links.

Example:

// Regular IUrlHelper:
string aboutUrl = Url.Action("About", "Home");
string buyUrl = Url.Action("Buy", "Products", new { id = 17, color = "red" });

// Theseus:
string aboutUrl = Url.To<HomeController>(y => y.About());
string buyUrl = Url.To<ProductsController>(y => y.Buy(17, "red"));

This library uses EpsilonEvaluator to evaluate the route parameters from the method arguments. Most expressions should be evaluated without compilation and compiled expressions are not cached.

Inspired by AspNet.Mvc.TypedRouting from Ivaylo Kenov.

Performance

Theseus is of course slower than generating the links the regular way.

If you want expression based routing with really good performance, take a look at https://github.com/mariusz96/uri-generation, it beats Theseus consistently, sometimes by as much as 200%. But the API is very different.

Generate links to method without parameters: | Method | Links per second | Note | | -------------------------------------------- | ---------------- | ------------------------- | | Url.To<HomeController>(y => y.Index()) | 2085989 | Theseus with cache | | Url.To<HomeController>(y => y.Index()) | 591933 | Theseus without cache | | Url.Action<HomeController>(y => y.Index()) | 535429 | from Panelak.TypedRouting | | Url.Action("Index", "Home") | 1105261 | - |

Generate links to method with scoped variable parameter: | Method | Links per second | Note | | ----------------------------------------------- | ---------------- | ------------------------- | | Url.To<HomeController>(y => y.List(page)) | 442179 | Cache not applicable | | Url.Action<HomeController>(y => y.List(page)) | 401513 | from Panelak.TypedRouting | | Url.Action("List", "Home", new { page }) | 976240 | - |

Generate links to method with property parameter: | Method | Links per second | Note | | ------------------------------------------------------------- | ---------------- | ------------------------- | | Url.To<HomeController>(y => y.List(this.CurrentPage)) | 404453 | Without cache | | Url.Action<HomeController>(y => y.List(this.CurrentPage)) | 8729 | from Panelak.TypedRouting | | Url.Action("List", "Home", new { page = this.CurrentPage }) | 982898 | - |

Thanks

  • blockmath_2048 for the name suggestion.
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.6.0 105 4/19/2025
0.5.0 169 4/6/2024
0.4.0 219 11/25/2023
0.3.0 160 11/18/2023
0.2.0 167 10/27/2023
0.1.2 172 10/25/2023
0.1.1 165 10/24/2023
0.1.0 155 10/24/2023