{"id":30424834,"url":"https://github.com/oleg-shilo/AsyncIt","last_synced_at":"2025-08-22T11:04:23.596Z","repository":{"id":236934790,"uuid":"793457677","full_name":"oleg-shilo/AsyncIt","owner":"oleg-shilo","description":"C# code-generator analyzer for building Async/Sync API","archived":false,"fork":false,"pushed_at":"2024-08-16T02:46:52.000Z","size":187,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-16T20:52:33.627Z","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/oleg-shilo.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":"2024-04-29T09:02:39.000Z","updated_at":"2024-08-19T14:56:37.000Z","dependencies_parsed_at":"2024-05-19T14:23:56.584Z","dependency_job_id":"94b0bee3-f37a-4bc2-8d7d-180479afd14e","html_url":"https://github.com/oleg-shilo/AsyncIt","commit_stats":null,"previous_names":["oleg-shilo/asyncit"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/oleg-shilo/AsyncIt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleg-shilo%2FAsyncIt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleg-shilo%2FAsyncIt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleg-shilo%2FAsyncIt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleg-shilo%2FAsyncIt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oleg-shilo","download_url":"https://codeload.github.com/oleg-shilo/AsyncIt/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleg-shilo%2FAsyncIt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271628166,"owners_count":24792821,"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","status":"online","status_checked_at":"2025-08-22T02:00:08.480Z","response_time":65,"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":[],"created_at":"2025-08-22T11:02:18.103Z","updated_at":"2025-08-22T11:04:23.576Z","avatar_url":"https://github.com/oleg-shilo.png","language":"C#","funding_links":[],"categories":["Content"],"sub_categories":["208. [AsyncIt](https://ignatandrei.github.io/RSCG_Examples/v2/docs/AsyncIt) , in the [Async](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#async) category"],"readme":"# AsyncIt\r\n\r\nAsyncIt is a NuGet package library that allows the automatic generation of additional synchronous and asynchronous APIs for existing user codebase and external packages.\r\n\r\nIt aims to extend user-defined CLR types by automating the otherwise manual process of defining repetitive and straightforward routines. Thus, the development, maintenance and consumption of the released API are simplified due to the balanced (close to ideal) ratio of the synchronous and asynchronous API endpoints:\r\n\r\n\u0026nbsp;\u0026nbsp;\u0026nbsp;_**Every functionality point has both Async and Sync API endpoints available.**_\r\n\r\nThis content is an extract from the project's main [Wiki page](https://github.com/oleg-shilo/AsyncIt/wiki). It is highly recommended that you read it, as it explains the deep reasons behind this project and details the more concrete usage scenarios.\r\n\r\n## Overview\r\n\r\nAsyncIt is a source generator that is integrated into the .NET build process as a special tool type - the so-called \"Analyzer\". It is invoked by the compiler during the assembly build and allows the injection of missing API endpoints based on the present assembly API. Thus, if the assembly being built has the `GetStatus` but not the `GetStatusAsync` method, then AsyncIt will generate the missing method with a straightforward implementation. It can also generate the synchronous API if it is not present in the original codebase:\r\n\r\n- The API defines synchronous methods only:\r\n\r\n  _Original code_\r\n\r\n  ```C#\r\n  public partial class DeviceLib\r\n  {\r\n      public static string GetStatus() {. . .}\r\n  }\r\n  ```\r\n\r\n  _Code that is fed to the C# compiler_\r\n\r\n  ```C#\r\n  public partial class DeviceLib\r\n  {\r\n      public static string GetStatus() {. . .}\r\n  }\r\n\r\n  public partial class DeviceLib // AsyncIt generated\r\n  {\r\n      public static Task\u003cstring\u003e GetStatusAsync() \r\n          =\u003e TaskRun(() =\u003e GetStatus());\r\n  }\r\n  ```\r\n\r\nAsyncIt does not do anything fancy. Like the `await` keyword, it cannot magically convert a synchronous routine into an asynchronous one and vice versa. Instead, it simply emits the code that the developer would type manually if he/she decides to use the API in a concurrency way that the API author did not anticipate. \r\n\r\nAsyncIt can also be used to balance API of the external assemblies (e.g. .NET base classes, nuget packages)\r\n\r\nThis is where AsyncIt is placed in the overall .NET concurrency model architecture: \r\n\r\n![image](https://github.com/oleg-shilo/AsyncIt/assets/16729806/dec186b7-706b-4aee-817b-9e7472c46fc9)\r\n\r\n## Usage\r\n\r\nIn order to integrate AsyncIt with your .NET project, add AsyncIt Nuget package. \r\n\r\n```ps\r\ndotnet add package AsyncIt\r\n```\r\n\r\nThat's it. Now, you can mark any type for which you want to generate async/sync methods with the `[Async]` attribute (see the details below), and the new source code will be generated and included in the build. \r\n\r\nYou can always inspect the generated code in the Visual Studio solution explorer:   \r\n\r\n![image](https://github.com/oleg-shilo/AsyncIt/assets/16729806/fabed4b6-3eec-4421-a293-ed10fad4a950)\r\n\r\n\r\n###  Extending user-defined types\r\n\r\nIn this scenario, a user type containing sync/async methods is extended by additional source file(s) implementing additional API methods.\r\nThe type can be extended either with an additional partial class definition or by the extension methods class.\r\n\r\nA typical usage can be illustrated by the code below.\r\n\r\n_Async scenario:_\r\n \r\n```C#\r\n[Async]\r\npublic partial class BankService\r\n{\r\n    public partial class OrderService\r\n    {\r\n        public Order GetOrder(int id) // and GetOrderAsync will be created by AsyncIt\r\n        {...}\r\n    }\r\n}\r\n\r\n...\r\n\r\nasync Task OnButtonClick(object sender, EventArgs args)\r\n{\r\n    Order order = await service.GetOrderAsync(this.OrderId);\r\n    orderLabel.Text = order.Name;\r\n}\r\n```\r\n\r\n_Sync scenario:_\r\n\r\n```c#\r\n[Async(Interface = Interface.Sync)]\r\npartial class AccountService\r\n{\r\n    public async Task\u003cAccount\u003e GetAccountAsync(int id) // and GetAccount will be created by AsyncIt\r\n    {...}\r\n}\r\n\r\n...\r\n\r\nstatic void Main()\r\n{\r\n   var account = new AccountService().GetAccount(333);\r\n   \r\n   File.WriteAllText($\"account_{account.Id}.txt\", account.Balance.ToString());\r\n}\r\n```\r\n\r\n###  Extending external types\r\n\r\nIn this scenario, an external type (from a referenced assembly) containing sync/async methods is extended by additional source file(s) implementing additional API methods.\r\nThe type can be extended by the extension methods class.\r\n\r\nA typical usage can be illustrated by the code below for generating on-fly synchronous methods for type `HttpClient`  .\r\n\r\n_Async scenario:_\r\n \r\n```C#\r\n// For all synchronous methods of DirectoryInfo will be created an async equivalent by AsyncIt\r\n[assembly: AsyncExternal(typeof(DirectoryInfo), Interface.Async)] \r\n\r\n...\r\n\r\nasync Task OnButtonClick(object sender, EventArgs args)\r\n{\r\n    var info = new DirectoryInfo(workingDir);\r\n    \r\n    string[] folders = await info.GetDirectoriesAsync(\"*\", SearchOption.AllDirectories);\r\n\r\n    foreach(var path in folders)\r\n      foldersListBox.Add(path);\r\n}\r\n```\r\n\r\n_Sync scenario:_\r\n\r\n```c#\r\n// For all asynchronous methods of HttpClient will be created a sync equivalent by AsyncIt\r\n[assembly: AsyncExternal(typeof(HttpClient), Interface.Sync)];\r\n\r\n...\r\n\r\nstatic void Main() \r\n    =\u003e File.WriteAllText(\r\n           \"temperature.txt\", \r\n           new HttpClient().GetString(\"https://www.weather.com/au/melbourne/temperature\"));\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foleg-shilo%2FAsyncIt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foleg-shilo%2FAsyncIt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foleg-shilo%2FAsyncIt/lists"}