< Summary

Information
Class: MyNet.Primitives.EnumExtensions
Assembly: MyNet.Primitives
File(s): https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Primitives/Extensions/EnumExtensions.cs
Tag: 323_28699572109
Line coverage
100%
Covered lines: 1
Uncovered lines: 0
Coverable lines: 1
Total lines: 26
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
CountFlags(...)100%11100%

File(s)

https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Primitives/Extensions/EnumExtensions.cs

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="EnumExtensions.cs" company="Stéphane ANDRE">
 3// Copyright (c) Stéphane ANDRE. All rights reserved.
 4// </copyright>
 5// -----------------------------------------------------------------------
 6
 7using System;
 8using System.Linq;
 9
 10#pragma warning disable IDE0130 // Namespace does not match folder structure
 11namespace MyNet.Primitives;
 12#pragma warning restore IDE0130 // Namespace does not match folder structure
 13
 14public static class EnumExtensions
 15{
 16    extension<T>(T options)
 17        where T : Enum
 18    {
 19        /// <summary>
 20        /// Counts how many flags are set on an enum value.
 21        /// </summary>
 22        /// <returns>The number of flags that are set.</returns>
 1223        public int CountFlags() => Enum.GetValues(typeof(T)).Cast<Enum>().Count(options.HasFlag);
 24    }
 25}
 26

Methods/Properties

CountFlags(T)