DotNetAnalyzers / AspNetCoreAnalyzers

MIT License
62 stars 4 forks source link

Warn when more than one [FromBody] #68

Open JohanLarsson opened 5 years ago

JohanLarsson commented 5 years ago
// Don't do this. All of the following actions result in an exception.
[HttpPost]
public IActionResult Action1(Product product, 
                             Order order) => null;

[HttpPost]
public IActionResult Action2(Product product, 
                             [FromBody] Order order) => null;

[HttpPost]
public IActionResult Action3([FromBody] Product product, 
                             [FromBody] Order order) => null;

https://docs.microsoft.com/en-us/aspnet/core/web-api/?view=aspnetcore-2.2#binding-source-parameter-inference