Attribute routing (or rather, direct routing) shouldn't necessarily be tied to attributes. Just like filter providers can be used to get filters from other places, the same should be true for attribute routing.
Also, the default (attribute) implementation should allow plugging in a custom direct route builder, for cases where the standard RouteAttribute is used but a custom interpretation of the route template is desired.
This feature will enable as a scenario allowing derived class to inherit routes (which is currently disabled by default).
(This work applies to both MVC and Web API.)
Note, when making these changes, some existing Contract.Asserts will need to become exception handling paths.
In RouteInfoDirectRouteFactory.cs, line 41:
IDirectRouteBuilder builder = context.CreateBuilder(_infoProvider.Template);
Contract.Assert(builder != null);
In RouteFactoryAttribute.cs, line 69:
IDirectRouteBuilder builder = context.CreateBuilder(Template);
Contract.Assert(builder != null);
In RouteAttribute.cs, line 49:
IDirectRouteBuilder builder = context.CreateBuilder(Template);
Contract.Assert(builder != null);
Also, the default (attribute) implementation should allow plugging in a custom direct route builder, for cases where the standard RouteAttribute is used but a custom interpretation of the route template is desired.
This feature will enable as a scenario allowing derived class to inherit routes (which is currently disabled by default).
(This work applies to both MVC and Web API.)
Note, when making these changes, some existing Contract.Asserts will need to become exception handling paths.
In RouteInfoDirectRouteFactory.cs, line 41:
IDirectRouteBuilder builder = context.CreateBuilder(_infoProvider.Template);
Contract.Assert(builder != null);
In RouteFactoryAttribute.cs, line 69:
IDirectRouteBuilder builder = context.CreateBuilder(Template);
Contract.Assert(builder != null);
In RouteAttribute.cs, line 49:
IDirectRouteBuilder builder = context.CreateBuilder(Template);
Contract.Assert(builder != null);