< Summary

Information
Class: IceRpc.Transports.Quic.Internal.QuicMultiplexedStream
Assembly: IceRpc
File(s): /home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc/Transports/Quic/Internal/QuicMultiplexedStream.cs
Tag: 2300_35243572715
Line coverage
100%
Covered lines: 42
Uncovered lines: 0
Coverable lines: 42
Total lines: 75
Line coverage: 100%
Branch coverage
77%
Covered branches: 14
Total branches: 18
Branch coverage: 77.7%
Method coverage
100%
Covered methods: 9
Fully covered methods: 9
Total methods: 9
Method coverage: 100%
Full method coverage: 100%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Id()100%11100%
get_Input()50%22100%
get_IsBidirectional()100%11100%
get_IsRemote()100%11100%
get_IsStarted()100%11100%
get_Output()50%22100%
get_WritesClosed()50%44100%
.ctor(...)100%88100%
ReleaseStream()100%22100%

File(s)

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

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3using System.Buffers;
 4using System.IO.Pipelines;
 5using System.Net.Quic;
 6using System.Runtime.Versioning;
 7
 8namespace IceRpc.Transports.Quic.Internal;
 9
 10/// <summary>The QUIC multiplexed stream implements an <see cref="IMultiplexedStream"/>.</summary>
 11[SupportedOSPlatform("linux")]
 12[SupportedOSPlatform("macos")]
 13[SupportedOSPlatform("windows")]
 14internal class QuicMultiplexedStream : IMultiplexedStream
 15{
 3016    public ulong Id { get; }
 17
 18    public PipeReader Input =>
 2793619        _inputPipeReader ?? throw new InvalidOperationException("A local unidirectional stream has no Input.");
 20
 37221    public bool IsBidirectional { get; }
 22
 1423    public bool IsRemote { get; }
 24
 225    public bool IsStarted => true;
 26
 27    public PipeWriter Output =>
 644928        _outputPipeWriter ?? throw new InvalidOperationException("A remote unidirectional stream has no Output.");
 29
 1230    public Task WritesClosed => _outputPipeWriter?.Closed ?? Task.CompletedTask;
 31
 32    private readonly QuicPipeReader? _inputPipeReader;
 33    private readonly QuicPipeWriter? _outputPipeWriter;
 34    private readonly QuicStream _stream;
 35
 59236    internal QuicMultiplexedStream(
 59237        QuicStream stream,
 59238        bool isRemote,
 59239        MemoryPool<byte> pool,
 59240        int minSegmentSize,
 59241        Action throwIfConnectionClosedOrDisposed)
 59242    {
 59243        Id = (ulong)stream.Id;
 59244        IsRemote = isRemote;
 59245        IsBidirectional = stream.Type == QuicStreamType.Bidirectional;
 46
 59247        int streamCount = stream.CanRead && stream.CanWrite ? 2 : 1;
 48
 59249        _stream = stream;
 59250        _inputPipeReader = stream.CanRead ?
 59251            new QuicPipeReader(
 59252                stream,
 59253                pool,
 59254                minSegmentSize,
 59255                ReleaseStream,
 59256                throwIfConnectionClosedOrDisposed) :
 59257            null;
 59258        _outputPipeWriter = stream.CanWrite ?
 59259            new QuicPipeWriter(
 59260                stream,
 59261                pool,
 59262                minSegmentSize,
 59263                ReleaseStream,
 59264                throwIfConnectionClosedOrDisposed) :
 59265            null;
 66
 67        void ReleaseStream()
 102368        {
 102369            if (Interlocked.Decrement(ref streamCount) == 0)
 56870            {
 56871                _ = _stream.DisposeAsync().AsTask();
 56872            }
 102373        }
 59274    }
 75}