-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Closed
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedapi-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementation
Description
Background and Motivation
A route is a string that has a standard syntax. An invalid route string errors at runtime when parsed. This typically happens at app startup. We want to tighten the dev loop and tell people their route is invalid in the IDE.
Proposed API
An analyzer that inspects route strings for invalid content.
A route string is indicated by [StringSyntax("Route")]
on the property, method argument, or constructor argument.
Usage Examples
public IEndpointConventionBuilder MapGet(
IEndpointRouteBuilder builder,
[StringSyntax("Route")] string pattern,
Delegate delegate)
{
// ...
}
endpoints.MapGet("{**slug?}", () => "hello world"); // <- invalid because parameter can't be catchall and optional
endpoints.MapGet("//login", () => "hello world"); // <- invalid because can't have consecutive forward slashes
endpoints.MapGet("{id}/{id}", () => "hello world"); // <- invalid because can't have duplicate parameter names
Alternative Designs
Risks
Metadata
Metadata
Assignees
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedapi-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementation