< Summary

Information
Class: IceRpc.Features.SliceFeature
Assembly: IceRpc.Slice
File(s): /home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc.Slice/Features/SliceFeature.cs
Tag: 1321_24790053727
Line coverage
95%
Covered lines: 22
Uncovered lines: 1
Coverable lines: 23
Total lines: 66
Line coverage: 95.6%
Branch coverage
66%
Covered branches: 8
Total branches: 12
Branch coverage: 66.6%
Method coverage
90%
Covered methods: 9
Fully covered methods: 9
Total methods: 10
Method coverage: 90%
Full method coverage: 90%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Default()100%11100%
get_BaseProxy()100%11100%
get_EncodeOptions()100%210%
get_MaxCollectionAllocation()100%11100%
get_MaxSegmentSize()100%11100%
.ctor(...)66.66%1212100%
get_BaseProxy()100%11100%
get_EncodeOptions()100%11100%
get_MaxCollectionAllocation()100%11100%
get_MaxSegmentSize()100%11100%

File(s)

/home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc.Slice/Features/SliceFeature.cs

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3using IceRpc.Slice;
 4
 5namespace IceRpc.Features;
 6
 7/// <summary>Default implementation of <see cref="ISliceFeature" />.</summary>
 8public sealed class SliceFeature : ISliceFeature
 9{
 10    /// <summary>Gets a <see cref="ISliceFeature" /> with default values for all properties.</summary>
 19911    public static ISliceFeature Default { get; } = new DefaultSliceFeature();
 12
 13    /// <inheritdoc/>
 114    public ISliceProxy? BaseProxy { get; }
 15
 16    /// <inheritdoc/>
 017    public SliceEncodeOptions? EncodeOptions { get; }
 18
 19    /// <inheritdoc/>
 120    public int MaxCollectionAllocation { get; }
 21
 22    /// <summary>Gets the maximum size of a Slice payload segment, in bytes. A Slice payload segment corresponds to the
 23    /// encoded arguments of an operation, the encoded return values of an operation, or a portion of a stream of
 24    /// variable-size elements.</summary>
 25    /// <value>The maximum segment size. Defaults to <c>1</c> MB.</value>
 126    public int MaxSegmentSize { get; }
 27
 28    /// <summary>Constructs a Slice feature.</summary>
 29    /// <param name="encodeOptions">The encode options.</param>
 30    /// <param name="maxCollectionAllocation">The maximum collection allocation. Use <c>-1</c> to get the default value:
 31    /// 8 times <paramref name="maxSegmentSize" /> if set, otherwise the value provided by <paramref
 32    /// name="defaultFeature" />.</param>
 33    /// <param name="maxSegmentSize">The maximum segment size. Use <c>-1</c> to get the default value.</param>
 34    /// <param name="baseProxy">The base proxy, used when decoding service addresses into proxies.</param>
 35    /// <param name="defaultFeature">A feature that provides default values for all parameters. <see langword="null" />
 36    /// is equivalent to <see cref="Default" />.</param>
 137    public SliceFeature(
 138        SliceEncodeOptions? encodeOptions = null,
 139        int maxCollectionAllocation = -1,
 140        int maxSegmentSize = -1,
 141        ISliceProxy? baseProxy = null,
 142        ISliceFeature? defaultFeature = null)
 143    {
 144        defaultFeature ??= Default;
 45
 146        EncodeOptions = encodeOptions ?? defaultFeature.EncodeOptions;
 47
 148        MaxCollectionAllocation = maxCollectionAllocation >= 0 ? maxCollectionAllocation :
 149            (maxSegmentSize >= 0 ? 8 * maxSegmentSize : defaultFeature.MaxCollectionAllocation);
 50
 151        MaxSegmentSize = maxSegmentSize >= 0 ? maxSegmentSize : defaultFeature.MaxSegmentSize;
 52
 153        BaseProxy = baseProxy ?? defaultFeature.BaseProxy;
 154    }
 55
 56    private class DefaultSliceFeature : ISliceFeature
 57    {
 14358        public ISliceProxy? BaseProxy => null;
 59
 160        public SliceEncodeOptions? EncodeOptions => null;
 61
 16262        public int MaxCollectionAllocation => 8 * MaxSegmentSize;
 63
 34864        public int MaxSegmentSize => 1024 * 1024;
 65    }
 66}