{"id":20879036,"url":"https://github.com/netfabric/netfabric.foreachex","last_synced_at":"2025-12-11T19:34:55.727Z","repository":{"id":197891259,"uuid":"699593088","full_name":"NetFabric/NetFabric.ForEachEx","owner":"NetFabric","description":"Enhances the functionality of the ForEach method, making it available for use with all types of collections.","archived":false,"fork":false,"pushed_at":"2023-11-09T20:55:35.000Z","size":85,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-19T09:42:33.658Z","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/NetFabric.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":"2023-10-02T23:58:51.000Z","updated_at":"2023-10-03T19:21:21.000Z","dependencies_parsed_at":"2025-01-19T09:42:20.392Z","dependency_job_id":"f64fd517-f0e9-4c92-b95c-e92dfc6fb3c0","html_url":"https://github.com/NetFabric/NetFabric.ForEachEx","commit_stats":null,"previous_names":["netfabric/netfabric.foreachex"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NetFabric%2FNetFabric.ForEachEx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NetFabric%2FNetFabric.ForEachEx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NetFabric%2FNetFabric.ForEachEx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NetFabric%2FNetFabric.ForEachEx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NetFabric","download_url":"https://codeload.github.com/NetFabric/NetFabric.ForEachEx/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243258138,"owners_count":20262295,"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-11-18T07:15:00.212Z","updated_at":"2025-12-11T19:34:55.658Z","avatar_url":"https://github.com/NetFabric.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NetFabric.ForEachEx\n\n## Overview\n\nThe NetFabric.ForEachEx package is a valuable addition to your .NET projects that enhances the functionality of the `ForEach` method, specifically designed for enumerables. With this package, you can seamlessly apply the `ForEachEx` method to various enumerable types, making your code cleaner, more concise, and more efficient.\n\n## Features\n\n- **Universal `ForEachEx`**: Apply the `ForEachEx` method to a wide range of enumerable types, including lists, arrays, spans, and more, simplifying your iteration code.\n\n- **Improved Readability**: Simplify your code by using a consistent `ForEachEx` syntax across different enumerable types, making it more readable and maintainable.\n\n- **Custom Value Actions**: Easily create custom value actions to perform operations on enumerable elements efficiently, all while avoiding heap allocations.\n\n- **Vectorization (SIMD) support**: Take advantage of vectorization (SIMD) support using `ForEachVectorEx` to improve the performance of your code.\n\n## Installation\n\nYou can easily add the NetFabric.ForEachEx package to your .NET project using NuGet Package Manager. Simply run the following command in your project directory:\n\n```bash\ndotnet add package NetFabric.ForEachEx\n```\n\n## Usage\n\nUsing NetFabric.ForEachEx is straightforward. First, ensure you've added the package to your project as described in the installation section.\n\nThen, you can import the `NetFabric` namespace and start using the enhanced `ForEachEx` method with various enumerable types:\n\n```csharp\nusing NetFabric;\n\n// ...\n\nvar myList = new List\u003cint\u003e { 1, 2, 3, 4, 5 };\n\nmyList.ForEachEx(item =\u003e Console.WriteLine(item));\n```\n\nThe `ForEachEx` method is now available for enumerable types, allowing you to iterate through and operate on their elements with ease.\n\nAdditionally, you can take advantage of custom value actions to perform specific operations on enumerable elements. Here's an example of how to create and use a custom value action:\n\n```csharp\nusing NetFabric;\n\n// Define a custom value action\npublic struct CustomValueAction\u003cT\u003e : IAction\u003cT\u003e\n{\n    private int count;\n\n    public CustomValueAction(int initialCount)\n    {\n        count = initialCount;\n    }\n\n    public void Invoke(T item)\n    {\n        // Implement your custom action here\n        Console.WriteLine($\"Item {count}: {item}\");\n        count++;\n    }\n}\n\n// ...\n\nvar values = new List\u003cint\u003e { 10, 20, 30, 40, 50 };\n\nvar customAction = new CustomValueAction\u003cint\u003e(1);\nvalues.ForEachEx(customAction); // Apply the custom action to the enumerable\n```\n\nIn this example, the `CustomValueAction\u003cT\u003e` struct is implemented to perform a custom action on each element of the `values` enumerable. You can define your logic inside the `Invoke` method of your custom value action.\n\nYou can also take advantage of vectorization (SIMD) support using the `ForEachVectorEx` method. Here's an example using the provided `SumValueAction` to summ all the items of the collection:\n\n```csharp\nusing NetFabric;\n\n// ...\n\nvar myList = new List\u003cint\u003e { 1, 2, 3, 4, 5 };\nvar action = new SumValueAction\u003cint\u003e();\nmyList.ForEachVectorEx(action);\nvar sum = action.Result;\n```\n\nYou can find how to implement a value action that support vectorization by checking the source code of the `SumValueAction` class.\n\nWith the NetFabric.ForEachEx package, you can easily apply the `ForEachEx` method to various enumerable types while also benefiting from the fact that value actions do not allocate on the heap, unlike lambda expressions. This can lead to improved memory efficiency in your code.\n\n## Benchmarks\n\nThe latest benchmarks for the NetFabric.ForEachEx package can be found in [BENCHMARKS.md](https://github.com/NetFabric/NetFabric.ForEachEx/blob/main/BENCHMARKS.md).\n\n## Contribution\n\nContributions are welcome! If you encounter issues or have suggestions for improvements, please feel free to open an issue or submit a pull request on our GitHub repository.\n\n## License\n\nThis package is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetfabric%2Fnetfabric.foreachex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetfabric%2Fnetfabric.foreachex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetfabric%2Fnetfabric.foreachex/lists"}