{"id":13629690,"url":"https://github.com/robertturner/StaticProxyGenerator","last_synced_at":"2025-04-17T09:35:46.412Z","repository":{"id":143365902,"uuid":"291949032","full_name":"robertturner/StaticProxyGenerator","owner":"robertturner","description":null,"archived":false,"fork":false,"pushed_at":"2020-12-13T07:38:28.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-01T05:46:14.223Z","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/robertturner.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-01T09:03:10.000Z","updated_at":"2020-12-13T07:38:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"64bc007c-7c4e-4a87-9065-33b3196b23ef","html_url":"https://github.com/robertturner/StaticProxyGenerator","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/robertturner%2FStaticProxyGenerator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertturner%2FStaticProxyGenerator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertturner%2FStaticProxyGenerator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertturner%2FStaticProxyGenerator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robertturner","download_url":"https://codeload.github.com/robertturner/StaticProxyGenerator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223751370,"owners_count":17196625,"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:16.672Z","updated_at":"2024-11-08T20:31:43.495Z","avatar_url":"https://github.com/robertturner.png","language":"C#","funding_links":[],"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"],"readme":"# StaticProxyGenerator\nInterface proxy generator.\nAt compile time creates class that implements target interface. Instantiation of the generated class accepts an InterceptorHandler which is called for all method calls.\n\n## Example\n\n```\npublic interface IMyIfce\n{\n  Task\u003cstring\u003e AsyncMethod(string arg1);\n  Task MethodWithNoReturn(int arg1, string arg2);\n  void SyncMethodNoArgs();\n}\n```\nCreate proxy of interface:\n```\nobject interceptionHandler(object instance, MethodInfo method, object[] args, Type[] genericArguments)\n{\n    switch (method.Name)\n    {\n        case nameof(IMyIfce.AsyncMethod): \n            return Task.FromResult((string)args[0]);\n        ... \n    }\n}\n\n// Get instance of proxy\nIMyIfce ifceProxy = ProxyGeneratorHelpers.InstantiateProxy\u003cIMyIfce\u003e(interceptionHandler);\n```\nSuper happy place:\n```\nstring result = await ifceProxy.AsyncMethod(\"an arg\");\n...\nawait ifceProxy.MethodWithNoReturn(4, \"arg2\");\n...\nifceProxy.SyncMethodNoArgs();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertturner%2FStaticProxyGenerator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobertturner%2FStaticProxyGenerator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertturner%2FStaticProxyGenerator/lists"}