Pure.DI  by DevTeam

Compile-time DI code generation for .NET

Created 5 years ago
786 stars

Top 44.4% on SourcePulse

GitHubView on GitHub
Project Summary

Pure.DI is a compile-time dependency injection (DI) code generator for .NET, designed to produce highly efficient and robust DI solutions. It targets .NET developers, from those working with legacy .NET Framework 2.0 to modern .NET versions, who require zero-overhead DI with compile-time safety. The primary benefit is eliminating runtime DI overhead and catching wiring errors before execution, ensuring production-ready code.

How It Works

Pure.DI operates by generating C# source code at compile time. It analyzes the object graph and constructor dependencies, producing lean, efficient code that is functionally equivalent to manual DI implementations. By avoiding reflection and dynamic instantiation, it achieves zero runtime overhead. Crucially, all dependency validation, including checks for missing dependencies and cyclic references, occurs during compilation, preventing runtime crashes and providing immediate feedback to developers.

Quick Start & Requirements

  • Installation: Install the Pure.DI NuGet package.
  • Prerequisites: .NET SDK 6.0.4+ is required for compilation. Projects can target older .NET Framework versions. C# 8+ is needed for projects utilizing the source generator.
  • Project Template: Use dotnet new install Pure.DI.Templates followed by dotnet new di to create a new project.
  • Documentation: The project includes a link to a generated class diagram image within the README.

Highlighted Details

  • Zero Overhead: Achieves performance comparable to hand-written code by eliminating reflection and runtime overhead.
  • Compile-Time Validation: Guarantees that all dependency wiring issues are detected during compilation, not at runtime.
  • Cross-Platform Compatibility: Supports a wide range of .NET runtimes, including .NET Framework 2.0+, .NET Core, .NET 5+, UWP, Unity, Xamarin, and Native AOT, with no runtime dependencies.
  • Familiar API: Designed to mirror the syntax of mainstream DI frameworks for easy adoption.
  • Transparency: Generated code is accessible and debuggable.
  • BCL Support: Includes built-in support for many .NET Base Class Library types.

Maintenance & Community

The project is maintained by DevTeam. Specific details on community engagement (e.g., Discord, Slack) or notable contributors are not detailed in the provided README.

Licensing & Compatibility

License information is not explicitly stated in the provided README.

Limitations & Caveats

No specific limitations or caveats are mentioned in the provided documentation. The project appears to be a mature and robust DI solution.

Health Check
Last Commit

16 hours ago

Responsiveness

Inactive

Pull Requests (30d)
0
Issues (30d)
2
Star History
17 stars in the last 30 days

Explore Similar Projects

Feedback? Help us improve.