- Replace broken reflection-based GetService(Type, args) with direct ResolveService method - Fix positional argument matching (type-based FirstOrDefault) - Fix greedy constructor scoring (no double-count) - Narrow TryGetService exception handling to InvalidOperationException - Throw on duplicate registrations - Add IDisposable support - Add thread-safe singleton creation - Create AGENTS.md with repo guide
1.7 KiB
1.7 KiB
Syrette — agent guide
Minimal C# DI library targeting net8.0;net9.0;net10.0.
Build commands
dotnet build Syrette # library only
dotnet build # everything (includes DISandbox console app)
dotnet pack Syrette -c Release --output .
SDK: .NET 10.0+ (see global.json — rollForward: latestMinor, allowPrerelease: true).
Project structure
| Path | Purpose |
|---|---|
Syrette/ |
Library (class lib). Entrypoints: ServiceContainer.cs, ServiceDescriptor.cs, ServiceLifetime.cs |
DISandbox/ |
Unofficial manual-test sandbox. Console app referencing Syrette. Not part of the shipped package. |
No test project exists. CI has the test step commented out (nuget-pkg-build.yml:24).
NuGet publishing
- CI (Gitea Actions) triggers on
v*tags orworkflow_dispatch. - Pushes to both nuget.org and a Gitea package feed.
- Version is
0.0.1.8-alphaperSyrette.csproj.
Library API
ServiceContainerexposes onlyAddSingleton/AddTransient(multiple overloads) andGetService<T>(),GetService(Type, args),TryGetService(Type, args),GetServices<T>(),GetServiceTypes<T>().- All registration methods return
ServiceContainerfor fluent chaining. - Constructor selection is greedy: picks the constructor with the most parameters satisfiable by registered services or explicit args.
- Only Singleton and Transient lifetimes; no scoped, no property/method injection.
ServiceContainer : IDisposable— disposes singleton instances that implementIDisposable.- Duplicate registrations (same
(ServiceType, ImplementationType)) throwInvalidOperationException. - Resolution-time args (
GetService(Type, args)) override registration-time args of the same type (type-based merge).