-
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 implemented
Description
Background and Motivation
When adding a route parameter to a minimal API or action:
- The route parameter needs to be added to the route
- .NET parameter needs to be added to the lambda/method.
An analyzer and fixer can automate step 2.
Proposed API
An analyzer inspects the route for route parameters and the lambda/action parameters. If the route has a parameter that isn't present in the lambda/action then the analyzer will suggest a fix.
- Suggestion level (it's valid to have a route parameter that's not used so this isn't a warning)
- Optional route parameter = nullable argument
- Route parameter constraint is used to infer the .NET type. e.g. int constraint = int method parameter. Same with guid, int, long, double, float, datetime, decimal, etc. No route parameter means the new parameter type is string.
- Put the new parameter in the method based on its position in the route.
Usage Examples
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 implemented