{"id":13732726,"url":"https://github.com/Rick-van-Dam/Singularity","last_synced_at":"2025-05-08T08:32:19.220Z","repository":{"id":40210653,"uuid":"131514789","full_name":"Rick-van-Dam/Singularity","owner":"Rick-van-Dam","description":"A extremely fast ioc container for high performance applications","archived":true,"fork":false,"pushed_at":"2020-09-14T18:07:45.000Z","size":17046,"stargazers_count":76,"open_issues_count":7,"forks_count":12,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-05-06T06:12:41.235Z","etag":null,"topics":["csharp","dependency-injection","dependency-injection-container","di","di-container","dotnet","duality","inversion-of-control","inversionofcontrol","ioc","ioc-container","ioc-framework","net","netcore","netstandard","singularity"],"latest_commit_sha":null,"homepage":"https://barsonax.github.io/Singularity.Docs/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Rick-van-Dam.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["Barsonax"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://www.paypal.me/RvanDam534"]}},"created_at":"2018-04-29T17:26:46.000Z","updated_at":"2025-04-22T20:05:43.000Z","dependencies_parsed_at":"2022-06-27T01:08:47.296Z","dependency_job_id":null,"html_url":"https://github.com/Rick-van-Dam/Singularity","commit_stats":null,"previous_names":["rick-van-dam/singularity"],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rick-van-Dam%2FSingularity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rick-van-Dam%2FSingularity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rick-van-Dam%2FSingularity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rick-van-Dam%2FSingularity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rick-van-Dam","download_url":"https://codeload.github.com/Rick-van-Dam/Singularity/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253029167,"owners_count":21843037,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","dependency-injection","dependency-injection-container","di","di-container","dotnet","duality","inversion-of-control","inversionofcontrol","ioc","ioc-container","ioc-framework","net","netcore","netstandard","singularity"],"created_at":"2024-08-03T03:00:33.043Z","updated_at":"2025-05-08T08:32:14.306Z","avatar_url":"https://github.com/Rick-van-Dam.png","language":"C#","readme":"\u003cimg width=\"64px\" src=\"https://github.com/Barsonax/Singularity/blob/master/src/Icon.png\" /\u003e\n\n# Singularity\n[![Discord](https://img.shields.io/discord/569232642105540608.svg)](https://discord.gg/cKFnjjk) [![NuGet Badge](https://buildstats.info/nuget/Singularity)](https://www.nuget.org/packages/Singularity/) [![Build Status](https://dev.azure.com/Barsonax/Singularity/_apis/build/status/Singularity-CI?branchName=master\u0026stageName=Build)](https://dev.azure.com/Barsonax/Singularity/_build/latest?definitionId=7\u0026branchName=master) ![Azure DevOps tests (branch)](https://img.shields.io/azure-devops/tests/Barsonax/Singularity/7/master.svg) [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=Barsonax_Singularity\u0026metric=sqale_rating)](https://sonarcloud.io/dashboard?id=Barsonax_Singularity) [![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=Barsonax_Singularity\u0026metric=reliability_rating)](https://sonarcloud.io/dashboard?id=Barsonax_Singularity) [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=Barsonax_Singularity\u0026metric=security_rating)](https://sonarcloud.io/dashboard?id=Barsonax_Singularity) ![coverage](https://img.shields.io/azure-devops/coverage/Barsonax/Singularity/7/master.svg) [![Beerpay](https://img.shields.io/beerpay/Barsonax/Singularity.svg)](https://beerpay.io/Barsonax/Singularity)\n\n## Features\n- Extreme performance, Singularity is one of the fastest if not the fastest dependency injection container out there. Don't believe me? Check out my [benchmarks](#Benchmarks) or if you want a second opinion check out the benchmarks that Daniel Palme made [here](https://github.com/danielpalme/IocPerformance).\n- Clean fluent API.\n- [Source Link](https://github.com/dotnet/sourcelink) enabled\n- Generic wrappers:\n  1. `Func\u003cT\u003e`\n  1. `Lazy\u003cT\u003e`\n  1. `Expression\u003cFunc\u003cT\u003e\u003e`\n  1. And any other generic wrapper you may have defined yourself.\n- Collection support:\n  1. `IEnumerable\u003cT\u003e`\n  1. `IReadOnlyCollection\u003cT\u003e`\n  1. `IReadOnlyList\u003cT\u003e`\n  1. `T[]`\n  1. `List\u003cT\u003e`\n  1. `ICollection\u003cT\u003e`\n  1. `IList\u003cT\u003e`\n  1. `HashSet\u003cT\u003e`\n  1. `ISet\u003cT\u003e`\n- Supports open generics.\n- Supports resolving unregistered concrete types.\n- Supports decorators.\n- Supports method and property injection without forcing you to litter attributes all over your code base. All configuration is kept inside the container.\n- Supports dynamically picking the most suitable constructor based on the available types that can be resolved.\n- Auto dispose, this is off by default but can be turned on with `With(DisposeBehavior)`or adding the lifetimes you want to auto dispose to `SingularitySettings.AutoDisposeLifetimes`.\n- Custom finalizers with the `WithFinalizer(Action\u003cTInstance\u003e)` method.\n- Supports Transient, Singleton and Scope lifetimes.\n- Supports child containers.\n- Supports best fit constructor selection\n- Clear error messages and fail fast to point you in the right direction as fast as possible.\n\n## Getting started\n### Installation\n`Singularity` can be installed through nuget. The packages that are available can be found in the [nuget](#nuget) section \n\n### A simple example\nIts easy to setup a container and request a instance:\n```cs\nvar container = new Container(builder =\u003e\n{\n    builder.Register\u003cITestService10, TestService10\u003e();\n});\n\nvar instance = container.GetInstance\u003cITestService10\u003e();\n```\nHowever `Singularity` can do much more than this simple example. You can request the instance with different wrapper types such as `Lazy\u003cT\u003e`:\n```cs\nvar lazyInstance = container.GetInstance\u003cLazy\u003cITestService10\u003e\u003e();\n```\nOr you can request the factory to create the instance:\n```cs\nvar factory = container.GetInstance\u003cFunc\u003cITestService10\u003e\u003e();\n```\nYou can even request the expression itself:\n```cs\nvar instanceExpression = container.GetInstance\u003cExpression\u003cFunc\u003cITestService10\u003e\u003e\u003e();\n```\nOfcourse its possible to combine these with for instance a collection type such as IEnumerable\u003cT\u003e or IReadOnlyList\u003cT\u003e:\n```cs\nvar instanceExpressions = container.GetInstance\u003cIReadOnlyList\u003cExpression\u003cFunc\u003cIPlugin\u003e\u003e\u003e\u003e(); //Returns all expressions for IPlugin registrations\n```\n\nAdvanced scenarios such as open generics are also supported. \n\n## Documentation\nMore info about `Singularity` can be found on the documentation website which can be found [here](https://barsonax.github.io/Singularity.Docs/).\n\n## Other\n### Benchmarks\nThe code used in the benchmark can be found [here](https://github.com/Barsonax/Singularity/blob/master/Singularity.TestClasses/Benchmark/SimpleSingularityContainerBenchmark.cs)\n```\nBenchmarkDotNet=v0.12.0, OS=Windows 10.0.18363\nAMD Ryzen 9 3900X, 1 CPU, 24 logical and 12 physical cores\n.NET Core SDK=3.1.200\n  [Host]       : .NET Core 3.1.2 (CoreCLR 4.700.20.6602, CoreFX 4.700.20.6702), X64 RyuJIT\n  LegacyJitX64 : .NET Framework 4.8 (4.8.4150.0), X64 RyuJIT\n  RyuJitX64    : .NET Core 2.1.16 (CoreCLR 4.6.28516.03, CoreFX 4.6.28516.10), X64 RyuJIT\n\nPlatform=X64  IterationTime=1.0000 s\n\n|    Method |          Job |       Jit |       Runtime |          Mean |       Error |      StdDev |  Gen 0 |  Gen 1 | Gen 2 | Allocated |\n|---------- |------------- |---------- |-------------- |--------------:|------------:|------------:|-------:|-------:|------:|----------:|\n| Singleton | LegacyJitX64 | LegacyJit |    .NET 4.7.2 |     10.539 ns |   0.1156 ns |   0.1082 ns |      - |      - |     - |         - |\n| Transient | LegacyJitX64 | LegacyJit |    .NET 4.7.2 |     15.095 ns |   0.0562 ns |   0.0525 ns | 0.0145 |      - |     - |      24 B |\n|  Combined | LegacyJitX64 | LegacyJit |    .NET 4.7.2 |     20.722 ns |   0.0707 ns |   0.0552 ns | 0.0338 |      - |     - |      56 B |\n|   Complex | LegacyJitX64 | LegacyJit |    .NET 4.7.2 |     27.218 ns |   0.2894 ns |   0.2566 ns | 0.0580 |      - |     - |      96 B |\n| Singleton |    RyuJitX64 |    RyuJit | .NET Core 2.1 |      9.569 ns |   0.0634 ns |   0.0593 ns |      - |      - |     - |         - |\n| Transient |    RyuJitX64 |    RyuJit | .NET Core 2.1 |     14.755 ns |   0.1025 ns |   0.0959 ns | 0.0145 |      - |     - |      24 B |\n|  Combined |    RyuJitX64 |    RyuJit | .NET Core 2.1 |     22.506 ns |   0.3656 ns |   0.3420 ns | 0.0337 |      - |     - |      56 B |\n|   Complex |    RyuJitX64 |    RyuJit | .NET Core 2.1 |     26.756 ns |   0.3521 ns |   0.3294 ns | 0.0578 |      - |     - |      96 B |\n| Singleton |    RyuJitX64 |    RyuJit | .NET Core 3.1 |     12.167 ns |   0.1213 ns |   0.1135 ns |      - |      - |     - |         - |\n| Transient |    RyuJitX64 |    RyuJit | .NET Core 3.1 |     14.461 ns |   0.0698 ns |   0.0653 ns | 0.0029 |      - |     - |      24 B |\n|  Combined |    RyuJitX64 |    RyuJit | .NET Core 3.1 |     20.933 ns |   0.2406 ns |   0.2251 ns | 0.0067 |      - |     - |      56 B |\n|   Complex |    RyuJitX64 |    RyuJit | .NET Core 3.1 |     24.196 ns |   0.1059 ns |   0.0991 ns | 0.0115 |      - |     - |      96 B |\n```\n\n### Nuget\n\n| Library | Version |\n|-------------|--------|\n| Singularity      | [![NuGet Badge](https://buildstats.info/nuget/Singularity)](https://www.nuget.org/packages/Singularity/) |\n| Singularity.Duality.core      | [![NuGet Badge](https://buildstats.info/nuget/Singularity.Duality.core)](https://www.nuget.org/packages/Singularity.Duality.core/)|\n| Singularity.Microsoft.DependencyInjection      | [![NuGet Badge](https://buildstats.info/nuget/Singularity.Microsoft.DependencyInjection)](https://www.nuget.org/packages/Singularity.Microsoft.DependencyInjection/)|\n| Singularity.AspNetCore.Hosting      | [![NuGet Badge](https://buildstats.info/nuget/Singularity.AspNetCore.Hosting)](https://www.nuget.org/packages/Singularity.AspNetCore.Hosting/)|\n| Singularity.AspNetCore.MVC      | [![NuGet Badge](https://buildstats.info/nuget/Singularity.AspNetCore.MVC)](https://www.nuget.org/packages/Singularity.AspNetCore.MVC/)|\n\n### Random info\n![GitHub repo size](https://img.shields.io/github/repo-size/Barsonax/Singularity.svg) ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/barsonax/singularity.svg) [![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=Barsonax_Singularity\u0026metric=ncloc)](https://sonarcloud.io/dashboard?id=Barsonax_Singularity) [![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=Barsonax_Singularity\u0026metric=duplicated_lines_density)](https://sonarcloud.io/dashboard?id=Barsonax_Singularity)\n\n\n[![Build History](https://buildstats.info/azurepipelines/chart/Barsonax/Singularity/7?branch=master)](https://dev.azure.com/Barsonax/Singularity/_build?definitionId=7)\n\n### Donations\n| Paypal |\n|-------------|\n|[![paypal](https://www.paypalobjects.com/en_US/NL/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=VTXT9EBQ3CF5E)|\n\n### Licensing\nLicensed under LGPL.\n","funding_links":["https://github.com/sponsors/Barsonax","https://www.paypal.me/RvanDam534","https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=VTXT9EBQ3CF5E"],"categories":["Runtime dependency injection"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRick-van-Dam%2FSingularity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRick-van-Dam%2FSingularity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRick-van-Dam%2FSingularity/lists"}