| | | 1 | | using System; |
| | | 2 | | |
| | | 3 | | namespace 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)] |
| | | 23 | | public 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> |
| | 0 | 29 | | 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> |
| | 0 | 35 | | public ValidatorProviderAttribute(string baseTypeName) |
| | | 36 | | { |
| | 0 | 37 | | BaseTypeName = baseTypeName ?? throw new ArgumentNullException(nameof(baseTypeName)); |
| | 0 | 38 | | } |
| | | 39 | | } |