< Summary

Information
Class: NexusLabs.Needlr.Generators.DiagnosticOptions
Assembly: NexusLabs.Needlr.Generators
File(s): /home/runner/work/needlr/needlr/src/NexusLabs.Needlr.Generators/DiagnosticOptions.cs
Line coverage
100%
Covered lines: 25
Uncovered lines: 0
Coverable lines: 25
Total lines: 74
Line coverage: 100%
Branch coverage
87%
Covered branches: 14
Total branches: 16
Branch coverage: 87.5%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Enabled()100%11100%
get_OutputPath()100%11100%
get_TypeFilter()100%11100%
.ctor(...)50%44100%
Parse(...)100%22100%
ParseBool(...)100%44100%
ParseFilter(...)100%66100%

File(s)

/home/runner/work/needlr/needlr/src/NexusLabs.Needlr.Generators/DiagnosticOptions.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3
 4namespace NexusLabs.Needlr.Generators;
 5
 6/// <summary>
 7/// Configuration options for diagnostic file generation.
 8/// </summary>
 9internal sealed class DiagnosticOptions
 10{
 11    /// <summary>
 12    /// Whether diagnostics are enabled.
 13    /// </summary>
 44114    public bool Enabled { get; }
 15
 16    /// <summary>
 17    /// Directory path where diagnostic files will be written.
 18    /// </summary>
 9719    public string OutputPath { get; }
 20
 21    /// <summary>
 22    /// Optional filter - only include types whose fully qualified names are in this set.
 23    /// If empty, all types are included.
 24    /// </summary>
 39425    public HashSet<string> TypeFilter { get; }
 26
 45027    public DiagnosticOptions(bool enabled, string outputPath, HashSet<string> typeFilter)
 28    {
 45029        Enabled = enabled;
 45030        OutputPath = outputPath ?? string.Empty;
 45031        TypeFilter = typeFilter ?? new HashSet<string>(StringComparer.Ordinal);
 45032    }
 33
 34    /// <summary>
 35    /// Parses diagnostic options from MSBuild property values.
 36    /// </summary>
 37    public static DiagnosticOptions Parse(string? enabledValue, string? outputPath, string? filterValue)
 38    {
 45039        var enabled = ParseBool(enabledValue);
 45040        var path = string.IsNullOrWhiteSpace(outputPath) ? string.Empty : outputPath!.Trim();
 45041        var filter = ParseFilter(filterValue);
 42
 45043        return new DiagnosticOptions(enabled, path, filter);
 44    }
 45
 46    private static bool ParseBool(string? value)
 47    {
 45048        if (string.IsNullOrWhiteSpace(value))
 33649            return false;
 50
 11451        return value!.Equals("true", StringComparison.OrdinalIgnoreCase) ||
 11452               value.Equals("1", StringComparison.Ordinal);
 53    }
 54
 55    private static HashSet<string> ParseFilter(string? value)
 56    {
 45057        var result = new HashSet<string>(StringComparer.Ordinal);
 58
 45059        if (string.IsNullOrWhiteSpace(value))
 43560            return result;
 61
 1562        var parts = value!.Split(new[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries);
 7663        foreach (var part in parts)
 64        {
 2365            var trimmed = part.Trim();
 2366            if (!string.IsNullOrEmpty(trimmed))
 67            {
 2368                result.Add(trimmed);
 69            }
 70        }
 71
 1572        return result;
 73    }
 74}