{"id":13629559,"url":"https://github.com/CodingFlow/decorator-generator","last_synced_at":"2025-04-17T09:34:50.410Z","repository":{"id":135013942,"uuid":"603612027","full_name":"CodingFlow/decorator-generator","owner":"CodingFlow","description":"Source generator for decorator pattern boilerplate code in C#.","archived":false,"fork":false,"pushed_at":"2024-07-29T15:17:45.000Z","size":1656,"stargazers_count":9,"open_issues_count":6,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-01T22:43:53.127Z","etag":null,"topics":["csharp","csharp-sourcegenerator","roslyn","source-generator","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CodingFlow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","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},"funding":{"github":"CodingFlow"}},"created_at":"2023-02-19T03:21:07.000Z","updated_at":"2024-06-06T21:17:43.000Z","dependencies_parsed_at":"2024-06-06T21:24:30.439Z","dependency_job_id":"a501e563-b22d-4067-a953-401c776bde74","html_url":"https://github.com/CodingFlow/decorator-generator","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodingFlow%2Fdecorator-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodingFlow%2Fdecorator-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodingFlow%2Fdecorator-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodingFlow%2Fdecorator-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CodingFlow","download_url":"https://codeload.github.com/CodingFlow/decorator-generator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223751236,"owners_count":17196591,"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","csharp-sourcegenerator","roslyn","source-generator","source-generators"],"created_at":"2024-08-01T22:01:13.591Z","updated_at":"2024-11-08T20:31:15.401Z","avatar_url":"https://github.com/CodingFlow.png","language":"C#","readme":"# Decorator Generator\n\n[![Nuget](https://img.shields.io/nuget/v/DecoratorGenerator)](https://www.nuget.org/packages/DecoratorGenerator)\n![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/CodingFlow/decorator-generator/pull-request.yml)\n[![Nuget](https://img.shields.io/nuget/dt/DecoratorGenerator)](https://www.nuget.org/packages/DecoratorGenerator)\n[![GitHub Sponsors](https://img.shields.io/github/sponsors/CodingFlow)](https://github.com/sponsors/CodingFlow)\n\nSource generator for decorator pattern boilerplate code in C#.\n\nWhen implementing the [decorator pattern in C#](https://en.wikipedia.org/wiki/Decorator_pattern#C#), it requires adding boilerplate code for every interface that needs to support decorators, namely the abstract class. Boilerplate is tedious to write and error-prone. This source generator solves this problem by automatically generating the abstract class. It only needs to be told which interfaces it should generate the abstract class for.\n\n![decorator-pattern-uml](https://user-images.githubusercontent.com/3643313/220009438-a2ef1990-af1e-4b56-a5c9-b3f1aed2d80f.png)\n\n# Getting Started\n\n## Installation\n\nAdd the library via NuGet to the project(s) that you want to auto-generate abstract decorator classes for:\n\n- Either via Project \u003e Manage NuGet Packages... / Browse / search for decorator-generator / Install\n- Or by running a command in the Package Manager Console\n\n```c#\nInstall-Package DecoratorGenerator\n```\n\n## Usage\n\nAdd a `Decorate` attribute to the interface:\n\n```c#\nusing DecoratorGenerator;\n\nnamespace SampleLibrary;\n\n[Decorate]\npublic interface ICat\n{\n    string Meow();\n}\n```\n\nBuild the project so the abstract class is generated for the interface. The generated class will be named after the interface, but without the `I` prefix. In this case, since the interface is `ICat` the class will be `CatDecorator`. Then create your decorator class as usual:\n\n```c#\nnamespace SampleLibrary;\n\npublic class BarkingCat : CatDecorator\n{\n    public BarkingCat(ICat cat) : base(cat)\n    {\n\n    }\n\n    public override string Meow()\n    {\n        return $\"woof woof - {base.Meow()}\";\n    }\n}\n\n```\n\nExample usage of the decorator:\n\n```c#\nusing SampleLibrary;\n\nnamespace SampleApp;\n\npartial class Program\n{\n\n    static void Main(string[] args)\n    {\n        var cat = new BarkingCat(new Cat());\n        var sound = cat.Meow();\n\n        Console.WriteLine(sound);\n    }\n\n}\n```\n\n# Configuration\n\n## List of Target Interfaces in a Config file\n\nTo generate decorator abstract classes for third party interfaces, Decorator Generator will look for a struct named `WrapperList` and generate classes of the types in the fields of the `WrapperList`:\n\n```c#\nusing Amazon.DynamoDBv2.DataModel;\n\npublic struct WrapperList\n{\n    // name the field whatever you want, the name isn't used, only the type is used.\n    IDynamoDBContext dynamoDBContext;\n}\n```\n\nIn this case, it will generate a class for `IDynamoDBContext` called `DynamoDBContextDecorator`. This feature will also work for your own interfaces if you prefer this approach instead of using the attribute.\n","funding_links":["https://github.com/sponsors/CodingFlow"],"categories":["Do not want to test 112 ( old ISourceGenerator )"],"sub_categories":["1. [ThisAssembly](https://ignatandrei.github.io/RSCG_Examples/v2/docs/ThisAssembly) , in the [EnhancementProject](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#enhancementproject) category"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCodingFlow%2Fdecorator-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FCodingFlow%2Fdecorator-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCodingFlow%2Fdecorator-generator/lists"}