Skip to content

Commit 33c3c7c

Browse files
authored
WebTransport interfaces require preview features (#43419)
AcceptAsync already had this. This just extends the treatment to the entire interface so we can make breaking changes to this API in a later release. We think we might expose a MultiplexedConnectionContext.
1 parent 9c8ad73 commit 33c3c7c

File tree

9 files changed

+19
-5
lines changed

9 files changed

+19
-5
lines changed

src/Http/Http.Features/src/IHttpWebTransportFeature.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace Microsoft.AspNetCore.Http.Features;
88
/// <summary>
99
/// API for accepting and retrieving WebTransport sessions.
1010
/// </summary>
11+
[RequiresPreviewFeatures("WebTransport is a preview feature")]
1112
public interface IHttpWebTransportFeature
1213
{
1314
/// <summary>
@@ -20,6 +21,5 @@ public interface IHttpWebTransportFeature
2021
/// </summary>
2122
/// <param name="cancellationToken">The cancellation token to cancel waiting for the session.</param>
2223
/// <returns>An instance of a WebTransportSession which will be used to control the connection.</returns>
23-
[RequiresPreviewFeatures("WebTransport is a preview feature")]
2424
ValueTask<IWebTransportSession> AcceptAsync(CancellationToken cancellationToken = default);
2525
}

src/Http/Http.Features/src/IWebTransportSession.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Runtime.Versioning;
45
using Microsoft.AspNetCore.Connections;
56

67
namespace Microsoft.AspNetCore.Http.Features;
78

89
/// <summary>
910
/// Controls the session and streams of a WebTransport session.
1011
/// </summary>
12+
[RequiresPreviewFeatures("WebTransport is a preview feature")]
1113
public interface IWebTransportSession
1214
{
1315
/// <summary>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
using Microsoft.AspNetCore.Http.Features.Authentication;
1212
using Microsoft.AspNetCore.Server.Kestrel.Core.Features;
1313

14+
#pragma warning disable CA2252 // WebTransport is a preview feature
15+
1416
#nullable enable
1517

1618
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http

src/Servers/Kestrel/Core/src/Internal/Http3/Http3Stream.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,9 @@ private Pipe CreateRequestBodyPipe(uint windowSize)
11691169
}
11701170
}
11711171

1172+
#pragma warning disable CA2252 // WebTransport is a preview feature
11721173
public override async ValueTask<IWebTransportSession> AcceptAsync(CancellationToken token)
1174+
#pragma warning restore CA2252 // WebTransport is a preview feature
11731175
{
11741176
if (_isWebTransportSessionAccepted)
11751177
{

src/Servers/Kestrel/Core/src/Internal/WebTransport/WebTransportSession.cs

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

1414
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.WebTransport;
1515

16+
#pragma warning disable CA2252 // WebTransport is a preview feature
1617
internal sealed class WebTransportSession : IWebTransportSession
1718
{
1819
private static readonly IStreamDirectionFeature _outputStreamDirectionFeature = new DefaultStreamDirectionFeature(canRead: false, canWrite: true);
@@ -190,3 +191,4 @@ internal bool TryRemoveStream(long streamId)
190191
return success;
191192
}
192193
}
194+
#pragma warning restore CA2252 // WebTransport is a preview feature

src/Servers/Kestrel/Core/test/Http1/Http1HttpProtocolFeatureCollectionTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ public void FeaturesSetByTypeSameAsGeneric()
127127
_collection[typeof(IHttpExtendedConnectFeature)] = CreateHttp1Connection();
128128
_collection[typeof(IHttpUpgradeFeature)] = CreateHttp1Connection();
129129
_collection[typeof(IPersistentStateFeature)] = CreateHttp1Connection();
130+
#pragma warning disable CA2252 // WebTransport is a preview feature
130131
_collection.Set<IHttpWebTransportFeature>(CreateHttp1Connection());
132+
#pragma warning restore CA2252 // WebTransport is a preview feature
131133

132134
CompareGenericGetterToIndexer();
133135

@@ -155,7 +157,9 @@ public void FeaturesSetByGenericSameAsByType()
155157
_collection.Set<IHttpExtendedConnectFeature>(CreateHttp1Connection());
156158
_collection.Set<IHttpUpgradeFeature>(CreateHttp1Connection());
157159
_collection.Set<IPersistentStateFeature>(CreateHttp1Connection());
160+
#pragma warning disable CA2252 // WebTransport is a preview feature
158161
_collection.Set<IHttpWebTransportFeature>(CreateHttp1Connection());
162+
#pragma warning restore CA2252 // WebTransport is a preview feature
159163

160164
CompareGenericGetterToIndexer();
161165

src/Servers/Kestrel/test/InMemory.FunctionalTests/Http3/WebTransport/WebTransportHandshakeTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ await Http3Api.InitializeConnectionAsync(async context =>
2727
{
2828
var success = true;
2929

30+
#pragma warning disable CA2252 // WebTransport is a preview feature
3031
var webTransportFeature = context.Features.GetRequiredFeature<IHttpWebTransportFeature>();
3132

3233
success &= webTransportFeature.IsWebTransportRequest;
3334

34-
#pragma warning disable CA2252 // This API requires opting into preview features
3535
try
3636
{
3737
var session = await webTransportFeature.AcceptAsync(CancellationToken.None).DefaultTimeout(); // todo session is null here

src/Servers/Kestrel/test/InMemory.FunctionalTests/Http3/WebTransport/WebTransportTestUtilities.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ internal class WebTransportTestUtilities
2222

2323
public static async ValueTask<WebTransportSession> GenerateSession(Http3InMemory inMemory, TaskCompletionSource exitSessionTcs)
2424
{
25+
#pragma warning disable CA2252 // WebTransport is a preview feature
2526
var appCompletedTcs = new TaskCompletionSource<IWebTransportSession>(TaskCreationOptions.RunContinuationsAsynchronously);
2627

2728
await inMemory.InitializeConnectionAsync(async context =>
2829
{
2930
var webTransportFeature = context.Features.GetRequiredFeature<IHttpWebTransportFeature>();
3031

31-
#pragma warning disable CA2252 // This API requires opting into preview features
3232
try
3333
{
3434
var session = await webTransportFeature.AcceptAsync(CancellationToken.None).DefaultTimeout();
@@ -38,7 +38,7 @@ await inMemory.InitializeConnectionAsync(async context =>
3838
{
3939
appCompletedTcs.SetException(exception);
4040
}
41-
#pragma warning restore CA2252
41+
#pragma warning restore CA2252 // WebTransport is a preview feature
4242

4343
// wait for the test to tell us to kill the application
4444
await exitSessionTcs.Task;

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ public static string GenerateFile()
8888
using Microsoft.AspNetCore.Connections.Features;
8989
using Microsoft.AspNetCore.Http.Features;
9090
using Microsoft.AspNetCore.Http.Features.Authentication;
91-
using Microsoft.AspNetCore.Server.Kestrel.Core.Features;";
91+
using Microsoft.AspNetCore.Server.Kestrel.Core.Features;
92+
93+
#pragma warning disable CA2252 // WebTransport is a preview feature";
9294

9395
return FeatureCollectionGenerator.GenerateFile(
9496
namespaceName: "Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http",

0 commit comments

Comments
 (0)