< Summary

Information
Class: IceRpc.Internal.IceProtocol
Assembly: IceRpc
File(s): /home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc/Internal/IceProtocol.cs
Tag: 1856_27024993493
Line coverage
100%
Covered lines: 31
Uncovered lines: 0
Coverable lines: 31
Total lines: 61
Line coverage: 100%
Branch coverage
100%
Covered branches: 10
Total branches: 10
Branch coverage: 100%
Method coverage
100%
Covered methods: 4
Fully covered methods: 4
Total methods: 4
Method coverage: 100%
Full method coverage: 100%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Instance()100%11100%
CheckPath(...)100%44100%
CheckServiceAddressParams(...)100%66100%
.ctor()100%11100%

File(s)

/home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc/Internal/IceProtocol.cs

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3using System.Collections.Immutable;
 4
 5namespace IceRpc.Internal;
 6
 7/// <summary>The Ice protocol class.</summary>
 8internal sealed class IceProtocol : Protocol
 9{
 10    /// <summary>Gets the Ice protocol singleton.</summary>
 574211    internal static IceProtocol Instance { get; } = new();
 12
 13    /// <summary>Checks if this absolute path is well-formed.</summary>
 14    /// <remarks>This check is more lenient than the check performed when encoding a service address with Ice because
 15    /// we want the default path (`/`) to be a valid path for all protocols. Sending a request to a null/empty identity
 16    /// is in itself ok and can succeed with an IceRPC server. With an Ice server, it will result in a dispatch
 17    /// exception with a <see cref="StatusCode.NotFound" /> status code.</remarks>
 18    internal override void CheckPath(string uriPath)
 26319    {
 26320        string workingPath = uriPath[1..]; // removes leading /.
 26321        int firstSlash = workingPath.IndexOf('/', StringComparison.Ordinal);
 22
 23        // We can have at most one slash in the working path.
 26324        if (firstSlash != -1 && firstSlash != workingPath.LastIndexOf('/'))
 225        {
 226            throw new FormatException($"Too many slashes in path '{uriPath}'.");
 27        }
 26128    }
 29
 30    /// <summary>Checks if the service address parameters are valid. The only valid parameter is adapter-id with a
 31    /// non-empty value.</summary>
 32    internal override void CheckServiceAddressParams(ImmutableDictionary<string, string> serviceAddressParams)
 9333    {
 37634        foreach ((string name, string value) in serviceAddressParams)
 5035        {
 5036            if (name == "adapter-id")
 4937            {
 4938                if (value.Length == 0)
 239                {
 240                    throw new FormatException("The value of the adapter-id parameter cannot be empty.");
 41                }
 4742            }
 43            else
 144            {
 145                throw new FormatException($"Invalid service address parameter name '{name}'.");
 46            }
 4747        }
 9048    }
 49
 50    private IceProtocol()
 1451        : base(
 1452            name: "ice",
 1453            defaultPort: 4061,
 1454            hasFields: false,
 1455            hasFragment: true,
 1456            hasPayloadContinuation: false,
 1457            supportsPayloadWriterInterceptors: false,
 1458            byteValue: 1)
 1459    {
 1460    }
 61}