< Summary

Information
Class: ZeroC.Slice.TypeExtensions
Assembly: ZeroC.Slice
File(s): /home/runner/work/icerpc-csharp/icerpc-csharp/src/ZeroC.Slice/TypeExtensions.cs
Tag: 275_13775359185
Line coverage
100%
Covered lines: 8
Uncovered lines: 0
Coverable lines: 8
Total lines: 30
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/icerpc-csharp/icerpc-csharp/src/ZeroC.Slice/TypeExtensions.cs

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3namespace ZeroC.Slice;
 4
 5/// <summary>Provides extension methods for <see cref="Type" />.</summary>
 6public static class TypeExtensions
 7{
 8    /// <summary>Retrieves the Slice type ID from a type with the attribute <see cref="SliceTypeIdAttribute"/>.
 9    /// </summary>
 10    /// <param name="type">The type of a class or interface generated by the Slice compiler.</param>
 11    /// <returns>The Slice type ID, or <see langword="null" /> if <paramref name="type" /> does not carry the
 12    /// <see cref="SliceTypeIdAttribute"/> attribute.
 13    /// </returns>
 14    public static string? GetSliceTypeId(this Type type)
 210115    {
 210116        object[] attributes = type.GetCustomAttributes(typeof(SliceTypeIdAttribute), false);
 210117        return attributes.Length == 1 && attributes[0] is SliceTypeIdAttribute typeId ? typeId.Value : null;
 210118    }
 19
 20    /// <summary>Retrieves the compact Slice type ID from a type with the attribute
 21    /// <see cref="CompactSliceTypeIdAttribute"/>.</summary>
 22    /// <param name="type">The type of a class generated by the Slice compiler.</param>
 23    /// <returns>The compact Slice type ID, or <see langword="null" /> if <paramref name="type" /> does not carry the
 24    /// <see cref="CompactSliceTypeIdAttribute"/> attribute.</returns>
 25    public static int? GetCompactSliceTypeId(this Type type)
 7526    {
 7527        object[] attributes = type.GetCustomAttributes(typeof(CompactSliceTypeIdAttribute), false);
 7528        return attributes.Length == 1 && attributes[0] is CompactSliceTypeIdAttribute typeId ? typeId.Value : null;
 7529    }
 30}