< Summary

Information
Class: IceRpc.Slice.SliceEncodeOptions
Assembly: IceRpc.Slice
File(s): /home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc.Slice/SliceEncodeOptions.cs
Tag: 275_13775359185
Line coverage
100%
Covered lines: 15
Uncovered lines: 0
Coverable lines: 15
Total lines: 48
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.Slice/SliceEncodeOptions.cs

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3using System.Buffers;
 4using System.IO.Pipelines;
 5
 6namespace IceRpc.Slice;
 7
 8/// <summary>Represents a property bag used to configure the encoding of payloads.</summary>
 9public sealed class SliceEncodeOptions
 10{
 11    /// <summary>Gets the default instance of <see cref="SliceEncodeOptions" />.</summary>
 24012    public static SliceEncodeOptions Default { get; } = new();
 13
 14    /// <summary>Gets the pipe options that the IceRPC + Slice integration uses when creating pipes. The IceRPC + Slice
 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>
 23717    public PipeOptions PipeOptions { get; }
 18
 19    /// <summary>Gets the stream flush threshold. When encoding a Slice stream (async enumerable), the IceRPC + Slice
 20    /// integration encodes the values provided by the source async enumerable into a pipe writer. The IceRPC + Slice
 21    /// integration flushes this pipe writer when no new value is available synchronously, or when it has written
 22    /// <c>StreamFlushThreshold</c> bytes to this pipe writer.</summary>
 2523    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>
 332    public SliceEncodeOptions(
 333        MemoryPool<byte>? pool = default,
 334        int minimumSegmentSize = -1,
 335        int streamFlushThreshold = -1)
 336    {
 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.
 340        PipeOptions = new(
 341            pool: pool,
 342            minimumSegmentSize: minimumSegmentSize,
 343            pauseWriterThreshold: 0,
 344            useSynchronizationContext: false);
 45
 346        StreamFlushThreshold = streamFlushThreshold == -1 ? 16 * 1024 : streamFlushThreshold;
 347    }
 48}