{"id":13628990,"url":"https://github.com/DragonsLord/TypeUtilities","last_synced_at":"2025-04-17T04:32:43.875Z","repository":{"id":37014873,"uuid":"492012509","full_name":"DragonsLord/TypeUtilities","owner":"DragonsLord","description":null,"archived":false,"fork":false,"pushed_at":"2023-01-01T11:17:20.000Z","size":135,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-08T19:42:53.362Z","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/DragonsLord.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}},"created_at":"2022-05-13T19:08:36.000Z","updated_at":"2024-09-11T09:25:16.000Z","dependencies_parsed_at":"2023-01-17T13:30:21.624Z","dependency_job_id":null,"html_url":"https://github.com/DragonsLord/TypeUtilities","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DragonsLord%2FTypeUtilities","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DragonsLord%2FTypeUtilities/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DragonsLord%2FTypeUtilities/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DragonsLord%2FTypeUtilities/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DragonsLord","download_url":"https://codeload.github.com/DragonsLord/TypeUtilities/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249316014,"owners_count":21249874,"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:01.071Z","updated_at":"2025-04-17T04:32:39.808Z","avatar_url":"https://github.com/DragonsLord.png","language":"C#","funding_links":[],"categories":["Content"],"sub_categories":["127. [TypeUtilities](https://ignatandrei.github.io/RSCG_Examples/v2/docs/TypeUtilities) , in the [FunctionalProgramming](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#functionalprogramming) category"],"readme":"# TypeUtilities\n\n[![Build](https://github.com/DragonsLord/TypeUtilities/actions/workflows/build.yml/badge.svg)](https://github.com/DragonsLord/TypeUtilities/actions/workflows/build.yml)\n[![NuGet](https://img.shields.io/nuget/v/TypeUtilities.svg)](https://www.nuget.org/packages/TypeUtilities/)\n\nType Utilities provides a source generators to create/transform one type into another.\n\nThis project was inspired by the [TypeScript Utility Types](https://www.typescriptlang.org/docs/handbook/utility-types.html) and was ment to bring similar functionality to the C# via source generators\n\n## Installation\n\nTo use the the TypeUtilities, install the [TypeUtilities package](https://www.nuget.org/packages/TypeUtilities) into your project.\n\nTo install the packages, add the references to your _csproj_ file, for example by running\n\n```bash\ndotnet add package TypeUtilities\n```\n\nThis adds a `\u003cPackageReference\u003e` to your project.\n\n## Usage\n\nTypeUtilities provides several attributes:\n\n### Map\n\nMap Attribute simply maps memebers of the source type to the target type using specified format.\n\n```csharp\nusing TypeUtilities;\nusing TypeUtilities.Abstractions;\n\npublic class SourceType\n{\n    public Guid Id { get; }\n    public int Value { get; set; }\n    public DateTime Created { get; set; }\n}\n\n[Map(typeof(SourceType))]\npublic partial class SimpleMap\n{\n}\n\n// Generated result\n//----- SimpleMap.map.SourceType.g.cs\npublic partial class SimpleMap\n{\n    public System.Guid Id { get; }\n    public int Value { get; set; }\n    public System.DateTime Created { get; set; }\n}\n// --------------------\n\n[Map(typeof(SourceType),\n      MemberDeclarationFormat = $\"{Tokens.Accessibility} string Mapped{Tokens.Name}{Tokens.Accessors}\",\n      MemberKindSelection = MemberKindFlags.ReadonlyProperty\n    )]\npublic partial class AdvancedMap\n{\n}\n\n// Generated result\n//----- AdvancedMap.map.SourceType.g.cs\npublic partial class AdvancedMap\n{\n    public string MappedId { get; }\n}\n// --------------------\n```\n\nMore detailed description for Map is provided [here](docs/Map.md)\n\n### Omit\n\nOmit Attribute is similar to Map but also accepts an explicit list of members that should be exluded\n\n```csharp\nusing TypeUtilities;\n\npublic class SourceType\n{\n    public Guid Id { get; }\n    public int Value { get; set; }\n    public DateTime Created { get; set; }\n}\n\n[Omit(typeof(SourceType), \"Value\")]\npublic partial class TargetType\n{\n  public int MyValue { get; set; }\n}\n\n// Generated result\n//----- TargetType.omit.SourceType.g.cs\npublic partial class TargetType\n{\n    public Guid Id { get; }\n    public DateTime Created { get; set; }\n}\n```\n\n### Pick\n\nPick Attribute is similar to Map but also requires to explicitly specify all members that should be included\n\n```csharp\nusing TypeUtilities;\n\npublic class SourceType\n{\n    public Guid Id { get; }\n    public int Value { get; set; }\n    public DateTime Created { get; set; }\n}\n\n[Pick(typeof(SourceType), \"Id\", nameof(SourceType.Value))]\npublic partial class TargetType\n{\n}\n\n// Generated result\n//----- TargetType.omit.SourceType.g.cs\npublic partial class TargetType\n{\n    public Guid Id { get; }\n    public int Value { get; set; }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDragonsLord%2FTypeUtilities","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDragonsLord%2FTypeUtilities","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDragonsLord%2FTypeUtilities/lists"}