{"id":46023013,"url":"https://github.com/andyelessar/sourcegen","last_synced_at":"2026-03-01T03:01:01.331Z","repository":{"id":341291913,"uuid":"1169592681","full_name":"AndyElessar/SourceGen","owner":"AndyElessar","description":"A collection of C# source generator for .NET project.","archived":false,"fork":false,"pushed_at":"2026-03-01T01:11:59.000Z","size":1161,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-01T01:56:21.112Z","etag":null,"topics":["csharp","csharp-sourcegenerator","dependency-injection","dotnet","source-generator","sourcegenerator"],"latest_commit_sha":null,"homepage":"https://github.com/AndyElessar/SourceGen","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AndyElessar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-28T23:04:10.000Z","updated_at":"2026-03-01T01:12:03.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/AndyElessar/SourceGen","commit_stats":null,"previous_names":["andyelessar/sourcegen"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/AndyElessar/SourceGen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndyElessar%2FSourceGen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndyElessar%2FSourceGen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndyElessar%2FSourceGen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndyElessar%2FSourceGen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AndyElessar","download_url":"https://codeload.github.com/AndyElessar/SourceGen/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndyElessar%2FSourceGen/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29959284,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T01:47:18.291Z","status":"online","status_checked_at":"2026-03-01T02:00:07.437Z","response_time":124,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","csharp-sourcegenerator","dependency-injection","dotnet","source-generator","sourcegenerator"],"created_at":"2026-03-01T03:00:32.778Z","updated_at":"2026-03-01T03:01:01.308Z","avatar_url":"https://github.com/AndyElessar.png","language":"C#","readme":"﻿# SourceGen\n\nA collection of C# Source Generators for compile-time code generation.\n\n## Packages\n\n|Package|Description|\n|:---|:---|\n|[![NuGet](https://img.shields.io/nuget/v/SourceGen.Ioc.svg)](https://www.nuget.org/packages/SourceGen.Ioc)|IoC/DI registration source generator for `Microsoft.Extensions.DependencyInjection.Abstractions`|\n|[![NuGet](https://img.shields.io/nuget/v/SourceGen.Ioc.Cli.svg)](https://www.nuget.org/packages/SourceGen.Ioc.Cli)|CLI tool for adding IoC attributes to existing projects|\n\n## SourceGen.Ioc\n\nA C# source generator that extends the capabilities of `Microsoft.Extensions.DependencyInjection.Abstractions` by generating registration code.\n\n### Why Use SourceGen.Ioc?\n\nCompared to `Microsoft.Extensions.DependencyInjection` aka. `MS.E.DI`:\n\n|Feature|MS.E.DI|SourceGen.Ioc|\n|:-|:-|:-|\n|Open Generic|Runtime resolution only|Auto-discovers closed types from usage|\n|Nested Open Generic|❌ Not supported|✅ Supported by auto-discovery and manual `[IocDiscover]` attribute|\n|Decorator Pattern|❌ Not supported|✅ Fully supported with type constraint validation|\n|Field/Property/Method Injection|❌ Not supported|✅ `[IocInject]` attribute|\n|Lifecycle validation|Runtime errors|✅ Compile-time analyzer|\n|Circular dependency|Runtime errors|✅ Compile-time analyzer|\n\n1. **Open Generic Auto-Discovery** - Automatically discovers closed generic types from constructor/property/method injection and `IServiceProvider.GetService\u003cT\u003e()` invocations\n\n2. **Nested Open Generic Support** - Supports nested open generic service interfaces (e.g., `IHandler\u003cRequest\u003cT\u003e, List\u003cT\u003e\u003e`) that `MS.E.DI` cannot resolve at runtime\n\n3. **Compile-time Analyzers** - Detects lifetime conflicts (e.g., Singleton depending on Scoped) and circular dependencies at compile time, not runtime\n\n4. **Field/Property/Method Injection** - Use `[IocInject]` attribute for injection beyond constructors\n\n5. **Decorator Pattern with Type Constraint Validation** - Built-in decorator chain support with automatic type constraint checking, skips non-matching decorators\n\n6. **Centralized Default Settings** - Use `[IocRegisterDefaults\u003cT\u003e]` to define default lifetime, decorators, and tags for all implementations of interface/base class\n\n7. **Tag-based Registration** - Use `Tags` parameter to group services, then selectively register them at runtime via `services.AddMyProject(\"Feature1\")`\n\n8. **External Type Registration** - Use `[IocRegisterFor\u003cT\u003e]` to register types you don't own (e.g., third-party library classes)\n\n9. **Module Import** - Use `[IocImportModule\u003cT\u003e]` to share `[IocRegisterDefaults]` settings across projects/assemblies\n\n10. **Wrapper Types** - Built-in support for `Lazy\u003cT\u003e`, `Func\u003cT\u003e`, collection types, and `IDictionary\u003cTKey, TValue\u003e` for keyed services\n\n11. **Factory \u0026 Instance Registration** - Use `Factory` or `Instance` properties on `[IocRegister]` for custom creation logic\n\n12. **Compile-time Container** - Use `[IocContainer]` to generate a high-performance container with typed resolution APIs\n\n### Installation\n\n```bash\ndotnet add package SourceGen.Ioc\n```\n\n### Quick Start\n\n```csharp\nusing SourceGen.Ioc;\nusing Microsoft.Extensions.DependencyInjection;\n\n// Basic registration\npublic interface IMyService;\n\n[IocRegister\u003cIMyService\u003e(ServiceLifetime.Scoped)]\ninternal class MyService : IMyService;\n\n// Register in DI container\nservices.AddMyProject(); // Generated extension method\n```\n\n### Documentation\n\nSee [SourceGen.Ioc Documentation](docs/SourceGen.Ioc/01_Overview.md) for complete usage guide.\n\n## License\n\nThis project is licensed under the MIT License.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandyelessar%2Fsourcegen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandyelessar%2Fsourcegen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandyelessar%2Fsourcegen/lists"}