{"id":17197216,"url":"https://github.com/thomaslevesque/quack","last_synced_at":"2025-04-13T20:50:59.963Z","repository":{"id":18855398,"uuid":"22071843","full_name":"thomaslevesque/Quack","owner":"thomaslevesque","description":"[POC] Duck-typing framework for .NET","archived":false,"fork":false,"pushed_at":"2014-11-07T02:21:39.000Z","size":164,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T11:13:11.926Z","etag":null,"topics":[],"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/thomaslevesque.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":"2014-07-21T16:34:28.000Z","updated_at":"2019-08-13T15:46:44.000Z","dependencies_parsed_at":"2022-07-12T22:10:30.228Z","dependency_job_id":null,"html_url":"https://github.com/thomaslevesque/Quack","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/thomaslevesque%2FQuack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomaslevesque%2FQuack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomaslevesque%2FQuack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomaslevesque%2FQuack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thomaslevesque","download_url":"https://codeload.github.com/thomaslevesque/Quack/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248782278,"owners_count":21160716,"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-10-15T01:55:49.101Z","updated_at":"2025-04-13T20:50:59.943Z","avatar_url":"https://github.com/thomaslevesque.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"Quack\n=====\n\n\u003e *“If it looks like a duck, swims like a duck, and quacks like a duck, then it probably is a duck.”*\n\nA very simple [duck-typing](http://en.wikipedia.org/wiki/Duck_typing) framework for .NET\n\nSuppose you have a class `Foo` that you don't own:\n\n```\npublic class Foo\n{\n    public int Id { get; }\n    public string Name { get; }\n\n    public void Frob() { ... }\n}\n```\n\nAn interface `IFoo` with the same members:\n\n```\npublic interface IFoo\n{\n    int Id { get; }\n    string Name { get; }\n\n    void Frob();\n}\n```\n\nAnd a method `UseFoo` that takes an `IFoo`:\n\n```\npublic void UseFoo(IFoo foo) { ... }\n```\n\nSince `Foo` doesn't implement `IFoo`, you can't pass it to `UseFoo`, even though it has all the correct members...\nThat's where [duck typing](http://en.wikipedia.org/wiki/Duck_typing) comes into play. C# doesn't natively support\nduck typing, but Quack lets you do this:\n\n\n```\nFoo foo = ...\nIFoo proxy = foo.DuckTypeAs\u003cIFoo\u003e();\nUseFoo(proxy)\n```\n\nQuack dynamically generates a proxy type that implements `IFoo` by calling the corresponding members in `Foo`. For better performance, the proxy type is generated once and cached per interface/target type couple.\n\n**Disclaimer**: this is a *very* early version, isn't fully tested (far from it), and has a few limitations:\n\n- it can only duck-type to an interface, not an abstract class\n- events are not supported yet\n- the signatures in the interface and the target type have to match exactly\n- both the interface and the target type have to be public\n- because it uses `Reflection.Emit`, it doesn't work with all .NET framework versions (e.g. it won't work in a PCL or a Windows Store app)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomaslevesque%2Fquack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthomaslevesque%2Fquack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomaslevesque%2Fquack/lists"}