< 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: 592_20856082467
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
Total methods: 9
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{
 2216    public ulong Id { get; }
 17
 18    public PipeReader Input =>
 2756019        _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 =>
 641228        _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
 57236    internal QuicMultiplexedStream(
 57237        QuicStream stream,
 57238        bool isRemote,
 57239        MemoryPool<byte> pool,
 57240        int minSegmentSize,
 57241        Action throwIfConnectionClosedOrDisposed)
 57242    {
 57243        Id = (ulong)stream.Id;
 57244        IsRemote = isRemote;
 57245        IsBidirectional = stream.Type == QuicStreamType.Bidirectional;
 46
 57247        int streamCount = stream.CanRead && stream.CanWrite ? 2 : 1;
 48
 57249        _stream = stream;
 57250        _inputPipeReader = stream.CanRead ?
 57251            new QuicPipeReader(
 57252                stream,
 57253                pool,
 57254                minSegmentSize,
 57255                ReleaseStream,
 57256                throwIfConnectionClosedOrDisposed) :
 57257            null;
 57258        _outputPipeWriter = stream.CanWrite ?
 57259            new QuicPipeWriter(
 57260                stream,
 57261                pool,
 57262                minSegmentSize,
 57263                ReleaseStream,
 57264                throwIfConnectionClosedOrDisposed) :
 57265            null;
 66
 67        void ReleaseStream()
 100468        {
 100469            if (Interlocked.Decrement(ref streamCount) == 0)
 55170            {
 55171                _ = _stream.DisposeAsync().AsTask();
 55172            }
 100473        }
 57274    }
 75}