{"id":13629646,"url":"https://github.com/Yeah69/MrMeeseeks.Visitor","last_synced_at":"2025-04-17T09:35:24.143Z","repository":{"id":156604369,"uuid":"622201267","full_name":"Yeah69/MrMeeseeks.Visitor","owner":"Yeah69","description":null,"archived":false,"fork":false,"pushed_at":"2023-04-26T19:10:45.000Z","size":38,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-09-30T15:29:13.970Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/Yeah69.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2023-04-01T12:25:58.000Z","updated_at":"2023-06-14T01:49:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"4d5886da-aafa-4f8a-bd74-aa9b2824737b","html_url":"https://github.com/Yeah69/MrMeeseeks.Visitor","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yeah69%2FMrMeeseeks.Visitor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yeah69%2FMrMeeseeks.Visitor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yeah69%2FMrMeeseeks.Visitor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yeah69%2FMrMeeseeks.Visitor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Yeah69","download_url":"https://codeload.github.com/Yeah69/MrMeeseeks.Visitor/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223285862,"owners_count":17119971,"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":[],"created_at":"2024-08-01T22:01:15.630Z","updated_at":"2024-11-08T20:31:32.809Z","avatar_url":"https://github.com/Yeah69.png","language":"C#","readme":"# MrMeeseeks.Visitor\n\nIf you like the Visitor pattern, but don't like to write the boilerplate code for it, then search no more. This Mr. Meeseeks will help you with that.\n\nThis is a source generator which generates the boilerplate code for the [Visitor Pattern](https://en.wikipedia.org/wiki/Visitor_pattern).\n\n## Nuget\n\nThe easiest way to use DIE is to get it via nuget. Here is the package page:\n\n[https://www.nuget.org/packages/MrMeeseeks.Visitor/](https://www.nuget.org/packages/MrMeeseeks.Visitor/)\n\nEither search for `MrMeeseeks.Visitor` in the nuget manager of the IDE of your choice.\n\nOr call the following PowerShell command:\n\n```powershell\nInstall-Package MrMeeseeks.Visitor\n```\n\n\nAlternatively, you can use `dotnet`:\n\n```sh\ndotnet add [your project] package MrMeeseeks.Visitor\n```\n\nOr manually add the package reference to the target `.csproj`:\n\n```xml\n\u003cPackageReference Include=\"MrMeeseeks.Visitor\" Version=\"[preferrably the current version]\" /\u003e\n```\n\n## Usage\n\nThe usage is very simple. You just need to declare a visitor interface, an base interface for the elements, an interface for each element and an implementation for each element.\nThen you just need to add a `VisitorInterfacePair` attribute with the visitor interface and the element interface types as input.\nAs long as the visitor interface, the element interface and the element implementations are partial, this source generator will generate the boilerplate code for you.\n\nHere is an example of the manual effort:\n\n```csharp\nnamespace MrMeeseeks.Visitor.Sample;\n\n[VisitorInterface(typeof(IElement))]\npublic partial interface IVisitor { }\n\npublic partial interface IElement { }\n\npublic interface IElementA : IElement { }\n\npublic partial class ElementA : IElementA { }\n\npublic interface IElementB : IElement { }\n\npublic partial class ElementB : IElementB { }\n\npublic interface IElementC : IElement { }\n\npublic partial class ElementC : IElementC { }\n```\n\nHere is what will be generated. Visitor interface:\n\n```csharp\nnamespace MrMeeseeks.Visitor.Sample\n{\n    partial interface IVisitor\n    {\n        void VisitIElementA(global::MrMeeseeks.Visitor.Sample.IElementA element);\n        void VisitIElementC(global::MrMeeseeks.Visitor.Sample.IElementC element);\n        void VisitIElementB(global::MrMeeseeks.Visitor.Sample.IElementB element);\n    }\n}\n```\n\nElement interface:\n\n```csharp\nnamespace MrMeeseeks.Visitor.Sample\n{\n    partial interface IElement\n    {\n        void Accept(global::MrMeeseeks.Visitor.Sample.IVisitor visitor);\n    }\n}\n```\n\nOne of the element implementations:\n\n```csharp\nnamespace MrMeeseeks.Visitor.Sample\n{\n    partial class ElementA\n    {\n        public void Accept(global::MrMeeseeks.Visitor.Sample.IVisitor visitor)\n        {\n            visitor.VisitIElementA(this);\n        }\n    }\n}\n```","funding_links":[],"categories":["Source Generators","Do not want to test 112 ( old ISourceGenerator )"],"sub_categories":["Patterns","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%2FYeah69%2FMrMeeseeks.Visitor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FYeah69%2FMrMeeseeks.Visitor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FYeah69%2FMrMeeseeks.Visitor/lists"}