< Summary

Information
Class: IceRpc.Protobuf.ProtobufFeature
Assembly: IceRpc.Protobuf
File(s): /home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc.Protobuf/ProtobufFeature.cs
Tag: 275_13775359185
Line coverage
21%
Covered lines: 3
Uncovered lines: 11
Coverable lines: 14
Total lines: 39
Line coverage: 21.4%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage
50%
Covered methods: 3
Total methods: 6
Method coverage: 50%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Default()100%11100%
get_MaxMessageLength()100%210%
get_EncodeOptions()100%210%
.ctor(...)0%4260%
get_MaxMessageLength()100%11100%
get_EncodeOptions()100%11100%

File(s)

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

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3namespace IceRpc.Protobuf;
 4
 5/// <summary>Default implementation of <see cref="IProtobufFeature" />.</summary>
 6public sealed class ProtobufFeature : IProtobufFeature
 7{
 8    /// <summary>Gets a <see cref="IProtobufFeature" /> with default values for all properties.</summary>
 439    public static IProtobufFeature Default { get; } = new DefaultProtobufFeature();
 10
 11    /// <summary>Gets the maximum length of an encoded Protobuf message, in bytes.</summary>
 12    /// <value>The maximum length of a Protobuf message. Defaults to <c>1</c> MB.</value>
 013    public int MaxMessageLength { get; }
 14
 15    /// <inheritdoc/>
 016    public ProtobufEncodeOptions? EncodeOptions { get; }
 17
 18    /// <summary>Constructs a Protobuf feature.</summary>
 19    /// <param name="maxMessageLength">The maximum message length. Use <c>-1</c> to get the default value.</param>
 20    /// <param name="encodeOptions">The encode options.</param>
 21    /// <param name="defaultFeature">A feature that provides default values for all parameters. <see langword="null" />
 22    /// is equivalent to <see cref="Default" />.</param>
 023    public ProtobufFeature(
 024        int maxMessageLength = -1,
 025        ProtobufEncodeOptions? encodeOptions = null,
 026        IProtobufFeature? defaultFeature = null)
 027    {
 028        defaultFeature ??= Default;
 029        MaxMessageLength = maxMessageLength >= 0 ? maxMessageLength : defaultFeature.MaxMessageLength;
 030        EncodeOptions = encodeOptions ?? defaultFeature.EncodeOptions;
 031    }
 32
 33    private class DefaultProtobufFeature : IProtobufFeature
 34    {
 4235        public int MaxMessageLength => 1024 * 1024;
 36
 1937        public ProtobufEncodeOptions? EncodeOptions => null;
 38    }
 39}