< Summary - Code Coverage

Information
Class: Plainquire.Filter.ParameterExtensions
Assembly: Plainquire.Filter
File(s): /home/runner/work/plainquire/plainquire/Plainquire.Filter/Plainquire.Filter/Extensions/ParameterExtensions.cs
Tag: 64_13932151703
Line coverage
100%
Covered lines: 7
Uncovered lines: 0
Coverable lines: 7
Total lines: 46
Line coverage: 100%
Branch coverage
100%
Covered branches: 8
Total branches: 8
Branch coverage: 100%
Method coverage
100%
Covered methods: 3
Total methods: 3
Method coverage: 100%

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
GetFilterableProperties(...)100%11100%
GetFilterParameterName(...)100%66100%
IsParameterFilterable(...)100%22100%

File(s)

/home/runner/work/plainquire/plainquire/Plainquire.Filter/Plainquire.Filter/Extensions/ParameterExtensions.cs

#LineLine coverage
 1using Plainquire.Filter.Abstractions;
 2using System;
 3using System.Collections.Generic;
 4using System.Linq;
 5using System.Reflection;
 6
 7namespace Plainquire.Filter;
 8
 9/// <summary>
 10/// Extension methods used to handle MVC controller action parameters
 11/// </summary>
 12public static class ParameterExtensions
 13{
 14    /// <summary>
 15    /// Gets all properties filterable by <see cref="EntityFilter"/>.
 16    /// </summary>
 17    /// <param name="type">The type.</param>
 18    /// <autogeneratedoc />
 19    public static IEnumerable<PropertyInfo> GetFilterableProperties(this Type type)
 1420        => type.GetProperties().Where(x => x.PropertyType.IsFilterableProperty() && x.IsParameterFilterable());
 21
 22    /// <summary>
 23    /// Gets the (MVC controller action) parameter name of the filter.
 24    /// </summary>
 25    /// <param name="member">The property to get the name for.</param>
 26    /// <param name="prefix">A prefix to use.</param>
 27    /// <autogeneratedoc />
 28    public static string GetFilterParameterName(this MemberInfo member, string? prefix = null)
 29    {
 4330        prefix ??= member.ReflectedType.ExpandTypeName();
 4331        var filterAttribute = member.GetCustomAttribute<FilterAttribute>();
 4332        var name = filterAttribute?.Name ?? member.Name;
 4333        return $"{prefix}{name}".LowercaseFirstChar();
 34    }
 35
 36    /// <summary>
 37    /// Determines whether this parameter is visible as (MVC controller action) parameter.
 38    /// </summary>
 39    /// <param name="member">The member.</param>
 40    /// <autogeneratedoc />
 41    private static bool IsParameterFilterable(this MemberInfo member)
 42    {
 5043        var filterAttribute = member.GetCustomAttribute<FilterAttribute>();
 5044        return filterAttribute?.Filterable != false;
 45    }
 46}