I'm looking for easy and convenient way to hide action methods in controllers in ASP.NET Core.
For some reason it's hard to find a complete and satisfactory answer.
For example, I want to hide specific action method in a specific controller for a given environment value (i.e. IWebHostEnvironment.EnvironmentName != Development).
I know about ServiceFilterAttribute, but this is the way to prevent execution of a method, and I prefer removing the action method completely from everywhere (as I said, conditionally), including generated swagger schemas. Something like NonAction attribute, but working with a runtime condition.
Still, if possible, I prefer using custom Attribute to decorate an action method.
Does anyone know any convenient ways to implement such behavior?