Dependency Injection
All core services are registered with a single extension method call:
services.AddAriadneNETServices();
services.AddAriadneNETWorkspaces(); // only when you check solutions on disk
AddAriadneNETWorkspaces() comes from the Ariadne.NET.Workspaces package. It registers ISolutionLoader and ISolutionValidator as singletons with AddSingleton, not through ZeroAlloc.Inject. ISolutionValidator needs IArchitectureValidator, so call both methods.
The method is hand-written and public. It calls the internal AddAriadneNETGeneratedServices(), which ZeroAlloc.Inject generates at compile time (every service class carries a [Singleton] attribute), and then AddGitClientResilience<GitCliClient>(), generated by ZeroAlloc.Resilience, which wraps the internal git client with a 60 second timeout and 3 retries. The MCP host project gets its own generated AddAriadneNETMcpServices(), which registers RuleResolutionHelper behind IRuleResolutionHelper. Adding a service means adding the attribute; there is no registration list to maintain.
Registration Table
All services use Singleton lifetime. AddAriadneNETServices() registers:
| Interface | Implementation | Purpose |
|---|---|---|
IRulePackLoader | YamlRulePackLoader | YAML → RulePack deserialization |
IBuiltinPackRegistry | BuiltinPackRegistry | Embedded template discovery and loading |
IRulePackMerger | RulePackMerger | Multi-pack composition |
IRulePackResolver | RulePackResolver | Reference resolution (builtin://, import://) |
ILayerInferenceEngine | LayerInferenceEngine | Role → layer mapping |
ICodeGeneratorService | CodeGeneratorService | Roslyn-based C# generation |
IGenerateOrchestrator | GenerateOrchestrator | Multi-component generation workflow |
IWorkspaceOrchestrator | WorkspaceOrchestrator | Project structure scaffolding |
IArchitectureValidator | ArchitectureValidator | Type graph checks against layer and role rules |
IImportsLoader | ImportsYamlLoader | Imports manifest parsing |
IGitSyncProvider | GitCliSyncProvider | Git clone, tag resolution, caching |
ISyncOrchestrator | SyncOrchestrator | Multi-import sync coordination |
Registered by AddAriadneNETWorkspaces() in Ariadne.NET.Workspaces, also as singletons:
| Interface | Implementation | Purpose |
|---|---|---|
ISolutionLoader | SolutionLoader | Loads a solution, filter or project into compilations with MSBuildWorkspace |
ISolutionValidator | SolutionValidator | Loads a path, checks its projects and returns an ArchitectureReport |
Why Singleton?
All services are stateless — they don't hold per-request state. The BuiltinPackRegistry caches loaded packs in a thread-safe dictionary, which benefits from Singleton lifetime. CodeGeneratorService creates a fresh AdhocWorkspace per call, avoiding shared mutable state.