< Summary

Information
Class: IceRpc.Internal.FacetExtensions
Assembly: IceRpc
File(s): /home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc/Internal/FacetExtensions.cs
Tag: 1321_24790053727
Line coverage
86%
Covered lines: 20
Uncovered lines: 3
Coverable lines: 23
Total lines: 44
Line coverage: 86.9%
Branch coverage
70%
Covered branches: 7
Total branches: 10
Branch coverage: 70%
Method coverage
100%
Covered methods: 5
Fully covered methods: 3
Total methods: 5
Method coverage: 100%
Full method coverage: 60%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
CheckFacetCount(...)50%2260%
EncodeFragmentAsFacet(...)100%22100%
DecodeFacet(...)100%11100%
ToFragment(...)75%4483.33%
ToFacet(...)50%22100%

File(s)

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

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3using IceRpc.Ice.Codec;
 4
 5namespace IceRpc.Internal;
 6
 7/// <summary>Provides extension methods for Ice facets.</summary>
 8internal static class FacetExtensions
 9{
 10    internal static void CheckFacetCount(this IList<string> facet)
 138911    {
 138912        if (facet.Count > 1)
 013        {
 014            throw new InvalidDataException("Received a Facet with too many sequence elements.");
 15        }
 138916    }
 17
 18    internal static void EncodeFragmentAsFacet(this ref IceEncoder encoder, string fragment)
 5119    {
 5120        if (fragment.Length == 0)
 5021        {
 5022            encoder.EncodeSize(0);
 5023        }
 24        else
 125        {
 126            encoder.EncodeSize(1);
 127            encoder.EncodeString(Uri.UnescapeDataString(fragment));
 128        }
 5129    }
 30
 31    internal static string[] DecodeFacet(this ref IceDecoder decoder) =>
 4532        decoder.DecodeSequence((ref IceDecoder decoder) => decoder.DecodeString());
 33
 34    internal static string ToFragment(this IList<string> facet) =>
 143135        facet.Count switch
 143136        {
 143037            0 => "",
 138            1 => Uri.EscapeDataString(facet[0]),
 039            _ => throw new InvalidDataException("Received a Facet with too many sequence elements.")
 143140        };
 41
 42    internal static IList<string> ToFacet(this string fragment) =>
 140943        fragment.Length == 0 ? [] : new List<string> { Uri.UnescapeDataString(fragment) };
 44}