< Summary

Information
Class: IceRpc.TypeExtensions
Assembly: IceRpc
File(s): /home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc/TypeExtensions.cs
Tag: 1321_24790053727
Line coverage
57%
Covered lines: 8
Uncovered lines: 6
Coverable lines: 14
Total lines: 35
Line coverage: 57.1%
Branch coverage
50%
Covered branches: 3
Total branches: 6
Branch coverage: 50%
Method coverage
100%
Covered methods: 1
Fully covered methods: 0
Total methods: 1
Method coverage: 100%
Full method coverage: 0%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
GetDefaultServicePath(...)50%9657.14%

File(s)

/home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc/TypeExtensions.cs

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3namespace IceRpc;
 4
 5/// <summary>Provides extension methods for <see cref="Type" />.</summary>
 6public static class TypeExtensions
 7{
 8    /// <summary>Retrieves the default service path with the attribute <see cref="DefaultServicePathAttribute"/>.
 9    /// </summary>
 10    /// <param name="type">The type of an interface.</param>
 11    /// <returns>The default service path.</returns>
 12    /// <exception cref="ArgumentException">Thrown if <paramref name="type" /> is not an interface, or if
 13    /// it does not have a <see cref="DefaultServicePathAttribute" /> attribute.</exception>
 14    public static string GetDefaultServicePath(this Type type)
 1115    {
 1116        if (type.IsInterface)
 1117        {
 1118            object[] attributes = type.GetCustomAttributes(typeof(DefaultServicePathAttribute), false);
 1119            if (attributes.Length == 1 && attributes[0] is DefaultServicePathAttribute defaultServicePath)
 1120            {
 1121                return defaultServicePath.Value;
 22            }
 23            else
 024            {
 025                throw new ArgumentException(
 026                    $"Interface '{type}' does not have a {nameof(DefaultServicePathAttribute)} attribute.",
 027                    nameof(type));
 28            }
 29        }
 30        else
 031        {
 032            throw new ArgumentException($"The type '{type}' is not an interface.", nameof(type));
 33        }
 1134    }
 35}