{"id":37048020,"url":"https://github.com/sankdeveloper/short-sharp","last_synced_at":"2026-01-14T05:37:09.304Z","repository":{"id":63757761,"uuid":"569576642","full_name":"sankdeveloper/short-sharp","owner":"sankdeveloper","description":"ShortSharp(Your short code helper) is a day to day used C# Helper utility around the most common wrappers.","archived":false,"fork":false,"pushed_at":"2022-12-28T05:13:31.000Z","size":742,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-29T01:08:23.060Z","etag":null,"topics":["csharp","dotnet","extension-methods","json"],"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/sankdeveloper.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-11-23T06:21:26.000Z","updated_at":"2023-01-02T04:56:54.000Z","dependencies_parsed_at":"2023-01-31T05:45:38.708Z","dependency_job_id":null,"html_url":"https://github.com/sankdeveloper/short-sharp","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/sankdeveloper/short-sharp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sankdeveloper%2Fshort-sharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sankdeveloper%2Fshort-sharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sankdeveloper%2Fshort-sharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sankdeveloper%2Fshort-sharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sankdeveloper","download_url":"https://codeload.github.com/sankdeveloper/short-sharp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sankdeveloper%2Fshort-sharp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28410844,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T05:26:33.345Z","status":"ssl_error","status_checked_at":"2026-01-14T05:21:57.251Z","response_time":107,"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":["csharp","dotnet","extension-methods","json"],"created_at":"2026-01-14T05:37:08.536Z","updated_at":"2026-01-14T05:37:09.294Z","avatar_url":"https://github.com/sankdeveloper.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n[![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](https://choosealicense.com/licenses/mit/)\n![Nuget](https://img.shields.io/nuget/dt/ShortSharp?color=grn)\n![Maintained - yes](https://img.shields.io/badge/Maintained-yes-green)\n[![dotnet package](https://github.com/sankdeveloper/short-sharp/actions/workflows/main.yml/badge.svg)](https://github.com/sankdeveloper/short-sharp/actions/workflows/main.yml)\n![Contributions - welcome](https://img.shields.io/badge/Contributions-welcome-blueviolet)\n![docs.rs](https://img.shields.io/docsrs/s)\n![GitHub issues](https://img.shields.io/github/issues-raw/sankdeveloper/short-sharp)\n![GitHub last commit (branch)](https://img.shields.io/github/last-commit/sankdeveloper/short-sharp/main)\n\n# \u003cimg align=\"left\" width=\"100\" height=\"100\" src=\"https://github.com/sankdeveloper/short-sharp/blob/main/ShortSharp/src/ShortSharp/logo.png?raw=true\"/\u003eShortSharp\n\nShortSharp(Your short code helper) is a day to day used C# Helper utility around the most common wrappers !!!\n\u003c/br\u003eLet us handle the most common code for your applications supporting, `Asp.net`, `Blazor`, `Webform`, `Xamarin` and plus in almost all type of C# applications that are targeted to `\u003e=net6`.\n\n## Installation\n\n```bash\n  Install-Package ShortSharp\n```\n\n```bash\n  dotnet add package ShortSharp --version 1.x.x\n```\n\n```bash\n  \u003cPackageReference Include=\"ShortSharp\" Version=\"1.x.x\" /\u003e\n```\n    \n## API Reference\n\n### ☞ Advance **Looping**\n```csharp\nforeach (var i in 5..10)\n{\n  // var index = 5; index \u003c result.Count; index++\n}\n```\n```csharp\nforeach (var i in ..10)\n{\n  // iterate 0 to x\n}\n```\n```csharp\nforeach (var i in 10)\n{\n  // iterate 0 to x\n}\n```\n\n### ☞ Utilities\n##### **Simple In-memory job scheduler**\n```csharp\nBackgroundCronJobScheduler.Instance.ScheduleNew(\n\t\tjobFunction: () =\u003e System.WriteLine(\"Task exeecuted\"),\n\t\tcrownIntervalInMinutes: 1);\n```\n##### **In-Memory File**\n```csharp\n// Create, Read, Write in memory file without creating on physical Disk based on UTF8-Encoding.\nInMemoryFile inMemoryFile = new();\n\n// Write fresh content to file.\ninMemoryFile.WriteContent(\"old\");\nawait inMemoryFile.WriteContentAsync(\"new\");\n\n// Append string content to file.(output: \"new-appended\")\nawait inMemoryFile.AppendContentAsync(\"-appended\");\n\n// Read all content of file.\nstring content = inMemoryFile.ReadContent();\nstring contentAsync = await inMemoryFile.ReadContentAsync();\n\n// Save content to physical file\ninMemoryFile.SaveAsFile(\"D:\\\\test.txt\");\nawait inMemoryFile.SaveAsFileAsync(\"D:\\\\test.txt\");\n\n// Clear content of the file.\ninMemoryFile.ClearFile();\n```\n\n### ☞ Helpers\n##### **Reflections**\n| Parameter | Type     | Description                |\n| :-------- | :------- | :------------------------- |\n| `Reflection.GetPublicPropertyNames\u003cTClass\u003e()` | `IEnumerable\u003cstring\u003e` | Read all properties of TClass |\n| `Reflection.GetPublicPropertyValues\u003cTClass\u003e(object)` | `IReadOnlyDictionary\u003cstring, object?\u003e` | Read all properties and values of TClass reference |\n\n### ☞ Json\n##### **Json Reader/Writer $\\textcolor{green}{(1.3.0)}$** \n| On | Type  | Returns | Description |\n| :-------- | :---- | :------------------------- |:------------------------- |\n|`object`|`.ToJson(bool indented = true)`|`string`| Converts a Type to a JSON string. |\n|`object`|`.ToJson(JsonSerializerOptions options)`|`string`| Converts a Type to a JSON string. |\n|`object`|`.ToJsonFileAsync(string fileName)`|`void`| Writes a Type to a JSON File. |\n|`FileInfo`|`.ReadJsonFileAsync\u003cT\u003e()`|`T`| Read a JSON File to strongly typed `T`. |\n|`FileInfo`|`.WriteJsonDataAsync()`|`void`| Writes a JSON File. |\n|`fileName as string`|`.ReadJsonFileAsync\u003cT\u003e()`|`T`| Read a JSON File to strongly typed `T` type. |\n| `string` | `.IsValidJson()` $\\textcolor{green}{(1.5.1)}$  | `bool` | Returns `true` if json string is valid else `false`. |\n\n```csharp\nstring validJson = \"{\\\"name\\\": \\\"John\\\", \\\"age\\\": 30, \\\"city\\\": \\\"New York\\\"}\";\nvalidJson.IsValidJson(); // returns true\n```\n\n##### **Json Converters**\n| Parameter | Description                |\n| :-------- | :------------------------- |\n| `DateTimeStringConverter` | datetime-in-string converter |\n| `IntConverter` | int-in-string converter |\n| `DynamicNestedObjectConverter` | dynamic object to Dictionary converter |\n\n```csharp\n// String format: \"2022-10-21\" (YYYY-mm-dd)\n[JsonPropertyName(\"date\")]\n[JsonConverter(typeof(DateTimeStringConverter))]\npublic DateTime Date { get; set; }\n\n// String format: \"123654789\"\n[JsonPropertyName(\"id\")]\n[JsonConverter(typeof(IntConverter))]\npublic int IntegerId { get; set; }\n\n// String format: {'prop1': {'one': 1}', 'prop2': {'two': 2}'.......}\n[JsonPropertyName(\"object\")]\n[JsonConverter(typeof(DynamicNestedObjectConverter))]\npublic IReadOnlyDictionary\u003cstring, dynamic\u003e\u003e DynamicObject { get; set; }\n```\n\n\n### ☞ Extensions\n##### **IEnumerable**\n```csharp\n// Also applies to all implemented collections\n// e.g. List, ICollection, IQuerable etc.\nprivate readonly List\u003cstring\u003e _list = new() { \"One\", \"Two\", \"Three\", \"Four\", \"Five\" };\nprivate IEnumerable\u003cTask\u003cT\u003e\u003e asyncTasks = new List() { Task1, Task2.............. Task_n};\n```\n| Parameter | Description                |\n| :-------- | :------------------------- |\n| `_list.ForEach()` | Like `List.ForEach()` but slightly better in terms of iterations using `IEnumerator`. |\n| `_list.ForEachWithReturn()` | Like `List.ForEach()` but with _returning_ back an new `IEnumerable` collection. |\n| `_list.PickRandom()` | Gets any one random item. |\n| `_list.PickRandom(n)` | Gets random 'n' number of items. |\n| `_list.Shuffle()` | Shuffle the list items. |\n| `_list.Shuffle(nTimes)` | Shuffle the list items n-times. |\n| `_list.Join(saperator: \",\")` | Gets back a string with coma saperated words. |\n| `_list.ToCsv()` $\\textcolor{green}{(1.5.0)}$ | Converts an `IEnumerable` to CSV formated `string`. |\n| `asyncTasks.WhenAllAsync()` | Wait till all task finishes. |\n| `asyncTasks.WhenAllSequentialAsync()` | Wait till all task finishes 'sequencially'. |\n| `asyncTasks.WhenAllByChunkAsync(chunkSize: 2)` | Process tasks by chunk(just like Pagination, e.g process 2 tasks at a time). |\n\n\n##### **ICollection**\n```csharp\n// Also applies to all implemented collections\n// e.g. List, ICollection, IQuerable etc.\nprivate readonly ICollection\u003cstring\u003e _list = new List\u003cstring\u003e { \"One\", \"Two\", \"Three\", \"Four\", \"Five\" };\n```\n| Parameter | Type  | Description                |\n| :-------- | :---- | :------------------------- |\n| `_list.AddIf(predicate, value) / _list.RemoveIf(predicate, value)` | `bool` | Adds/removes only if the value satisfies the predicate. |\n| `_list.AddIfNotContains(value)` | `bool` | Add value if the ICollection doesn't contains it already. |\n| `_list.AddRange(v1, v2...) / _list.RemoveRange(v1, v2...)` | `void` | Adds/removes a range to 'values'. |\n| `_list.AddRangeIf(predicate, v1, v2...) / _list.RemoveRangeIf(predicate, v1, v2...)` | `void` | Adds/ removes a collection of objects to the end of this collection only for value who satisfies the predicate. |\n| `_list.RemoveWhere(predicate)` | `void` | Removes value that satisfies the predicate. |\n\n\n##### **IDictionary**\n```csharp\nprivate Dictionary\u003cstring, string\u003e _dictionary = new();\n```\n| Parameter | Type  | Description                |\n| :-------- | :---- | :------------------------- |\n| `_dictionary.AddIfNotContainsKey(key, value)` | `bool` | Adds if not contains key. |\n| `_dictionary.RemoveIfContainsKey(key)` | `bool` | Removes if contains key. |\n| `_dictionary.UpsertByKey(key, value)` | `value` | Add if the key does not already exist, or to update a key/value pair in the IDictionary\u0026lt;TKey, TValue\u0026gt;\u003e if the key already exists. |\n| `_dictionary.GetOrAdd(predicate, value)` | `value` | Adds a key/value pair if the key does not already exist. |\n| `_dictionary.RemoveIfContainsKey(predicate, value)` | `void` | Removes if contains key. |\n\n##### **Boolean** Extensions\n```csharp\nbool str = true;\n```\n| Parameter | Type     | Description                |\n| :-------- | :------- | :------------------------- |\n| `str.AsYOrN()` | `string` |  Returns Char 'Y' for true, 'N' for false. |\n| `str.AsYesOrNo()` | `string` |  Returns string 'Yes' for true, 'No' for false. |\n| `str.As0Or1()` | `string` |  Returns int '1' for true, '0' for false. |\n| `str.AsZeroOrOne()` | `string` |  Returns Char 'Zero' for true, 'One' for false. |\n\n\n##### **DateTime** Extensions\n```csharp\nDateTime dt = new DateTime();\n```\n| Parameter | Type     | Description                |\n| :-------- | :------- | :------------------------- |\n| `dt.IsValid()` | `bool` | Is falling in valid date time range |\n| `dt.AssumeUniversalTime()` | `DateTime` | Assumes to DateTimeKind.Utc for current date-time |\n| `dt.ToJavaScriptTicks()` | `long` | Gets javascript date-time. |\n\n\n##### **Enum** Extensions\n```csharp\nenum Level \n{\n  [Description(\"Low Level description\")] \n  Low,\n  \n  [Description(\"Medium Level description\")] \n  Medium,\n  \n  [Description(\"High Level description\")] \n  High\n}\n\nLevel @enum = Level.Medium;\n```\n| Parameter | Type     | Description                |\n| :-------- | :------- | :------------------------- |\n| `@enum.GetDescription()` | `string` |Get description attribute value |\n| `@enum.GetDescriptions()` | `IEnumerable\u003cstring\u003e` | Get multiple description attribute value |\n| `EnumExtensions.ToDictionary(Level)` | `Dictionary\u003cstring, string\u003e` | Converts to dictionary |\n\n\n##### **QueryString** Extensions\n```csharp\nvar urlLink = \"http://www.my-url/users?type=xyz\";\nUri uri = new Uri(urlLink);\n```\n| Parameter | Type     | Description                |\n| :-------- | :------- | :------------------------- |\n| `uri.QueryString()` | `NameValueCollection` | get entire querystring name/value collection |\n| `urlLink.QueryString()` | `NameValueCollection` | get entire querystring name/value collection |\n| `uri.TryGetQueryStringParam(paramKey)` | `string?` | get single querystring value with specified key |\n| `urlLink.TryGetQueryStringParam()` | `string?` | get single querystring value with specified key |\n\n##### **OI** Extensions $\\textcolor{green}{(1.2.1)}$\n| On | Type  | Returns | Description |\n| :-------- | :---- | :------------------------- |:------------------------- |\n|`string`|`ToDirectoryInfo()`|`DirectoryInfo`| Converts to directory |\n|`DirectoryInfo`|`Clear()`|`void`| A DirectoryInfo extension method that clears all files and directories in this directory.|\n|`DirectoryInfo`|`DeleteDirectoriesWhere(predicate)`|`void`| A DirectoryInfo extension method that deletes the directories where. |\n|`DirectoryInfo`|`DeleteDirectoriesWhere(predicate, searchOption, searchPattern = \"*.*\")`|`void`| A DirectoryInfo extension method that deletes the directories where. |\n|`DirectoryInfo`|`DeleteFilesWhere(predicate)`|`void`| A DirectoryInfo extension method that deletes the files where. |\n|`DirectoryInfo`|`DeleteFilesWhere(predicate, searchOption, searchPattern = \"*.*\")`|`void`| A DirectoryInfo extension method that deletes the files where. |\n|`DirectoryInfo`|`DeleteOlderThan(DateTime minDate, searchOption, searchPattern = \"*.*\")`|`void`| A DirectoryInfo extension method that deletes the older than. |\n|`DirectoryInfo`|`EnsureDirectoryExists()`|`DirectoryInfo`| Creates all directories and subdirectories in the specified @this if the directory doesn't already exists. This methods is the same as FileInfo.CreateDirectory however it's less ambigues about what happen if the directory already exists. |\n|`DirectoryInfo`|`EnumerateDirectories(string searchPattern = \"*.*\", SearchOption searchOption = SearchOption.TopDirectoryOnly)`|`IEnumerable\u003cDirectoryInfo\u003e`| Enumerate directories|\n|`DirectoryInfo`|`GetDirectories(string searchPatterns, SearchOption searchOption)`|`DirectoryInfo[]`| Get all directories |\n|`DirectoryInfo`|`GetDirectories(string[] searchPatterns, SearchOption searchOption)`|`DirectoryInfo[]`| Get all directories |\n|`DirectoryInfo`|`GetFiles(string searchPatterns = \"*.*\", SearchOption searchOption = SearchOption.TopDirectoryOnly)`|`FileInfo[]`| Get all files |\n|`DirectoryInfo`|`GetFiles(string[] searchPatterns, SearchOption searchOption = SearchOption.TopDirectoryOnly)`|`FileInfo[]`| Get all files |\n|`DirectoryInfo`|`GetFilesWhere(Func\u003cFileInfo, bool\u003e predicate, string searchPattern = \"*.*\", SearchOption searchOption = SearchOption.TopDirectoryOnly)`|`FileInfo[]`| Get all files with Where predicate having true/false. |\n|`DirectoryInfo`|`PathCombine(params string[] paths)`|`string`| Combines multiples string into a path. |\n|`DirectoryInfo`|`PathCombineFile(params string[] paths)`|`FileInfo`| Combines multiples string into a 'File' path. |\n|`DirectoryInfo`|`EnumerateFiles(string searchPattern = \"*.*\", SearchOption searchOption = SearchOption.TopDirectoryOnly)`|`IEnumerable\u003cFileInfo\u003e`| Enumerate Files. |\n|`FileInfo`|`EnsureExists()`|`FileInfo`| Create file if not exists else dose nothing. |\n|`fileName as string`|`ToFileInfo()`|`FileInfo`| Converts string file path to `FileInfo`. |\n\n\n##### **String** Extensions\n```csharp\nvar str = \"Hello, Blah blah blah...\";\n```\n| Parameter | Type     | Description                |\n| :-------- | :------- | :------------------------- |\n| `str.EqualsCaseSensitive(string compareTo)` | `bool` | Case Sensitive comparison |\n| `str.EqualsCaseIgnore(string compareTo)` | `bool` | Case In-sensitive comparison |\n| `str.GetMD5Hash(bool toBase64 = false, bool unicode = false)` | `string?` | Get MD hash |\n| `str.UrlEncode()` | `string` | Encodes a URL string. |\n| `str.UrlEncode(Encoding encoding)` | `string` | Encodes a URL string to specific encoding. |\n| `str.UrlDecode()` | `string` |  Converts a string that has been encoded for transmission in a URL into a decoded string. |\n| `str.UrlDecode(Encoding encoding)` | `string` |  Converts a string that has been encoded for transmission in a URL into a decoded string. |\n| `str.HtmlEncode()` | `string` | Converts a string to an HTML-encoded string.  |\n| `str.HtmlDecode()` | `string` |  Converts a string that has been HTML-encoded for HTTP transmission into a decoded string. |\n| `str.ToMemoryStream(Encoding encoding)` | `string` |  Convert value to a MemoryStream, using a default Unicode encoding. |\n| `str.IsInteger()` | `bool` |  Check if string is an Integer number. |\n| `str.IsDouble()` | `bool` |  Check if string is an Double number. |\n\n\n\n## License\n[MIT](https://choosealicense.com/licenses/mit/)\n\n## Authors\n- [@SanketNaik](https://github.com/sankdeveloper)\n\n## Feedback\nIf you have any feedback, please reach out to us at sankdeveloper@gmail.com\n\n\n## Roadmap\n- [x] CI/CD pipeline for Nuget.org push.\n- [ ] More features will be still in progress to add.\n- [ ] Test cases and code coverage.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsankdeveloper%2Fshort-sharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsankdeveloper%2Fshort-sharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsankdeveloper%2Fshort-sharp/lists"}