From cbc3b4e6f5569bc33dc261044f45d563169ce85b Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Tue, 6 Oct 2015 15:03:00 -0700 Subject: [PATCH] PR Feedback * Sorting namespaces * Removing `as` casting for Frame's implemented interfaces --- samples/SampleApp/Startup.cs | 9 ++++----- .../Http/Frame.FeatureCollection.cs | 4 ++++ .../ChunkedResponseTests.cs | 2 +- .../ConnectionFilterTests.cs | 2 +- .../FrameFeatureCollection.cs | 9 +++++++++ 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/samples/SampleApp/Startup.cs b/samples/SampleApp/Startup.cs index 5453372842..834aadd1d1 100644 --- a/samples/SampleApp/Startup.cs +++ b/samples/SampleApp/Startup.cs @@ -4,9 +4,10 @@ using System; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; -using Microsoft.Extensions.Logging; -using Microsoft.Dnx.Runtime; +using Microsoft.AspNet.Http.Features; using Microsoft.AspNet.Server.Kestrel; +using Microsoft.Dnx.Runtime; +using Microsoft.Extensions.Logging; #if DNX451 using System.IO; @@ -20,7 +21,7 @@ namespace SampleApp { public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IApplicationEnvironment env) { - var ksi = app.ServerFeatures[typeof(IKestrelServerInformation)] as IKestrelServerInformation; + var ksi = app.ServerFeatures.Get(); //ksi.ThreadCount = 4; loggerFactory.MinimumLevel = LogLevel.Debug; @@ -50,8 +51,6 @@ namespace SampleApp context.Request.Path, context.Request.QueryString); - foreach (var q in context.Request.Query) { } - context.Response.ContentLength = 11; context.Response.ContentType = "text/plain"; await context.Response.WriteAsync("Hello world"); diff --git a/src/Microsoft.AspNet.Server.Kestrel/Http/Frame.FeatureCollection.cs b/src/Microsoft.AspNet.Server.Kestrel/Http/Frame.FeatureCollection.cs index bb9f2928ff..54190bf4c2 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Http/Frame.FeatureCollection.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Http/Frame.FeatureCollection.cs @@ -16,6 +16,10 @@ namespace Microsoft.AspNet.Server.Kestrel.Http { public partial class Frame : IFeatureCollection, IHttpRequestFeature, IHttpResponseFeature, IHttpUpgradeFeature { + // NOTE: When feature interfaces are added to or removed from this Frame class implementation, + // then the list of `implementedFeatures` in the generated code project MUST also be updated. + // See also: tools/Microsoft.AspNet.Server.Kestrel.GeneratedCode/FrameFeatureCollection.cs + private string _scheme; private string _pathBase; private int _featureRevision; diff --git a/test/Microsoft.AspNet.Server.KestrelTests/ChunkedResponseTests.cs b/test/Microsoft.AspNet.Server.KestrelTests/ChunkedResponseTests.cs index 4c9f926600..d84bf41df1 100644 --- a/test/Microsoft.AspNet.Server.KestrelTests/ChunkedResponseTests.cs +++ b/test/Microsoft.AspNet.Server.KestrelTests/ChunkedResponseTests.cs @@ -1,10 +1,10 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using Microsoft.AspNet.Http.Features; using System; using System.Text; using System.Threading.Tasks; +using Microsoft.AspNet.Http.Features; using Xunit; namespace Microsoft.AspNet.Server.KestrelTests diff --git a/test/Microsoft.AspNet.Server.KestrelTests/ConnectionFilterTests.cs b/test/Microsoft.AspNet.Server.KestrelTests/ConnectionFilterTests.cs index d184cda6d2..b37d72a6e2 100644 --- a/test/Microsoft.AspNet.Server.KestrelTests/ConnectionFilterTests.cs +++ b/test/Microsoft.AspNet.Server.KestrelTests/ConnectionFilterTests.cs @@ -5,8 +5,8 @@ using System.IO; using System.Threading.Tasks; using Microsoft.AspNet.Server.Kestrel.Filter; using Microsoft.AspNet.Server.Kestrel.Http; -using Xunit; using Microsoft.AspNet.Http.Features; +using Xunit; namespace Microsoft.AspNet.Server.KestrelTests { diff --git a/tools/Microsoft.AspNet.Server.Kestrel.GeneratedCode/FrameFeatureCollection.cs b/tools/Microsoft.AspNet.Server.Kestrel.GeneratedCode/FrameFeatureCollection.cs index 95b0539be6..d7025100f7 100644 --- a/tools/Microsoft.AspNet.Server.Kestrel.GeneratedCode/FrameFeatureCollection.cs +++ b/tools/Microsoft.AspNet.Server.Kestrel.GeneratedCode/FrameFeatureCollection.cs @@ -45,6 +45,15 @@ namespace Microsoft.AspNet.Server.Kestrel.GeneratedCode typeof(ISessionFeature), }; + // NOTE: This list MUST always match the set of feature interfaces implemented by Frame. + // See also: src/Microsoft.AspNet.Server.Kestrel/Http/Frame.FeatureCollection.cs + var implementedFeatures = new[] + { + typeof(IHttpRequestFeature), + typeof(IHttpResponseFeature), + typeof(IHttpUpgradeFeature), + }; + return $@" using System; using System.Collections.Generic;