{"id":22800986,"url":"https://github.com/dailydevops/arguments","last_synced_at":"2026-03-15T13:58:03.008Z","repository":{"id":191206396,"uuid":"684152533","full_name":"dailydevops/arguments","owner":"dailydevops","description":"Provides a set of backward compatible `throw` helper methods, which have been added in previous .NET versions.","archived":false,"fork":false,"pushed_at":"2025-04-09T19:24:22.000Z","size":448,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-09T20:29:40.752Z","etag":null,"topics":["dotnet","guard","source-only"],"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/dailydevops.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["dailydevops"]}},"created_at":"2023-08-28T15:04:36.000Z","updated_at":"2025-04-09T19:24:25.000Z","dependencies_parsed_at":"2023-10-04T04:36:13.694Z","dependency_job_id":"39f8d2ed-0ce2-40ef-8e2f-6f875286120d","html_url":"https://github.com/dailydevops/arguments","commit_stats":null,"previous_names":["dailydevops/arguments"],"tags_count":14,"template":false,"template_full_name":"dailydevops/dotnet-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dailydevops%2Farguments","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dailydevops%2Farguments/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dailydevops%2Farguments/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dailydevops%2Farguments/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dailydevops","download_url":"https://codeload.github.com/dailydevops/arguments/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251774437,"owners_count":21641723,"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":["dotnet","guard","source-only"],"created_at":"2024-12-12T08:08:35.366Z","updated_at":"2026-03-15T13:58:03.002Z","avatar_url":"https://github.com/dailydevops.png","language":"C#","readme":"# Arguments\n\n[![License](https://img.shields.io/github/license/dailydevops/arguments.svg)](https://github.com/dailydevops/arguments/blob/main/LICENSE)\n[![Build Status](https://img.shields.io/github/actions/workflow/status/dailydevops/arguments/ci.yml?branch=main)](https://github.com/dailydevops/arguments/actions)\n[![NuGet](https://img.shields.io/nuget/v/NetEvolve.Arguments.svg)](https://www.nuget.org/packages/NetEvolve.Arguments/)\n[![NuGet Downloads](https://img.shields.io/nuget/dt/NetEvolve.Arguments.svg)](https://www.nuget.org/packages/NetEvolve.Arguments/)\n[![Contributors](https://img.shields.io/github/contributors/dailydevops/arguments.svg)](https://github.com/dailydevops/arguments/graphs/contributors)\n\nA universal polyfill library that provides modern `ArgumentNullException.ThrowIf*` and `ArgumentException.ThrowIf*` helper methods across all .NET runtimes (.NET Standard 2.0+, .NET Framework 4.6.2+, .NET 6.0+), enabling consistent argument validation patterns regardless of target framework version.\n\n## Overview\n\nNetEvolve.Arguments brings modern .NET argument validation APIs to legacy frameworks, allowing you to write consistent defensive programming code across all supported .NET platforms. The library polyfills the `ThrowIfNull`, `ThrowIfNullOrEmpty`, `ThrowIfNullOrWhiteSpace`, and comparison-based validation methods that were introduced in later .NET versions, making them available to projects targeting older frameworks.\n\nThis solution provides a single, focused library designed to:\n\n- **Enable modern code patterns**: Write modern argument validation code that works on .NET Framework 4.6.2 through .NET 10.0\n- **Maintain consistency**: Use the same API surface across all target frameworks without conditional compilation\n- **Simplify maintenance**: Replace verbose manual null checks and validation logic with concise, expressive helper methods\n- **Improve code quality**: Apply defensive programming practices consistently throughout your codebase\n\n## Projects\n\n### Core Library\n\n- **NetEvolve.Arguments** - The main polyfill library providing argument validation helper methods for:\n  - Null checking (`ThrowIfNull`)\n  - Empty/whitespace validation (`ThrowIfNullOrEmpty`, `ThrowIfNullOrWhiteSpace`)\n  - Equality validation (`ThrowIfEqual`, `ThrowIfNotEqual`)\n  - Comparison validation (`ThrowIfGreaterThan`, `ThrowIfGreaterThanOrEqual`, `ThrowIfLessThan`, `ThrowIfLessThanOrEqual`)\n  - Object disposal validation (`ObjectDisposedException.ThrowIf`)\n\n### Tests\n\n- **NetEvolve.Arguments.Tests.Unit** - Comprehensive unit tests covering all validation methods across all target frameworks\n\n## Features\n\n- **Universal compatibility** - Supports .NET Standard 2.0+, .NET Framework 4.6.2, 4.7.2, 4.8, 4.8.1, and .NET 6.0 through 10.0\n- **Modern API surface** - Provides the same helper methods available in .NET 6+ to all target frameworks\n- **Zero overhead** - On frameworks where native implementations exist, the polyfills are compiled out\n- **Type-safe validation** - Generic and specialized overloads for common scenarios including pointers and spans\n- **Performance optimized** - Minimal allocations and optimized code paths for each target framework\n- **Comprehensive testing** - Extensive unit test coverage across all supported frameworks\n\n## Getting Started\n\n### Prerequisites\n\n- [.NET SDK 10.0](https://dotnet.microsoft.com/download) or higher for building the solution\n- [Git](https://git-scm.com/) for version control\n- [Visual Studio 2022](https://visualstudio.microsoft.com/) or [Visual Studio Code](https://code.visualstudio.com/) (recommended)\n\n### Installation\n\nAdd the NuGet package to your project:\n\n```bash\ndotnet add package NetEvolve.Arguments\n```\n\nOr via Package Manager Console:\n\n```powershell\nInstall-Package NetEvolve.Arguments\n```\n\nOr add directly to your `.csproj` file:\n\n```xml\n\u003cItemGroup\u003e\n  \u003cPackageReference Include=\"NetEvolve.Arguments\" /\u003e\n\u003c/ItemGroup\u003e\n```\n\n\u003e [!NOTE]\n\u003e This project uses Centralized Package Version Management. When adding the package reference, omit the `Version` attribute - versions are managed centrally in [Directory.Packages.props](https://github.com/dailydevops/arguments/blob/main/Directory.Packages.props).\n\n### Usage Examples\n\n**Null validation:**\n\n```csharp\nusing System;\n\npublic void ProcessData(string data)\n{\n    ArgumentNullException.ThrowIfNull(data);\n    // Process data safely\n}\n```\n\n**Empty/whitespace validation:**\n\n```csharp\nusing System;\n\npublic void ValidateInput(string input)\n{\n    ArgumentException.ThrowIfNullOrEmpty(input);\n    ArgumentException.ThrowIfNullOrWhiteSpace(input);\n    // Input is guaranteed to have content\n}\n```\n\n**Comparison validation:**\n\n```csharp\nusing System;\n\npublic void SetTimeout(int milliseconds)\n{\n    ArgumentOutOfRangeException.ThrowIfNegative(milliseconds);\n    ArgumentOutOfRangeException.ThrowIfGreaterThan(milliseconds, 60000);\n    // Timeout is between 0 and 60000\n}\n```\n\n**Object disposal validation:**\n\n```csharp\nusing System;\n\npublic class MyDisposable : IDisposable\n{\n    private bool _disposed;\n\n    public void DoWork()\n    {\n        ObjectDisposedException.ThrowIf(_disposed, this);\n        // Safe to perform work\n    }\n\n    public void Dispose() =\u003e _disposed = true;\n}\n```\n\n## Development\n\n### Building\n\nClone the repository and build the solution:\n\n```bash\ngit clone https://github.com/dailydevops/arguments.git\ncd arguments\ndotnet restore\ndotnet build\n```\n\n### Running Tests\n\nRun all tests across all target frameworks:\n\n```bash\ndotnet test\n```\n\nRun tests for a specific project:\n\n```bash\ndotnet test tests/NetEvolve.Arguments.Tests.Unit\n```\n\n### Code Formatting\n\nThis project uses [CSharpier](https://csharpier.com/) for consistent code formatting:\n\n```bash\ndotnet csharpier format .\n```\n\nCode formatting is automatically enforced during builds via the `CSharpier.MSBuild` package.\n\n### Project Structure\n\n```txt\nsrc/\n└── NetEvolve.Arguments/                            # Main polyfill library\n    ├── Argument*.cs                                # Obsolete implementations\n    ├── ArgumentExceptionPolyfill.cs                # Polyfill implementations\n    ├── ArgumentNullExceptionPolyfills.cs           # Polyfill implementations\n    ├── ArgumentOutOfRangeExceptionPolyfills.cs     # Polyfill implementations\n    └── ObjectDisposedExceptionPolyfills.cs         # Polyfill implementations\n\ntests/\n└── NetEvolve.Arguments.Tests.Unit/                 # Comprehensive unit tests\n\ndecisions/                                          # Architecture Decision Records (ADRs)\ntemplates/                                          # Documentation templates\n```\n\n## Architecture\n\nThis library follows a polyfill architecture pattern:\n\n- **Conditional compilation**: Uses preprocessor directives to provide native implementations where available and polyfills where needed\n- **Framework detection**: Automatically detects target framework capabilities at compile time\n- **Zero-overhead abstraction**: On modern frameworks, the polyfills compile to simple pass-through calls or are eliminated entirely\n- **Backward compatibility**: Ensures older frameworks receive functionally equivalent implementations\n\nFor detailed architectural decisions, see:\n\n- [Centralized Package Version Management](https://github.com/dailydevops/arguments/blob/main/decisions/2025-07-10-centralized-package-version-management.md)\n- [Conventional Commits](https://github.com/dailydevops/arguments/blob/main/decisions/2025-07-10-conventional-commits.md)\n- [GitVersion for Automated Semantic Versioning](https://github.com/dailydevops/arguments/blob/main/decisions/2025-07-10-gitversion-automated-semantic-versioning.md)\n- [.NET 10 and C# 13 Adoption](https://github.com/dailydevops/arguments/blob/main/decisions/2025-07-11-dotnet-10-csharp-13-adoption.md)\n- [English as Project Language](https://github.com/dailydevops/arguments/blob/main/decisions/2025-07-11-english-as-project-language.md)\n- [DateTimeOffset and TimeProvider Usage](https://github.com/dailydevops/arguments/blob/main/decisions/2026-01-21-datetimeoffset-and-timeprovider-usage.md)\n- [All Architecture Decision Records](https://github.com/dailydevops/arguments/tree/main/decisions/)\n\n## Contributing\n\nWe welcome contributions from the community! Please read our [Contributing Guidelines](https://github.com/dailydevops/arguments/blob/main/CONTRIBUTING.md) before submitting a pull request.\n\nKey points:\n\n- Follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) format for commit messages\n- Write tests for new functionality across all relevant target frameworks\n- Follow existing code style and conventions (enforced by analyzers and CSharpier)\n- Update documentation as needed\n- Ensure all tests pass on all target frameworks before submitting\n\n### Code of Conduct\n\nThis project adheres to the Contributor Covenant [Code of Conduct](https://github.com/dailydevops/arguments/blob/main/CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to info@daily-devops.net.\n\n### Documentation\n\n- **[Architecture Decision Records](https://github.com/dailydevops/arguments/tree/main/decisions/)** - Detailed architectural decisions and rationale\n- **[Contributing Guidelines](https://github.com/dailydevops/arguments/blob/main/CONTRIBUTING.md)** - How to contribute to this project\n- **[Code of Conduct](https://github.com/dailydevops/arguments/blob/main/CODE_OF_CONDUCT.md)** - Community standards and expectations\n- **[License](https://github.com/dailydevops/arguments/blob/main/LICENSE)** - Project licensing information (MIT License)\n- **[Release Notes](https://github.com/dailydevops/arguments/releases/)** - Version history and changelog\n\n### Versioning\n\nThis project uses [GitVersion](https://gitversion.net/) for automated semantic versioning based on Git history and [Conventional Commits](https://www.conventionalcommits.org/). Version numbers are automatically calculated during the build process:\n\n- **Major version** (1.0.0 → 2.0.0): Breaking changes indicated by `!` or `BREAKING CHANGE:` footer in commit messages\n- **Minor version** (1.0.0 → 1.1.0): New features added via `feat:` commits\n- **Patch version** (1.0.0 → 1.0.1): Bug fixes and maintenance via `fix:`, `chore:`, `docs:`, etc.\n\nFor more details, see [GitVersion for Automated Semantic Versioning](https://github.com/dailydevops/arguments/blob/main/decisions/2025-07-10-gitversion-automated-semantic-versioning.md).\n\n### Support\n\n- **Issues**: Report bugs or request features on [GitHub Issues](https://github.com/dailydevops/arguments/issues)\n- **Documentation**: Read the full documentation in this repository\n- **NuGet**: Download the package from [NuGet.org](https://www.nuget.org/packages/NetEvolve.Arguments/)\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](https://github.com/dailydevops/arguments/blob/main/LICENSE) file for details.\n\n---\n\n\u003e [!NOTE]\n\u003e **Made with ❤️ by the NetEvolve Team**\n\u003e\n\u003e Visit us at [https://www.daily-devops.net](https://www.daily-devops.net) for more information about our services and solutions.\n","funding_links":["https://github.com/sponsors/dailydevops"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdailydevops%2Farguments","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdailydevops%2Farguments","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdailydevops%2Farguments/lists"}