Skip to content

Commit 1173fbd

Browse files
authored
Enable nullable on server transports (#28348)
1 parent abbbd44 commit 1173fbd

33 files changed

+128
-97
lines changed

src/Servers/Connections.Abstractions/src/IConnectionListener.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public interface IConnectionListener : IAsyncDisposable
2323
/// </summary>
2424
/// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
2525
/// <returns>A <see cref="ValueTask{ConnectionContext}"/> that completes when a connection is accepted, yielding the <see cref="ConnectionContext" /> representing the connection.</returns>
26-
ValueTask<ConnectionContext> AcceptAsync(CancellationToken cancellationToken = default);
26+
ValueTask<ConnectionContext?> AcceptAsync(CancellationToken cancellationToken = default);
2727

2828
/// <summary>
2929
/// Stops listening for incoming connections.

src/Servers/Connections.Abstractions/src/IMulitplexedConnectionListener.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ public interface IMultiplexedConnectionListener : IAsyncDisposable
3232
/// <param name="features">A feature collection to pass options when accepting a connection.</param>
3333
/// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
3434
/// <returns>A <see cref="ValueTask{ConnectionContext}"/> that completes when a connection is accepted, yielding the <see cref="MultiplexedConnectionContext" /> representing the connection.</returns>
35-
ValueTask<MultiplexedConnectionContext> AcceptAsync(IFeatureCollection? features = null, CancellationToken cancellationToken = default);
35+
ValueTask<MultiplexedConnectionContext?> AcceptAsync(IFeatureCollection? features = null, CancellationToken cancellationToken = default);
3636
}
3737
}

src/Servers/Connections.Abstractions/src/MultiplexedConnectionContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public abstract class MultiplexedConnectionContext : BaseConnectionContext, IAsy
1818
/// </summary>
1919
/// <param name="cancellationToken"></param>
2020
/// <returns></returns>
21-
public abstract ValueTask<ConnectionContext> AcceptAsync(CancellationToken cancellationToken = default);
21+
public abstract ValueTask<ConnectionContext?> AcceptAsync(CancellationToken cancellationToken = default);
2222

2323
/// <summary>
2424
/// Creates an outbound connection

