< Summary

Information
Class: ArturRios.Extensions.EnumExtensions
Assembly: ArturRios.Extensions
File(s): D:\Repositories\dotnet-extensions\src\EnumExtensions.cs
Line coverage
100%
Covered lines: 7
Uncovered lines: 0
Coverable lines: 7
Total lines: 24
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
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
GetDescription(...)100%44100%

File(s)

D:\Repositories\dotnet-extensions\src\EnumExtensions.cs

#LineLine coverage
 1using System.ComponentModel;
 2
 3namespace ArturRios.Extensions;
 4
 5/// <summary>
 6///     Provides extension methods for enums, such as retrieving the DescriptionAttribute value.
 7/// </summary>
 8public static class EnumExtensions
 9{
 10    /// <summary>
 11    ///     Gets the value of the <see cref="DescriptionAttribute" /> for the enum value, if present.
 12    /// </summary>
 13    /// <param name="value">The enum value.</param>
 14    /// <returns>The description text, or null if not found.</returns>
 15    public static string? GetDescription(this Enum value)
 316    {
 317        var field = value.GetType().GetField(value.ToString());
 318        var attribute = field?.GetCustomAttributes(typeof(DescriptionAttribute), false)
 319            .Cast<DescriptionAttribute>()
 320            .FirstOrDefault();
 21
 322        return attribute?.Description;
 323    }
 24}

Methods/Properties

GetDescription(System.Enum)