< Summary

Information
Class: IceRpc.Internal.IceProtocol
Assembly: IceRpc
File(s): /home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc/Internal/IceProtocol.cs
Tag: 1321_24790053727
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>
 563411    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)
 24819    {
 24820        string workingPath = uriPath[1..]; // removes leading /.
 24821        int firstSlash = workingPath.IndexOf('/', StringComparison.Ordinal);
 22
 23        // We can have at most one slash in the working path.
 24824        if (firstSlash != -1 && firstSlash != workingPath.LastIndexOf('/'))
 225        {
 226            throw new FormatException($"Too many slashes in path '{uriPath}'.");
 27        }
 24628    }
 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)
 8133    {
 31434        foreach ((string name, string value) in serviceAddressParams)
 3735        {
 3736            if (name == "adapter-id")
 3637            {
 3638                if (value.Length == 0)
 239                {
 240                    throw new FormatException("The value of the adapter-id parameter cannot be empty.");
 41                }
 3442            }
 43            else
 144            {
 145                throw new FormatException($"Invalid service address parameter name '{name}'.");
 46            }
 3447        }
 7848    }
 49
 50    private IceProtocol()
 1051        : base(
 1052            name: "ice",
 1053            defaultPort: 4061,
 1054            hasFields: false,
 1055            hasFragment: true,
 1056            hasPayloadContinuation: false,
 1057            supportsPayloadWriterInterceptors: false,
 1058            byteValue: 1)
 1059    {
 1060    }
 61}