{"id":26800585,"url":"https://github.com/ktsu-dev/delegatetransform","last_synced_at":"2026-02-16T07:17:52.472Z","repository":{"id":271810474,"uuid":"914623457","full_name":"ktsu-dev/DelegateTransform","owner":"ktsu-dev","description":null,"archived":false,"fork":false,"pushed_at":"2026-02-14T01:51:12.000Z","size":305,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-14T08:26:21.437Z","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/ktsu-dev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.md","dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":"COPYRIGHT.md","agents":null,"dco":null,"cla":null}},"created_at":"2025-01-10T00:57:00.000Z","updated_at":"2026-02-14T01:49:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"a85dd867-b726-4649-b4ed-8a9d1dd0ddc6","html_url":"https://github.com/ktsu-dev/DelegateTransform","commit_stats":null,"previous_names":["ktsu-dev/delegatetransform"],"tags_count":59,"template":false,"template_full_name":null,"purl":"pkg:github/ktsu-dev/DelegateTransform","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktsu-dev%2FDelegateTransform","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktsu-dev%2FDelegateTransform/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktsu-dev%2FDelegateTransform/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktsu-dev%2FDelegateTransform/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ktsu-dev","download_url":"https://codeload.github.com/ktsu-dev/DelegateTransform/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktsu-dev%2FDelegateTransform/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29502934,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-16T05:57:17.024Z","status":"ssl_error","status_checked_at":"2026-02-16T05:56:49.929Z","response_time":115,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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-03-29T20:17:54.233Z","updated_at":"2026-02-16T07:17:52.456Z","avatar_url":"https://github.com/ktsu-dev.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ktsu.DelegateTransform\n\n\u003e A utility library for transforming values using delegates in C#.\n\n[![License](https://img.shields.io/github/license/ktsu-dev/DelegateTransform)](https://github.com/ktsu-dev/DelegateTransform/blob/main/LICENSE.md)\n[![NuGet](https://img.shields.io/nuget/v/ktsu.DelegateTransform.svg)](https://www.nuget.org/packages/ktsu.DelegateTransform/)\n[![NuGet Downloads](https://img.shields.io/nuget/dt/ktsu.DelegateTransform.svg)](https://www.nuget.org/packages/ktsu.DelegateTransform/)\n[![Build Status](https://github.com/ktsu-dev/DelegateTransform/workflows/build/badge.svg)](https://github.com/ktsu-dev/DelegateTransform/actions)\n[![GitHub Stars](https://img.shields.io/github/stars/ktsu-dev/DelegateTransform?style=social)](https://github.com/ktsu-dev/DelegateTransform/stargazers)\n\n## Introduction\n\nDelegateTransform is a utility library that provides methods for transforming values using various delegate types in C#. It offers a clean and efficient way to apply transformations using `ActionRef`, `Func`, and `FuncRef` delegates, making your code more readable and functional.\n\n**Important**: All `With` methods return a new transformed value - they never mutate the original input. This provides functional programming semantics even when using reference-based delegates.\n\n## Features\n\n- **ActionRef Transformations**: Modify copies of values by reference using action delegates\n- **Func Transformations**: Transform values using function delegates\n- **FuncRef Transformations**: Transform values by reference using function delegates that return values\n- **Copy-on-Transform**: Original values are never mutated\n- **Generic Implementation**: Works with any value or reference type\n\n## Supported Frameworks\n\n- .NET 10.0, 9.0, 8.0, 7.0, 6.0\n- .NET Standard 2.1\n\n## Installation\n\n### Package Manager Console\n\n```powershell\nInstall-Package ktsu.DelegateTransform\n```\n\n### .NET CLI\n\n```bash\ndotnet add package ktsu.DelegateTransform\n```\n\n### Package Reference\n\n```xml\n\u003cPackageReference Include=\"ktsu.DelegateTransform\" Version=\"x.y.z\" /\u003e\n```\n\n## Usage Examples\n\n### With ActionRef\n\nThe `With` method can be used with an `ActionRef\u003cT\u003e` delegate to apply a transformation by reference and return the result:\n\n```csharp\nusing ktsu.DelegateTransform;\n\nint input = 5;\nint result = DelegateTransform.With(input, (ref int x) =\u003e x *= 2);\n// result is 10, input is still 5 (original unchanged)\n```\n\n### With Func\n\nThe `With` method can be used with a `Func\u003cT, T\u003e` delegate to transform the input value:\n\n```csharp\nusing ktsu.DelegateTransform;\n\nint input = 5;\nint result = DelegateTransform.With(input, x =\u003e x * 2);\n// result is 10\n```\n\n### With FuncRef\n\nThe `With` method can be used with a `FuncRef\u003cT\u003e` delegate to transform the input value by reference:\n\n```csharp\nusing ktsu.DelegateTransform;\n\nint input = 5;\nint result = DelegateTransform.With(input, (ref int x) =\u003e x * x);\n// result is 25, input is still 5 (original unchanged)\n```\n\n### Chaining Transformations\n\nYou can chain multiple transformations by nesting calls:\n\n```csharp\nusing ktsu.DelegateTransform;\n\n// Starting value\nstring input = \"example\";\n\n// Chain of transformations\nstring step1 = DelegateTransform.With(input, s =\u003e s.ToUpper());           // \"EXAMPLE\"\nstring step2 = DelegateTransform.With(step1, s =\u003e s.Replace(\"EX\", \"**\")); // \"**AMPLE\"\nstring result = DelegateTransform.With(step2, s =\u003e s + \" transformed\");   // \"**AMPLE transformed\"\n\nConsole.WriteLine(result); // Outputs: **AMPLE transformed\n```\n\n### Complex Object Transformations\n\n```csharp\nusing ktsu.DelegateTransform;\n\nvar person = new Person { Name = \"John\", Age = 30 };\n\n// Transform using ActionRef (for reference types, the object is modified)\nPerson updatedPerson = DelegateTransform.With(person, (ref Person p) =\u003e {\n    p.Name = p.Name.ToUpper();\n    p.Age += 1;\n});\n\nConsole.WriteLine($\"{updatedPerson.Name}, {updatedPerson.Age}\"); // Outputs: JOHN, 31\n\n// Transform using Func to create a string description\nstring description = DelegateTransform.With(person, p =\u003e\n    $\"{p.Name} is {p.Age} years old\");\n\nConsole.WriteLine(description); // Outputs: JOHN is 31 years old\n```\n\n## API Reference\n\n### Delegate Types\n\n```csharp\n// Custom delegate for actions on references\npublic delegate void ActionRef\u003cT\u003e(ref T item);\n\n// Custom delegate for functions on references\npublic delegate T FuncRef\u003cT\u003e(ref T item);\n```\n\n### `DelegateTransform` Static Class\n\nThe main class providing transformation methods.\n\n#### Methods\n\n| Method | Parameters | Return Type | Description |\n|--------|------------|-------------|-------------|\n| `With\u003cT\u003e` | `T input, ActionRef\u003cT\u003e delegate` | `T` | Creates a copy, applies the action by reference, returns the modified copy |\n| `With\u003cT\u003e` | `T input, Func\u003cT, T\u003e delegate` | `T` | Applies a function to the input and returns the result |\n| `With\u003cT\u003e` | `T input, FuncRef\u003cT\u003e delegate` | `T` | Passes input by reference to the function and returns the result |\n\nAll methods throw `ArgumentNullException` if the delegate is null.\n\n## Design Principles\n\n### Copy-on-Transform\n\nThe library follows a functional programming pattern where the original input is never mutated:\n\n```csharp\npublic static T With\u003cT\u003e(T input, ActionRef\u003cT\u003e @delegate)\n{\n    Ensure.NotNull(@delegate);\n\n    T output = input;  // Creates a copy\n    @delegate(ref output);\n    return output;\n}\n```\n\nThis ensures predictable behavior and prevents side effects on the original values.\n\n### Performance Considerations\n\nFor value types (structs), a copy is made before transformation. For large structs where you want to avoid copying, consider using the `FuncRef\u003cT\u003e` overload which passes by reference and returns the modified value.\n\nFor reference types (classes), the \"copy\" is actually a copy of the reference, so the underlying object can be modified. If you need true immutability for reference types, create a new instance within your delegate.\n\n## Contributing\n\nContributions are welcome! Here's how you can help:\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add some amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\nPlease make sure to update tests as appropriate and adhere to the existing coding style.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fktsu-dev%2Fdelegatetransform","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fktsu-dev%2Fdelegatetransform","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fktsu-dev%2Fdelegatetransform/lists"}