< Summary

Information
Class: IceRpc.Transports.Quic.Internal.QuicMultiplexedStream
Assembly: IceRpc.Transports.Quic
File(s): /home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc.Transports.Quic/Internal/QuicMultiplexedStream.cs
Tag: 275_13775359185
Line coverage
100%
Covered lines: 42
Uncovered lines: 0
Coverable lines: 42
Total lines: 71
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;
 6
 7namespace IceRpc.Transports.Quic.Internal;
 8
 9/// <summary>The Quic multiplexed stream implements an <see cref="IMultiplexedStream"/>.</summary>
 10internal class QuicMultiplexedStream : IMultiplexedStream
 11{
 4412    public ulong Id { get; }
 13
 14    public PipeReader Input =>
 5474715        _inputPipeReader ?? throw new InvalidOperationException("A local unidirectional stream has no Input.");
 16
 74217    public bool IsBidirectional { get; }
 18
 2819    public bool IsRemote { get; }
 20
 421    public bool IsStarted => true;
 22
 23    public PipeWriter Output =>
 1282124        _outputPipeWriter ?? throw new InvalidOperationException("A remote unidirectional stream has no Output.");
 25
 2426    public Task WritesClosed => _outputPipeWriter?.Closed ?? Task.CompletedTask;
 27
 28    private readonly QuicPipeReader? _inputPipeReader;
 29    private readonly QuicPipeWriter? _outputPipeWriter;
 30    private readonly QuicStream _stream;
 31
 114232    internal QuicMultiplexedStream(
 114233        QuicStream stream,
 114234        bool isRemote,
 114235        MemoryPool<byte> pool,
 114236        int minSegmentSize,
 114237        Action throwIfConnectionClosedOrDisposed)
 114238    {
 114239        Id = (ulong)stream.Id;
 114240        IsRemote = isRemote;
 114241        IsBidirectional = stream.Type == QuicStreamType.Bidirectional;
 42
 114243        int streamCount = stream.CanRead && stream.CanWrite ? 2 : 1;
 44
 114245        _stream = stream;
 114246        _inputPipeReader = stream.CanRead ?
 114247            new QuicPipeReader(
 114248                stream,
 114249                pool,
 114250                minSegmentSize,
 114251                ReleaseStream,
 114252                throwIfConnectionClosedOrDisposed) :
 114253            null;
 114254        _outputPipeWriter = stream.CanWrite ?
 114255            new QuicPipeWriter(
 114256                stream,
 114257                pool,
 114258                minSegmentSize,
 114259                ReleaseStream,
 114260                throwIfConnectionClosedOrDisposed) :
 114261            null;
 62
 63        void ReleaseStream()
 200464        {
 200465            if (Interlocked.Decrement(ref streamCount) == 0)
 110066            {
 110067                _ = _stream.DisposeAsync().AsTask();
 110068            }
 200469        }
 114270    }
 71}