< Summary

Information
Class: NexusLabs.Needlr.Generators.ValidatorProviderAttribute
Assembly: NexusLabs.Needlr.Generators.Attributes
File(s): /home/runner/work/needlr/needlr/src/NexusLabs.Needlr.Generators.Attributes/ValidatorProviderAttribute.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 4
Coverable lines: 4
Total lines: 39
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_BaseTypeName()100%210%
.ctor(...)0%620%

File(s)

/home/runner/work/needlr/needlr/src/NexusLabs.Needlr.Generators.Attributes/ValidatorProviderAttribute.cs

#LineLine coverage
 1using System;
 2
 3namespace NexusLabs.Needlr.Generators;
 4
 5/// <summary>
 6/// Marks an assembly as providing a validator base type that the Needlr analyzer should recognize.
 7/// When a type used with <c>[Options(Validator = typeof(...))]</c> inherits from the specified base type,
 8/// the analyzer will not report NDLRGEN014 (validator missing interface).
 9/// </summary>
 10/// <remarks>
 11/// <para>
 12/// This enables integration packages (like FluentValidation adapters) to teach the core analyzer
 13/// about their validator types without the core needing direct knowledge of those packages.
 14/// </para>
 15/// <para>
 16/// Example usage in an extension package:
 17/// <code>
 18/// [assembly: ValidatorProvider("FluentValidation.AbstractValidator`1")]
 19/// </code>
 20/// </para>
 21/// </remarks>
 22[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
 23public sealed class ValidatorProviderAttribute : Attribute
 24{
 25    /// <summary>
 26    /// The metadata name of the base validator type.
 27    /// Use backtick notation for generic types: "FluentValidation.AbstractValidator`1"
 28    /// </summary>
 029    public string BaseTypeName { get; }
 30
 31    /// <summary>
 32    /// Initializes a new instance of the <see cref="ValidatorProviderAttribute"/> class.
 33    /// </summary>
 34    /// <param name="baseTypeName">The fully-qualified metadata name of the base validator type.</param>
 035    public ValidatorProviderAttribute(string baseTypeName)
 36    {
 037        BaseTypeName = baseTypeName ?? throw new ArgumentNullException(nameof(baseTypeName));
 038    }
 39}