OSSRouter - create from the Microsoft Router Component source code How to Extract and Transform the AspNetCore source files for the Router Component 2022-08-01 gman_43229@yahoo.com *** NOTE: this is relatively straight forward so just follow the steps below. *** STEP 1 *** Install Visual Studio Extension (or the VSCode extension/addon) Wix Toolset VisualStudio 2022 Extensions *** STEP 2 *** Download the source code; AspNetCore ZIP file: .NET 6.0.6 .NET 7 Preview 5 The whole AspNetCore source including Blazor: https://github.com/dotnet/aspnetcore click: Code then Download Or, just the Blazor Components portion: https://github.com/dotnet/aspnetcore/tree/main/src/Components?WT.mc_id=dotnet-35129-website Unzip the source into a folder/directory *** STEP 3 *** from the aspnetcore source, copy the following directory/folders and content: src\Components\Components\Src <-- affected by Wix Toolset Extension ! copy to: [project]\Components\Components <-- to your target project HotReload qty 1 file Reflection qty 3 files Routing qty 19 files Shared qty 2 files *** STEP 4 *** must comment out all of the code in the following files (or delete the files): Components/Routing/ INavigationInterception.cs LocationChangedEventArgs.cs RouteData.cs Router.cs <-- see Note 1 below Components/Shared/ QueryStringEnumerable.cs <-- see optional Step 10 Note 1: may need to comment out a small portion of code in this file. for: ""private static partial class Log" and the three references to it. *** STEP 5 *** Prepend the full namespace to specific class models below: Components/Routing/ Router.cs <-- see Note 2 below Note 2: prepend the full namespace to the "RouteData" class model (qty 2 places): example: from: RouteData to: Microsoft.AspNetCore.Components.RouteData *** STEP 6 *** Rename the first two namespace prefixes: From: namespace Microsoft.AspNetCore.Components...; To: namespace [namespace prefixes].Components...; *** [namespace prefixes] = OSS.Blazor *** except for HotReloadManager.cs file (do not rename anything in this file) *** STEP 7 *** In selected using statetments, rename the first two namespace prefixes: examples: using [namespace prefixes].Components.Reflection; *** [namespace prefixes] = OSS.Blazor *** using [namespace prefixes].Components.Routing; using static [namespace prefixes].Internal.LinkerFlags; *** STEP 8 *** Rename Router.cs to desire name [xxxRouter.cs] *** [xxxRouter.cs] = OSSRouter.cs *** And also in qty 5 locations in the Router.cs file *** STEP 9 *** Note: if RouteContext.cs is already modified should be able to use this file instead adding the properties listed below) Add properties to: RouteContext.cs public string? Path { get; } public bool? IsNavigationIntercepted { get; set; } public int? HandlerSegmentIndex { get; set; } public bool EndRouting { get; set; } Add parameters to the constructor: public RouteContext(string path, bool? isNavigationIntercepted = null, int? options = null) change constructor from 'internal' to 'public'. *** Optional STEP 10 - *** ------------------------------------------------- the following three files are not used; can optionally comment out all of the code (or delete the files): or, just leave the files as-is. Components/Routing/ IHostEnvironmentNavigationManager.cs QueryParameterNameComparer.cs QueryParameterValueSupplier.cs ------------------------------------------------- the following file contains a code fragment for .NET 7 or above: Components/Shared/ QueryStringEnumerable.cs if not using .NET 7 or above then must do the following (or comment out all of the code) (or delete the files): Instead of commenting out all of the code, comment out only part of the code in the SpanHelper.ReplacePlusWithSpaceCore() method: if (Vector256.IsHardwareAccelerated && n >= Vector256.Count) if (Vector128.IsHardwareAccelerated && n >= Vector128.Count) (commenting out the two 'if' statements prevents a compile error if using .NET 6 or lower) ("IsHardwareAccelerated" is a .NET 7 feature; not supported in .NET 6 or lower) *** STEP 11 - *************************************************************** ------------------------------------------------- Create an alternate 'custom' router URL decoder action-method delegate that is specific to your requirements. Or, perhaps I can assist. I created an extensive custom route decoder library that the revised OSSRouter Component invokes to match the incoming URL route to a target page. It manages ModuleLists (ie lists of ModuleItems; that are displayed in the upper title area). Each ModuleItem is a list of TreeItem models; to display as a nav menu along the left side. A selected item in the nav menu is a selected TreeItem model (which is a target page component) URL pattern it decodes: xyz.com/ModuleListName/ModuleItemName/PageName/ optionalSeg1/optionalSeg2?yourQueryString=true ModuleListName <-- for a Breadcrumb type component in the upper title area; displays a list of ModuleItems (each are a NavMenu) ModuleItemName <-- for a TreeView type component along the left side; PageName <-- the page type component to show in the page area (a TreeItem model is a page endpoint descriptor) Lists of 'TreeItem' models are used as lookup lists for decoding an incoming URL route and also to encode (build) a URL for use with NavigationManager.NavigateTo(url). That is.. the TreeItem lists are the source of truth for decoding and encoding a route. * can eliminate using the @page directives in liew of using the above. See the details in the original Telerik Forums/UI for Blazor called: "Deep Linking in Blazor".