In ASP.NET MVC (regardless of version, if it's important, assume I am using the latest Core 2.1) we control the behavior and parameter binding of the app by annotating the controller with attributes, for example [HttpPost] for a method that is supposed to be called as POST and [FromQuery] for a method parameter that is supposed to come from the query string.
Now as I have found out the hard way in the last months, there are countless ways to mix this up. If you have two parameters declared as [FromBody] for example, one will always be null because only one can represent the body. Or if your method is tagged with [HttpGet] your [FromBody] will come back null because the standard says that's not how it's done. And believe me, there are many more ways to get it wrong.
I accept that these are all my mistakes. If I do it correctly, it will work. However, what baffles me is that this is something that could be found at compile time. There is zero runtime dependencies in this. And I only find out when I debug it and it doesn't work. I understand that it's not the compilers job to find logical flaws in my program, but surely they could be found by a controller factory upon constructing it? A unit test where I throw all my controller types into a test method? Or a tool like static code analysis or stylecop?
I googled and I came up with zero. So my assumption is that my google skill is not up to it.
Is there really no method in the .NET Framework to check if all my controller attributes add up to something that can be served correctly? Is there no way to tell me I fu...mbled that up?
And if there really is none, before I write it myself, is that for a reason? If I wrote this myself is there any known reason why one shouldn't do that?