The package works fine currently but there are design issues I want to improve. I spent hours searching through the ASP.NET MVC 6 source code and the current implementation is the best thing I could acomplish.
Currently the routing and the link generation are configured with two separate methods in the Startup class. It will be better, if it is only one. The problem is that the routes are registered before configuration because they use IApplicationModelConvention, and the link generation requires the built services collection, which is available only in the configuration method.
The ExpressionRouteHelper searches trough a list of ControllerActionDescriptor and caches the match. If there is a better way to get the ControllerActionDescriptor by MethodInfo, it should be used but I could not find such in the MVC source code. The ControllerActionDescriptor may not be needed but then I need to replicate all the route constraints selection algorithm, which depend on interfaces and can be interchangable. Current implementation works correctly with any custom implementation because it relies only on the IActionDescriptorsCollectionProvider interface.
I could not find better way to provide Controller, IHtmlHelper and IUrlHelper extension methods with the IActionDescriptorsCollectionProvider. Currently the services collection is set to the static ExpressionRouteHelper class on application start, which works, but I would like to use the dependency injection, if possible. However, I could not think of any other possible solution.
If you have any suggestions, please let me know with a comment here or with a pull request.
The package works fine currently but there are design issues I want to improve. I spent hours searching through the ASP.NET MVC 6 source code and the current implementation is the best thing I could acomplish.
Startup
class. It will be better, if it is only one. The problem is that the routes are registered before configuration because they useIApplicationModelConvention
, and the link generation requires the built services collection, which is available only in the configuration method.ExpressionRouteHelper
searches trough a list ofControllerActionDescriptor
and caches the match. If there is a better way to get theControllerActionDescriptor
byMethodInfo
, it should be used but I could not find such in the MVC source code. TheControllerActionDescriptor
may not be needed but then I need to replicate all the route constraints selection algorithm, which depend on interfaces and can be interchangable. Current implementation works correctly with any custom implementation because it relies only on theIActionDescriptorsCollectionProvider
interface.Controller
,IHtmlHelper
andIUrlHelper
extension methods with theIActionDescriptorsCollectionProvider
. Currently the services collection is set to the staticExpressionRouteHelper
class on application start, which works, but I would like to use the dependency injection, if possible. However, I could not think of any other possible solution.If you have any suggestions, please let me know with a comment here or with a pull request.