< Summary

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

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_IncludeNamespacePrefixes()100%11100%
get_IncludeSelf()100%11100%

File(s)

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

#LineLine coverage
 1using System;
 2
 3namespace NexusLabs.Needlr.Generators;
 4
 5/// <summary>
 6/// Marks an assembly for compile-time type registry generation.
 7/// The source generator will scan all referenced assemblies and generate
 8/// a TypeRegistry class containing all injectable types.
 9/// </summary>
 10/// <remarks>
 11/// <para>
 12/// This attribute triggers the source generator to analyze all types
 13/// in referenced assemblies at compile time, eliminating the need for
 14/// runtime reflection-based type discovery.
 15/// </para>
 16/// <para>
 17/// Use <see cref="IncludeNamespacePrefixes"/> to filter which types
 18/// are included in the generated registry. This is similar to the
 19/// <c>MatchingAssemblies()</c> method in the reflection-based approach.
 20/// </para>
 21/// </remarks>
 22/// <example>
 23/// <code>
 24/// // Include all types from NexusLabs and MyCompany namespaces
 25/// [assembly: GenerateTypeRegistry(IncludeNamespacePrefixes = new[] { "NexusLabs", "MyCompany" })]
 26/// </code>
 27/// </example>
 28[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]
 29public sealed class GenerateTypeRegistryAttribute : Attribute
 30{
 31    /// <summary>
 32    /// Gets or sets namespace prefix filters. Only types in namespaces starting with
 33    /// these prefixes will be included in the generated registry.
 34    /// </summary>
 35    /// <remarks>
 36    /// This is analogous to the <c>MatchingAssemblies()</c> configuration in the
 37    /// reflection-based approach. If null or empty, all namespaces are included.
 38    /// </remarks>
 339    public string[]? IncludeNamespacePrefixes { get; set; }
 40
 41    /// <summary>
 42    /// Gets or sets whether to include types from the current assembly
 43    /// in addition to referenced assemblies.
 44    /// </summary>
 45    /// <remarks>
 46    /// Defaults to <c>true</c>. Set to <c>false</c> to only include types
 47    /// from project references.
 48    /// </remarks>
 749    public bool IncludeSelf { get; set; } = true;
 50}