< Summary

Information
Class: DotNetApiDiff.Models.Configuration.FilterConfiguration
Assembly: DotNetApiDiff
File(s): /home/runner/work/dotnet-api-diff/dotnet-api-diff/src/DotNetApiDiff/Models/Configuration/FilterConfiguration.cs
Line coverage
100%
Covered lines: 26
Uncovered lines: 0
Coverable lines: 26
Total lines: 81
Line coverage: 100%
Branch coverage
100%
Covered branches: 8
Total branches: 8
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_IncludeNamespaces()100%11100%
get_ExcludeNamespaces()100%11100%
get_IncludeTypes()100%11100%
get_ExcludeTypes()100%11100%
get_IncludeInternals()100%11100%
get_IncludeCompilerGenerated()100%11100%
CreateDefault()100%11100%
IsValid()100%88100%

File(s)

/home/runner/work/dotnet-api-diff/dotnet-api-diff/src/DotNetApiDiff/Models/Configuration/FilterConfiguration.cs

#LineLine coverage
 1// Copyright DotNet API Diff Project Contributors - SPDX Identifier: MIT
 2using System.Text.Json.Serialization;
 3
 4namespace DotNetApiDiff.Models.Configuration;
 5
 6/// <summary>
 7/// Configuration for filtering types and namespaces during API comparison
 8/// </summary>
 9public class FilterConfiguration
 10{
 11    /// <summary>
 12    /// List of namespaces to include in the comparison (if empty, all namespaces are included)
 13    /// </summary>
 14    [JsonPropertyName("includeNamespaces")]
 33115    public List<string> IncludeNamespaces { get; set; } = new List<string>();
 16
 17    /// <summary>
 18    /// List of namespaces to exclude from the comparison
 19    /// </summary>
 20    [JsonPropertyName("excludeNamespaces")]
 31721    public List<string> ExcludeNamespaces { get; set; } = new List<string>();
 22
 23    /// <summary>
 24    /// List of type name patterns to include in the comparison (if empty, all types are included)
 25    /// </summary>
 26    [JsonPropertyName("includeTypes")]
 31727    public List<string> IncludeTypes { get; set; } = new List<string>();
 28
 29    /// <summary>
 30    /// List of type name patterns to exclude from the comparison
 31    /// </summary>
 32    [JsonPropertyName("excludeTypes")]
 31633    public List<string> ExcludeTypes { get; set; } = new List<string>();
 34
 35    /// <summary>
 36    /// Whether to include internal types in the comparison
 37    /// </summary>
 38    [JsonPropertyName("includeInternals")]
 29339    public bool IncludeInternals { get; set; } = false;
 40
 41    /// <summary>
 42    /// Whether to include compiler-generated types in the comparison
 43    /// </summary>
 44    [JsonPropertyName("includeCompilerGenerated")]
 28845    public bool IncludeCompilerGenerated { get; set; } = false;
 46
 47    /// <summary>
 48    /// Creates a default filter configuration
 49    /// </summary>
 50    /// <returns>A default filter configuration</returns>
 51    public static FilterConfiguration CreateDefault()
 7052    {
 7053        return new FilterConfiguration
 7054        {
 7055            IncludeNamespaces = new List<string>(),
 7056            ExcludeNamespaces = new List<string>(),
 7057            IncludeTypes = new List<string>(),
 7058            ExcludeTypes = new List<string>(),
 7059            IncludeInternals = false,
 7060            IncludeCompilerGenerated = false
 7061        };
 7062    }
 63
 64    /// <summary>
 65    /// Validates the filter configuration
 66    /// </summary>
 67    /// <returns>True if valid, false otherwise</returns>
 68    public bool IsValid()
 3269    {
 70        // All patterns should be non-empty
 3271        if (IncludeNamespaces.Any(string.IsNullOrWhiteSpace) ||
 3272            ExcludeNamespaces.Any(string.IsNullOrWhiteSpace) ||
 3273            IncludeTypes.Any(string.IsNullOrWhiteSpace) ||
 3274            ExcludeTypes.Any(string.IsNullOrWhiteSpace))
 475        {
 476            return false;
 77        }
 78
 2879        return true;
 3280    }
 81}