Skip to content

Commit cba981f

Browse files
committed
Move interface implement on class to generated (to match order)
1 parent 138f8b5 commit cba981f

7 files changed

+39
-35
lines changed

src/Servers/Kestrel/Core/src/Internal/Http/HttpProtocol.FeatureCollection.cs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,11 @@
1616

1717
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
1818
{
19-
internal partial class HttpProtocol : IHttpRequestFeature,
20-
IHttpResponseFeature,
21-
IHttpResponseBodyFeature,
22-
IRouteValuesFeature,
23-
IEndpointFeature,
24-
IHttpRequestIdentifierFeature,
25-
IHttpRequestTrailersFeature,
26-
IHttpUpgradeFeature,
27-
IRequestBodyPipeFeature,
28-
IHttpConnectionFeature,
29-
IHttpRequestLifetimeFeature,
30-
IHttpBodyControlFeature,
31-
IHttpMaxRequestBodySizeFeature,
32-
IHttpRequestBodyDetectionFeature
19+
internal partial class HttpProtocol
3320
{
3421
// NOTE: When feature interfaces are added to or removed from this HttpProtocol class implementation,
35-
// then the list of `implementedFeatures` in the generated code project MUST also be updated.
22+
// then the list of `implementedFeatures` in the generated code project MUST also be updated first
23+
// and the code generator re-reun, which will change the interface list.
3624
// See also: tools/CodeGenerator/HttpProtocolFeatureCollection.cs
3725

3826
string IHttpRequestFeature.Protocol

src/Servers/Kestrel/Core/src/Internal/Http/HttpProtocol.Generated.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,21 @@
1414

1515
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
1616
{
17-
internal partial class HttpProtocol : IFeatureCollection
17+
internal partial class HttpProtocol : IFeatureCollection,
18+
IHttpRequestFeature,
19+
IHttpResponseFeature,
20+
IHttpResponseBodyFeature,
21+
IRouteValuesFeature,
22+
IEndpointFeature,
23+
IHttpRequestIdentifierFeature,
24+
IHttpRequestTrailersFeature,
25+
IHttpUpgradeFeature,
26+
IRequestBodyPipeFeature,
27+
IHttpConnectionFeature,
28+
IHttpRequestLifetimeFeature,
29+
IHttpBodyControlFeature,
30+
IHttpMaxRequestBodySizeFeature,
31+
IHttpRequestBodyDetectionFeature
1832
{
1933
// Implemented features
2034
internal protected IHttpRequestFeature? _currentIHttpRequestFeature;

src/Servers/Kestrel/shared/TransportConnection.FeatureCollection.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,11 @@
1111

1212
namespace Microsoft.AspNetCore.Connections
1313
{
14-
internal partial class TransportConnection : IConnectionIdFeature,
15-
IConnectionTransportFeature,
16-
IConnectionItemsFeature,
17-
IMemoryPoolFeature,
18-
IConnectionLifetimeFeature
14+
internal partial class TransportConnection
1915
{
2016
// NOTE: When feature interfaces are added to or removed from this TransportConnection class implementation,
21-
// then the list of `features` in the generated code project MUST also be updated.
17+
// then the list of `features` in the generated code project MUST also be updated first
18+
// and the code generator re-reun, which will change the interface list.
2219
// See also: tools/CodeGenerator/TransportConnectionFeatureCollection.cs
2320

2421
MemoryPool<byte> IMemoryPoolFeature.MemoryPool => MemoryPool;

src/Servers/Kestrel/shared/TransportConnection.Generated.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@
1313

1414
namespace Microsoft.AspNetCore.Connections
1515
{
16-
internal partial class TransportConnection : IFeatureCollection
16+
internal partial class TransportConnection : IFeatureCollection,
17+
IConnectionIdFeature,
18+
IConnectionTransportFeature,
19+
IConnectionItemsFeature,
20+
IMemoryPoolFeature,
21+
IConnectionLifetimeFeature
1722
{
1823
// Implemented features
1924
internal protected IConnectionIdFeature? _currentIConnectionIdFeature;
@@ -22,8 +27,6 @@ internal partial class TransportConnection : IFeatureCollection
2227
internal protected IMemoryPoolFeature? _currentIMemoryPoolFeature;
2328
internal protected IConnectionLifetimeFeature? _currentIConnectionLifetimeFeature;
2429

25-
// Other reserved feature slots
26-
2730
private int _featureRevision;
2831

2932
private List<KeyValuePair<Type, object>>? MaybeExtra;

src/Servers/Kestrel/shared/TransportMultiplexedConnection.FeatureCollection.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,16 @@
33

44
using System.Buffers;
55
using System.Collections.Generic;
6-
using System.IO.Pipelines;
76
using System.Threading;
87
using Microsoft.AspNetCore.Connections.Features;
98

109
namespace Microsoft.AspNetCore.Connections
1110
{
12-
internal partial class TransportMultiplexedConnection : IConnectionIdFeature,
13-
IConnectionItemsFeature,
14-
IMemoryPoolFeature,
15-
IConnectionLifetimeFeature
11+
internal partial class TransportMultiplexedConnection
1612
{
1713
// NOTE: When feature interfaces are added to or removed from this TransportConnection class implementation,
18-
// then the list of `features` in the generated code project MUST also be updated.
14+
// then the list of `features` in the generated code project MUST also be updated first
15+
// and the code generator re-reun, which will change the interface list.
1916
// See also: tools/CodeGenerator/TransportConnectionFeatureCollection.cs
2017

2118
MemoryPool<byte> IMemoryPoolFeature.MemoryPool => MemoryPool;

src/Servers/Kestrel/shared/TransportMultiplexedConnection.Generated.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313

1414
namespace Microsoft.AspNetCore.Connections
1515
{
16-
internal partial class TransportMultiplexedConnection : IFeatureCollection
16+
internal partial class TransportMultiplexedConnection : IFeatureCollection,
17+
IConnectionIdFeature,
18+
IConnectionItemsFeature,
19+
IMemoryPoolFeature,
20+
IConnectionLifetimeFeature
1721
{
1822
// Implemented features
1923
internal protected IConnectionIdFeature? _currentIConnectionIdFeature;

src/Servers/Kestrel/tools/CodeGenerator/FeatureCollectionGenerator.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ public static string GenerateFile(string namespaceName, string className, string
3232
3333
namespace {namespaceName}
3434
{{
35-
internal partial class {className} : IFeatureCollection
35+
internal partial class {className} : IFeatureCollection{Each(implementedFeatures.Where(f => !skipResetFeatures.Contains(f)), feature => $@",
36+
{new string(' ', className.Length)}{feature}")}
3637
{{
3738
// Implemented features{Each(implementedFeatures.Where(f => !skipResetFeatures.Contains(f)), feature => $@"
3839
internal protected {feature}? _current{feature};")}{Each(implementedFeatures.Where(f => skipResetFeatures.Contains(f)), feature => $@"
39-
internal protected {feature}? _current{feature};")}
40+
internal protected {feature}? _current{feature};")}{(allFeatures.Where(f => !implementedFeatures.Contains(f)).FirstOrDefault() is not null ? @"
4041
41-
// Other reserved feature slots{Each(allFeatures.Where(f => !implementedFeatures.Contains(f)), feature => $@"
42+
// Other reserved feature slots" : "")}{Each(allFeatures.Where(f => !implementedFeatures.Contains(f)), feature => $@"
4243
internal protected {feature}? _current{feature};")}
4344
4445
private int _featureRevision;

0 commit comments

Comments
 (0)