< Summary

Information
Class: IceRpc.Transports.Quic.QuicClientTransport
Assembly: IceRpc
File(s): /home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc/Transports/Quic/QuicClientTransport.cs
Tag: 592_20856082467
Line coverage
86%
Covered lines: 40
Uncovered lines: 6
Coverable lines: 46
Total lines: 87
Line coverage: 86.9%
Branch coverage
70%
Covered branches: 14
Total branches: 20
Branch coverage: 70%
Method coverage
100%
Covered methods: 5
Total methods: 5
Method coverage: 100%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Name()100%11100%
.ctor(...)100%11100%
.ctor()100%11100%
CreateConnection(...)70%21.352085%
CheckParams(...)100%11100%

File(s)

/home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc/Transports/Quic/QuicClientTransport.cs

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3using IceRpc.Transports.Quic.Internal;
 4using System.Net;
 5using System.Net.Quic;
 6using System.Net.Security;
 7using System.Runtime.Versioning;
 8
 9namespace IceRpc.Transports.Quic;
 10
 11/// <summary>Implements <see cref="IMultiplexedClientTransport"/> using QUIC.</summary>
 12[SupportedOSPlatform("linux")]
 13[SupportedOSPlatform("macos")]
 14[SupportedOSPlatform("windows")]
 15public class QuicClientTransport : IMultiplexedClientTransport
 16{
 17    /// <inheritdoc/>
 12718    public string Name => "quic";
 19
 20    private readonly QuicClientTransportOptions _quicTransportOptions;
 21
 22    /// <summary>Constructs a QUIC client transport.</summary>
 23    /// <param name="options">The options to configure the QUIC client transport.</param>
 24424    public QuicClientTransport(QuicClientTransportOptions options) => _quicTransportOptions = options;
 25
 26    /// <summary>Constructs a QUIC client transport.</summary>
 27    public QuicClientTransport()
 428        : this(new QuicClientTransportOptions())
 429    {
 430    }
 31
 32    /// <inheritdoc/>
 33    public IMultiplexedConnection CreateConnection(
 34        ServerAddress serverAddress,
 35        MultiplexedConnectionOptions options,
 36        SslClientAuthenticationOptions? clientAuthenticationOptions)
 11837    {
 11838        if (!QuicConnection.IsSupported)
 039        {
 040            throw new NotSupportedException(
 041                "The QUIC client transport is not available on this system. Please review the Platform Dependencies for 
 42        }
 43
 11844        if ((serverAddress.Transport is string transport && transport != Name) || !CheckParams(serverAddress))
 145        {
 146            throw new ArgumentException(
 147                $"The server address '{serverAddress}' contains parameters that are not valid for the QUIC client transp
 148                nameof(serverAddress));
 49        }
 50
 11751        if (serverAddress.Transport is null)
 052        {
 053            serverAddress = serverAddress with { Transport = Name };
 054        }
 55
 11756        clientAuthenticationOptions = clientAuthenticationOptions?.Clone() ?? new();
 11757        clientAuthenticationOptions.TargetHost ??= serverAddress.Host;
 11758        clientAuthenticationOptions.ApplicationProtocols ??=
 11759        [
 11760            // Mandatory with Quic
 11761            new(serverAddress.Protocol.Name)
 11762        ];
 63
 11764        EndPoint endpoint = IPAddress.TryParse(serverAddress.Host, out IPAddress? ipAddress) ?
 11765            new IPEndPoint(ipAddress, serverAddress.Port) :
 11766            new DnsEndPoint(serverAddress.Host, serverAddress.Port);
 67
 11768        var quicClientOptions = new QuicClientConnectionOptions
 11769        {
 11770            ClientAuthenticationOptions = clientAuthenticationOptions,
 11771            DefaultCloseErrorCode = (int)MultiplexedConnectionCloseError.Aborted,
 11772            DefaultStreamErrorCode = 0,
 11773            HandshakeTimeout = options.HandshakeTimeout,
 11774            IdleTimeout = _quicTransportOptions.IdleTimeout,
 11775            InitialReceiveWindowSizes = _quicTransportOptions.InitialReceiveWindowSizes,
 11776            KeepAliveInterval = _quicTransportOptions.KeepAliveInterval,
 11777            LocalEndPoint = _quicTransportOptions.LocalNetworkAddress,
 11778            RemoteEndPoint = endpoint,
 11779            MaxInboundBidirectionalStreams = options.MaxBidirectionalStreams,
 11780            MaxInboundUnidirectionalStreams = options.MaxUnidirectionalStreams
 11781        };
 82
 11783        return new QuicMultiplexedClientConnection(options, quicClientOptions);
 11784    }
 85
 11886    private static bool CheckParams(ServerAddress serverAddress) => serverAddress.Params.Count == 0;
 87}