From ccfeef6353bde4af51c382a90e020f382d5fc26b Mon Sep 17 00:00:00 2001 From: Ben Adams Date: Thu, 8 Oct 2015 14:42:57 -0400 Subject: [PATCH] All features to have backing object --- .../Http/Frame.Generated.cs | 96 +++++++++++++++++++ .../FrameFeatureCollection.cs | 16 ++-- 2 files changed, 103 insertions(+), 9 deletions(-) diff --git a/src/Microsoft.AspNet.Server.Kestrel/Http/Frame.Generated.cs b/src/Microsoft.AspNet.Server.Kestrel/Http/Frame.Generated.cs index 0c0f3d6398..dca313f9a7 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Http/Frame.Generated.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Http/Frame.Generated.cs @@ -24,6 +24,12 @@ namespace Microsoft.AspNet.Server.Kestrel.Http private static readonly Type ISessionFeatureType = typeof(global::Microsoft.AspNet.Http.Features.ISessionFeature); private static readonly Type IHttpSendFileFeatureType = typeof(global::Microsoft.AspNet.Http.Features.IHttpSendFileFeature); private static readonly Type IHttpUpgradeFeatureType = typeof(global::Microsoft.AspNet.Http.Features.IHttpUpgradeFeature); + private static readonly Type IResponseCookiesFeatureType = typeof(global::Microsoft.AspNet.Http.Features.Internal.IResponseCookiesFeature); + private static readonly Type IItemsFeatureType = typeof(global::Microsoft.AspNet.Http.Features.Internal.IItemsFeature); + private static readonly Type ITlsConnectionFeatureType = typeof(global::Microsoft.AspNet.Http.Features.ITlsConnectionFeature); + private static readonly Type IHttpWebSocketFeatureType = typeof(global::Microsoft.AspNet.Http.Features.IHttpWebSocketFeature); + private static readonly Type ISessionFeatureType = typeof(global::Microsoft.AspNet.Http.Features.ISessionFeature); + private static readonly Type IHttpSendFileFeatureType = typeof(global::Microsoft.AspNet.Http.Features.IHttpSendFileFeature); private object _currentIHttpRequestFeature; private object _currentIHttpResponseFeature; @@ -35,6 +41,12 @@ namespace Microsoft.AspNet.Server.Kestrel.Http private object _currentIQueryFeature; private object _currentIFormFeature; private object _currentIHttpUpgradeFeature; + private object _currentIResponseCookiesFeature; + private object _currentIItemsFeature; + private object _currentITlsConnectionFeature; + private object _currentIHttpWebSocketFeature; + private object _currentISessionFeature; + private object _currentIHttpSendFileFeature; private void FastReset() { @@ -49,6 +61,12 @@ namespace Microsoft.AspNet.Server.Kestrel.Http _currentIHttpAuthenticationFeature = null; _currentIQueryFeature = null; _currentIFormFeature = null; + _currentIResponseCookiesFeature = null; + _currentIItemsFeature = null; + _currentITlsConnectionFeature = null; + _currentIHttpWebSocketFeature = null; + _currentISessionFeature = null; + _currentIHttpSendFileFeature = null; } private object FastFeatureGet(Type key) @@ -130,6 +148,30 @@ namespace Microsoft.AspNet.Server.Kestrel.Http { return _currentIHttpUpgradeFeature; } + if (key == typeof(global::Microsoft.AspNet.Http.Features.Internal.IResponseCookiesFeature)) + { + return _currentIResponseCookiesFeature; + } + if (key == typeof(global::Microsoft.AspNet.Http.Features.Internal.IItemsFeature)) + { + return _currentIItemsFeature; + } + if (key == typeof(global::Microsoft.AspNet.Http.Features.ITlsConnectionFeature)) + { + return _currentITlsConnectionFeature; + } + if (key == typeof(global::Microsoft.AspNet.Http.Features.IHttpWebSocketFeature)) + { + return _currentIHttpWebSocketFeature; + } + if (key == typeof(global::Microsoft.AspNet.Http.Features.ISessionFeature)) + { + return _currentISessionFeature; + } + if (key == typeof(global::Microsoft.AspNet.Http.Features.IHttpSendFileFeature)) + { + return _currentIHttpSendFileFeature; + } return SlowFeatureGet(key); } @@ -260,6 +302,36 @@ namespace Microsoft.AspNet.Server.Kestrel.Http { _currentIHttpUpgradeFeature = feature; return; + } + if (key == typeof(global::Microsoft.AspNet.Http.Features.Internal.IResponseCookiesFeature)) + { + _currentIResponseCookiesFeature = feature; + return; + } + if (key == typeof(global::Microsoft.AspNet.Http.Features.Internal.IItemsFeature)) + { + _currentIItemsFeature = feature; + return; + } + if (key == typeof(global::Microsoft.AspNet.Http.Features.ITlsConnectionFeature)) + { + _currentITlsConnectionFeature = feature; + return; + } + if (key == typeof(global::Microsoft.AspNet.Http.Features.IHttpWebSocketFeature)) + { + _currentIHttpWebSocketFeature = feature; + return; + } + if (key == typeof(global::Microsoft.AspNet.Http.Features.ISessionFeature)) + { + _currentISessionFeature = feature; + return; + } + if (key == typeof(global::Microsoft.AspNet.Http.Features.IHttpSendFileFeature)) + { + _currentIHttpSendFileFeature = feature; + return; }; SetExtra(key, feature); } @@ -330,6 +402,30 @@ namespace Microsoft.AspNet.Server.Kestrel.Http { yield return new KeyValuePair(IHttpUpgradeFeatureType, _currentIHttpUpgradeFeature as global::Microsoft.AspNet.Http.Features.IHttpUpgradeFeature); } + if (_currentIResponseCookiesFeature != null) + { + yield return new KeyValuePair(IResponseCookiesFeatureType, _currentIResponseCookiesFeature as global::Microsoft.AspNet.Http.Features.Internal.IResponseCookiesFeature); + } + if (_currentIItemsFeature != null) + { + yield return new KeyValuePair(IItemsFeatureType, _currentIItemsFeature as global::Microsoft.AspNet.Http.Features.Internal.IItemsFeature); + } + if (_currentITlsConnectionFeature != null) + { + yield return new KeyValuePair(ITlsConnectionFeatureType, _currentITlsConnectionFeature as global::Microsoft.AspNet.Http.Features.ITlsConnectionFeature); + } + if (_currentIHttpWebSocketFeature != null) + { + yield return new KeyValuePair(IHttpWebSocketFeatureType, _currentIHttpWebSocketFeature as global::Microsoft.AspNet.Http.Features.IHttpWebSocketFeature); + } + if (_currentISessionFeature != null) + { + yield return new KeyValuePair(ISessionFeatureType, _currentISessionFeature as global::Microsoft.AspNet.Http.Features.ISessionFeature); + } + if (_currentIHttpSendFileFeature != null) + { + yield return new KeyValuePair(IHttpSendFileFeatureType, _currentIHttpSendFileFeature as global::Microsoft.AspNet.Http.Features.IHttpSendFileFeature); + } if (MaybeExtra != null) { diff --git a/tools/Microsoft.AspNet.Server.Kestrel.GeneratedCode/FrameFeatureCollection.cs b/tools/Microsoft.AspNet.Server.Kestrel.GeneratedCode/FrameFeatureCollection.cs index 9ee9b3ced8..4c45f6802d 100644 --- a/tools/Microsoft.AspNet.Server.Kestrel.GeneratedCode/FrameFeatureCollection.cs +++ b/tools/Microsoft.AspNet.Server.Kestrel.GeneratedCode/FrameFeatureCollection.cs @@ -53,10 +53,6 @@ namespace Microsoft.AspNet.Server.Kestrel.GeneratedCode typeof(IHttpResponseFeature), typeof(IHttpUpgradeFeature), }; - - // Only the always, common and implmented features will have backed objects - // the sometimes, rare and user-defined features will use the MaybeExtra collection - var cachedFeatures = alwaysFeatures.Concat(commonFeatures).Union(implementedFeatures); return $@" using System; @@ -65,18 +61,20 @@ using System.Collections.Generic; namespace Microsoft.AspNet.Server.Kestrel.Http {{ public partial class Frame - {{{Each(cachedFeatures, feature => $@" + {{{Each(allFeatures, feature => $@" private static readonly Type {feature.Name}Type = typeof(global::{feature.FullName});")} +{Each(allFeatures, feature => $@" + private object _current{feature.Name};")} private void FastReset() {{{Each(implementedFeatures, feature => $@" _current{feature.Name} = this;")} - {Each(cachedFeatures.Where( f => !implementedFeatures.Contains(f)), feature => $@" + {Each(allFeatures.Where( f => !implementedFeatures.Contains(f)), feature => $@" _current{feature.Name} = null;")} }} private object FastFeatureGet(Type key) - {{{Each(cachedFeatures, feature => $@" + {{{Each(allFeatures, feature => $@" if (key == typeof(global::{feature.FullName})) {{ return _current{feature.Name}; @@ -113,7 +111,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http private void FastFeatureSet(Type key, object feature) {{ _featureRevision++; - {Each(cachedFeatures, feature => $@" + {Each(allFeatures, feature => $@" if (key == typeof(global::{feature.FullName})) {{ _current{feature.Name} = feature; @@ -123,7 +121,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http }} private IEnumerable> FastEnumerable() - {{{Each(cachedFeatures, feature => $@" + {{{Each(allFeatures, feature => $@" if (_current{feature.Name} != null) {{ yield return new KeyValuePair({feature.Name}Type, _current{feature.Name} as global::{feature.FullName});