SharpPyxis.Results 1.0.0

dotnet add package SharpPyxis.Results --version 1.0.0
                    
NuGet\Install-Package SharpPyxis.Results -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SharpPyxis.Results" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SharpPyxis.Results" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="SharpPyxis.Results" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SharpPyxis.Results --version 1.0.0
                    
#r "nuget: SharpPyxis.Results, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SharpPyxis.Results@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SharpPyxis.Results&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=SharpPyxis.Results&version=1.0.0
                    
Install as a Cake Tool

SharpPyxis

A collection of small, focused .NET primitives with zero external dependencies.

Each package is independent — take only what you need.

Package Description NuGet
SharpPyxis.Results Result<T> and Error primitives for explicit error handling (coming soon)
SharpPyxis.Guards Argument validation guards and UserFacingException (coming soon)

Target frameworks: net8.0, net10.0


SharpPyxis.Results

Represent operation outcomes without throwing exceptions. Model success and failure explicitly.

Installation

dotnet add package SharpPyxis.Results

Usage

using SharpPyxis.Results;

// Return a result from a service
public Result<User> FindUser(Guid id)
{
    var user = _db.Find(id);
    return user is null
        ? Result.Failure<User>(Error.NotFound("User.NotFound", $"User {id} was not found."))
        : Result.Success(user);
}

// Consume it
var result = FindUser(id);

if (result.IsFailure)
    return result.Error; // Error.Code, Error.Message, Error.Type

var user = result.Value;

Error factory methods

Error.NotFound("User.NotFound", "User was not found.")
Error.Conflict("Email.Conflict", "Email is already in use.")
Error.Validation("Name.Required", "Name is required.")
Error.Unauthorized("Auth.Expired", "Token has expired.")
Error.Forbidden("Role.Missing", "Insufficient permissions.")
Error.Unexpected("Order.Failed", "An unexpected error occurred.")

SharpPyxis.Guards

Argument validation guards that throw developer-facing exceptions on invalid input. Parameter names are captured automatically — no nameof() required at call sites.

Installation

dotnet add package SharpPyxis.Guards

Usage

using SharpPyxis.Guards;

public UserService(IUserRepository repository)
{
    _repository = Guard.NotNull(repository);
}

public Task<User> CreateAsync(string name, string email, Guid tenantId)
{
    Guard.NotWhiteSpace(name);
    Guard.NotEmpty(email);
    Guard.NotEmpty(tenantId);
    Guard.Satisfies(name, n => n.Length <= 100, "Name must be 100 characters or fewer.");

    // ...
}

UserFacingException

For cases where returning a Result<T> is impractical and the error message is safe to surface to the end user:

throw new UserFacingException("Invoice amount must be greater than zero.");

// With a custom HTTP status code:
throw new UserFacingException("Resource has been locked.", statusCode: 423);

Contributing

Contributions welcome. Each package must remain independently usable with zero external dependencies (only the .NET SDK).

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net8.0

    • 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.

Version Downloads Last Updated
1.0.0 142 4/28/2026