Skip to content

Generate route handler-endpoints at compile time via source generator #45524

@captainsafia

Description

@captainsafia

Currently, RequestDelegates for associated route handler-based endpoints are generated at runtime using LINQ expressions. This is a process that requires a fair amount of reflection. We can leverage source generation to generate these endpoints via static analysis.

Some of this work has been prototyped in uController and will need to be formalized as part of the official project.

Generator Basics

  • Add RequestDelegateGenerator scaffold to aspnetcore repo
  • Respect EnableRequestDelegateGenerator flag in Web SDK
  • Refactor code to support marking GeneratedRouteBuilderExtensions as file class
  • Set up code and tests for emitting diagnostics from the generator
  • Support for a RouteEndpointDataSource implementation that supports a func for populating metadata
  • Support for an RouteEndpointDataSource implementation that allows customizing what RDF is called to produce filtered delegate calls

Invoking Handlers

  • Support generating correct delegate type signature for a given handler
  • Support emitting correct generic-EndpointFilterInvocationContext for a given filtered invocation

Metadata

Metadata

Assignees

Labels

old-area-web-frameworks-do-not-use*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions