{"id":26800607,"url":"https://github.com/ktsu-dev/extensions","last_synced_at":"2026-02-14T03:31:40.884Z","repository":{"id":217431370,"uuid":"743826172","full_name":"ktsu-dev/Extensions","owner":"ktsu-dev","description":null,"archived":false,"fork":false,"pushed_at":"2026-02-01T05:06:48.000Z","size":722,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-01T16:37:11.968Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PowerShell","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":"2024-01-16T04:19:59.000Z","updated_at":"2026-02-01T05:03:15.000Z","dependencies_parsed_at":"2024-04-04T23:30:24.697Z","dependency_job_id":"078d855f-0f39-43f8-bd30-51946c25af5c","html_url":"https://github.com/ktsu-dev/Extensions","commit_stats":null,"previous_names":["ktsu-io/extensions","ktsu-dev/extensions"],"tags_count":139,"template":false,"template_full_name":null,"purl":"pkg:github/ktsu-dev/Extensions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktsu-dev%2FExtensions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktsu-dev%2FExtensions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktsu-dev%2FExtensions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktsu-dev%2FExtensions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ktsu-dev","download_url":"https://codeload.github.com/ktsu-dev/Extensions/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktsu-dev%2FExtensions/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29147365,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-06T02:39:25.012Z","status":"ssl_error","status_checked_at":"2026-02-06T02:37:22.784Z","response_time":59,"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:18:04.280Z","updated_at":"2026-02-06T03:01:08.875Z","avatar_url":"https://github.com/ktsu-dev.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ktsu.Extensions\n\n\u003e A comprehensive utility library of extension methods for collections, strings, dictionaries, and reflection in .NET.\n\n[![License](https://img.shields.io/github/license/ktsu-dev/Extensions)](https://github.com/ktsu-dev/Extensions/blob/main/LICENSE.md)\n[![NuGet](https://img.shields.io/nuget/v/ktsu.Extensions.svg)](https://www.nuget.org/packages/ktsu.Extensions/)\n[![NuGet Downloads](https://img.shields.io/nuget/dt/ktsu.Extensions.svg)](https://www.nuget.org/packages/ktsu.Extensions/)\n[![Build Status](https://github.com/ktsu-dev/Extensions/workflows/build/badge.svg)](https://github.com/ktsu-dev/Extensions/actions)\n[![GitHub Stars](https://img.shields.io/github/stars/ktsu-dev/Extensions?style=social)](https://github.com/ktsu-dev/Extensions/stargazers)\n\n## Introduction\n\n`ktsu.Extensions` is a utility library that enhances the functionality of standard .NET types through extension methods. It provides a wide range of utilities for batch operations, string manipulations, and reflection helpers, making it easier to work with common data structures and types in a consistent, null-safe manner.\n\n## Features\n\n- **Enumerable Extensions**\n  - `WithIndex`: Enumerates over an enumerable with the index of the item\n  - `ToCollection`: Converts an enumerable to a collection\n  - `ForEach`: Applies an action to each element of an enumerable\n  - `AnyNull`: Checks if the enumerable contains any null items\n  - `Join`: Concatenates elements with a separator\n  - `ToStringEnumerable`: Converts items to strings with null handling\n  - `WriteItemsToConsole`: Outputs collection items to the console\n\n- **Collection Extensions**\n  - `AddFrom`: Adds items from an enumerable to a collection\n  - `ReplaceWith`: Replaces all items in a collection with items from an enumerable\n\n- **Dictionary Extensions**\n  - `GetOrCreate`: Gets the value for a key or creates a new value if the key doesn't exist\n  - `AddOrReplace`: Adds a new value or replaces an existing value\n\n- **String Extensions**\n  - Ordinal comparison helpers (`StartsWithOrdinal`, `EndsWithOrdinal`, `ContainsOrdinal`)\n  - Prefix/suffix manipulation (`RemoveSuffix`, `RemovePrefix`)\n  - `ReplaceOrdinal`: Replaces text using ordinal comparison\n  - Line ending utilities (`DetermineLineEndings`, `NormalizeLineEndings`)\n\n- **Reflection Extensions**\n  - `TryFindMethod`: Searches for methods across inheritance hierarchies\n\n## Installation\n\n### Package Manager Console\n\n```powershell\nInstall-Package ktsu.Extensions\n```\n\n### .NET CLI\n\n```bash\ndotnet add package ktsu.Extensions\n```\n\n### Package Reference\n\n```xml\n\u003cPackageReference Include=\"ktsu.Extensions\" Version=\"x.y.z\" /\u003e\n```\n\n## Usage Examples\n\n### Enumerable Extensions\n\n```csharp\nusing ktsu.Extensions;\n\n// Iterate with index\nforeach (var (item, index) in myList.WithIndex())\n{\n    Console.WriteLine($\"Item at position {index}: {item}\");\n}\n\n// Apply action to each item\nmyList.ForEach(item =\u003e Console.WriteLine(item));\n\n// Check for nulls\nif (myList.AnyNull())\n{\n    Console.WriteLine(\"List contains null items\");\n}\n\n// Join items with a separator\nvar items = new[] { \"apple\", \"banana\", \"cherry\" };\nstring joined = items.Join(\", \");  // \"apple, banana, cherry\"\n\n// Convert to string enumerable\nvar numbers = new[] { 1, 2, 3 };\nvar strings = numbers.ToStringEnumerable();  // [\"1\", \"2\", \"3\"]\n```\n\n### String Extensions\n\n```csharp\nusing ktsu.Extensions;\n\nstring text = \"Hello, World!\";\n\n// Ordinal string comparisons\nif (text.StartsWithOrdinal(\"Hello\"))\n{\n    Console.WriteLine(\"Text starts with 'Hello'\");\n}\n\n// Prefix/suffix manipulation\nstring withoutPrefix = text.RemovePrefix(\"Hello, \");  // \"World!\"\nstring withoutSuffix = text.RemoveSuffix(\"!\");        // \"Hello, World\"\n\n// Line ending handling\nstring mixedText = \"Line1\\r\\nLine2\\nLine3\";\nvar lineEndingStyle = mixedText.DetermineLineEndings();  // LineEndingStyle.Mixed\nstring normalized = mixedText.NormalizeLineEndings(LineEndingStyle.Unix);  // All \\n\n```\n\n### Dictionary Extensions\n\n```csharp\nusing ktsu.Extensions;\n\nvar cache = new Dictionary\u003cstring, List\u003cstring\u003e\u003e();\n\n// Get or create a value (uses parameterless constructor)\nvar items = cache.GetOrCreate(\"key\");\nitems.Add(\"item1\");\n\n// Get or create with a specific default value\nvar otherItems = cache.GetOrCreate(\"key2\", new List\u003cstring\u003e { \"default\" });\n\n// Add or replace a value\ncache.AddOrReplace(\"key3\", new List\u003cstring\u003e { \"item2\" });\n```\n\n### Collection Extensions\n\n```csharp\nusing ktsu.Extensions;\n\nvar collection = new List\u003cstring\u003e();\n\n// Add multiple items at once\ncollection.AddFrom(new[] { \"item1\", \"item2\", \"item3\" });\n\n// Replace all items in the collection\ncollection.ReplaceWith(new[] { \"new1\", \"new2\" }); // Collection now contains only \"new1\" and \"new2\"\n```\n\n## Advanced Usage\n\n### Null Item Handling\n\n```csharp\nusing ktsu.Extensions;\n\nvar items = new[] { \"one\", null, \"three\" };\n\n// Convert to strings with null handling\nvar strings1 = items.ToStringEnumerable(NullItemHandling.Remove);   // [\"one\", \"three\"]\nvar strings2 = items.ToStringEnumerable(NullItemHandling.Include);  // [\"one\", null, \"three\"]\n// NullItemHandling.Throw will throw an exception if null items are found\n\n// Join with null handling\nvar joined = items.Join(\", \", NullItemHandling.Remove);  // \"one, three\"\n```\n\n### Reflection Helpers\n\n```csharp\nusing ktsu.Extensions;\nusing System.Reflection;\n\n// Find a method across inheritance hierarchy\nif (someType.TryFindMethod(\"MethodName\", BindingFlags.Instance | BindingFlags.Public, out var methodInfo))\n{\n    // Use the method info\n    methodInfo.Invoke(instance, parameters);\n}\n```\n\n## API Reference\n\n### Enumerable Extensions\n\n| Method | Description |\n|--------|-------------|\n| `WithIndex` | Enumerates with the index of each item |\n| `ToCollection` | Converts an enumerable to a collection |\n| `ForEach` | Applies an action to each element |\n| `AnyNull` | Checks if enumerable contains any null items |\n| `Join` | Concatenates elements with a separator |\n| `ToStringEnumerable` | Converts items to strings with null handling |\n| `WriteItemsToConsole` | Displays enumerable items in console |\n\n### String Extensions\n\n| Method | Description |\n|--------|-------------|\n| `StartsWithOrdinal` | Checks if string starts with value using ordinal comparison |\n| `EndsWithOrdinal` | Checks if string ends with value using ordinal comparison |\n| `ContainsOrdinal` | Checks if string contains value using ordinal comparison |\n| `RemovePrefix` | Removes a prefix from a string if present |\n| `RemoveSuffix` | Removes a suffix from a string if present |\n| `ReplaceOrdinal` | Replaces text using ordinal comparison |\n| `DetermineLineEndings` | Identifies line ending style in a string |\n| `NormalizeLineEndings` | Converts line endings to a specific style |\n\n### Collection Extensions\n\n| Method | Description |\n|--------|-------------|\n| `AddFrom` | Adds items from an enumerable to a collection |\n| `ReplaceWith` | Replaces all items in a collection with new items |\n\n### Dictionary Extensions\n\n| Method | Description |\n|--------|-------------|\n| `GetOrCreate` | Gets existing value or creates new one |\n| `AddOrReplace` | Adds a new value or replaces existing one |\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.\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%2Fextensions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fktsu-dev%2Fextensions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fktsu-dev%2Fextensions/lists"}