{"id":22131772,"url":"https://github.com/laicasaane/typewrap","last_synced_at":"2026-05-04T02:39:10.243Z","repository":{"id":265345166,"uuid":"759726573","full_name":"laicasaane/TypeWrap","owner":"laicasaane","description":"C# source generator to simplify the creation of wrapper types.","archived":false,"fork":false,"pushed_at":"2026-02-03T07:07:59.000Z","size":750,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-24T01:41:04.546Z","etag":null,"topics":["source-generator","type-library","unity3d","wrapper","wrapping"],"latest_commit_sha":null,"homepage":"","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/laicasaane.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["laicasaane"]}},"created_at":"2024-02-19T08:13:41.000Z","updated_at":"2026-02-03T07:07:56.000Z","dependencies_parsed_at":"2024-11-29T02:14:15.645Z","dependency_job_id":"2241626c-50e9-4cda-aecc-61644e135d07","html_url":"https://github.com/laicasaane/TypeWrap","commit_stats":null,"previous_names":["laicasaane/typewrap"],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/laicasaane/TypeWrap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laicasaane%2FTypeWrap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laicasaane%2FTypeWrap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laicasaane%2FTypeWrap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laicasaane%2FTypeWrap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/laicasaane","download_url":"https://codeload.github.com/laicasaane/TypeWrap/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laicasaane%2FTypeWrap/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32592719,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T22:12:39.696Z","status":"online","status_checked_at":"2026-05-04T02:00:06.625Z","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":["source-generator","type-library","unity3d","wrapper","wrapping"],"created_at":"2024-12-01T18:37:22.965Z","updated_at":"2026-05-04T02:39:10.238Z","avatar_url":"https://github.com/laicasaane.png","language":"C#","funding_links":["https://github.com/sponsors/laicasaane"],"categories":[],"sub_categories":[],"readme":"# TypeWrap\n\nThis library utilizes Roslyn Source Generator to generate type wrappers for any C# type.\n\n## Features\n\n- Any C# type can be wrapped, with an exception of `dynamic`.\n- Wrappers can be a `struct`, a `class`, or a `record`.\n    - A `record` wrapper can also be generic if needed.\n- Wrappers have `implicit` and `explicit` operators to convert between itself and the original type.\n- All public members of the original type are exposed in the wrapper. Supported members are fields, properties,\n  events, indexers, methods, and operators.\n- `IEquatable\u003cT\u003e` and `IComparable\u003cT\u003e` are implemented for the wrapper if the original type allows them.\n- Equality operators (`==`, `!=`) are overloaded for the wrapper if the original type allows them.\n\n## Installation\n\n### Requirements\n\n- Unity 2022.3 or later\n\n### Unity Package Manager\n\n1. Open menu `Window` -\u003e `Package Manager`.\n2. Click the `+` button at the top-left corner, then choose `Add package from git URL...`.\n\n    ![add package by git url](imgs/add-package-by-git-url-1.png)\n\n3. Enter the package URL \n    ```\n    https://github.com/laicasaane/TypeWrap.git?path=/Packages/com.laicasaane.typewrap#1.2.5\n    ```\n\n    ![enter git url then press add button](imgs/add-package-by-git-url-2.png)\n\n### OpenUPM\n\n1. Install [OpenUPM CLI](https://openupm.com/docs/getting-started.html#installing-openupm-cli).\n2. Run the following command in your Unity project root directory:\n\n```sh\nopenupm add com.laicasaane.typewrap\n```\n\n## Usage\n\n### [WrapType] Attribute\n\n- Use this attribute if the wrapper itself is either a `struct` or a `class`.\n    - In case of a `class`, it must not inherit from any other class.\n    - The wrapper must be `partial`.\n- By default, the underlying type name is `value`. You can change it by specifying the `memberName` argument.\n- By default, a type converter is generated for the wrapper. You can exclude it by specifying the `ExcludeConverter` property.\n\n```cs\n[WrapType(typeof(int))]\npublic partial struct IntWrapper { }\n\n[WrapType(typeof(List\u003cint\u003e), memberName: \"wrappedList\")]\npublic partial class ListInt { }\n\n[WrapType(typeof(IDisposable), ExcludeConverter = true)]\npublic readonly partial struct DisposableObject { }\n```\n\n### [WrapRecord] Attribute\n\n- Use this attribute if the wrapper itself is either a `record struct` or a `record class`.\n    - In case of a `record class`, it must not inherit from any other class.\n    - The wrapper must be `partial`.\n- The primary constructor of the record must have exactly 1 parameter.\n- By default, a type converter is generated for the wrapper.\n  You can exclude it by specifying the `ExcludeConverter` property.\n\n```cs\n[WrapRecord(ExcludeConverter = true)]\npublic partial record struct IntWrapper(int Value);\n\n[WrapRecord]\npublic partial record class ListT\u003cT\u003e(List\u003cT\u003e _);\n\n[WrapRecord]\npublic readonly partial record struct Coord2D(Vector2Int _);\n```\n\n### A sample for generated code\n\n- For this user-written code:\n\n  ```cs\n  public enum FruitKind { Apple, Banana, Orange, }\n\n  [WrapRecord]\n  public readonly partial record struct FruitKindValue(FruitKind _);\n  ```\n\n- Source generator will emit something like this:\n\n  [FruitKindValue.g.cs](docs/FruitKindValue.g.cs)\n\n\u003e [!NOTE]\n\u003e The file above has been sanitized to a degree to improve readability within this tutorial.\n\u003e The actual generated code includes additional attributes and fully qualified type names\n\u003e to ensure correctness and avoid ambiguities.\n\n## Notes\n\n- To have `record` in Unity, you'll need\n  - Unity 2022.3 or later\n  - Enable `C# 10` feature by placing this\n  [`csc.rsp`](Packages/com.laicasaane.typewrap/Samples~/TypeWrap.Samples/csc.rsp) file inside your `Assets` folder.\n    - Or better: place it inside the folder that contains an Assembly Definition (`.asmdef` file).\n\n- To have `readonly record` in any assembly (or `.asmdef`):\n  - Copy this [`IsExternalInit.cs`](Packages/com.laicasaane.typewrap/Samples~/TypeWrap.Samples/IsExternalInit.cs) file\n  into that assembly.\n    - Or better: copy to the core assembly which is referenced by other assemblies.\n\n- You might also want to place this [`Directory.Build.props`](Directory.Build.props) file in your `Assets`\n  **and** the root of your project to enable the `C# 10` feature for the code editor.\n\n\u003e [!IMPORTANT]\n\u003e If you're using Visual Studio or VSCode and have installed packagg [`com.unity.ide.visualstudio`][vspackage2_0_24]\n\u003e version `2.0.24` or later, you don't need `Directory.Build.props` file. Because the compiler option `-langversion`\n\u003e specified in `csc.rsp` file will be respected and applied to the generated `.csproj` files.\n\u003e\n\n[vspackage2_0_24]: https://docs.unity3d.com/Packages/com.unity.ide.visualstudio@2.0/changelog/CHANGELOG.html#2024---2025-09-04\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaicasaane%2Ftypewrap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flaicasaane%2Ftypewrap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaicasaane%2Ftypewrap/lists"}