< Summary

Information
Class: IceRpc.Protobuf.ProtobufEncodeOptions
Assembly: IceRpc.Protobuf
File(s): /home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc.Protobuf/ProtobufEncodeOptions.cs
Tag: 275_13775359185
Line coverage
100%
Covered lines: 15
Uncovered lines: 0
Coverable lines: 15
Total lines: 47
Line coverage: 100%
Branch coverage
50%
Covered branches: 1
Total branches: 2
Branch coverage: 50%
Method coverage
100%
Covered methods: 4
Total methods: 4
Method coverage: 100%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Default()100%11100%
get_PipeOptions()100%11100%
get_StreamFlushThreshold()100%11100%
.ctor(...)50%22100%

File(s)

/home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc.Protobuf/ProtobufEncodeOptions.cs

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3using System.Buffers;
 4using System.IO.Pipelines;
 5
 6namespace IceRpc.Protobuf;
 7
 8/// <summary>Represents a property bag used to configure the encoding of payloads.</summary>
 9public sealed class ProtobufEncodeOptions
 10{
 11    /// <summary>Gets the default instance of <see cref="ProtobufEncodeOptions" />.</summary>
 5712    public static ProtobufEncodeOptions Default { get; } = new();
 13
 14    /// <summary>Gets the pipe options that the IceRPC + Protobuf uses when creating pipes. The IceRPC + Protobuf
 15    /// integration creates a pipe when encoding a request or response payload, and when encoding an async enumerable
 16    /// into a <see cref="PipeReader" />.</summary>
 5617    public PipeOptions PipeOptions { get; }
 18
 19    /// <summary>Gets the stream flush threshold. When encoding a Protobuf stream (async enumerable), the
 20    /// IceRpc + Protobuf encodes the values provided by the source async enumerable into a pipe writer. The
 21    /// IceRpc + Protobuf integration flushes this pipe writer when no new value is available synchronously, or when
 22    /// it has written StreamFlushThreshold bytes to this pipe writer.</summary>
 2623    public int StreamFlushThreshold { get; }
 24
 25    /// <summary>Constructs a new instance.</summary>
 26    /// <param name="pool">The pool parameter for the constructor of <see cref="System.IO.Pipelines.PipeOptions" />.
 27    /// </param>
 28    /// <param name="minimumSegmentSize">The minimum segment size for the constructor of
 29    /// <see cref="System.IO.Pipelines.PipeOptions" />.</param>
 30    /// <param name="streamFlushThreshold">The value of <see cref="StreamFlushThreshold" />. The default value (-1) is
 31    /// equivalent to 16 KB.</param>
 132    public ProtobufEncodeOptions(
 133        MemoryPool<byte>? pool = default,
 134        int minimumSegmentSize = -1,
 135        int streamFlushThreshold = -1)
 136    {
 37        // We keep the default readerScheduler (ThreadPool) because pipes created from these PipeOptions are never
 38        // ReadAsync concurrently with a FlushAsync/Complete on the pipe writer. The writerScheduler does not matter
 39        // since FlushAsync never blocks.
 140        PipeOptions = new(
 141            pool: pool,
 142            minimumSegmentSize: minimumSegmentSize,
 143            pauseWriterThreshold: 0,
 144            useSynchronizationContext: false);
 145        StreamFlushThreshold = streamFlushThreshold == -1 ? 16 * 1024 : streamFlushThreshold;
 146    }
 47}