Jak używać
- Skopiuj polecenie instalacji i sprawdź źródła przed instalacją we własnym środowisku agenta.
- W oryginale sprawdź wymagane narzędzia, dane dostępowe i obsługiwane środowiska.
- Opisz dane wejściowe i oczekiwany rezultat; porównaj wynik ze źródłami.
npx skills add https://github.com/haxen/skills-test --skill keyed-servicePrzed rozpoczęciem
- Instalacja nie obejmuje subskrypcji modelu, limitu API ani uprawnień do plików.
- Gwiazdki i instalacje pokazują aktywność, a nie niezależny test jakości lub bezpieczeństwa.
Treść z repozytorium z zachowaniem nagłówków, przykładów, kodu, tabel, linków i obrazów.
modul-connect/naming-conventions/keyed-service
C# Keyed Service Naming Convention
Rule Definition
When generating or refactoring C# constructors using the [FromKeyedServices] attribute, the parameter name must be derived from the Key Argument rather than the Interface Type.
Logic & Transformation
- Source of Truth: Use the value inside
[FromKeyedServices(...)](e.g.,ModulConnect.Queries.Postgres.Backoffice). - Identifier Extraction: Take the last segment of the Key (e.g.,
Backoffice). - Contextual Suffixing: - If the namespace contains
.Queries., appendQuery.
- If the namespace contains
.Commands., appendCommand.
- Casing: Convert the result to
camelCasefor the parameter and_camelCasefor the private field.
Examples
✅ Correct (Key-Derived)
public class OrderProcessor(
[FromKeyedServices(ModulConnect.Queries.Postgres.Backoffice)]
IDataAccess backofficeQuery)
{
private readonly IDataAccess _backofficeQuery = backofficeQuery;
}❌ Incorrect (Type-Derived)
// DO NOT use the interface name "dataAccess"
public class OrderProcessor(
[FromKeyedServices(ModulConnect.Queries.Postgres.Backoffice)]
IDataAccess dataAccess)
{
/* ... */
}Rationale
In a modular architecture, the interface (e.g., IDataAccess) defines the contract, but the Key defines the instance's specific responsibility. Naming the parameter after the Key prevents naming collisions when multiple implementations of the same interface are injected and provides immediate semantic clarity.




