< Summary

Information
Class: IceRpc.OutgoingFrame
Assembly: IceRpc
File(s): /home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc/OutgoingFrame.cs
Tag: 1321_24790053727
Line coverage
89%
Covered lines: 25
Uncovered lines: 3
Coverable lines: 28
Total lines: 84
Line coverage: 89.2%
Branch coverage
83%
Covered branches: 10
Total branches: 12
Branch coverage: 83.3%
Method coverage
100%
Covered methods: 7
Fully covered methods: 6
Total methods: 7
Method coverage: 100%
Full method coverage: 85.7%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Payload()100%11100%
get_PayloadContinuation()100%11100%
set_PayloadContinuation(...)75%44100%
get_Protocol()100%11100%
Use(...)75%5466.66%
GetPayloadWriter(...)100%44100%
.ctor(...)100%11100%

File(s)

/home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc/OutgoingFrame.cs

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3using System.IO.Pipelines;
 4
 5namespace IceRpc;
 6
 7/// <summary>Represents the base class for outgoing frames.</summary>
 8public abstract class OutgoingFrame
 9{
 10    /// <summary>Gets or sets the payload of this frame.</summary>
 11    /// <value>The payload of this frame. Defaults to a <see cref="PipeReader" /> that returns an empty
 12    /// sequence.</value>
 13    /// <remarks>IceRPC completes the payload <see cref="PipeReader" /> with the <see
 14    /// cref="PipeReader.Complete(Exception?)" /> method. It never calls <see
 15    /// cref="PipeReader.CompleteAsync(Exception?)" />. The implementation of <see
 16    /// cref="PipeReader.Complete(Exception?)" /> should not block.</remarks>
 2453517    public PipeReader Payload { get; set; } = EmptyPipeReader.Instance;
 18
 19    /// <summary>Gets or sets the payload continuation of this frame. The payload continuation is a continuation of <see
 20    /// cref="Payload"/>. The receiver cannot distinguish any seam between payload and payload continuation in the <see
 21    /// cref="IncomingFrame.Payload" /> it receives.</summary>
 22    /// <value>The payload continuation of this frame. Defaults to <see langword="null" /> meaning no
 23    /// continuation.</value>
 24    /// <remarks>IceRPC completes the payload continuation <see cref="PipeReader" /> with the <see
 25    /// cref="PipeReader.Complete(Exception?)" /> method. It never calls <see
 26    /// cref="PipeReader.CompleteAsync(Exception?)" />. The implementation of <see
 27    /// cref="PipeReader.Complete(Exception?)" /> should not block.</remarks>
 28    public PipeReader? PayloadContinuation
 29    {
 992130        get => _payloadContinuation;
 31        set
 20032        {
 20033            _payloadContinuation = Protocol.HasPayloadContinuation || value is null ?
 20034                value : throw new NotSupportedException(
 20035                    $"The '{Protocol}' protocol does not support payload continuation.");
 20036        }
 37    }
 38
 39    /// <summary>Gets the protocol of this frame.</summary>
 40    /// <value>The <see cref="IceRpc.Protocol" /> value of this frame.</value>
 617041    public Protocol Protocol { get; }
 42
 43    private PipeReader? _payloadContinuation;
 44
 45    private Stack<Func<PipeWriter, PipeWriter>>? _payloadWriterInterceptorStack;
 46
 47    /// <summary>Installs a payload writer interceptor in this outgoing frame. This interceptor is executed just
 48    /// before sending <see cref="Payload" />, and is typically used to compress both <see cref="Payload" /> and
 49    /// <see cref="PayloadContinuation" />.</summary>
 50    /// <param name="payloadWriterInterceptor">The payload writer interceptor to install.</param>
 51    /// <returns>This outgoing frame.</returns>
 52    /// <remarks>IceRPC completes the payload writer <see cref="PipeWriter" /> with the <see
 53    /// cref="PipeWriter.Complete(Exception?)" /> method. It never calls <see
 54    /// cref="PipeWriter.CompleteAsync(Exception?)" />. The implementation of <see
 55    /// cref="PipeWriter.Complete(Exception?)" /> should not block.</remarks>
 56    public OutgoingFrame Use(Func<PipeWriter, PipeWriter> payloadWriterInterceptor)
 1357    {
 1358        if (!Protocol.SupportsPayloadWriterInterceptors)
 059        {
 060            throw new NotSupportedException(
 061                $"The '{Protocol}' protocol does not support payload writer interceptors.");
 62        }
 1363        _payloadWriterInterceptorStack ??= new();
 1364        _payloadWriterInterceptorStack.Push(payloadWriterInterceptor);
 1365        return this;
 1366    }
 67
 68    /// <summary>Returns the payload writer to use when sending the payload.</summary>
 69    internal PipeWriter GetPayloadWriter(PipeWriter writer)
 183270    {
 183271        if (_payloadWriterInterceptorStack is not null)
 1372        {
 6573            foreach (Func<PipeWriter, PipeWriter> interceptor in _payloadWriterInterceptorStack)
 1374            {
 1375                writer = interceptor(writer);
 1376            }
 1377        }
 183278        return writer;
 183279    }
 80
 81    /// <summary>Constructs an outgoing frame.</summary>
 82    /// <param name="protocol">The protocol used to send the frame.</param>
 1199883    private protected OutgoingFrame(Protocol protocol) => Protocol = protocol;
 84}