< Summary

Information
Class: IceRpc.Features.ProtobufFeature
Assembly: IceRpc.Protobuf
File(s): /home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc.Protobuf/Features/ProtobufFeature.cs
Tag: 1321_24790053727
Line coverage
21%
Covered lines: 3
Uncovered lines: 11
Coverable lines: 14
Total lines: 41
Line coverage: 21.4%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage
50%
Covered methods: 3
Fully covered methods: 3
Total methods: 6
Method coverage: 50%
Full 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/Features/ProtobufFeature.cs

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3using IceRpc.Protobuf;
 4
 5namespace IceRpc.Features;
 6
 7/// <summary>Default implementation of <see cref="IProtobufFeature" />.</summary>
 8public sealed class ProtobufFeature : IProtobufFeature
 9{
 10    /// <summary>Gets a <see cref="IProtobufFeature" /> with default values for all properties.</summary>
 4311    public static IProtobufFeature Default { get; } = new DefaultProtobufFeature();
 12
 13    /// <summary>Gets the maximum length of an encoded Protobuf message, in bytes.</summary>
 14    /// <value>The maximum length of a Protobuf message. Defaults to <c>1</c> MB.</value>
 015    public int MaxMessageLength { get; }
 16
 17    /// <inheritdoc/>
 018    public ProtobufEncodeOptions? EncodeOptions { get; }
 19
 20    /// <summary>Constructs a Protobuf feature.</summary>
 21    /// <param name="maxMessageLength">The maximum message length. Use <c>-1</c> to get the default value.</param>
 22    /// <param name="encodeOptions">The encode options.</param>
 23    /// <param name="defaultFeature">A feature that provides default values for all parameters. <see langword="null" />
 24    /// is equivalent to <see cref="Default" />.</param>
 025    public ProtobufFeature(
 026        int maxMessageLength = -1,
 027        ProtobufEncodeOptions? encodeOptions = null,
 028        IProtobufFeature? defaultFeature = null)
 029    {
 030        defaultFeature ??= Default;
 031        MaxMessageLength = maxMessageLength >= 0 ? maxMessageLength : defaultFeature.MaxMessageLength;
 032        EncodeOptions = encodeOptions ?? defaultFeature.EncodeOptions;
 033    }
 34
 35    private class DefaultProtobufFeature : IProtobufFeature
 36    {
 4237        public int MaxMessageLength => 1024 * 1024;
 38
 1939        public ProtobufEncodeOptions? EncodeOptions => null;
 40    }
 41}