< Summary

Information
Class: IceRpc.Features.IceFeature
Assembly: IceRpc.Ice
File(s): /home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc.Ice/Features/IceFeature.cs
Tag: 1321_24790053727
Line coverage
96%
Covered lines: 30
Uncovered lines: 1
Coverable lines: 31
Total lines: 87
Line coverage: 96.7%
Branch coverage
68%
Covered branches: 11
Total branches: 16
Branch coverage: 68.7%
Method coverage
92%
Covered methods: 13
Fully covered methods: 13
Total methods: 14
Method coverage: 92.8%
Full 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_MaxPayloadSize()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_MaxPayloadSize()100%11100%

File(s)

/home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc.Ice/Features/IceFeature.cs

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3using IceRpc.Ice;
 4using IceRpc.Ice.Codec;
 5
 6namespace IceRpc.Features;
 7
 8/// <summary>Default implementation of <see cref="IIceFeature" />.</summary>
 9public sealed class IceFeature : IIceFeature
 10{
 11    /// <summary>Gets a <see cref="IIceFeature" /> with default values for all properties.</summary>
 25912    public static IIceFeature Default { get; } = new DefaultIceFeature();
 13
 14    /// <inheritdoc/>
 115    public IActivator? Activator { get; }
 16
 17    /// <inheritdoc/>
 118    public IIceProxy? BaseProxy { get; }
 19
 20    /// <inheritdoc/>
 021    public IceEncodeOptions? EncodeOptions { get; }
 22
 23    /// <inheritdoc/>
 124    public int MaxCollectionAllocation { get; }
 25
 26    /// <summary>Gets the maximum depth when decoding a class recursively.</summary>
 27    /// <value>The maximum depth. Defaults to <c>100</c>.</value>
 128    public int MaxDepth { get; }
 29
 30    /// <summary>Gets the maximum size of an Ice-encoded payload, in bytes. An Ice-encoded payload corresponds to the
 31    /// encoded arguments of an operation, or the encoded return values of an operation.</summary>
 32    /// <value>The maximum size of an Ice-encoded payload, in bytes. Defaults to <c>1</c> MB.</value>
 33    /// <remarks>The payload size does not include the size of any header for this payload, such as the encapsulation
 34    /// header with the ice protocol.</remarks>
 135    public int MaxPayloadSize { get; }
 36
 37    /// <summary>Constructs an Ice feature.</summary>
 38    /// <param name="activator">The activator.</param>
 39    /// <param name="encodeOptions">The encode options.</param>
 40    /// <param name="maxCollectionAllocation">The maximum collection allocation. Use <c>-1</c> to get the default value:
 41    /// 8 times <paramref name="maxPayloadSize" /> if set, otherwise the value provided by
 42    /// <paramref name="defaultFeature" />.</param>
 43    /// <param name="maxDepth">The maximum depth. Use <c>-1</c> to get the default value.</param>
 44    /// <param name="maxPayloadSize">The maximum size of an Ice-encoded payload, in bytes. Use <c>-1</c> to get the
 45    /// default value.</param>
 46    /// <param name="baseProxy">The base proxy, used when decoding service addresses into proxies.</param>
 47    /// <param name="defaultFeature">A feature that provides default values for all parameters. <see langword="null" />
 48    /// is equivalent to <see cref="Default" />.</param>
 149    public IceFeature(
 150        IActivator? activator = null,
 151        IceEncodeOptions? encodeOptions = null,
 152        int maxCollectionAllocation = -1,
 153        int maxDepth = -1,
 154        int maxPayloadSize = -1,
 155        IIceProxy? baseProxy = null,
 156        IIceFeature? defaultFeature = null)
 157    {
 158        defaultFeature ??= Default;
 59
 160        Activator = activator ?? defaultFeature.Activator;
 161        EncodeOptions = encodeOptions ?? defaultFeature.EncodeOptions;
 62
 163        MaxCollectionAllocation = maxCollectionAllocation >= 0 ? maxCollectionAllocation :
 164            (maxPayloadSize >= 0 ? 8 * maxPayloadSize : defaultFeature.MaxCollectionAllocation);
 65
 166        MaxDepth = maxDepth >= 0 ? maxDepth : defaultFeature.MaxDepth;
 67
 168        MaxPayloadSize = maxPayloadSize >= 0 ? maxPayloadSize : defaultFeature.MaxPayloadSize;
 69
 170        BaseProxy = baseProxy ?? defaultFeature.BaseProxy;
 171    }
 72
 73    private class DefaultIceFeature : IIceFeature
 74    {
 18775        public IActivator? Activator => null;
 76
 12877        public IIceProxy? BaseProxy => null;
 78
 179        public IceEncodeOptions? EncodeOptions => null;
 80
 12981        public int MaxCollectionAllocation => 8 * MaxPayloadSize;
 82
 12983        public int MaxDepth => 100;
 84
 37085        public int MaxPayloadSize => 1024 * 1024;
 86    }
 87}