From f88b20608249a0d4e703b0e8048a16ff0b3dc548 Mon Sep 17 00:00:00 2001 From: Chris R Date: Wed, 7 Oct 2015 09:20:12 -0700 Subject: [PATCH] #310 Do not automatically wrap IFeatureCollections. --- .../Builder/HttpContextFactory.cs | 2 +- .../HostingEngineTests.cs | 23 ------------------- .../HttpContextFactoryFacts.cs | 2 +- 3 files changed, 2 insertions(+), 25 deletions(-) diff --git a/src/Microsoft.AspNet.Hosting/Builder/HttpContextFactory.cs b/src/Microsoft.AspNet.Hosting/Builder/HttpContextFactory.cs index 7fccad6854..d24250405b 100644 --- a/src/Microsoft.AspNet.Hosting/Builder/HttpContextFactory.cs +++ b/src/Microsoft.AspNet.Hosting/Builder/HttpContextFactory.cs @@ -11,7 +11,7 @@ namespace Microsoft.AspNet.Hosting.Builder { public HttpContext CreateHttpContext(IFeatureCollection featureCollection) { - return new DefaultHttpContext(new FeatureCollection(featureCollection)); + return new DefaultHttpContext(featureCollection); } } } \ No newline at end of file diff --git a/test/Microsoft.AspNet.Hosting.Tests/HostingEngineTests.cs b/test/Microsoft.AspNet.Hosting.Tests/HostingEngineTests.cs index e3bd3759a7..159c2775b5 100644 --- a/test/Microsoft.AspNet.Hosting.Tests/HostingEngineTests.cs +++ b/test/Microsoft.AspNet.Hosting.Tests/HostingEngineTests.cs @@ -308,29 +308,6 @@ namespace Microsoft.AspNet.Hosting Assert.IsType(httpContext.Features.Get()); } - [Fact] - public void Hosting_CreatesDefaultRequestIdentifierFeature_IfNotPresent_ForImmutableFeatureCollection() - { - // Arrange - HttpContext httpContext = null; - var requestDelegate = new RequestDelegate(innerHttpContext => - { - httpContext = innerHttpContext; - return Task.FromResult(0); - }); - - _featuresSupportedByThisHost = new ReadOnlyFeatureCollection(); - - var hostingEngine = CreateHostingEngine(requestDelegate); - - // Act - var disposable = hostingEngine.Start(); - - // Assert - Assert.NotNull(httpContext); - Assert.IsType(httpContext.Features.Get()); - } - [Fact] public void HostingEngine_DoesNot_CreateDefaultRequestIdentifierFeature_IfPresent() { diff --git a/test/Microsoft.AspNet.Hosting.Tests/HttpContextFactoryFacts.cs b/test/Microsoft.AspNet.Hosting.Tests/HttpContextFactoryFacts.cs index 302da49712..a355ca0842 100644 --- a/test/Microsoft.AspNet.Hosting.Tests/HttpContextFactoryFacts.cs +++ b/test/Microsoft.AspNet.Hosting.Tests/HttpContextFactoryFacts.cs @@ -16,7 +16,7 @@ namespace Microsoft.AspNet.Hosting.Tests { var env = new Dictionary(); var contextFactory = new HttpContextFactory(); - var context = contextFactory.CreateHttpContext(new OwinFeatureCollection(env)); + var context = contextFactory.CreateHttpContext(new FeatureCollection(new OwinFeatureCollection(env))); // Setting a feature will throw if the above feature collection is not wrapped in a mutable feature collection. context.Features.Set(new CustomFeature(100));