< Summary

Information
Class: IceRpc.Slice.SliceFeature
Assembly: IceRpc.Slice
File(s): /home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc.Slice/SliceFeature.cs
Tag: 275_13775359185
Line coverage
96%
Covered lines: 30
Uncovered lines: 1
Coverable lines: 31
Total lines: 84
Line coverage: 96.7%
Branch coverage
68%
Covered branches: 11
Total branches: 16
Branch coverage: 68.7%
Method coverage
92%
Covered methods: 13
Total methods: 14
Method coverage: 92.8%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Default()100%11100%
get_Activator()100%11100%
get_BaseProxy()100%11100%
get_EncodeOptions()100%210%
get_MaxCollectionAllocation()100%11100%
get_MaxDepth()100%11100%
get_MaxSegmentSize()100%11100%
.ctor(...)68.75%1616100%
get_Activator()100%11100%
get_BaseProxy()100%11100%
get_EncodeOptions()100%11100%
get_MaxCollectionAllocation()100%11100%
get_MaxDepth()100%11100%
get_MaxSegmentSize()100%11100%

File(s)

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

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3using ZeroC.Slice;
 4
 5namespace IceRpc.Slice;
 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>
 36911    public static ISliceFeature Default { get; } = new DefaultSliceFeature();
 12
 13    /// <inheritdoc/>
 114    public IActivator? Activator { get; }
 15
 16    /// <inheritdoc/>
 117    public IProxy? BaseProxy { get; }
 18
 19    /// <inheritdoc/>
 020    public SliceEncodeOptions? EncodeOptions { get; }
 21
 22    /// <inheritdoc/>
 123    public int MaxCollectionAllocation { get; }
 24
 25    /// <summary>Gets the maximum depth when decoding a class recursively.</summary>
 26    /// <value>The maximum depth. Defaults to <c>100</c>.</value>
 127    public int MaxDepth { get; }
 28
 29    /// <summary>Gets the maximum size of a Slice payload segment, in bytes. A Slice payload segment corresponds to the
 30    /// encoded arguments of an operation, the encoded return values of an operation, or a portion of a stream of
 31    /// variable-size elements.</summary>
 32    /// <value>The maximum segment size. Defaults to <c>1</c> MB.</value>
 133    public int MaxSegmentSize { get; }
 34
 35    /// <summary>Constructs a Slice feature.</summary>
 36    /// <param name="activator">The activator.</param>
 37    /// <param name="encodeOptions">The encode options.</param>
 38    /// <param name="maxCollectionAllocation">The maximum collection allocation. Use <c>-1</c> to get the default value:
 39    /// 8 times <paramref name="maxSegmentSize" /> if set, otherwise the value provided by <paramref
 40    /// name="defaultFeature" />.</param>
 41    /// <param name="maxDepth">The maximum depth. Use <c>-1</c> to get the default value.</param>
 42    /// <param name="maxSegmentSize">The maximum segment size. Use <c>-1</c> to get the default value.</param>
 43    /// <param name="baseProxy">The base proxy, used when decoding service addresses into proxies.</param>
 44    /// <param name="defaultFeature">A feature that provides default values for all parameters. <see langword="null" />
 45    /// is equivalent to <see cref="Default" />.</param>
 146    public SliceFeature(
 147        IActivator? activator = null,
 148        SliceEncodeOptions? encodeOptions = null,
 149        int maxCollectionAllocation = -1,
 150        int maxDepth = -1,
 151        int maxSegmentSize = -1,
 152        IProxy? baseProxy = null,
 153        ISliceFeature? defaultFeature = null)
 154    {
 155        defaultFeature ??= Default;
 56
 157        Activator = activator ?? defaultFeature.Activator;
 158        EncodeOptions = encodeOptions ?? defaultFeature.EncodeOptions;
 59
 160        MaxCollectionAllocation = maxCollectionAllocation >= 0 ? maxCollectionAllocation :
 161            (maxSegmentSize >= 0 ? 8 * maxSegmentSize : defaultFeature.MaxCollectionAllocation);
 62
 163        MaxDepth = maxDepth >= 0 ? maxDepth : defaultFeature.MaxDepth;
 64
 165        MaxSegmentSize = maxSegmentSize >= 0 ? maxSegmentSize : defaultFeature.MaxSegmentSize;
 66
 167        BaseProxy = baseProxy ?? defaultFeature.BaseProxy;
 168    }
 69
 70    private class DefaultSliceFeature : ISliceFeature
 71    {
 20872        public IActivator? Activator => null;
 73
 21374        public IProxy? BaseProxy => null;
 75
 176        public SliceEncodeOptions? EncodeOptions => null;
 77
 23278        public int MaxCollectionAllocation => 8 * MaxSegmentSize;
 79
 21980        public int MaxDepth => 100;
 81
 57582        public int MaxSegmentSize => 1024 * 1024;
 83    }
 84}