{"id":15649099,"url":"https://github.com/kant2002/sourcegeneratorskit","last_synced_at":"2025-10-15T00:16:34.417Z","repository":{"id":54988710,"uuid":"364640930","full_name":"kant2002/SourceGeneratorsKit","owner":"kant2002","description":"Utility library for faster writing source generators","archived":false,"fork":false,"pushed_at":"2021-05-06T03:54:51.000Z","size":8,"stargazers_count":61,"open_issues_count":2,"forks_count":7,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-02-25T08:51:19.282Z","etag":null,"topics":["source-generators"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kant2002.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-05T16:31:31.000Z","updated_at":"2024-11-04T15:04:19.000Z","dependencies_parsed_at":"2022-08-14T08:20:20.712Z","dependency_job_id":null,"html_url":"https://github.com/kant2002/SourceGeneratorsKit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kant2002%2FSourceGeneratorsKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kant2002%2FSourceGeneratorsKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kant2002%2FSourceGeneratorsKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kant2002%2FSourceGeneratorsKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kant2002","download_url":"https://codeload.github.com/kant2002/SourceGeneratorsKit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242667466,"owners_count":20166296,"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":["source-generators"],"created_at":"2024-10-03T12:27:51.823Z","updated_at":"2025-10-15T00:16:34.362Z","avatar_url":"https://github.com/kant2002.png","language":"C#","readme":"Source Generators Toolkit\n=========================\n\n![Nuget](https://img.shields.io/nuget/v/SourceGeneratorsKit)\n\nToolkit for writing source generators, and specifically collect important information about project to aid generation itself.\n\n# Getting started\n\n```\n[Generator]\npublic class MagicGenerator : ISourceGenerator\n{\n    SyntaxReceiver syntaxReceiver = new MethodsWithAttributeReceiver(\"MagicAttribute\");\n\n    /// \u003cinheritdoc/\u003e\n    public void Initialize(GeneratorInitializationContext context)\n    {\n        context.RegisterForSyntaxNotifications(() =\u003e syntaxReceiver);\n    }\n\n    public void Execute(GeneratorExecutionContext context)\n    {\n        // Retrieve the populated receiver\n        if (!(context.SyntaxContextReceiver is SyntaxReceiver receiver))\n        {\n            return;\n        }\n\n        foreach (IMethodSymbol methodSymbol in this.syntaxReceiver.Methods)\n        {\n            // process your method here.\n        }\n    }\n}\n```\n\n# Find all classes which implements specific interface\n```\n[Generator]\npublic class MagicGenerator : ISourceGenerator\n{\n    SyntaxReceiver syntaxReceiver = new ClassesWithInterfacesReceiver(\"IEnumerable\");\n\n    /// \u003cinheritdoc/\u003e\n    public void Initialize(GeneratorInitializationContext context)\n    {\n        context.RegisterForSyntaxNotifications(() =\u003e syntaxReceiver);\n    }\n\n    public void Execute(GeneratorExecutionContext context)\n    {\n        // Retrieve the populated receiver\n        if (!(context.SyntaxContextReceiver is SyntaxReceiver receiver))\n        {\n            return;\n        }\n\n        foreach (INamedTypeSymbol classSymbol in this.syntaxReceiver.Classes)\n        {\n            // process your class here.\n        }\n    }\n}\n```\n\n# Find all classes which derived from well-known type\n```\n[Generator]\npublic class MagicGenerator : ISourceGenerator\n{\n    SyntaxReceiver syntaxReceiver = new DerivedClassesReceiver(\"DbConnection\");\n\n    /// \u003cinheritdoc/\u003e\n    public void Initialize(GeneratorInitializationContext context)\n    {\n        context.RegisterForSyntaxNotifications(() =\u003e syntaxReceiver);\n    }\n\n    public void Execute(GeneratorExecutionContext context)\n    {\n        // Retrieve the populated receiver\n        if (!(context.SyntaxContextReceiver is SyntaxReceiver receiver))\n        {\n            return;\n        }\n\n        foreach (INamedTypeSymbol classSymbol in this.syntaxReceiver.Classes)\n        {\n            // process your class here.\n        }\n    }\n}\n```\n\n# Find all members with given attribute\n\n```\n[Generator]\npublic class MagicGenerator : ISourceGenerator\n{\n    SyntaxReceiver syntaxReceiver = new MethodsWithAttributeReceiver(\"MagicAttribute\");\n\n    /// \u003cinheritdoc/\u003e\n    public void Initialize(GeneratorInitializationContext context)\n    {\n        context.RegisterForSyntaxNotifications(() =\u003e syntaxReceiver);\n    }\n\n    public void Execute(GeneratorExecutionContext context)\n    {\n        // Retrieve the populated receiver\n        if (!(context.SyntaxContextReceiver is SyntaxReceiver receiver))\n        {\n            return;\n        }\n\n        foreach (IMethodSymbol methodSymbol in this.syntaxReceiver.Methods)\n        {\n            // process your method here.\n            var parameters = methodSymbol.Parameters;\n            foreach (var parameter in parameters)\n            {\n                // Do your parameter magic here.\n            }\n        }\n    }\n}\n```\n\n# Work with multiple receivers\n\n```\n[Generator]\npublic class AggregateMagicGenerator : ISourceGenerator\n{\n    SyntaxReceiver syntaxReceiver1 = new MethodsWithAttributeReceiver(\"MagicAttribute\");\n    SyntaxReceiver syntaxReceiver2 = new DerivedClassesReceiver(\"DbConnection\");\n    SyntaxReceiver agregateSyntaxReceiver;\n\n    public MagicGenerator()\n    {\n        this.agregateSyntaxReceiver = new AggregateSyntaxContextReceiver(this.syntaxReceiver1, this.syntaxReceiver2);\n    }\n\n    /// \u003cinheritdoc/\u003e\n    public void Initialize(GeneratorInitializationContext context)\n    {\n        context.RegisterForSyntaxNotifications(() =\u003e agregateSyntaxReceiver);\n    }\n\n    public void Execute(GeneratorExecutionContext context)\n    {\n        // Retrieve the populated receiver\n        if (!(context.SyntaxContextReceiver is SyntaxReceiver receiver))\n        {\n            return;\n        }\n\n        foreach (IMethodSymbol methodSymbol in this.syntaxReceiver1.Methods)\n        {\n            // process your method here.\n            var parameters = methodSymbol.Parameters;\n            foreach (var parameter in parameters)\n            {\n                // Do your parameter magic here.\n            }\n        }\n\n        foreach (INamedTypeSymbol classSymbol in this.syntaxReceiver2.Classes)\n        {\n            // process your class here.\n        }\n    }\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkant2002%2Fsourcegeneratorskit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkant2002%2Fsourcegeneratorskit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkant2002%2Fsourcegeneratorskit/lists"}