IResultPattern 1.8.5
dotnet add package IResultPattern --version 1.8.5
NuGet\Install-Package IResultPattern -Version 1.8.5
<PackageReference Include="IResultPattern" Version="1.8.5" />
<PackageVersion Include="IResultPattern" Version="1.8.5" />
<PackageReference Include="IResultPattern" />
paket add IResultPattern --version 1.8.5
#r "nuget: IResultPattern, 1.8.5"
#:package IResultPattern@1.8.5
#addin nuget:?package=IResultPattern&version=1.8.5
#tool nuget:?package=IResultPattern&version=1.8.5
๐ IResultPattern
A lightweight and expressive result-handling package for .NET applications.
โจ Clean. Explicit. Production-ready.
Stop returning raw exceptions for expected outcomes.
Stop mixing business logic with HTTP responses.
Start modeling results explicitly.
๐ฆ NuGet: https://www.nuget.org/packages/IResultPattern/
๐ฏ What is this package?
IResultPattern is a dependency-free result modeling library for .NET. It gives you a consistent, strongly-typed way to represent operation outcomes across application layers.
Instead of throwing exceptions for flow control or returning loosely structured responses, you return explicit, predictable results.
โ Perfect for
- ASP.NET Core Web APIs
- Clean Architecture
- Domain-Driven Design (DDD)
- Microservices
- Event-driven systems
- Modular monoliths
๐ฆ Install
dotnet add package IResultPattern
using IMustafaZeynali.IResultPattern;
โจ Key features
๐น Explicit status modeling
Statuses are aligned with HTTP semantics:
| Status | Code |
|---|---|
| Success | 200 |
| Created | 201 |
| NoContent | 204 |
| BadRequest | 400 |
| Unauthorized | 401 |
| Forbidden | 403 |
| NotFound | 404 |
| Conflict | 409 |
| ValidationError | 422 |
| InternalServerError | 500 |
| ServiceUnavailable | 503 |
๐น Strongly-typed results
Result // no payload
Result<TData> // single item
ResultList<TData> // collection + pagination
TData must be a reference type (class).
๐น Built-in pagination
ResultList<T> implements IPageInfo with:
TotalItemCountPageCountPageNumberPageSize
๐น Clean Architecture friendly
- Separates business outcomes from transport concerns
- Improves readability and testability
- Reduces exception misuse
- Provides a consistent response contract
๐น Lightweight & dependency-free
- No external dependencies
- Targets
netstandard2.1 - Explicit factory methods โ no hidden magic
๐น Backward compatible
The legacy Failure(string) overloads remain available and are marked [Obsolete]. Prefer specific status methods instead.
๐ง Why use this instead of exceptions?
Exceptions should represent exceptional conditions โ not validation failures or other predictable outcomes.
This package encourages:
- Explicit business outcomes
- Better error handling
- Consistent API behavior
- Easier testing
- Clearer code semantics
๐ฅ Examples
๐ Without data
return Result.Success();
return Result.NotFound("User not found");
return Result.ValidationError("Email is required");
๐ Single item
return Result<User>.Success(user);
return Result<User>.NotFound("User not found");
return Result<User>.ValidationError("Email is required");
๐ List with pagination
return ResultList<User>.Success(users, totalItemCount: 120);
return ResultList<User>.Success(users, pageInfo);
return ResultList<User>.NotFound("No users found");
return ResultList<User>.ValidationError("Invalid page size");
โก Implicit conversions
Result result = ResultStatus.NotFound; // failure statuses
Result<User> ok = user; // wraps as Success
๐ฅ Who is this for?
Developers who:
- Care about clean, explicit code
- Use DDD or Clean Architecture
- Want expressive application flow
- Build scalable APIs and services
๐ License
Licensed under the Apache License 2.0.
๐ Contributing
Found a bug or have an idea?
Open an issue: https://github.com/IMustafaZeynali/IResultPattern/issues
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.