Designed for low-ceremony use, performance, and extensibility.
Targets: net45;netstandard2.0;netstandard2.1;net6.0;net7.0;net8.0
NuGet packages:
Live Documentation created with CsToMd
Two original parts of the DryIoc are now the separate projects: FastExpressionCompiler and ImTools
The listed .MsDI packages are respective Microsoft.Extensions.DependencyInjection adapters
DryIoc 6.0.0 (.MsDI 8.0.0), MsDI 9.0.0, Grace 7.2.1 (.MsDI 7.1.0), Autofac 8.1.1 (.MsDI 10.0.0), Lamar 14.0.1
BenchmarkDotNet v0.14.0, Windows 11 (10.0.22631.4391/23H2/2023Update/SunValley3)
Intel Core i9-8950HK CPU 2.90GHz (Coffee Lake), 1 CPU, 12 logical and 6 physical cores
.NET SDK 9.0.100
[Host] : .NET 9.0.0 (9.0.24.52809), X64 RyuJIT AVX2
DefaultJob : .NET 9.0.0 (9.0.24.52809), X64 RyuJIT AVX2
| Method | Mean | Error | StdDev | Median | Ratio | RatioSD | Gen0 | Gen1 | Gen2 | Allocated | Alloc Ratio |
| ------------ | -----------: | ---------: | ---------: | -----------: | -----: | ------: | -------: | ------: | ------: | --------: | ----------: |
| DryIoc | 65.70 us | 1.309 us | 2.553 us | 64.46 us | 1.00 | 0.05 | 5.2490 | 0.4883 | - | 32.74 KB | 1.00 |
| DryIoc_MsDI | 97.96 us | 1.959 us | 4.382 us | 96.59 us | 1.49 | 0.09 | 6.5918 | 0.6104 | - | 40.89 KB | 1.25 |
| MsDI | 81.25 us | 1.624 us | 4.686 us | 82.73 us | 1.24 | 0.08 | 14.8926 | - | - | 91.15 KB | 2.78 |
| Autofac | 323.50 us | 6.408 us | 8.555 us | 320.06 us | 4.93 | 0.23 | 49.8047 | - | - | 306.93 KB | 9.37 |
| Autofac_MsDI | 367.96 us | 7.324 us | 14.111 us | 362.58 us | 5.61 | 0.30 | 59.0820 | - | - | 364.77 KB | 11.14 |
| Lamar_MsDI | 3,643.30 us | 56.678 us | 55.666 us | 3,630.33 us | 55.53 | 2.25 | 82.0313 | 3.9063 | - | 524.96 KB | 16.03 |
| Grace | 13,870.26 us | 282.593 us | 824.337 us | 13,837.66 us | 211.41 | 14.82 | 109.3750 | 93.7500 | 15.6250 | 686.94 KB | 20.98 |
| Grace_MsDI | 17,079.41 us | 318.034 us | 326.598 us | 17,025.77 us | 260.33 | 10.92 | 125.0000 | 93.7500 | - | 854.11 KB | 26.09 |
DryIoc 6.0.0 (.MsDI 8.0.0), MsDI 9.0.0, Grace 7.2.1 (.MsDI 7.1.0), Autofac 8.1.1 (.MsDI 10.0.0), Lamar 14.0.1
BenchmarkDotNet v0.14.0, Windows 11 (10.0.22631.4391/23H2/2023Update/SunValley3)
Intel Core i9-8950HK CPU 2.90GHz (Coffee Lake), 1 CPU, 12 logical and 6 physical cores
.NET SDK 9.0.100
[Host] : .NET 9.0.0 (9.0.24.52809), X64 RyuJIT AVX2
DefaultJob : .NET 9.0.0 (9.0.24.52809), X64 RyuJIT AVX2
| Method | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Gen1 | Allocated | Alloc Ratio |
| ------------ | --------: | --------: | --------: | ----: | ------: | ------: | -----: | --------: | ----------: |
| DryIoc | 1.357 us | 0.0105 us | 0.0093 us | 1.00 | 0.01 | 0.4730 | 0.0038 | 2.91 KB | 1.00 |
| DryIoc_MsDI | 1.815 us | 0.0126 us | 0.0118 us | 1.34 | 0.01 | 0.5074 | 0.0038 | 3.11 KB | 1.07 |
| MsDI | 2.800 us | 0.0146 us | 0.0114 us | 2.06 | 0.02 | 0.7896 | 0.0114 | 4.85 KB | 1.67 |
| Grace | 1.535 us | 0.0125 us | 0.0117 us | 1.13 | 0.01 | 0.5169 | 0.0038 | 3.17 KB | 1.09 |
| Grace_MsDI | 1.709 us | 0.0249 us | 0.0256 us | 1.26 | 0.02 | 0.5493 | 0.0038 | 3.37 KB | 1.16 |
| Lamar_MsDI | 5.314 us | 0.0197 us | 0.0184 us | 3.92 | 0.03 | 0.9689 | 0.9613 | 5.95 KB | 2.05 |
| Autofac | 36.715 us | 0.2231 us | 0.1863 us | 27.06 | 0.22 | 7.2021 | 0.4883 | 44.49 KB | 15.31 |
| Autofac_MsDI | 48.139 us | 0.6987 us | 0.6194 us | 35.48 | 0.50 | 10.1318 | 0.6714 | 62.27 KB | 21.42 |
container.Validate()
.Transient
, Singleton
, Scoped
in multiple flavors including the scoping to the specific service ancestor in the object graphuseParentReuse
and to useDecorateeReuse
(for decorators)preventDisposal
and weaklyReferenced
T[]
, IEnumerable<T>
, LazyEnumerable<T>
, and I(ReadOnly)Collection|List<T>
Lazy<T>
, Func<T>
, Meta<TMetadata, T>
or Tuple<TMetadata, T>
, KeyValuePair<TKey, T>
Func<TArg, T>
, Func<TArg1, TArg2, T>
, etcTuple<SomeMetadata, Func<ISomeService>>[]
DryIoc implements a service resolution and injection via expression compilation and interpretation.
The interpretation is the only option for the target platforms without the System.Reflection.Emit
like the Xamarin iOS.
Check the Resolution Pipeline document for more details.
Icon made by Freepik from www.flaticon.com is licensed by CC 3.0 BY