designing-dotnet-types
/designing-dotnet-types
Choose the right kind of .NET type for new behavior — static class, extension method, injected service, hosted service, options type, record, or interface. USE FOR: deciding how to shape a new unit of behavior or data before writing it, or reviewing that an existing type has the right shape for its dependencies and lifecycle. DO NOT USE FOR: registering a type or choosing its DI lifetime (use configuring-dotnet-dependency-injection).
- Author
- nice3point ↗
- Repository
- revit-skills ↗
- Licence
- MIT
- Last repository change
- 08.10.2026
Assessment and security
- Files in this package
- 1
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 08.10.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Choose the right kind of .NET type for new behavior — static class, extension method, injected service, hosted service, options type, record, or interface. USE FOR: deciding how to shape a new unit of behavior or data before writing it, or reviewing that an existing type has the right shape for its dependencies and lifecycle. DO NOT USE FOR: registering a type or choosing its DI lifetime (use configuring-dotnet-dependency-injection).
Original author description
Choose the right kind of .NET type for new behavior — static class, extension method, injected service, hosted service, options type, record, or interface. USE FOR: deciding how to shape a new unit of behavior or data before writing it, or reviewing that an existing type has the right shape for its dependencies and lifecycle. DO NOT USE FOR: registering a type or choosing its DI lifetime (use configuring-dotnet-dependency-injection).
How it works
- When to use
- Static classes
- Extension methods
- Services
- Hosted services
- Data and configuration types
- Validation
- Common Pitfalls
SKILL.md preview
--- name: designing-dotnet-types description: > Choose the right kind of .NET type for new behavior — static class, extension method, injected service, hosted service, options type, record, or interface. USE FOR: deciding how to shape a new unit of behavior or data before writing it, or reviewing that an existing type has the right shape for its dependencies and lifecycle. DO NOT USE FOR: registering a type or choosing its DI lifetime (use configuring-dotnet-dependency-injection). license: MIT --- # Designing .NET Types Pick the type from its dependency and lifecycle needs, not from habit. ## When to use - Adding a new unit of behavior and deciding whether it is a static helper, an extension, a service, or a hosted service. - Adding data or configuration and deciding between a `record` and an options type. - Reviewing whether a type hides dependencies it should declare. ## Static classes Use a static class only for stateless behavior with no injected dependency, configuration, logging, I/O, clock, cache, or mutable state. Make a static method deterministic for the same input unless its name says otherwise. ## Extension methods Use an extension method for a small operation centered on its receiver type, free of injected dependencies, I/O, hidden mutation, and expensive enumeration. Use an ordinary service when the operation needs configuration, logging, another collaborator, or a lifetime. ## Services Use an injected service when behavior depends on configuration, logging, I/O, a client, a clock, a cache, or another injectable collaborator. - Limit the service API to one capability boundary. - Use a primary constructor for dependencies; do not add fields that only mirror them. - Add an interface when a consumer must substitute the implementation, choose among implementations, or depend on a stable boundary; DI registration alone is not a reason. ## Hosted services Use `IHostedService` or `BackgroundService` for work that starts with the host, stops with the host, or continuously consumes an independent source. Implement request handling and one-shot operations in ordinary services. ## Data and configuration types Use a `record` for immutable data crossing a method, process, or configuration boundary. Use a dedicated options type for a cohesive configuration section; never store mutable configuration on a service. ## Validation - [ ] The type matches its dependency and lifecycle needs. - [ ] A static or extension method hides no I/O, mutation, or injected collaborator. - [ ] A service exposes one capability boundary. - [ ] An interface exists only for a real substitution or boundary need. ## Common Pitfalls | Pitfall | Correct approach | |-------------------------------------------------------|------------------------------------------------------------------------| | Static helper that quietly reads a file or clock | Make it a service with the dependency injected. | | Extension method taking a `DbContext` or `HttpClient` | Use a service; extensions are for receiver-centric operations. | | Interface added for every DI-registered class | Register the concrete type; add an interface only for a real boundary. | | Mutable "settings" service storing configuration | Bind an options type (use binding-and-validating-options). |
Versions
The database has no other skills named designing-dotnet-types.
Database snapshot: 13.11.2026 · package version 1db587a6d6ae (SHA-256 digest of the entire package)
Downloads in the last 30 days: 3 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100configuring-dotnet-hosting
Configure a .NET application host and its feature-registration extensions on IHostApplicationBuilder. USE FOR: composing HostApplicationBuilder/WebApplicationBuilder, writing IHostApplicationBuilder extension methods, registering shared service defaults, and host startup and… - 100configuring-dotnet-dependency-injection
Register and review .NET dependency-injection services and lifetimes on IServiceCollection. USE FOR: adding a registration, choosing singleton/scoped/transient, grouping registrations behind a feature extension, assembly scanning with Scrutor, or validating a service graph. DO… - 90dotnet-dependency-injection
Use .NET's built-in DI with correct lifetimes, the options pattern, and constructor injection free of service-locator drift. Use when wiring .NET services or debugging captive-dependency and disposal bugs. - 100dotnet-patterns
Idiomatic C# and .NET patterns, conventions, dependency injection, async/await, and best practices for building robust, maintainable .NET applications. Use when writing or reviewing C# / .NET code — DI, async, or general conventions. - 100dotnet-patterns
Idiomatic C# and .NET patterns, conventions, dependency injection, async/await, and best practices for building robust, maintainable .NET applications. Use when writing or reviewing C# / .NET code — DI, async, or general conventions. - 96playwright-dotnet
Playwright .NET test generation instructions Triggers on: **