| | | 1 | | using System; |
| | | 2 | | |
| | | 3 | | namespace 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)] |
| | | 29 | | public 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> |
| | 3 | 39 | | 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> |
| | 7 | 49 | | public bool IncludeSelf { get; set; } = true; |
| | | 50 | | } |