Add warning for the reserved route parameter names in ASP.NET routes
- Dominant language
- C#
- Stars
- 20.7k
- Forks
- 4.3k
- PR merge metrics
- PR metrics pending
Description
**Brief description:**
Add the compiler warning for using [reserved route parameter names](https://learn.microsoft.com/en-us/aspnet/core/mvc/controllers/routing?view=aspnetcore-9.0#reserved-routing-names) in ASP.NET routes
**Languages applicable:**
Both
**Code example that the analyzer should report:**
```csharp
[HttpGet]
[Route("/api/actions/{action}/apply")]
public IActionResult ApplyAction(string action)
{
return Ok();
}
```
**Additional information:**
The current behavior returns an HTTP 404 error when using reserved keywords (`action`, `controller`, etc.) as route parameters. The runtime doesn't indicate why the route fails to map to the controller's method - it simply returns 404. It would be helpful if the IDE could render wavy underlines with a warning when reserved keywords are used as route parameter names, preventing this hard-to-debug issue at design time.
**Documentation requirements:**
When this analyzer is implemented, it must be documented by following the steps at [Documentation for IDE CodeStyle analyzers](https://github.com/dotnet/roslyn/blob/main/docs/contributing/Documentation%20for%20IDE%20CodeStyle%20analyzers.md).
Contributor guide
Assessment
This issue has not been assessed yet.