diff options
author | Marek Habersack <grendel@twistedcode.net> | 2009-05-28 00:54:42 +0400 |
---|---|---|
committer | Marek Habersack <grendel@twistedcode.net> | 2009-05-28 00:54:42 +0400 |
commit | 798a6ee9cf13e6e033ef070818b7c749565a7b7c (patch) | |
tree | 6a914bf1a36a0d420828495672ed2dc9556b7376 /mcs/class | |
parent | 01e82cb5275b5ca0ce2d6a3f056e2687c27c9611 (diff) |
Backport of r134877
svn path=/branches/mono-2-4/mcs/; revision=134878
Diffstat (limited to 'mcs/class')
6 files changed, 78 insertions, 7 deletions
diff --git a/mcs/class/System.Web.Routing/ChangeLog b/mcs/class/System.Web.Routing/ChangeLog index 11b899451bf..2fa743e4a9e 100644 --- a/mcs/class/System.Web.Routing/ChangeLog +++ b/mcs/class/System.Web.Routing/ChangeLog @@ -1,3 +1,8 @@ +2009-05-27 Marek Habersack <mhabersack@novell.com> + + * Makefile (LIB_MCS_FLAGS): added support for defining the DEBUG + symbol on compiler command line. + 2009-05-25 Marek Habersack <mhabersack@novell.com> * System.Web.Routing_test.dll.sources: added diff --git a/mcs/class/System.Web.Routing/Makefile b/mcs/class/System.Web.Routing/Makefile index c4b13953413..f8495b96102 100644 --- a/mcs/class/System.Web.Routing/Makefile +++ b/mcs/class/System.Web.Routing/Makefile @@ -14,6 +14,10 @@ ifeq (2.0, $(FRAMEWORK_VERSION)) LIB_MCS_FLAGS += -d:NET_3_5 endif +ifdef DEBUG +LIB_MCS_FLAGS += -define:DEBUG +endif + TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) EXTRA_DISTFILES = diff --git a/mcs/class/System.Web.Routing/System.Web.Routing/ChangeLog b/mcs/class/System.Web.Routing/System.Web.Routing/ChangeLog index 977e128f09a..211ec3c0723 100644 --- a/mcs/class/System.Web.Routing/System.Web.Routing/ChangeLog +++ b/mcs/class/System.Web.Routing/System.Web.Routing/ChangeLog @@ -1,3 +1,9 @@ +2009-05-27 Marek Habersack <mhabersack@novell.com> + + * PatternParser.cs: if Match is passed an empty path, do not + attempt to match the Url segments, skip to defaults matching right + away. + 2009-05-25 Marek Habersack <mhabersack@novell.com> * UrlPattern.cs: removed - replaced by PatternParser below. diff --git a/mcs/class/System.Web.Routing/System.Web.Routing/PatternParser.cs b/mcs/class/System.Web.Routing/System.Web.Routing/PatternParser.cs index bc4a97ced60..d3a31866367 100644 --- a/mcs/class/System.Web.Routing/System.Web.Routing/PatternParser.cs +++ b/mcs/class/System.Web.Routing/System.Web.Routing/PatternParser.cs @@ -207,18 +207,29 @@ namespace System.Web.Routing { var ret = new RouteValueDictionary (); string url = Url; + string [] argSegs; + int argsCount; + + if (String.IsNullOrEmpty (path)) { + argSegs = null; + argsCount = 0; + } else { + // quick check + if (String.Compare (url, path, StringComparison.Ordinal) == 0 && url.IndexOf ('{') < 0) + return AddDefaults (ret, defaults); + + argSegs = path.Split ('/'); + argsCount = argSegs.Length; + } - // quick check - if (String.Compare (url, path, StringComparison.Ordinal) == 0 && url.IndexOf ('{') < 0) - return AddDefaults (ret, defaults); - - string [] argSegs = path.Split ('/'); - int argsCount = argSegs.Length; bool haveDefaults = defaults != null && defaults.Count > 0; + if (argsCount == 1 && String.IsNullOrEmpty (argSegs [0])) + argsCount = 0; + if (!haveDefaults && ((haveSegmentWithCatchAll && argsCount < segmentCount) || (!haveSegmentWithCatchAll && argsCount != segmentCount))) return null; - + int i = 0; foreach (PatternSegment segment in segments) { diff --git a/mcs/class/System.Web.Routing/Test/System.Web.Routing/ChangeLog b/mcs/class/System.Web.Routing/Test/System.Web.Routing/ChangeLog index 2770716ec0a..8affe4360b0 100644 --- a/mcs/class/System.Web.Routing/Test/System.Web.Routing/ChangeLog +++ b/mcs/class/System.Web.Routing/Test/System.Web.Routing/ChangeLog @@ -1,3 +1,8 @@ +2009-05-27 Marek Habersack <mhabersack@novell.com> + + * RouteCollectionTest.cs: added a test for routes from + NerdDinner. + 2009-05-25 Marek Habersack <mhabersack@novell.com> * RouteTest.cs: added several tests for GetVirtualPath, diff --git a/mcs/class/System.Web.Routing/Test/System.Web.Routing/RouteCollectionTest.cs b/mcs/class/System.Web.Routing/Test/System.Web.Routing/RouteCollectionTest.cs index 5b21fbd1e54..d13c325e94d 100644 --- a/mcs/class/System.Web.Routing/Test/System.Web.Routing/RouteCollectionTest.cs +++ b/mcs/class/System.Web.Routing/Test/System.Web.Routing/RouteCollectionTest.cs @@ -483,5 +483,45 @@ namespace MonoTests.System.Web.Routing Assert.AreEqual ("./Test/test.html", vpd.VirtualPath, "#1"); Assert.AreEqual (0, vpd.DataTokens.Count, "#2"); } + + [Test (Description="Routes from NerdDinner")] + public void GetRouteDataNerdDinner () + { + var c = new RouteCollection (); + + c.Add ("UpcomingDiners", + new MyRoute ("Dinners/Page/{page}", new MyRouteHandler ()) { Defaults = new RouteValueDictionary (new { controller = "Dinners", action = "Index" }) } + ); + + c.Add ("Default", + new MyRoute ("{controller}/{action}/{id}", new MyRouteHandler ()) { Defaults = new RouteValueDictionary (new { controller = "Home", action = "Index", id = "" })} + ); + + var hc = new HttpContextStub2 ("~/", String.Empty, String.Empty); + hc.SetResponse (new HttpResponseStub (3)); + var rd = c.GetRouteData (hc); + + Assert.IsNotNull (rd, "#A1"); + } + + [Test (Description="Routes from NerdDinner")] + public void GetRouteDataNerdDinner2 () + { + var c = new RouteCollection (); + + c.Add ("UpcomingDiners", + new MyRoute ("Dinners/Page/{page}", new MyRouteHandler ()) { Defaults = new RouteValueDictionary (new { controller = "Dinners", action = "Index" }) } + ); + + c.Add ("Default", + new MyRoute ("{controller}/{action}/{id}", new MyRouteHandler ()) { Defaults = new RouteValueDictionary (new { controller = "Home", action = "Index", id = "" })} + ); + + var hc = new HttpContextStub2 ("~/Home/Index", String.Empty, String.Empty); + hc.SetResponse (new HttpResponseStub (3)); + var rd = c.GetRouteData (hc); + + Assert.IsNotNull (rd, "#A1"); + } } } |