{"id":22997736,"url":"https://github.com/lucaleone/powerup","last_synced_at":"2025-04-02T13:22:46.138Z","repository":{"id":144200081,"uuid":"155198617","full_name":"lucaleone/PowerUp","owner":"lucaleone","description":"PowerUp is an extension methods library for .Net CORE, it add usefull functionalities so the framework","archived":false,"fork":false,"pushed_at":"2018-11-01T15:31:54.000Z","size":164,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-08T06:19:45.259Z","etag":null,"topics":["core","dotnet-core","library","microsoft","net"],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/PowerupCore","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/lucaleone.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":"2018-10-29T11:13:28.000Z","updated_at":"2022-02-10T21:40:22.000Z","dependencies_parsed_at":"2023-07-04T15:46:37.046Z","dependency_job_id":null,"html_url":"https://github.com/lucaleone/PowerUp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucaleone%2FPowerUp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucaleone%2FPowerUp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucaleone%2FPowerUp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucaleone%2FPowerUp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lucaleone","download_url":"https://codeload.github.com/lucaleone/PowerUp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246820177,"owners_count":20839194,"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":["core","dotnet-core","library","microsoft","net"],"created_at":"2024-12-15T06:08:17.388Z","updated_at":"2025-04-02T13:22:46.130Z","avatar_url":"https://github.com/lucaleone.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PowerUp, extension methods library for .Net CORE\n![](https://raw.githubusercontent.com/lucaleone/PowerUp/master/Resources/PowerUpNuget.png) PowerUp is an extension methods library for .Net CORE, it add usefull functionalities to the framework.\u003cbr /\u003e\n## Download\n[PowerupCore Nuget](https://www.nuget.org/packages/PowerupCore)\u003cbr /\u003e\n[PowerupCore Azure Nuget](https://www.nuget.org/packages/PowerupCore.Azure)\u003cbr /\u003e\n## What is different about this library?\n⏩ Lightweight: the goal is not to contains 5k methods, but to only have everyday useful methods (in my opinion 😁)\u003cbr /\u003e\n🚀 .Net CORE compatible\u003cbr /\u003e\n🥊 Unit tested\u003cbr /\u003e\n🤓 100% documented\u003cbr /\u003e\n\nAll the extension method are explained and a [Raison d'être](https://en.wikipedia.org/wiki/Raison_d%27%C3%AAtre) is provided in the following documentation.\n### Contents\n1. [StringExtensions](https://github.com/lucaleone/PowerUp/blob/master/README.md#stringextensions)\n2. [EnumExtensions](https://github.com/lucaleone/PowerUp/blob/master/README.md#enumextensions)\n3. [CollectionExtensions](https://github.com/lucaleone/PowerUp/blob/master/README.md#collectionextensions)\n4. [GenericExtensions](https://github.com/lucaleone/PowerUp/blob/master/README.md#genericextensions)\n5. [AzureExtensions](https://github.com/lucaleone/PowerUp/blob/master/README.md#azureextensions)\n## StringExtensions\n### IsInteger\nSimplify the syntax necessary to verify wehather the string content is an inter or not.\u003cbr\u003e\n__Why?__\u003cbr\u003e\nTo remove repetitive code\n```csharp\nif(\"42\".IsInteger())\n  Foo();\n```\n### Remove\nRemoves from a string the content of the parameter string.\u003cbr\u003e\n__Why?__\u003cbr\u003e\nTo remove repetitive code\n```csharp\n\"My text\".Remove(\"My\") // result: \" text\"\n// instead of\n\"My text\".Replace(\"My\", string.Empty); // result: \" text\"\n  Foo();\n```\n### Format\nGives a shorter syntax for the string's method _Format_.\u003cbr\u003e\n__Why?__\u003cbr\u003e\nTo make the code shorter\n```csharp\n// .net syntax\nstring.Format(\"Debug Level: {0} \\\"{1}\\\" {3}\", DebugLevel.Info, \"Everything is awesome!\", DateTime.Now);\n// PowerUp syntax\n\"Debug Level: {0} \\\"{1}\\\" {3}\".Format(DebugLevel.Info, \"Everything is awesome!\", DateTime.Now);\n```\n### ToEnum\u003c\u003e\nAllows to easily convert a tring to an enum.\u003cbr\u003e\n__Why?__\u003cbr\u003e\nTo remove repetitive code\n```csharp\nprivate enum TestEnum\n{\n    Val1,\n    Val2,\n    Val3\n}\n\nvar enumVar = \"Val1\".ToEnum\u003cTestEnum\u003e();\n```\n## EnumExtensions\n### GetDescription\u003c\u003e\nAllows to get the readable description of the enum value.\n```csharp\nprivate enum TestEnum\n{\n    [Description(\"Value with description\")]\n    ValWithDesc = 1,\n    ValNoDesc = 2,\n    AnotherNoDesc =3\n}\nvar testObject = TestEnum.ValWithDesc;\nstring description = testObject.GetDescription();\n```\n## CollectionExtensions\n### RemoveRange\u003c\u003e\nHelps to remove more elements at once from a collection.\u003cbr\u003e\n__Why?__\u003cbr\u003e\nTo provide a usefull addidional features to collections\n```csharp\nsourceList.RemoveRange(deleteList);\n```\n### Clone\u003c\u003e\nPerforms a deep copy frim a collection of _ICloneable_ objects.\n```csharp\nvar testList = _fixture.Create\u003cList\u003cclonableObj\u003e\u003e();\nvar clone = testList.Clone();\nclone.First() != testList.First()\n```\n### GetLastIndex\u003c\u003e\nGets the last index of a collection.\u003cbr\u003e\n__Why?__\u003cbr\u003e\nTo remove repetitive code\n```csharp\nsourceList.GetLastIndex() == (sourceList.Count - 1)\n```\n## GenericExtensions\n### ThrowIfNull\u003c\u003e\nThrows ArgumentNullException if the given argument is null.\u003cbr\u003e\n__Why?__\u003cbr\u003e\nTo replace the Guard.ArgumentNotNull in .net CORE\n```csharp\nobjectShouldNotBeNUll.ThrowIfNull(nameof(objectShouldNotBeNUll));\n// Inspired on Microsoft.Practices.EnterpriseLibrary.Common.Utility\nGuard.ArgumentNotNull(objectShouldNotBeNUll, nameof(objectShouldNotBeNUll));\n```\n### IsNull\u003c\u003e and IsNotNull\u003c\u003e\nVerify that a object is null or not null.\u003cbr\u003e\n__Why?__\u003cbr\u003e\nTo make the syntax to verify null cleaner and more human readable\n```csharp\nvar someObject = new object();\n//Before\nif(someObject!=null)\n  Foo();\n//PowerUp\nif(someObject.isNull())\n  Foo();\n```\n### Between\u003c\u003e\nVerify that the object value is between the lower and upper bound.\u003cbr\u003e\n__Why?__\u003cbr\u003e\nTo simplify the syntax to verify that an onbject value is between a certain range\n```csharp\nif(5.Between(2, 8))\n  Foo();\nif(7.Between(7, 12, BetweenOptions.Inclusive))\n  Foo();\n```\n## LoggerExtensions\n### LogThisMethod\nAllows to simply log information about the calling method.\u003cbr\u003e\n__Why?__\u003cbr\u003e\nTo avoid boring code, and copy paste problem \nthe tipical scenario is at the beginning of a Controller method like:\n```csharp\n[HttpPut]\n[Route(\"[action]\")]\n[Produces(\"application/json\")]\n[ProducesResponseType(typeof(Product), StatusCodes.Status201Created)]\n[ProducesResponseType(typeof(string), StatusCodes.Status400BadRequest)]\npublic async Task\u003cIActionResult\u003e AddProduct([FromBody] NewProduct newProduct)\n{\n    _logger.LogDebug($\"{DateTime.UtcNow:dd/MMM/yyyy} | 32: CatalogController.AddProduct()}\");\n    if (!ModelState.IsValid)\n        return BadRequest(ModelState);\n    ....\n```\nthe logging method can now be simply:\n```csharp\n...\npublic async Task\u003cIActionResult\u003e AddProduct([FromBody] NewProduct newProduct)\n{\n    _logger.LogThisMethod();\n    ...\n```\nIt's easy from the example to see how much it can reduce the ammount of code and the possibility of errors\n\n## AzureExtensions\n### RedundantParse\nThe storage access keys in Azure are used in authentication for accessing the storage account.\u003cbr\u003e\nWhen you create a storage account you are provided with two storage access keys i.e. Primary and Secondary access keys.\u003cbr\u003e\nSee more https://blogs.msdn.microsoft.com/mast/2013/11/06/why-does-an-azure-storage-account-have-two-access-keys/ \u003cbr\u003e\n__Why?__\u003cbr\u003e\n__RedundantParse__ allowes you redundantly connect using the primary key or automatically switch to the seconday.\n\n```xml\n\u003cadd key=\"QueueConnectionString1\" value=\"DefaultEndpointsProtocol=https;AccountName=weu##########\" /\u003e\n\u003cadd key=\"QueueConnectionString2\" value=\"DefaultEndpointsProtocol=https;AccountName=weu##########\" /\u003e\n\u003cadd key=\"QueueReference\" value=\"myQueueReference\" /\u003e\n```\n\n```csharp\nvar storageAccount = CloudStorageAccountHelper.RedundantParse(\n                    CloudConfigurationManager.GetSetting(\"QueueConnectionString1\"),\n                    CloudConfigurationManager.GetSetting(\"QueueConnectionString2\"));\nvar queueClient = storageAccount.CreateCloudQueueClient();\nvar myQueue = queueClient.GetQueueReference(ConfigurationManager.AppSettings[\"QueueReference\"]);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucaleone%2Fpowerup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucaleone%2Fpowerup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucaleone%2Fpowerup/lists"}