Skip to content

@route directive and source generator for route name constants#1883

Draft
tomasherceg wants to merge 1 commit intomainfrom
experiment/route-generator
Draft

@route directive and source generator for route name constants#1883
tomasherceg wants to merge 1 commit intomainfrom
experiment/route-generator

Conversation

@tomasherceg
Copy link
Member

Registering all routes individually in DotvvmStartup.cs is painful. I've added an option to use @route directive in DotHTML markup files and have the route auto-generated using source generator.

The results looks as follows:

using DotVVM.Framework.Routing;

namespace DotVVM.Samples.Common
{
    public static class DotvvmRoutes
    {
        // constants for all route names (generated from relative path in the project directory)
        public const string Default = nameof(Default);

        // generated method that will be called from DotvvmStartup to register all routes
        public static void RegisterRoutes(DotvvmRouteTable routes) {
            routes.Add("Default", "test", "Views/Default.dothtml");
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant