Commit Graph

83 Commits

Author SHA1 Message Date
Ryan Nowak 226cfb1e0d Optimize TemplateMatcher
Replaces a bunch of dictionary operations with indexing into an array by
doing some caching. Also eliminating an enumerator allocation by changing
from IReadOnlyDictionary to RouteValueDictionary.
2016-01-05 10:47:51 -08:00
Ryan Nowak 33f9bdadef Pool state used to generate URL 2015-12-28 09:27:41 -08:00
Hao Kung a956fe53c1 OptionsModel => Options 2015-12-21 15:54:13 -08:00
Ryan Nowak 813171a016 Reduce allocation in URL generation
This change optimizes our a per-operation dictionary that really can just
be cached for the whole app's lifetime.
2015-12-18 09:20:52 -08:00
Pranav K 2ab24aa0f4 Remove custom url encoding
Fixes #214
2015-12-16 09:06:49 -08:00
Ryan Nowak 36180ab6d0 Add IRouteHandler, RouteBase, and IRoutingFeature
Adds IRouterHandler, an abstraction for endpoints in the routing system
that can't chain (example: delegates). The idea is that some kinds of
routes aren't really friendly to chaining. If you don't support chaining,
then accept IRouteHandler and work with that rather than IRouter.

There's one implementation of IRouteHandler, RouteHandler. It implements
both IRouter and IRouteHandler.

Adds RouteBase as a base class for routes based on our template syntax and
defaults/constraints/data-tokens. Updated a lot of signatures to be
get/set virtual and mutable to facilitate or bigger variety of usage
scenarios.

Renamed TemplateRoute to just Route, now inherits from RouteBase.

Adds IRoutingFeature for middleware scenarios where you don't have access
to the route context.

Also adds some basic extension methods for accessing route values.
2015-12-10 17:55:03 -08:00
Ryan Nowak b01183f023 Simplify link generation code
- Removes ProvidedValues and IsBound

- Removes best-effort link generation

- simplify code where possible

- lots of test simplification
2015-12-07 11:04:19 -08:00
Ryan Nowak d4b96b27c0 Optimize RouteValueDictionary, expose concrete type
This change optimizes allocations by RouteValueDictionary based on usage.

First, implement a struct Enumerator, and expose the concrete RVD type
from all extensibility points. We wanted to try and decouple this code
from RVD originally and use IDictionary everywhere. After doing that we've
found that it allocates an unacceptable number of enumerators.

Secondly, optimize copies of RVD for the case where you're copying an RVC
to another (common case). When doing this we can copy the count to get the
right capacity, and copy the entries without allocating an enumerator.

Lastly, optimize RVD for the case where it's a wrapper around a poco
object. We 'upgrade' to a writable full dictionary if you try to write to
it, or call one of a number of APIs that are uncommonly used. We could
produce optimized versions of things like `Keys` and `CopyTo` if necessary
in the future.
2015-11-25 09:49:10 -08:00
Pranav K cad81fa608 Updating tests to use moq.netcore 2015-11-23 12:24:35 -08:00
Ajay Bhargav Baaskaran 4d69ad0db2 Moved AttributeRouting from MVC 2015-11-17 12:03:12 -08:00
Ajay Bhargav Baaskaran cef221f57a Added Template property to RouteTemplate 2015-11-12 15:28:02 -08:00
Ryan Nowak 371d4e62da Remove string.Split from routing
This change removes the call to string.Split and a few substrings, and
replaces it with a tokenizer API. The tokenizer isn't really optimized
right now for compute - it should probably be an iterator- but it's a
significant improvement on what we're doing.
2015-10-06 10:21:00 -07:00
Pranav K 2f8dba6659 Renaming Microsoft.Framework.* -> Microsoft.Extensions.* 2015-10-03 15:44:48 -07:00
Pranav K c6941e797f Replacing NotNullAttribute with exceptions 2015-09-11 15:08:04 -07:00
Ajay Bhargav Baaskaran 0882a393a4 Removed unwanted logging for non-matching routes 2015-06-23 10:53:58 -07:00
N. Taylor Mullen 352732fc62 Update LICENSE.txt and license header on files. 2015-05-01 13:59:22 -07:00
Kiran Challa 1c66e0a317 Cleanup logging
- Removed existing logger scopes as we want to minimize the number of scopes being created.
- Cleaned up tests related to removal of scopes.
- Added new log statements.
- Removed old logger structure base implementation and related tests. Added new tests also.
2015-04-08 14:20:36 -07:00
Kiran Challa 6e18fc2f74 Reacting to ILogger api changes 2015-04-04 01:24:42 -07:00
ianhong ff209f04bb Should GetVirtualPath returns PathString 2015-03-22 19:39:20 -07:00
ianhong 3693002b02 Introducing VirtualPathData for IRouter.GetVirtualPath 2015-03-19 21:59:20 -07:00
N. Taylor Mullen da775351e2 Update aspnet50/aspnetcore50 => dnx451/dnxcore50. 2015-03-08 12:55:34 -07:00
Brennan 3e99d38dbb Logging.Testing namespace change 2015-03-06 09:48:36 -08:00
Hao Kung 979b75dda4 React to DI changes 2015-03-04 18:06:42 -08:00
Brennan be7984eebc Logging test objects were copy-pasta from logging repo, removing and using official version 2015-02-25 12:58:51 -08:00
Mugdha Kulkarni f9a9b80681 Fixing the error message. The error message for malformed template was too complex listing all
the errors that can happen in one message. I have separated the message in 2 different messages.
 1. When there is a parameter or a literal following the optional parameter.
 2. when optional parameter is preceded by a literal other than period which is not allowed.
