{"id":28276149,"url":"https://github.com/nogic1008/throwhelperextensions","last_synced_at":"2026-03-01T22:02:21.090Z","repository":{"id":293079638,"uuid":"982863112","full_name":"nogic1008/ThrowHelperExtensions","owner":"nogic1008","description":"Use ThrowHelper methods (ex. `ArgumentException.ThrowIfNull`) on your elderly .NET project","archived":false,"fork":false,"pushed_at":"2026-02-10T04:54:33.000Z","size":88,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-10T09:48:07.752Z","etag":null,"topics":["csharp","dotnet","throw"],"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/nogic1008.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-05-13T14:13:26.000Z","updated_at":"2026-02-10T04:54:37.000Z","dependencies_parsed_at":"2025-06-16T16:36:43.199Z","dependency_job_id":"0f408865-b9f8-4d31-97d0-f27cb0f2cc02","html_url":"https://github.com/nogic1008/ThrowHelperExtensions","commit_stats":null,"previous_names":["nogic1008/throwhelperextensions"],"tags_count":4,"template":false,"template_full_name":"nogic1008/dotnet-ci-example","purl":"pkg:github/nogic1008/ThrowHelperExtensions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nogic1008%2FThrowHelperExtensions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nogic1008%2FThrowHelperExtensions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nogic1008%2FThrowHelperExtensions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nogic1008%2FThrowHelperExtensions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nogic1008","download_url":"https://codeload.github.com/nogic1008/ThrowHelperExtensions/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nogic1008%2FThrowHelperExtensions/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29986241,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T21:06:37.093Z","status":"ssl_error","status_checked_at":"2026-03-01T21:05:45.052Z","response_time":124,"last_error":"SSL_read: 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","throw"],"created_at":"2025-05-21T04:18:38.478Z","updated_at":"2026-03-01T22:02:21.084Z","avatar_url":"https://github.com/nogic1008.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ThrowHelperExtensions\n\n[![NuGet (stable version)](https://img.shields.io/nuget/v/Nogic.ThrowHelperExtensions?logo=nuget)](https://www.nuget.org/packages/Nogic.ThrowHelperExtensions/)\n[![GitHub releases (including pre-releases)](https://img.shields.io/github/v/release/nogic1008/ThrowHelperExtensions?include_prereleases\u0026sort=semver)](https://github.com/nogic1008/ThrowHelperExtensions/releases)\n[![.NET CI](https://github.com/nogic1008/ThrowHelperExtensions/actions/workflows/dotnet-ci.yml/badge.svg)](https://github.com/nogic1008/ThrowHelperExtensions/actions/workflows/dotnet-ci.yml)\n[![codecov](https://codecov.io/gh/nogic1008/ThrowHelperExtensions/graph/badge.svg?token=r9tFgjErCH)](https://codecov.io/gh/nogic1008/ThrowHelperExtensions)\n[![CodeFactor](https://www.codefactor.io/repository/github/nogic1008/ThrowHelperExtensions/badge)](https://www.codefactor.io/repository/github/nogic1008/ThrowHelperExtensions)\n[![License](https://img.shields.io/github/license/nogic1008/ThrowHelperExtensions)](LICENSE)\n\nUse ThrowHelper methods (ex. `ArgumentException.ThrowIfNull`) on your elderly .NET project\n\n## Usage\n\n### 1. Set `LangVersion` to C# 14\n\nThis package uses [Extension members](https://learn.microsoft.com/dotnet/csharp/whats-new/csharp-14#extension-members) feature on C# 14.\n\nPlease Add below on your `.csproj` or `Directory.Build.props`.\n\n```xml\n\u003cPropertyGroup\u003e\n  \u003cLangVersion\u003e14\u003c/LangVersion\u003e\n\u003c/PropertyGroup\u003e\n```\n\n### 2. Add Package\n\n```console\ndotnet add package Nogic.ThrowHelperExtensions\n```\n\n### 3. Use throw helpers\n\n```csharp\nnamespace Samples;\n\npublic class Sample\n{\n    public string Value1 { get; }\n\n    public Sample(string value1)\n    {\n        // On .NET 6.0 or higher, it calls `ArgumentNullException.ThrowIfNull` directly.\n        // On others, it calls `System.ExceptionPolyfills.ThrowIfNull` polyfill via extension members.\n        ArgumentNullException.ThrowIfNull(value1);\n\n        this.Value1 = value1;\n    }\n}\n```\n\n## API\n\n- [`ArgumentException.ThrowIfNullOrEmpty(string?, string?)`](https://learn.microsoft.com/dotnet/api/system.argumentexception.throwifnullorempty?view=net-7.0)\n- [`ArgumentException.ThrowIfNullOrWhiteSpace(string?, string?)`](https://learn.microsoft.com/dotnet/api/system.argumentexception.throwifnullorwhitespace?view=net-8.0)\n- [`ArgumentNullException.ThrowIfNull(object?, string?)`](https://learn.microsoft.com/dotnet/api/system.argumentnullexception.throwifnull?view=net-6.0#System_ArgumentNullException_ThrowIfNull_System_Object_System_String_)\n- [`ArgumentNullException.ThrowIfNull(void*, string?)`](https://learn.microsoft.com/dotnet/api/system.argumentnullexception.throwifnull?view=net-7.0#system-argumentnullexception-throwifnull(system-void*-system-string))\n  - Set `AllowUnsafeBlocks` to `true` in your project file to use this overload.\n- [`ObjectDisposedException.ThrowIf(bool, object)`](https://learn.microsoft.com/dotnet/api/system.objectdisposedexception.throwif?view=net-7.0#system-objectdisposedexception-throwif(system-boolean-system-object))\n- [`ObjectDisposedException.ThrowIf(bool, Type)`](https://learn.microsoft.com/dotnet/api/system.objectdisposedexception.throwif?view=net-7.0#system-objectdisposedexception-throwif(system-boolean-system-type))\n- [`ArgumentOutOfRangeException.ThrowIfEqual\u003cT\u003e(T, T, string?)`](https://learn.microsoft.com/dotnet/api/system.argumentoutofrangeexception.throwifequal?view=net-10.0)\n- [`ArgumentOutOfRangeException.ThrowIfGreaterThan\u003cT\u003e(T, T, string?) where T : IComparable\u003cT\u003e`](https://learn.microsoft.com/dotnet/api/system.argumentoutofrangeexception.throwifgreaterthan?view=net-8.0)\n- [`ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual\u003cT\u003e(T, T, string?) where T : IComparable\u003cT\u003e`](https://learn.microsoft.com/dotnet/api/system.argumentoutofrangeexception.throwifgreaterthanorequal?view=net-8.0)\n- [`ArgumentOutOfRangeException.ThrowIfLessThan\u003cT\u003e(T, T, string?) where T : IComparable\u003cT\u003e`](https://learn.microsoft.com/dotnet/api/system.argumentoutofrangeexception.throwiflessthan?view=net-8.0)\n- [`ArgumentOutOfRangeException.ThrowIfLessThanOrEqual\u003cT\u003e(T, T, string?) where T : IComparable\u003cT\u003e`](https://learn.microsoft.com/dotnet/api/system.argumentoutofrangeexception.throwiflessthanorequal?view=net-8.0)\n- [`ArgumentOutOfRangeException.ThrowIfNegative\u003cT\u003e(T, string?) where T : INumberBase\u003cT\u003e`](https://learn.microsoft.com/dotnet/api/system.argumentoutofrangeexception.throwifnegative?view=net-8.0) [^1]\n- [`ArgumentOutOfRangeException.ThrowIfNegativeOrZero\u003cT\u003e(T, string?) where T : INumberBase\u003cT\u003e`](https://learn.microsoft.com/dotnet/api/system.argumentoutofrangeexception.throwifnegativeorzero?view=net-8.0) [^1]\n- [`ArgumentOutOfRangeException.ThrowIfNotEqual\u003cT\u003e(T, T, string?)`](https://learn.microsoft.com/dotnet/api/system.argumentoutofrangeexception.throwifnotequal?view=net-10.0)\n- [`ArgumentOutOfRangeException.ThrowIfZero\u003cT\u003e(T, string?) where T : INumberBase\u003cT\u003e`](https://learn.microsoft.com/dotnet/api/system.argumentoutofrangeexception.throwifzero?view=net-8.0) [^1]\n\n[^1]: [`INumberBase\u003cT\u003e`](https://learn.microsoft.com/dotnet/api/system.numerics.inumberbase-1?view=net-7.0) is not available in .NET 6.0 or below (including .NET Standard 2.0).\n  So, this method only has overloads for the built-in numeric types. (`byte`, `sbyte`, `short`, `ushort`, `int`, `uint`, `long`, `ulong`, `float`, `double`, `decimal`, `nint`, `nuint`, `char`)\n\n### Limitations\n\n- Except for `ArgumentNullException.ThrowIfNull`, exception messages are not localized.\n- Unlike .NET 8.0 and 9.0, these methods do not have `IEquatable\u003cT\u003e` constraint on type parameter `T`. (based on .NET 10.0+ source code)\n  - `ArgumentOutOfRangeException.ThrowIfEqual\u003cT\u003e(T, T, string?)`\n  - `ArgumentOutOfRangeException.ThrowIfNotEqual\u003cT\u003e(T, T, string?)`\n- The generated class `System.ExceptionPolyfills` is `internal`.\n\n## Options\n\n### ThrowHelperExtensionsGenerateAttributes\n\nBy default, this generator will generate necessary attribute types. (ex. `DoesNotReturnAttribute`)\nIf you want to disable attribute generation (for example, use other generator like [PolySharp](https://www.nuget.org/packages/PolySharp/)), you can set the following MSBuild property in your project file:\n\n```xml\n\u003cProject Sdk=\"Microsoft.NET.Sdk\"\u003e\n  \u003cPropertyGroup\u003e\n    \u003cThrowHelperExtensionsGenerateAttributes\u003efalse\u003c/ThrowHelperExtensionsGenerateAttributes\u003e\n  \u003c/PropertyGroup\u003e\n\u003c/Project\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnogic1008%2Fthrowhelperextensions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnogic1008%2Fthrowhelperextensions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnogic1008%2Fthrowhelperextensions/lists"}