< 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: 1321_24790053727
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 =>
 2776219        _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 =>
 644428        _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
 58836    internal QuicMultiplexedStream(
 58837        QuicStream stream,
 58838        bool isRemote,
 58839        MemoryPool<byte> pool,
 58840        int minSegmentSize,
 58841        Action throwIfConnectionClosedOrDisposed)
 58842    {
 58843        Id = (ulong)stream.Id;
 58844        IsRemote = isRemote;
 58845        IsBidirectional = stream.Type == QuicStreamType.Bidirectional;
 46
 58847        int streamCount = stream.CanRead && stream.CanWrite ? 2 : 1;
 48
 58849        _stream = stream;
 58850        _inputPipeReader = stream.CanRead ?
 58851            new QuicPipeReader(
 58852                stream,
 58853                pool,
 58854                minSegmentSize,
 58855                ReleaseStream,
 58856                throwIfConnectionClosedOrDisposed) :
 58857            null;
 58858        _outputPipeWriter = stream.CanWrite ?
 58859            new QuicPipeWriter(
 58860                stream,
 58861                pool,
 58862                minSegmentSize,
 58863                ReleaseStream,
 58864                throwIfConnectionClosedOrDisposed) :
 58865            null;
 66
 67        void ReleaseStream()
 102068        {
 102069            if (Interlocked.Decrement(ref streamCount) == 0)
 56770            {
 56771                _ = _stream.DisposeAsync().AsTask();
 56772            }
 102073        }
 58874    }
 75}