2015-02-16 17:40:04 -08:00
Ryan Nowak 9ee946073a Add support for best-effort link-generation
This change adds a feature needed for aspnet/Mvc#302

There's a new option in routing that allows link-generation to proceed
when the route values cannot be validated. The key scenario for this is
during development of an MVC site. Routing will refuse to generate a link
to actions which don't exists, this is a breaking change from the MVC5
behavior. Setting UseBestEffortLinkGeneration will allow routing to return
a value even when we can't match the action.

This option will remain off by default - setting this to on will impact
link-generation in a bunch of scenarios involving areas where we've
improved the logic for MVC6. If you're considering leaving this on outside
of development scenarios, then make sure to be as explicit with route values
as possible (don't rely on ambient values).

Functional tests to follow up in the MVC repo.
2015-02-11 14:38:30 -08:00
Mugdha Kulkarni 4e5fc2e2dd Fixing Routing Issue: 136
The RegEx inline constraint doesn't take care of Escape characters.
2015-02-10 11:16:30 -08:00
Doug Bunting c59366e8a7 Quick cleanup
- `DefaultInlineConstraintResolver` has no need of a `IServiceProvider`

nits:
- add doc comments for changed `DefaultInlineConstraintResolver` ctor
- let VS add a dev server port to sample's .kproj
- add debugSettings.json and .vs/ to .gitignore
2015-01-30 10:02:58 -08:00
Pranav K 29a5cb8aa9 Change the namespace for the MapRoute extension 2015-01-23 16:08:38 -08:00
Mugdha Kulkarni 3626900bc9 Basic URL Extension functionality working.
1. Template parser now allows a parameter to be an optional parameter in a complex segment if
   it is the last and only optional parameter and it is followed by a period.
2. Template matcher modified to take into consideration the optional parameter in the complex
   segment. Also the period shouldn't be present if the optional parameter is not present
2015-01-16 16:25:53 -08:00
Mugdha Kulkarni f549a550a9 Fixing the issue #123.
Added OptionalRouteConstraint class to take care of optional inline parameter. It will create the OptionalRouteConstraint for a inline parameter that is optional with real constraint on the parameter as inner constraint of OptionalRouteConstraint.
2014-12-04 10:54:27 -08:00
Hao Kung 21a6f44c38 GetDefaultServices -> AddRouting with TryAdd 2014-11-24 16:37:10 -08:00
Doug Bunting 1a101d7815 Delete trailing whitespace
- #EngineeringDay
- Total replaced: 105  Matching files: 44 in *.cs files
- Total replaced: 27  Matching files: 1 in all other files
2014-11-20 09:40:12 -08:00
Ryan Nowak 01345eca91 Fix for #92 - Make Constraints, DataTokens, and Defaults readonly
The properties on TemplateRoute for DataTokens and Defaults are now
readonly. This prevents modifying these collections in a way that
invalidates cached data, or violates thread-safety.

To do the same for constraints, this change includes a substantial refactor
of how we realize inline constraints, and moves the constraint resolver
out of the parsing phase.

This allow creates a builder for the constraint map, that will make it
easier to implement features like optional constraints, and is reusable
for anyone building their own type of routing system.
2014-11-18 11:24:25 -08:00
Ryan Nowak 87f0bbb092 adding tests 2014-10-31 16:00:04 -07:00
Ryan Nowak d78e5478a7 Fix for #65,116 - Implement 'stack of routers'
This is the routing part of the fix. MVC will be updated as well
(attribute routing).

As the graph of routers is traversed, routers add themselves to the
current 'path', which unwinds on a failed path.

This mechanism is opt-in. Whoever adds something needs to remove it as
part of cleanup. If a router in the tree doesn't interact with the
.Routers property, then there are no consequences for those that do.

Additionally, fixing #116 as part of the same change. This means that we
create a nested 'RouteData' and then restore it on the way out. This is
simpler than just dealing with the .Routers property in isolation.
2014-10-31 14:07:35 -07:00
jacalvar 02a0a218b9 [Fixes #90] RouteTemplate does not take RouteData
Changed the implementation of route template to merge the existing route data
with the values obtained from parsing the request path with the given template.

Restored original route data values in case the route template data does not match.
2014-10-22 13:22:11 -07:00
Stephen Halter fff1d62f01 Change GetService calls to GetRequiredService
GetRequiredService throws for missing services like GetService used to.
2014-10-17 15:31:57 -07:00
Hao Kung 86dcbfd0d1 React to options and hosting changes
Uses EnsureRequestServices to force RequestServices to be created
2014-10-14 19:09:15 -07:00
SonjaKhan 2a8ac595d8 Refactoring ILogger, see aspnet/Logging#3 2014-10-14 10:20:58 -07:00
jacalvar 3ff9d6e8a0 [Fixes #108] Disallow the use of '*' in route parameter names 2014-10-13 15:55:02 -07:00
David Fowler 4a8de5dad4 Updated to use the new target framework in project.json 2014-09-04 01:50:07 -07:00
harshgMSFT efdd3054d2 Adding DataTokens Support. 2014-08-11 11:59:00 -07:00
harshgMSFT 5b849596bb Fix for Issue#55 Changing Template->RouteTemplate 2014-08-06 16:14:50 -07:00
Ben Brown fca9831115 Routing Logging
Added scoped logging to RouterMiddleware, RouteCollection, and
TemplateRoute.
2014-08-01 13:59:48 -07:00
Ryan Nowak 61436fb7d1 Revert "Revert "Fix for issue 85 - Dictionary types should return null on key not found""
This is reverting the revert. We're going to go ahead with this change and
work around it in MVC.

This reverts commit 0e826e69e6.
2014-07-31 15:01:03 -07:00
Ryan Nowak 0e826e69e6 Revert "Fix for issue 85 - Dictionary types should return null on key not found"
This is causing issues with routing functional tests in CoreCLR. Suspect
CoreCLR compat issue.

This reverts commit ae65001e84.
2014-07-25 14:35:36 -07:00
Ryan Nowak ae65001e84 Fix for issue 85 - Dictionary types should return null on key not found
This change makes RouteValueDictionary a full IDictionary implementation
instead of a subclass of Dictionary.

Followed the patterns used in the old implementation, namely preserving
the struct-returning behavior of Keys/Values/GetEnumerator.
2014-07-25 13:17:52 -07:00
Ryan Nowak 3eb6c22330 Make RoutePartsEqual public. 2014-07-15 14:25:05 -07:00
Ryan Nowak 63dcdd6ca5 Fix for #77 - pass ambient values not in the template to constraints
This change adds tests and makes the behavior consistent with legacy MVC
as far as what values are visible in constraints.

This is important because it allows constraints to make decisions based on
whether or not a value is present even if it's not in the template. This
is similar to the behavior of WebAPI link generation or Area link
generation in MVC 5 - but without hardcoding.
2014-07-08 10:18:00 -07:00