src/Servers/Connections.Abstractions/src/PublicAPI.Shipped.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Microsoft.AspNetCore.Connections.IConnectionBuilder.Use(System.Func<Microsoft.As
102102
Microsoft.AspNetCore.Connections.IConnectionFactory
103103
Microsoft.AspNetCore.Connections.IConnectionFactory.ConnectAsync(System.Net.EndPoint! endpoint, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<Microsoft.AspNetCore.Connections.ConnectionContext!>
104104
Microsoft.AspNetCore.Connections.IConnectionListener
105-
Microsoft.AspNetCore.Connections.IConnectionListener.AcceptAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<Microsoft.AspNetCore.Connections.ConnectionContext!>
105+
Microsoft.AspNetCore.Connections.IConnectionListener.AcceptAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<Microsoft.AspNetCore.Connections.ConnectionContext?>
106106
Microsoft.AspNetCore.Connections.IConnectionListener.EndPoint.get -> System.Net.EndPoint!
107107
Microsoft.AspNetCore.Connections.IConnectionListener.UnbindAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask
108108
Microsoft.AspNetCore.Connections.IConnectionListenerFactory

src/Servers/Connections.Abstractions/src/PublicAPI.Unshipped.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Microsoft.AspNetCore.Connections.Experimental.IMultiplexedConnectionBuilder.Use(
66
Microsoft.AspNetCore.Connections.Experimental.IMultiplexedConnectionFactory
77
Microsoft.AspNetCore.Connections.Experimental.IMultiplexedConnectionFactory.ConnectAsync(System.Net.EndPoint! endpoint, Microsoft.AspNetCore.Http.Features.IFeatureCollection? features = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<Microsoft.AspNetCore.Connections.Experimental.MultiplexedConnectionContext!>
88
Microsoft.AspNetCore.Connections.Experimental.IMultiplexedConnectionListener
9-
Microsoft.AspNetCore.Connections.Experimental.IMultiplexedConnectionListener.AcceptAsync(Microsoft.AspNetCore.Http.Features.IFeatureCollection? features = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<Microsoft.AspNetCore.Connections.Experimental.MultiplexedConnectionContext!>
9+
Microsoft.AspNetCore.Connections.Experimental.IMultiplexedConnectionListener.AcceptAsync(Microsoft.AspNetCore.Http.Features.IFeatureCollection? features = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<Microsoft.AspNetCore.Connections.Experimental.MultiplexedConnectionContext?>
1010
Microsoft.AspNetCore.Connections.Experimental.IMultiplexedConnectionListener.EndPoint.get -> System.Net.EndPoint!
1111
Microsoft.AspNetCore.Connections.Experimental.IMultiplexedConnectionListener.UnbindAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask
1212
Microsoft.AspNetCore.Connections.Experimental.IMultiplexedConnectionListenerFactory
@@ -19,5 +19,5 @@ Microsoft.AspNetCore.Connections.Experimental.MultiplexedConnectionBuilder.Use(S
1919
Microsoft.AspNetCore.Connections.Experimental.MultiplexedConnectionContext
2020
Microsoft.AspNetCore.Connections.Experimental.MultiplexedConnectionContext.MultiplexedConnectionContext() -> void
2121
Microsoft.AspNetCore.Connections.Experimental.MultiplexedConnectionDelegate
22-
abstract Microsoft.AspNetCore.Connections.Experimental.MultiplexedConnectionContext.AcceptAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<Microsoft.AspNetCore.Connections.ConnectionContext!>
22+
abstract Microsoft.AspNetCore.Connections.Experimental.MultiplexedConnectionContext.AcceptAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<Microsoft.AspNetCore.Connections.ConnectionContext?>
2323
abstract Microsoft.AspNetCore.Connections.Experimental.MultiplexedConnectionContext.ConnectAsync(Microsoft.AspNetCore.Http.Features.IFeatureCollection? features = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<Microsoft.AspNetCore.Connections.ConnectionContext!>

src/Servers/Kestrel/Core/src/Internal/Infrastructure/IConnectionListenerOfT.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ internal interface IConnectionListener<T> : IConnectionListenerBase where T : Ba
1818
/// </summary>
1919
/// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
2020
/// <returns>A <see cref="ValueTask{T}"/> that completes when a connection is accepted, yielding the <see cref="BaseConnectionContext" /> representing the connection.</returns>
21-
ValueTask<T> AcceptAsync(CancellationToken cancellationToken = default);
21+
ValueTask<T?> AcceptAsync(CancellationToken cancellationToken = default);
2222
}
2323
}

src/Servers/Kestrel/Core/src/Internal/Infrastructure/TransportManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public GenericConnectionListener(IConnectionListener connectionListener)
162162

163163
public EndPoint EndPoint => _connectionListener.EndPoint;
164164

165-
public ValueTask<ConnectionContext> AcceptAsync(CancellationToken cancellationToken = default)
165+
public ValueTask<ConnectionContext?> AcceptAsync(CancellationToken cancellationToken = default)
166166
=> _connectionListener.AcceptAsync(cancellationToken);
167167

168168
public ValueTask UnbindAsync(CancellationToken cancellationToken = default)
@@ -183,7 +183,7 @@ public GenericMultiplexedConnectionListener(IMultiplexedConnectionListener multi
183183

184184
public EndPoint EndPoint => _multiplexedConnectionListener.EndPoint;
185185

186-
public ValueTask<MultiplexedConnectionContext> AcceptAsync(CancellationToken cancellationToken = default)
186+
public ValueTask<MultiplexedConnectionContext?> AcceptAsync(CancellationToken cancellationToken = default)
187187
=> _multiplexedConnectionListener.AcceptAsync(features: null, cancellationToken);
188188

189189
public ValueTask UnbindAsync(CancellationToken cancellationToken = default)

src/Servers/Kestrel/Transport.Quic/src/Internal/FakeTlsConnectionFeature.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ public FakeTlsConnectionFeature()
1515
{
1616
}
1717

18-
public X509Certificate2 ClientCertificate { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
18+
public X509Certificate2? ClientCertificate { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
1919

20-
public Task<X509Certificate2> GetClientCertificateAsync(CancellationToken cancellationToken)
20+
public Task<X509Certificate2?> GetClientCertificateAsync(CancellationToken cancellationToken)
2121
{
2222
throw new NotImplementedException();
2323
}

src/Servers/Kestrel/Transport.Quic/src/Internal/QuicConnectionContext.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public override void Abort(ConnectionAbortedException abortReason)
7474
_closeTask = _connection.CloseAsync(errorCode: Error);
7575
}
7676

77-
public override async ValueTask<ConnectionContext> AcceptAsync(CancellationToken cancellationToken = default)
77+
public override async ValueTask<ConnectionContext?> AcceptAsync(CancellationToken cancellationToken = default)
7878
{
7979
try
8080
{
@@ -90,7 +90,7 @@ public override async ValueTask<ConnectionContext> AcceptAsync(CancellationToken
9090
return null;
9191
}
9292

93-
public override ValueTask<ConnectionContext> ConnectAsync(IFeatureCollection features = null, CancellationToken cancellationToken = default)
93+
public override ValueTask<ConnectionContext> ConnectAsync(IFeatureCollection? features = null, CancellationToken cancellationToken = default)
9494
{
9595
QuicStream quicStream;
9696

src/Servers/Kestrel/Transport.Quic/src/Internal/QuicConnectionListener.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ internal class QuicConnectionListener : IMultiplexedConnectionListener, IAsyncDi
2626

2727
public QuicConnectionListener(QuicTransportOptions options, IQuicTrace log, EndPoint endpoint)
2828
{
29+
if (options.Alpn == null)
30+
{
31+
throw new InvalidOperationException("QuicTransportOptions.Alpn must be configured with a value.");
32+
}
33+
2934
_log = log;
3035
_context = new QuicTransportContext(_log, options);
3136
EndPoint = endpoint;
@@ -46,7 +51,7 @@ public QuicConnectionListener(QuicTransportOptions options, IQuicTrace log, EndP
4651

4752
public EndPoint EndPoint { get; set; }
4853

49-
public async ValueTask<MultiplexedConnectionContext> AcceptAsync(IFeatureCollection features = null, CancellationToken cancellationToken = default)
54+
public async ValueTask<MultiplexedConnectionContext?> AcceptAsync(IFeatureCollection? features = null, CancellationToken cancellationToken = default)
5055
{
5156
try
5257
{

0 commit comments

Comments
 (0)