| | | 1 | | using System; |
| | | 2 | | using System.Linq; |
| | | 3 | | |
| | | 4 | | namespace NexusLabs.Needlr.Generators.Models; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// Information about a discovered injectable type. |
| | | 8 | | /// </summary> |
| | | 9 | | internal readonly struct DiscoveredType |
| | | 10 | | { |
| | | 11 | | public DiscoveredType(string typeName, string[] interfaceNames, string assemblyName, GeneratorLifetime lifetime, Typ |
| | | 12 | | { |
| | 233538 | 13 | | TypeName = typeName; |
| | 233538 | 14 | | InterfaceNames = interfaceNames; |
| | 233538 | 15 | | AssemblyName = assemblyName; |
| | 233538 | 16 | | Lifetime = lifetime; |
| | 233538 | 17 | | ConstructorParameters = constructorParameters; |
| | 233538 | 18 | | ServiceKeys = serviceKeys; |
| | 233538 | 19 | | SourceFilePath = sourceFilePath; |
| | 233538 | 20 | | SourceLine = sourceLine; |
| | 233538 | 21 | | IsDisposable = isDisposable; |
| | 233538 | 22 | | InterfaceInfos = interfaceInfos ?? Array.Empty<InterfaceInfo>(); |
| | 233538 | 23 | | } |
| | | 24 | | |
| | 11516826 | 25 | | public string TypeName { get; } |
| | 10338273 | 26 | | public string[] InterfaceNames { get; } |
| | | 27 | | /// <summary> |
| | | 28 | | /// Detailed interface information including source locations. |
| | | 29 | | /// </summary> |
| | 238390 | 30 | | public InterfaceInfo[] InterfaceInfos { get; } |
| | 482176 | 31 | | public string AssemblyName { get; } |
| | 1154411 | 32 | | public GeneratorLifetime Lifetime { get; } |
| | 973858 | 33 | | public TypeDiscoveryHelper.ConstructorParameterInfo[] ConstructorParameters { get; } |
| | | 34 | | /// <summary> |
| | | 35 | | /// Service keys from [Keyed] attributes on this type. |
| | | 36 | | /// </summary> |
| | 577968 | 37 | | public string[] ServiceKeys { get; } |
| | 296582 | 38 | | public string? SourceFilePath { get; } |
| | | 39 | | /// <summary> |
| | | 40 | | /// The 1-based line number where this type is declared. |
| | | 41 | | /// </summary> |
| | 233548 | 42 | | public int SourceLine { get; } |
| | | 43 | | /// <summary> |
| | | 44 | | /// True if this type implements IDisposable or IAsyncDisposable. |
| | | 45 | | /// </summary> |
| | 2433 | 46 | | public bool IsDisposable { get; } |
| | | 47 | | |
| | | 48 | | /// <summary> |
| | | 49 | | /// Gets the constructor parameter types (for backward compatibility with existing code paths). |
| | | 50 | | /// </summary> |
| | 289353 | 51 | | public string[] ConstructorParameterTypes => ConstructorParameters.Select(p => p.TypeName).ToArray(); |
| | | 52 | | |
| | | 53 | | /// <summary> |
| | | 54 | | /// True if any constructor parameters are keyed services. |
| | | 55 | | /// </summary> |
| | 0 | 56 | | public bool HasKeyedParameters => ConstructorParameters.Any(p => p.IsKeyed); |
| | | 57 | | |
| | | 58 | | /// <summary> |
| | | 59 | | /// True if this type has [Keyed] attributes for keyed registration. |
| | | 60 | | /// </summary> |
| | 47870 | 61 | | public bool IsKeyed => ServiceKeys.Length > 0; |
| | | 62 | | } |