From c59366e8a7fcc61e759d13cd2f17fe1876597215 Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Fri, 30 Jan 2015 10:02:58 -0800 Subject: [PATCH] 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 --- .gitignore | 2 ++ samples/RoutingSample.Web/RoutingSample.Web.kproj | 5 +++-- .../DefaultInlineConstraintResolver.cs | 11 +++++++---- .../DefaultInlineConstraintResolverTest.cs | 5 +---- .../InlineRouteParameterParserTests.cs | 2 +- .../RouteConstraintBuilderTest.cs | 4 +--- .../Template/TemplateBinderTests.cs | 2 +- .../Template/TemplateMatcherTests.cs | 2 +- .../TemplateParserDefaultValuesTests.cs | 2 +- 9 files changed, 18 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 9274ba2c88..2253fa08e6 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,8 @@ _ReSharper.*/ packages/ artifacts/ PublishProfiles/ +.vs/ +debugSettings.json *.user *.suo *.cache diff --git a/samples/RoutingSample.Web/RoutingSample.Web.kproj b/samples/RoutingSample.Web/RoutingSample.Web.kproj index b1837197a5..bf53632392 100644 --- a/samples/RoutingSample.Web/RoutingSample.Web.kproj +++ b/samples/RoutingSample.Web/RoutingSample.Web.kproj @@ -1,4 +1,4 @@ - + 14.0 @@ -12,6 +12,7 @@ 2.0 + 25397 - + \ No newline at end of file diff --git a/src/Microsoft.AspNet.Routing/DefaultInlineConstraintResolver.cs b/src/Microsoft.AspNet.Routing/DefaultInlineConstraintResolver.cs index e0f02a6a58..a3c54c050f 100644 --- a/src/Microsoft.AspNet.Routing/DefaultInlineConstraintResolver.cs +++ b/src/Microsoft.AspNet.Routing/DefaultInlineConstraintResolver.cs @@ -18,12 +18,15 @@ namespace Microsoft.AspNet.Routing public class DefaultInlineConstraintResolver : IInlineConstraintResolver { private readonly IDictionary _inlineConstraintMap; - private readonly IServiceProvider _serviceProvider; - public DefaultInlineConstraintResolver(IServiceProvider serviceProvider, - IOptions routeOptions) + /// + /// Initializes a new instance of the class. + /// + /// + /// Accessor for containing the constraints of interest. + /// + public DefaultInlineConstraintResolver(IOptions routeOptions) { - _serviceProvider = serviceProvider; _inlineConstraintMap = routeOptions.Options.ConstraintMap; } diff --git a/test/Microsoft.AspNet.Routing.Tests/DefaultInlineConstraintResolverTest.cs b/test/Microsoft.AspNet.Routing.Tests/DefaultInlineConstraintResolverTest.cs index d0248ea88a..3484f10721 100644 --- a/test/Microsoft.AspNet.Routing.Tests/DefaultInlineConstraintResolverTest.cs +++ b/test/Microsoft.AspNet.Routing.Tests/DefaultInlineConstraintResolverTest.cs @@ -302,10 +302,7 @@ namespace Microsoft.AspNet.Routing.Tests { var optionsAccessor = new Mock>(); optionsAccessor.SetupGet(o => o.Options).Returns(routeOptions); - var serviceProvider = new Mock(); - serviceProvider.Setup(o => o.GetService(It.Is(type => type == typeof(ITypeActivator)))) - .Returns(new TypeActivator()); - return new DefaultInlineConstraintResolver(serviceProvider.Object, optionsAccessor.Object); + return new DefaultInlineConstraintResolver(optionsAccessor.Object); } private class MultiConstructorRouteConstraint : IRouteConstraint diff --git a/test/Microsoft.AspNet.Routing.Tests/InlineRouteParameterParserTests.cs b/test/Microsoft.AspNet.Routing.Tests/InlineRouteParameterParserTests.cs index 9cc3ad3a0d..5d2346727c 100644 --- a/test/Microsoft.AspNet.Routing.Tests/InlineRouteParameterParserTests.cs +++ b/test/Microsoft.AspNet.Routing.Tests/InlineRouteParameterParserTests.cs @@ -300,7 +300,7 @@ namespace Microsoft.AspNet.Routing.Tests .Add("test", typeof(TestRouteConstraint))); var serviceProvider = services.BuildServiceProvider(); var accessor = serviceProvider.GetRequiredService>(); - return new DefaultInlineConstraintResolver(serviceProvider, accessor); + return new DefaultInlineConstraintResolver(accessor); } private class TestRouteConstraint : IRouteConstraint diff --git a/test/Microsoft.AspNet.Routing.Tests/RouteConstraintBuilderTest.cs b/test/Microsoft.AspNet.Routing.Tests/RouteConstraintBuilderTest.cs index e01ad7cefc..92d56222de 100644 --- a/test/Microsoft.AspNet.Routing.Tests/RouteConstraintBuilderTest.cs +++ b/test/Microsoft.AspNet.Routing.Tests/RouteConstraintBuilderTest.cs @@ -179,14 +179,12 @@ namespace Microsoft.AspNet.Routing private static RouteConstraintBuilder CreateBuilder(string template) { - var services = new Mock(MockBehavior.Strict); - var options = new Mock>(MockBehavior.Strict); options .SetupGet(o => o.Options) .Returns(new RouteOptions()); - var inlineConstraintResolver = new DefaultInlineConstraintResolver(services.Object, options.Object); + var inlineConstraintResolver = new DefaultInlineConstraintResolver(options.Object); return new RouteConstraintBuilder(inlineConstraintResolver, template); } } diff --git a/test/Microsoft.AspNet.Routing.Tests/Template/TemplateBinderTests.cs b/test/Microsoft.AspNet.Routing.Tests/Template/TemplateBinderTests.cs index 34ccb0376d..4968e4672c 100644 --- a/test/Microsoft.AspNet.Routing.Tests/Template/TemplateBinderTests.cs +++ b/test/Microsoft.AspNet.Routing.Tests/Template/TemplateBinderTests.cs @@ -1182,7 +1182,7 @@ namespace Microsoft.AspNet.Routing.Template.Tests var services = new ServiceCollection().AddOptions(); var serviceProvider = services.BuildServiceProvider(); var accessor = serviceProvider.GetRequiredService>(); - return new DefaultInlineConstraintResolver(serviceProvider, accessor); + return new DefaultInlineConstraintResolver(accessor); } private class PathAndQuery diff --git a/test/Microsoft.AspNet.Routing.Tests/Template/TemplateMatcherTests.cs b/test/Microsoft.AspNet.Routing.Tests/Template/TemplateMatcherTests.cs index 5aa0bfc9ad..840801bb7d 100644 --- a/test/Microsoft.AspNet.Routing.Tests/Template/TemplateMatcherTests.cs +++ b/test/Microsoft.AspNet.Routing.Tests/Template/TemplateMatcherTests.cs @@ -929,7 +929,7 @@ namespace Microsoft.AspNet.Routing.Template.Tests var services = new ServiceCollection().AddOptions(); var serviceProvider = services.BuildServiceProvider(); var accessor = serviceProvider.GetRequiredService>(); - return new DefaultInlineConstraintResolver(serviceProvider, accessor); + return new DefaultInlineConstraintResolver(accessor); } } } diff --git a/test/Microsoft.AspNet.Routing.Tests/TemplateParserDefaultValuesTests.cs b/test/Microsoft.AspNet.Routing.Tests/TemplateParserDefaultValuesTests.cs index a87b0bf7cf..ac3dbea2e9 100644 --- a/test/Microsoft.AspNet.Routing.Tests/TemplateParserDefaultValuesTests.cs +++ b/test/Microsoft.AspNet.Routing.Tests/TemplateParserDefaultValuesTests.cs @@ -108,7 +108,7 @@ namespace Microsoft.AspNet.Routing.Tests var services = new ServiceCollection().AddOptions(); var serviceProvider = services.BuildServiceProvider(); var accessor = serviceProvider.GetRequiredService>(); - return new DefaultInlineConstraintResolver(serviceProvider, accessor); + return new DefaultInlineConstraintResolver(accessor); } } }