{"id":20633549,"url":"https://github.com/davidelettieri/visitor-generator","last_synced_at":"2026-04-22T07:36:07.059Z","repository":{"id":64769933,"uuid":"577895049","full_name":"davidelettieri/visitor-generator","owner":"davidelettieri","description":"A POC source generator that supports the implementation of the visitor pattern","archived":false,"fork":false,"pushed_at":"2025-05-07T13:50:37.000Z","size":65,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-07T14:48:56.879Z","etag":null,"topics":["csharp","source-generators","visitor-pattern"],"latest_commit_sha":null,"homepage":"https://davidelettieri.it/2023/03/18/Visitor-pattern-source-generator","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/davidelettieri.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-13T19:15:43.000Z","updated_at":"2025-05-07T13:50:41.000Z","dependencies_parsed_at":"2023-11-10T15:31:24.886Z","dependency_job_id":"9f3c9f8b-41e1-4091-9138-04f8f32f4d7e","html_url":"https://github.com/davidelettieri/visitor-generator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/davidelettieri/visitor-generator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidelettieri%2Fvisitor-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidelettieri%2Fvisitor-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidelettieri%2Fvisitor-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidelettieri%2Fvisitor-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidelettieri","download_url":"https://codeload.github.com/davidelettieri/visitor-generator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidelettieri%2Fvisitor-generator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32126197,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-22T00:31:26.853Z","status":"online","status_checked_at":"2026-04-22T02:00:05.693Z","response_time":58,"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","source-generators","visitor-pattern"],"created_at":"2024-11-16T14:20:57.258Z","updated_at":"2026-04-22T07:36:07.027Z","avatar_url":"https://github.com/davidelettieri.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# visitor-generator\n\nThe source generator allows to easily implement the visitor pattern. It is a proof of concepts and it requires the usage of partial interfaces and partial classes to implements the required methods.\n\nStarting point is an interface that all the nodes that we want to visit have to implement. For example\n\n```csharp\n[VisitorNode]\npublic partial interface INode\n{\n}\n```\n\nAfter this we need to define partial classes for all the nodes. For example \n\n```csharp\npublic partial class Success : INode { }\npublic partial class Failure : INode { }\n```\n\nWith these sample the generator will produce the following code\n\n```csharp\n// Augment the base interface with the required Accept method\npublic partial interface INode\n{\n    T Accept\u003cT\u003e(INodeVisitor\u003cT\u003e visitor);\n}\n\n// Definine the visitor interface\npublic interface INodeVisitor\u003cT\u003e\n{\n    T Visit(Success node);\n    T Visit(Failure node);\n}\n\n// Implement the Accept\u003cT\u003e method on the nodes\npublic partial class Success\n{\n    public T Accept\u003cT\u003e(INodeVisitor\u003cT\u003e visitor) =\u003e visitor.Visit(this);\n}\n\npublic partial class Failure\n{\n    public T Accept\u003cT\u003e(INodeVisitor\u003cT\u003e visitor) =\u003e visitor.Visit(this);\n}\n```\n\n## Using the package\n\nThe package is published here on github. Please follow the documentation to add the nuget source https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-nuget-registry\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidelettieri%2Fvisitor-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidelettieri%2Fvisitor-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidelettieri%2Fvisitor-generator/lists"}