plugins/shiny-extensions/skills/shiny-di/SKILL.md
Generate and configure Shiny DI for .NET - attribute-driven service registration with source generators, keyed services, categories, and multi-interface support
npx skillsauth add shinyorg/skills shiny-diInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
You are an expert in Shiny Extensions Dependency Injection, a .NET library providing attribute-driven service registration with source generators.
Invoke this skill when the user wants to:
[Singleton], [Scoped], or [Transient] attributes with source generationDocumentation: https://shinylib.net/extensions/di/
Repository: https://github.com/shinyorg/Shiny.Extensions
Package: Shiny.Extensions.DependencyInjection
Namespace: Shiny
Mark classes with attributes for automatic DI registration via source generation:
[Singleton] // Singleton lifetime
public class MyService : IMyService { }
[Scoped] // Scoped lifetime
public class MyRepository : IRepository { }
[Transient] // Transient lifetime
public class MyFactory : IFactory { }
All registration attributes support these properties:
| Property | Type | Description |
|----------|------|-------------|
| AsSelf | bool | Register as the class itself rather than its interface |
| Type | Type | Register against a specific interface (when class implements multiple) |
| KeyedName | string? | Register as a keyed service |
| Category | string? | Category for conditional registration |
| TryAdd | bool | Use TryAdd semantics (won't replace existing registrations) |
// Register as the class itself
[Singleton(AsSelf = true)]
public class AppState { }
// Register against a specific interface
[Singleton(Type = typeof(ISpecificInterface))]
public class MultiInterfaceService : ISpecificInterface, IOtherInterface { }
// Keyed service
[Singleton(KeyedName = "primary")]
public class PrimaryCache : ICache { }
// Category-based conditional registration
[Singleton(Category = "premium")]
public class PremiumFeature : IFeature { }
// TryAdd semantics
[Singleton(TryAdd = true)]
public class DefaultLogger : ILogger { }
// Register all source-generated services
builder.Services.AddShinyServiceRegistry();
// Register with specific categories only
builder.Services.AddShinyServiceRegistry("premium", "analytics");
// Register a singleton against all implemented interfaces
services.AddSingletonAsImplementedInterfaces<MyService>();
services.AddSingletonAsImplementedInterfaces<MyService>("keyName");
// Register scoped against all implemented interfaces
services.AddScopedAsImplementedInterfaces<MyService>();
// Check registrations
bool hasService = services.HasService<IMyService>();
bool hasImpl = services.HasImplementation<MyService>();
// Lazy resolution
Lazy<IMyService> lazy = services.GetLazyService<IMyService>(required: true);
[Singleton], [Scoped], [Transient]) over manual registrationCategory for optional features that may not always be registeredKeyedName when multiple implementations of the same interface existAddShinyServiceRegistry() to activate source-generated registrations[Singleton]/[Scoped]/[Transient] attributes over manual services.Add*() callsKeyedName to disambiguatedevelopment
Guide for generating code that uses Shiny.Data.Sync for reliable, background-capable bidirectional JSON sync over HTTP on iOS, Android, Windows, Linux, macOS, and Blazor WASM
devops
Guide for implementing push notifications in .NET MAUI apps using Shiny.Push (native FCM/APNs) and Shiny.Push.AzureNotificationHubs
tools
Cross-platform local notification management for .NET MAUI apps using Shiny, supporting scheduled, repeating, and geofence-triggered notifications with channels, badges, and interactive actions.
tools
GPS tracking, geofence monitoring, and motion activity recognition for .NET MAUI, iOS, and Android using Shiny.Locations