< Summary

Information
Class: Ice.TypeExtensions
Assembly: Ice
File(s): /home/runner/work/ice/ice/csharp/src/Ice/TypeExtensions.cs
Tag: 71_18251537082
Line coverage
100%
Covered lines: 4
Uncovered lines: 0
Coverable lines: 4
Total lines: 33
Line coverage: 100%
Branch coverage
100%
Covered branches: 8
Total branches: 8
Branch coverage: 100%
Method coverage
100%
Covered methods: 2
Total methods: 2
Method coverage: 100%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
GetSliceTypeId(...)100%44100%
GetCompactSliceTypeId(...)100%44100%

File(s)

/home/runner/work/ice/ice/csharp/src/Ice/TypeExtensions.cs

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3#nullable enable
 4
 5namespace Ice;
 6
 7/// <summary>Provides extension methods for <see cref="Type" />.</summary>
 8// Corresponds to IceRPC's ZeroC.Slice.TypeExtensions.
 9public static class TypeExtensions
 10{
 11    /// <summary>Retrieves the Slice type ID from a type with the attribute <see cref="SliceTypeIdAttribute"/>.
 12    /// </summary>
 13    /// <param name="type">The type of a class or interface generated by the Slice compiler.</param>
 14    /// <returns>The Slice type ID, or <see langword="null" /> if <paramref name="type" /> does not carry the
 15    /// <see cref="SliceTypeIdAttribute"/> attribute.
 16    /// </returns>
 17    public static string? GetSliceTypeId(this Type type)
 18    {
 119        object[] attributes = type.GetCustomAttributes(typeof(SliceTypeIdAttribute), false);
 120        return attributes.Length == 1 && attributes[0] is SliceTypeIdAttribute typeId ? typeId.Value : null;
 21    }
 22
 23    /// <summary>Retrieves the compact Slice type ID from a type with the attribute
 24    /// <see cref="CompactSliceTypeIdAttribute"/>.</summary>
 25    /// <param name="type">The type of a class generated by the Slice compiler.</param>
 26    /// <returns>The compact Slice type ID, or <see langword="null" /> if <paramref name="type" /> does not carry the
 27    /// <see cref="CompactSliceTypeIdAttribute"/> attribute.</returns>
 28    public static int? GetCompactSliceTypeId(this Type type)
 29    {
 130        object[] attributes = type.GetCustomAttributes(typeof(CompactSliceTypeIdAttribute), false);
 131        return attributes.Length == 1 && attributes[0] is CompactSliceTypeIdAttribute typeId ? typeId.Value : null;
 32    }
 33}