< 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: 1321_24790053727
Line coverage
71%
Covered lines: 37
Uncovered lines: 15
Coverable lines: 52
Total lines: 100
Line coverage: 71.1%
Branch coverage
45%
Covered branches: 11
Total branches: 24
Branch coverage: 45.8%
Method coverage
80%
Covered methods: 4
Fully covered methods: 3
Total methods: 5
Method coverage: 80%
Full method coverage: 60%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_DefaultName()100%11100%
IsSslRequired(...)0%4260%
.ctor(...)100%11100%
.ctor()100%11100%
CreateConnection(...)61.11%261871.11%

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.Internal;
 4using IceRpc.Transports.Quic.Internal;
 5using System.Net;
 6using System.Net.Quic;
 7using System.Net.Security;
 8using System.Runtime.Versioning;
 9
 10namespace IceRpc.Transports.Quic;
 11
 12/// <summary>Implements <see cref="IMultiplexedClientTransport"/> using QUIC.</summary>
 13[SupportedOSPlatform("linux")]
 14[SupportedOSPlatform("macos")]
 15[SupportedOSPlatform("windows")]
 16public class QuicClientTransport : IMultiplexedClientTransport
 17{
 18    /// <inheritdoc/>
 1519    public string DefaultName => "quic";
 20
 21    /// <inheritdoc/>
 022    public bool IsSslRequired(string? transportName) => transportName is null or "quic" ? true :
 023        throw new NotSupportedException($"The QUIC client transport does not support transport '{transportName}'.");
 24
 25    private readonly QuicClientTransportOptions _quicTransportOptions;
 26
 27    /// <summary>Constructs a QUIC client transport.</summary>
 28    /// <param name="options">The options to configure the QUIC client transport.</param>
 24229    public QuicClientTransport(QuicClientTransportOptions options) => _quicTransportOptions = options;
 30
 31    /// <summary>Constructs a QUIC client transport.</summary>
 32    public QuicClientTransport()
 433        : this(new QuicClientTransportOptions())
 434    {
 435    }
 36
 37    /// <inheritdoc/>
 38    public IMultiplexedConnection CreateConnection(
 39        TransportAddress transportAddress,
 40        MultiplexedConnectionOptions options,
 41        SslClientAuthenticationOptions? clientAuthenticationOptions)
 12242    {
 12243        if (!QuicConnection.IsSupported)
 044        {
 045            throw new NotSupportedException(
 046                "The QUIC client transport is not available on this system. Please review the Platform Dependencies for 
 47        }
 48
 12249        if (transportAddress.TransportName is string name && name != DefaultName)
 050        {
 051            throw new NotSupportedException($"The QUIC client transport does not support transport '{name}'.");
 52        }
 53
 12254        if (transportAddress.Params.Count > 0)
 155        {
 156            throw new ArgumentException(
 157                "The transport address contains parameters that are not valid for the QUIC client transport.",
 158                nameof(transportAddress));
 59        }
 60
 12161        if (clientAuthenticationOptions is null)
 062        {
 063            throw new ArgumentNullException(
 064                nameof(clientAuthenticationOptions),
 065                "The QUIC client transport requires the SSL client authentication options to be set.");
 66        }
 67
 12168        if (clientAuthenticationOptions.ApplicationProtocols
 12169            is not List<SslApplicationProtocol> applicationProtocols || applicationProtocols.Count == 0)
 070        {
 071            throw new ArgumentException(
 072                "The QUIC client transport requires ApplicationProtocols to be set in the SSL client authentication opti
 073                nameof(clientAuthenticationOptions));
 74        }
 75
 12176        clientAuthenticationOptions = clientAuthenticationOptions.ShallowClone();
 12177        clientAuthenticationOptions.TargetHost ??= transportAddress.Host;
 78
 12179        EndPoint endPoint = IPAddress.TryParse(transportAddress.Host, out IPAddress? ipAddress) ?
 12180            new IPEndPoint(ipAddress, transportAddress.Port) :
 12181            new DnsEndPoint(transportAddress.Host, transportAddress.Port);
 82
 12183        var quicClientOptions = new QuicClientConnectionOptions
 12184        {
 12185            ClientAuthenticationOptions = clientAuthenticationOptions,
 12186            DefaultCloseErrorCode = (int)MultiplexedConnectionCloseError.Aborted,
 12187            DefaultStreamErrorCode = 0,
 12188            HandshakeTimeout = options.HandshakeTimeout,
 12189            IdleTimeout = _quicTransportOptions.IdleTimeout,
 12190            InitialReceiveWindowSizes = _quicTransportOptions.InitialReceiveWindowSizes,
 12191            KeepAliveInterval = _quicTransportOptions.KeepAliveInterval,
 12192            LocalEndPoint = _quicTransportOptions.LocalNetworkAddress,
 12193            RemoteEndPoint = endPoint,
 12194            MaxInboundBidirectionalStreams = options.MaxBidirectionalStreams,
 12195            MaxInboundUnidirectionalStreams = options.MaxUnidirectionalStreams
 12196        };
 97
 12198        return new QuicMultiplexedClientConnection(options, quicClientOptions);
 12199    }
 100}