Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Roslyn
  3. StrongInject

StrongInject

MITC#1.4.4

A compile-time checked dependency injection container for C# using Roslyn source generators.

GitHubGitHub
868 stars25 forks0 contributors

What is StrongInject?

StrongInject is a dependency injection container for C# that performs all dependency resolution checks at compile time using Roslyn source generators. It eliminates runtime errors by validating registrations during compilation and generates fast, reflection-free code for resolving dependencies. The container supports async initialization, scope management, and integrates with various .NET application types.

Target Audience

C# developers building .NET applications who need a performant, type-safe dependency injection solution, especially those targeting platforms like UWP or iOS where reflection is limited.

Value Proposition

Developers choose StrongInject for its compile-time safety, which catches missing dependencies early, and its performance due to the absence of reflection. Its async support and modular design make it suitable for modern .NET applications.

Overview

compile time dependency injection for .NET

Use Cases

Best For

  • Ensuring compile-time dependency validation in C# projects
  • Building high-performance .NET applications without reflection overhead
  • Implementing async-aware dependency injection with initialization and disposal
  • Organizing dependencies using reusable modules and decorators
  • Integrating DI with ASP.NET Core, Xamarin, WPF, or console apps
  • Enforcing best practices like non-invasive design and proper resource disposal

Not Ideal For

  • Projects requiring dynamic dependency registration at runtime without recompilation
  • Teams heavily invested in Microsoft's built-in DI container who prioritize ecosystem integration over compile-time safety
  • Applications with rapidly changing dependency graphs based on user configuration or plugins
  • Developers unfamiliar with Roslyn source generators who may struggle with setup and error diagnostics

Pros & Cons

Pros

Compile-Time Safety

Detects missing dependencies during compilation, not runtime, as shown in the example where omitting MyService registration causes a SI0102 error at build time.

Reflection-Free Performance

Uses Roslyn source generators to generate fast, linker-friendly code, eliminating reflection overhead and ensuring compatibility with platforms like UWP and iOS.

Async Initialization Support

Fully supports asynchronous initialization and disposal via IRequiresAsyncInitialization, allowing IO-bound tasks like database calls during resolution.

Modular Design

Offers a module system with RegisterModuleAttribute for reusable dependency groupings, enabling organized and maintainable container configurations.

Thread Safety Guarantees

Provides safe concurrent resolution and disposal, with guarantees that SingleInstance dependencies are created only once and no leaks occur during disposal.

Cons

Verbose Configuration Overhead

Requires explicit registration via attributes and container classes for each dependency, which can be tedious and error-prone in large or complex projects.

Limited Ecosystem and Maturity

Compared to established DI containers like Autofac or Microsoft.Extensions.DependencyInjection, it has fewer third-party integrations, community plugins, and is still under active development per the roadmap.

Steeper Learning Curve

Demands understanding of source generators and StrongInject-specific patterns (e.g., Owned<T>, decorators), with error messages from compile-time checks potentially being cryptic for newcomers.

Reduced Runtime Flexibility

The compile-time nature limits dynamic scenarios, such as hot-reloading dependencies or runtime service selection without pre-registration, forcing workarounds like factory methods.

Frequently Asked Questions

Quick Stats

Stars868
Forks25
Contributors0
Open Issues19
Last commit1 year ago
CreatedSince 2020

Tags

#module-system#hacktoberfest#decorator-pattern#dependency-injection#csharp#async#ioc#dotnet#csharp-sourcegenerator#di#roslyn#source-generators#ioc-container#compile-time

Built With

R
Roslyn
S
Source Generators
C
C++
.
.NET 5

Included in

Roslyn734
Auto-fetched 5 hours ago

Related Projects

Generator.EqualsGenerator.Equals

A source code generator for automatically implementing IEquatable<T> using only attributes.

Stars190
Forks22
Last commit2 days ago
JsonSrcGenJsonSrcGen

Json library that uses .NET 5 Source Generators

Stars151
Forks5
Last commit4 years ago
StructPackerStructPacker

Low-level, lightweight and performance-focused serializer for C# struct types that uses Source Generators technology.

Stars81
Forks7
Last commit4 years ago
WrapperValueObjectWrapperValueObject

A .NET source generator for creating simple value objects wrapping primitive types.

Stars52
Forks3
Last commit3 years ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub