| | | 1 | | using System; |
| | | 2 | | using System.Collections.Generic; |
| | | 3 | | |
| | | 4 | | namespace NexusLabs.Needlr.Generators.Export; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// Root model for the Needlr dependency graph export. |
| | | 8 | | /// Serialized to needlr-graph.json for IDE tooling consumption. |
| | | 9 | | /// </summary> |
| | | 10 | | internal sealed class NeedlrGraph |
| | | 11 | | { |
| | | 12 | | public string SchemaVersion { get; set; } = "1.0"; |
| | | 13 | | public string GeneratedAt { get; set; } = DateTime.UtcNow.ToString("O"); |
| | | 14 | | public string? ProjectPath { get; set; } |
| | | 15 | | public string? AssemblyName { get; set; } |
| | | 16 | | public List<GraphService> Services { get; set; } = new(); |
| | | 17 | | public List<GraphDiagnostic> Diagnostics { get; set; } = new(); |
| | | 18 | | public GraphStatistics Statistics { get; set; } = new(); |
| | | 19 | | } |
| | | 20 | | |
| | | 21 | | /// <summary> |
| | | 22 | | /// Represents a discovered service in the dependency graph. |
| | | 23 | | /// </summary> |
| | | 24 | | internal sealed class GraphService |
| | | 25 | | { |
| | | 26 | | public string Id { get; set; } = string.Empty; |
| | | 27 | | public string TypeName { get; set; } = string.Empty; |
| | | 28 | | public string FullTypeName { get; set; } = string.Empty; |
| | | 29 | | public string? AssemblyName { get; set; } |
| | | 30 | | public List<GraphInterface> Interfaces { get; set; } = new(); |
| | | 31 | | public string Lifetime { get; set; } = string.Empty; |
| | | 32 | | public GraphLocation? Location { get; set; } |
| | | 33 | | public List<GraphDependency> Dependencies { get; set; } = new(); |
| | | 34 | | public List<GraphDecorator> Decorators { get; set; } = new(); |
| | | 35 | | public List<string> Interceptors { get; set; } = new(); |
| | | 36 | | public List<string> Attributes { get; set; } = new(); |
| | | 37 | | public List<string> ServiceKeys { get; set; } = new(); |
| | | 38 | | public GraphServiceMetadata Metadata { get; set; } = new(); |
| | | 39 | | } |
| | | 40 | | |
| | | 41 | | /// <summary> |
| | | 42 | | /// Represents an interface implemented by a service. |
| | | 43 | | /// </summary> |
| | | 44 | | internal sealed class GraphInterface |
| | | 45 | | { |
| | | 46 | | public string Name { get; set; } = string.Empty; |
| | | 47 | | public string FullName { get; set; } = string.Empty; |
| | | 48 | | public GraphLocation? Location { get; set; } |
| | | 49 | | } |
| | | 50 | | |
| | | 51 | | /// <summary> |
| | | 52 | | /// Represents a source file location. |
| | | 53 | | /// </summary> |
| | | 54 | | internal sealed class GraphLocation |
| | | 55 | | { |
| | 38 | 56 | | public string? FilePath { get; set; } |
| | 38 | 57 | | public int Line { get; set; } |
| | 38 | 58 | | public int Column { get; set; } |
| | | 59 | | } |
| | | 60 | | |
| | | 61 | | /// <summary> |
| | | 62 | | /// Represents a dependency of a service. |
| | | 63 | | /// </summary> |
| | | 64 | | internal sealed class GraphDependency |
| | | 65 | | { |
| | | 66 | | public string ParameterName { get; set; } = string.Empty; |
| | | 67 | | public string TypeName { get; set; } = string.Empty; |
| | | 68 | | public string FullTypeName { get; set; } = string.Empty; |
| | | 69 | | public string? ResolvedTo { get; set; } |
| | | 70 | | public string? ResolvedLifetime { get; set; } |
| | | 71 | | public bool IsKeyed { get; set; } |
| | | 72 | | public string? ServiceKey { get; set; } |
| | | 73 | | } |
| | | 74 | | |
| | | 75 | | /// <summary> |
| | | 76 | | /// Represents a decorator applied to a service. |
| | | 77 | | /// </summary> |
| | | 78 | | internal sealed class GraphDecorator |
| | | 79 | | { |
| | | 80 | | public string TypeName { get; set; } = string.Empty; |
| | | 81 | | public int Order { get; set; } |
| | | 82 | | } |
| | | 83 | | |
| | | 84 | | /// <summary> |
| | | 85 | | /// Additional metadata about a service. |
| | | 86 | | /// </summary> |
| | | 87 | | internal sealed class GraphServiceMetadata |
| | | 88 | | { |
| | | 89 | | public bool HasFactory { get; set; } |
| | | 90 | | public bool HasOptions { get; set; } |
| | | 91 | | public bool IsHostedService { get; set; } |
| | | 92 | | public bool IsDisposable { get; set; } |
| | | 93 | | public bool IsPlugin { get; set; } |
| | | 94 | | } |
| | | 95 | | |
| | | 96 | | /// <summary> |
| | | 97 | | /// Represents a diagnostic (warning/error) from generation. |
| | | 98 | | /// </summary> |
| | | 99 | | internal sealed class GraphDiagnostic |
| | | 100 | | { |
| | | 101 | | public string Id { get; set; } = string.Empty; |
| | | 102 | | public string Severity { get; set; } = string.Empty; |
| | | 103 | | public string Message { get; set; } = string.Empty; |
| | | 104 | | public GraphLocation? Location { get; set; } |
| | | 105 | | public List<string> RelatedServices { get; set; } = new(); |
| | | 106 | | } |
| | | 107 | | |
| | | 108 | | /// <summary> |
| | | 109 | | /// Statistics about the generated graph. |
| | | 110 | | /// </summary> |
| | | 111 | | internal sealed class GraphStatistics |
| | | 112 | | { |
| | | 113 | | public int TotalServices { get; set; } |
| | | 114 | | public int Singletons { get; set; } |
| | | 115 | | public int Scoped { get; set; } |
| | | 116 | | public int Transient { get; set; } |
| | | 117 | | public int Decorators { get; set; } |
| | | 118 | | public int Interceptors { get; set; } |
| | | 119 | | public int Factories { get; set; } |
| | | 120 | | public int Options { get; set; } |
| | | 121 | | public int HostedServices { get; set; } |
| | | 122 | | public int Plugins { get; set; } |
| | | 123 | | } |